diff --git a/OAT.xml b/OAT.xml index 6bed6e36e3e135c3d53854ae1949b10c9eaff3c0..f50b452b4e22bb02c662b938f80b30ca2067beb8 100644 --- a/OAT.xml +++ b/OAT.xml @@ -64,13 +64,6 @@ Note:If the text contains special characters, please escape them according to th - - - - - diff --git a/services/distributeddataservice/adapter/include/schema_helper/get_schema_helper.h b/services/distributeddataservice/adapter/include/schema_helper/get_schema_helper.h deleted file mode 100644 index 9a0462f788c15015eed86968101af026d7288390..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/adapter/include/schema_helper/get_schema_helper.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -* 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. -*/ -#ifndef OHOS_DISTRIBUTED_DATA_SERVICES_ADAPTER_GET_SCHEMA_HELPER_H -#define OHOS_DISTRIBUTED_DATA_SERVICES_ADAPTER_GET_SCHEMA_HELPER_H - -#include -#include - -#include "iremote_object.h" - -namespace OHOS { -namespace AppExecFwk { -class IBundleMgr; -} -} // namespace OHOS - -namespace OHOS::DistributedData { -struct AppInfo { - std::string bundleName; - int32_t userId; - int32_t appIndex; -}; - -class GetSchemaHelper final : public std::enable_shared_from_this { -public: - static GetSchemaHelper &GetInstance(); - std::vector GetSchemaFromHap(const std::string &schemaPath, const AppInfo &info); - -private: - GetSchemaHelper() = default; - ~GetSchemaHelper(); - 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->OnRemoteDied(); - } - } - - private: - std::weak_ptr owner_; - }; - void OnRemoteDied(); - sptr GetBundleMgr(); - std::mutex mutex_; - sptr object_; - sptr deathRecipient_; -}; -} // namespace OHOS::DistributedData -#endif // OHOS_DISTRIBUTED_DATA_SERVICES_ADAPTER_GET_SCHEMA_HELPER_H \ No newline at end of file diff --git a/services/distributeddataservice/adapter/schema_helper/BUILD.gn b/services/distributeddataservice/adapter/schema_helper/BUILD.gn deleted file mode 100644 index 26095037dd806772c7558398eed28582115fdd58..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/adapter/schema_helper/BUILD.gn +++ /dev/null @@ -1,49 +0,0 @@ -# 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. -import("//build/ohos.gni") -import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni") - -config("module_public_config") { - visibility = [ ":*" ] - include_dirs = [ "../include/schema_helper" ] -} - -ohos_source_set("distributeddata_schema_helper") { - branch_protector_ret = "pac_ret" - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - boundary_sanitize = true - ubsan = true - } - sources = [ "src/get_schema_helper.cpp" ] - - cflags_cc = [ "-fvisibility=hidden" ] - - include_dirs = [ "../include/schema_helper" ] - - public_configs = [ ":module_public_config" ] - external_deps = [ - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", - "hilog:libhilog", - "ipc:ipc_single", - "kv_store:datamgr_common", - "resource_management:global_resmgr", - "samgr:samgr_proxy", - ] - subsystem_name = "distributeddatamgr" - part_name = "datamgr_service" - defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] -} diff --git a/services/distributeddataservice/adapter/schema_helper/src/get_schema_helper.cpp b/services/distributeddataservice/adapter/schema_helper/src/get_schema_helper.cpp deleted file mode 100644 index 25ce22999748e3d43a7d21e921602a98dd3102b8..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/adapter/schema_helper/src/get_schema_helper.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* -* 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. -*/ - -#define LOG_TAG "SchemaHelper" -#include "get_schema_helper.h" - -#include "bundle_mgr_interface.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" -#include "log_print.h" -#include "resource_manager.h" -#include "system_ability_definition.h" - -namespace OHOS { -namespace DistributedData { -using namespace OHOS::Global::Resource; - -sptr GetSchemaHelper::GetBundleMgr() -{ - std::lock_guard lock(mutex_); - if (object_ != nullptr) { - return iface_cast(object_); - } - sptr systemAbilityManager = - SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (systemAbilityManager == nullptr) { - ZLOGE("Failed to get system ability mgr."); - return nullptr; - } - object_ = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); - if (object_ == nullptr) { - ZLOGE("BMS service not ready to complete."); - return nullptr; - } - deathRecipient_ = new (std::nothrow) GetSchemaHelper::ServiceDeathRecipient(weak_from_this()); - if (deathRecipient_ == nullptr) { - ZLOGE("deathRecipient alloc failed."); - object_ = nullptr; - return nullptr; - } - if (!object_->AddDeathRecipient(deathRecipient_)) { - ZLOGE("add death recipient failed."); - object_ = nullptr; - deathRecipient_ = nullptr; - return nullptr; - } - return iface_cast(object_); -} -std::vector GetSchemaHelper::GetSchemaFromHap(const std::string &schemaPath, const AppInfo &info) -{ - std::vector schemas; - auto bmsClient = GetBundleMgr(); - if (bmsClient == nullptr) { - ZLOGE("GetBundleMgr is nullptr!"); - return schemas; - } - OHOS::AppExecFwk::BundleInfo bundleInfo; - int32_t flag = static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE); - auto ret = bmsClient->GetCloneBundleInfo(info.bundleName, flag, info.appIndex, bundleInfo, info.userId); - if (ret != ERR_OK) { - ZLOGE("GetCloneBundleInfo failed. errCode:%{public}d", ret); - return schemas; - } - - std::shared_ptr resMgr(CreateResourceManager()); - if (resMgr == nullptr) { - ZLOGE("resMgr is nullptr."); - return schemas; - } - for (auto &hapModuleInfo : bundleInfo.hapModuleInfos) { - resMgr->AddResource(hapModuleInfo.hapPath.c_str()); - size_t length = 0; - std::unique_ptr fileContent; - auto ret = resMgr->GetRawFileFromHap(schemaPath, length, fileContent); - if (ret != ERR_OK) { - ZLOGD("GetRawFileFromHap failed. bundleName:%{public}s ret:%{public}d", info.bundleName.c_str(), ret); - continue; - } - std::string schema(fileContent.get(), fileContent.get() + length); - schemas.emplace_back(std::move(schema)); - } - return schemas; -} -void GetSchemaHelper::OnRemoteDied() -{ - std::lock_guard lock(mutex_); - ZLOGE("remote object died, object=null ? %{public}s.", object_ == nullptr ? "true" : "false"); - if (object_ != nullptr) { - object_->RemoveDeathRecipient(deathRecipient_); - } - object_ = nullptr; - deathRecipient_ = nullptr; -} - -GetSchemaHelper::~GetSchemaHelper() -{ - std::lock_guard lock(mutex_); - if (object_ != nullptr) { - object_->RemoveDeathRecipient(deathRecipient_); - } -} - -GetSchemaHelper &GetSchemaHelper::GetInstance() -{ - static GetSchemaHelper helper; - return helper; -} -} // namespace DistributedData -} // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/app/src/installer/installer_impl.cpp b/services/distributeddataservice/app/src/installer/installer_impl.cpp index 6977b3ab9b2e3d74a184795f674f179edab58c39..f470cd641810662ae4352039f0034d3e3c6fdb45 100644 --- a/services/distributeddataservice/app/src/installer/installer_impl.cpp +++ b/services/distributeddataservice/app/src/installer/installer_impl.cpp @@ -104,6 +104,21 @@ void InstallEventSubscriber::OnUninstall(const std::string &bundleName, int32_t void InstallEventSubscriber::OnUpdate(const std::string &bundleName, int32_t userId, int32_t appIndex) { kvStoreDataService_->OnUpdate(bundleName, userId, appIndex); + std::string prefix = StoreMetaData::GetPrefix( + { DeviceManagerAdapter::GetInstance().GetLocalDevice().uuid, std::to_string(userId), "default", bundleName }); + std::vector storeMetaData; + if (!MetaDataManager::GetInstance().LoadMeta(prefix, storeMetaData, true)) { + ZLOGE("load meta failed! bundleName:%{public}s, userId:%{public}d, appIndex:%{public}d", bundleName.c_str(), + userId, appIndex); + return; + } + for (auto &meta : storeMetaData) { + if (meta.instanceId == appIndex && !meta.appId.empty() && !meta.storeId.empty()) { + ZLOGI("updated bundleName:%{public}s, storeId:%{public}s, userId:%{public}d, appIndex:%{public}d", + bundleName.c_str(), Anonymous::Change(meta.storeId).c_str(), userId, appIndex); + MetaDataManager::GetInstance().DelMeta(CloudInfo::GetSchemaKey(meta), true); + } + } } void InstallEventSubscriber::OnInstall(const std::string &bundleName, int32_t userId, int32_t appIndex) diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 8d732f7d034b8bd451a203b3422d3b05c5882abc..02244700ea81eff07e313e4151f28392a417f326 100755 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -193,13 +193,6 @@ void KvStoreDataService::LoadFeatures() for (auto const &feature : features) { GetFeatureInterface(feature); } - auto staticActs = FeatureSystem::GetInstance().GetStaticActs(); - staticActs.ForEach([exec = executors_](const auto &name, std::shared_ptr acts) { - if (acts != nullptr) { - acts->SetThreadPool(exec); - } - return false; - }); } /* RegisterClientDeathObserver */ diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn index f85d7b550348928f82494508b66ddc537bca4d41..d9cf068b78cf0aa8b8e10e1982ccc8e56867d439 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -64,7 +64,6 @@ ohos_shared_library("distributeddatasvcfwk") { "cloud/cloud_info.cpp", "cloud/cloud_last_sync_info.cpp", "cloud/cloud_lock_event.cpp", - "cloud/cloud_mark.cpp", "cloud/cloud_report.cpp", "cloud/cloud_server.cpp", "cloud/cloud_share_event.cpp", @@ -116,7 +115,6 @@ ohos_shared_library("distributeddatasvcfwk") { "utils/ref_count.cpp", "utils/time_utils.cpp", ] - cflags = [ "-Werror", "-Wno-multichar", diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index 0d80c15d91173fc425bcebab62db211d277c0c52..191c6f88eff51b27cddde990cba8f51f2fa9e502 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -148,16 +148,4 @@ std::string CloudInfo::GetKey(const std::string &prefix, const std::initializer_ { return Constant::Join(prefix, Constant::KEY_SEPARATOR, fields); } - -std::optional CloudInfo::GetAppInfo(const std::string &bundleName) const -{ - if (bundleName.empty()) { - return std::nullopt; - } - auto it = apps.find(bundleName); - if (it == apps.end()) { - return std::nullopt; - } - return it->second; -} } // namespace OHOS::DistributedData \ No newline at end of file diff --git a/services/distributeddataservice/framework/cloud/cloud_mark.cpp b/services/distributeddataservice/framework/cloud/cloud_mark.cpp deleted file mode 100644 index 37e69ad2e8a8eabf7fdcf1c223a5bf745ab3ad9c..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/framework/cloud/cloud_mark.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - */ - -#include "cloud/cloud_mark.h" - -namespace OHOS::DistributedData { - -static constexpr const char *KEY_PREFIX = "CloudMark"; -static constexpr const char *KEY_SEPARATOR = "###"; -bool CloudMark::Marshal(Serializable::json &node) const -{ - SetValue(node[GET_NAME(isClearWaterMark)], isClearWaterMark); - return true; -} - -bool CloudMark::Unmarshal(const Serializable::json &node) -{ - GetValue(node, GET_NAME(isClearWaterMark), isClearWaterMark); - return true; -} - -std::string CloudMark::GetKey() -{ - return GetKey({ deviceId, std::to_string(userId), "default", bundleName, storeId, std::to_string(index) }); -} - -std::string CloudMark::GetKey(const std::initializer_list &fields) -{ - std::string prefix = KEY_PREFIX; - for (const auto &field : fields) { - prefix.append(KEY_SEPARATOR).append(field); - } - return prefix; -} -} // namespace OHOS::DistributedData \ No newline at end of file diff --git a/services/distributeddataservice/framework/feature/static_acts.cpp b/services/distributeddataservice/framework/feature/static_acts.cpp index f023d8da09ae5011eba2fe765cfdc573edc0ab80..28b4d0c45a4bcee0d4e106db96dc3924c7733e77 100644 --- a/services/distributeddataservice/framework/feature/static_acts.cpp +++ b/services/distributeddataservice/framework/feature/static_acts.cpp @@ -37,18 +37,4 @@ int32_t StaticActs::OnClearAppStorage(const std::string &bundleName, int32_t use { return E_OK; } - -void StaticActs::SetThreadPool(std::shared_ptr executors) -{ - executors_ = executors; -} - -void StaticActs::Execute(Task task) -{ - auto executor = executors_; - if (executor == nullptr) { - return; - } - executor->Execute(std::move(task)); -} } diff --git a/services/distributeddataservice/framework/include/cloud/cloud_event.h b/services/distributeddataservice/framework/include/cloud/cloud_event.h index 7c347470981f5e540afddcab8f10363df5420e20..abb96c1dd217ddcdc96bd57abdb89c01e10336a0 100644 --- a/services/distributeddataservice/framework/include/cloud/cloud_event.h +++ b/services/distributeddataservice/framework/include/cloud/cloud_event.h @@ -39,7 +39,6 @@ public: LOCK_CLOUD_CONTAINER, UNLOCK_CLOUD_CONTAINER, SET_SEARCH_TRIGGER, - UPGRADE_SCHEMA, CLOUD_BUTT }; diff --git a/services/distributeddataservice/framework/include/cloud/cloud_info.h b/services/distributeddataservice/framework/include/cloud/cloud_info.h index c565fcd2f4fd090899044837887c5333f7416945..b8ef793b4e4a383cdf2bf5864cb0eb5cc83bdf30 100644 --- a/services/distributeddataservice/framework/include/cloud/cloud_info.h +++ b/services/distributeddataservice/framework/include/cloud/cloud_info.h @@ -15,7 +15,6 @@ #ifndef OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_INFO_H #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_INFO_H -#include #include "metadata/store_meta_data.h" #include "serializable/serializable.h" namespace OHOS::DistributedData { @@ -53,7 +52,6 @@ public: bool IsOn(const std::string &bundleName, int32_t instanceId = 0) const; bool IsAllSwitchOff() const; static std::string GetPrefix(const std::initializer_list &field); - std::optional GetAppInfo(const std::string &bundleName) const; bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; diff --git a/services/distributeddataservice/framework/include/cloud/cloud_mark.h b/services/distributeddataservice/framework/include/cloud/cloud_mark.h deleted file mode 100644 index 47c5783d976c613594226763b49c9cdfece92a2a..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/framework/include/cloud/cloud_mark.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -#ifndef OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_MARK_H -#define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_MARK_H -#include "serializable/serializable.h" -#include "store/store_info.h" -namespace OHOS::DistributedData { -class API_EXPORT CloudMark final : public Serializable { -public: - bool isClearWaterMark = false; - std::string bundleName; - std::string deviceId; - std::string storeId; - int32_t userId = 0; - int32_t index = 0; - CloudMark() = default; - CloudMark(const StoreInfo &info) - : bundleName(info.bundleName), deviceId(info.deviceId), storeId(info.storeName), userId(info.user), - index(info.instanceId) - { - } - bool Marshal(json &node) const override; - bool Unmarshal(const json &node) override; - std::string GetKey(); - std::string GetKey(const std::initializer_list &fields); -}; - -} // namespace OHOS::DistributedData -#endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_MARK_H diff --git a/services/distributeddataservice/framework/include/feature/static_acts.h b/services/distributeddataservice/framework/include/feature/static_acts.h index beda3e42956199c27187596d0309444c5061f179..92a1977239f0f305ca5b521e044b4c43effdd086 100644 --- a/services/distributeddataservice/framework/include/feature/static_acts.h +++ b/services/distributeddataservice/framework/include/feature/static_acts.h @@ -17,25 +17,16 @@ #define OHOS_DISTRIBUTED_DATA_FRAMEWORK_STATIC_ACTS_H #include #include - #include "error/general_error.h" -#include "executor_pool.h" #include "visibility.h" - namespace OHOS::DistributedData { class API_EXPORT StaticActs { public: - using Task = ExecutorPool::Task; virtual ~StaticActs(); virtual int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index); virtual int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index); virtual int32_t OnAppInstall(const std::string &bundleName, int32_t user, int32_t index); virtual int32_t OnClearAppStorage(const std::string &bundleName, int32_t user, int32_t index, int32_t tokenId); - void SetThreadPool(std::shared_ptr executors); - void Execute(Task task); - -private: - std::shared_ptr executors_; }; } // namespace OHOS::DistributedData #endif // OHOS_DISTRIBUTED_DATA_FRAMEWORK_STATIC_ACTS_H diff --git a/services/distributeddataservice/service/cloud/BUILD.gn b/services/distributeddataservice/service/cloud/BUILD.gn index b36909c07967979acfa47d36caaf246362aaaa40..8253551ed913cf1dd33325b2a28d93482eb83b7f 100755 --- a/services/distributeddataservice/service/cloud/BUILD.gn +++ b/services/distributeddataservice/service/cloud/BUILD.gn @@ -61,10 +61,7 @@ ohos_source_set("distributeddata_cloud") { "-Oz", ] - deps = [ - "${data_service_path}/adapter/network:distributeddata_network", - "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", - ] + deps = [ "${data_service_path}/adapter/network:distributeddata_network" ] external_deps = [ "access_token:libtokenid_sdk", diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 2492401664a18bf3233d35bc14309e7836d8da30..5ac9a72414c424790c9c69967f346913d657cac4 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -24,7 +24,6 @@ #include "account/account_delegate.h" #include "checker/checker_manager.h" #include "cloud/cloud_last_sync_info.h" -#include "cloud/cloud_mark.h" #include "cloud/cloud_server.h" #include "cloud/cloud_share_event.h" #include "cloud/make_query_event.h" @@ -43,7 +42,6 @@ #include "reporter.h" #include "relational_store_manager.h" #include "runtime_config.h" -#include "get_schema_helper.h" #include "store/auto_cache.h" #include "sync_manager.h" #include "sync_strategies/network_sync_strategy.h" @@ -51,7 +49,6 @@ #include "values_bucket.h" #include "xcollie.h" - namespace OHOS::CloudData { using namespace DistributedData; using namespace std::chrono; @@ -72,7 +69,6 @@ static constexpr const char *FT_USER_UNLOCK = "USER_UNLOCK"; static constexpr const char *FT_NETWORK_RECOVERY = "NETWORK_RECOVERY"; static constexpr const char *FT_SERVICE_INIT = "SERVICE_INIT"; static constexpr const char *FT_SYNC_TASK = "SYNC_TASK"; -static constexpr const char *CLOUD_SCHEMA = "arkdata/cloud/cloud_schema.json"; __attribute__((used)) CloudServiceImpl::Factory CloudServiceImpl::factory_; const CloudServiceImpl::SaveStrategy CloudServiceImpl::STRATEGY_SAVERS[Strategy::STRATEGY_BUTT] = { &CloudServiceImpl::SaveNetworkStrategy @@ -103,9 +99,6 @@ CloudServiceImpl::CloudServiceImpl() EventCenter::GetInstance().Subscribe(CloudEvent::CLOUD_SHARE, [this](const Event &event) { CloudShare(event); }); - EventCenter::GetInstance().Subscribe(CloudEvent::UPGRADE_SCHEMA, [this](const Event &event) { - DoSync(event); - }); MetaDataManager::GetInstance().Subscribe( Subscription::GetPrefix({ "" }), [this](const std::string &key, const std::string &value, int32_t flag) -> auto { @@ -845,18 +838,8 @@ bool CloudServiceImpl::UpdateSchema(int32_t user, CloudSyncScene scene) } auto keys = cloudInfo.GetSchemaKey(); for (const auto &[bundle, key] : keys) { - HapInfo hapInfo{ .user = user, .instIndex = 0, .bundleName = bundle }; - auto appInfoOpt = cloudInfo.GetAppInfo(bundle); - if (appInfoOpt.has_value()) { - const CloudInfo::AppInfo &appInfo = appInfoOpt.value(); - hapInfo.instIndex = appInfo.instanceId; - } - SchemaMeta schemaMeta; - std::tie(status, schemaMeta) = GetSchemaFromHap(hapInfo); - if (status != SUCCESS) { - std::tie(status, schemaMeta) = GetAppSchemaFromServer(user, bundle); - } + std::tie(status, schemaMeta) = GetAppSchemaFromServer(user, bundle); if (status == NOT_SUPPORT) { ZLOGW("app not support, del cloudInfo! user:%{public}d, bundleName:%{public}s", user, bundle.c_str()); MetaDataManager::GetInstance().DelMeta(cloudInfo.GetKey(), true); @@ -868,7 +851,6 @@ bool CloudServiceImpl::UpdateSchema(int32_t user, CloudSyncScene scene) SchemaMeta oldMeta; if (MetaDataManager::GetInstance().LoadMeta(key, oldMeta, true)) { UpgradeSchemaMeta(user, oldMeta); - UpdateClearWaterMark(hapInfo, schemaMeta, oldMeta); } MetaDataManager::GetInstance().SaveMeta(key, schemaMeta, true); } @@ -966,12 +948,7 @@ std::pair CloudServiceImpl::GetSchemaMeta(int32_t userId, c return { SUCCESS, schemaMeta }; } UpgradeSchemaMeta(userId, schemaMeta); - HapInfo hapInfo{ .user = userId, .instIndex = instanceId, .bundleName = bundleName }; - std::tie(status, schemaMeta) = GetSchemaFromHap(hapInfo); - if (status == SUCCESS) { - MetaDataManager::GetInstance().SaveMeta(schemaKey, schemaMeta, true); - return { status, schemaMeta }; - } + if (!Account::GetInstance()->IsVerified(userId)) { ZLOGE("user:%{public}d is locked!", userId); return { ERROR, schemaMeta }; @@ -1031,92 +1008,7 @@ int32_t CloudServiceImpl::CloudStatic::OnAppUninstall(const std::string &bundleN int32_t CloudServiceImpl::CloudStatic::OnAppInstall(const std::string &bundleName, int32_t user, int32_t index) { - ZLOGI("bundleName:%{public}s,user:%{public}d,instanceId:%{public}d", bundleName.c_str(), user, index); - auto ret = UpdateCloudInfoFromServer(user); - if (ret == E_OK) { - StoreInfo info{.bundleName = bundleName, .instanceId = index, .user = user}; - EventCenter::GetInstance().PostEvent(std::make_unique(CloudEvent::GET_SCHEMA, info)); - } - return ret; -} - -int32_t CloudServiceImpl::CloudStatic::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) -{ - ZLOGI("bundleName:%{public}s,user:%{public}d,instanceId:%{public}d", bundleName.c_str(), user, index); - HapInfo hapInfo{ .user = user, .instIndex = index, .bundleName = bundleName }; - Execute([this, hapInfo]() { UpdateSchemaFromHap(hapInfo); }); - return SUCCESS; -} - -int32_t CloudServiceImpl::UpdateSchemaFromHap(const HapInfo &hapInfo) -{ - auto [status, cloudInfo] = GetCloudInfoFromMeta(hapInfo.user); - if (status != SUCCESS) { - return status; - } - if (!cloudInfo.Exist(hapInfo.bundleName, hapInfo.instIndex)) { - return ERROR; - } - - std::string schemaKey = CloudInfo::GetSchemaKey(hapInfo.user, hapInfo.bundleName, hapInfo.instIndex); - auto [ret, newSchemaMeta] = GetSchemaFromHap(hapInfo); - if (ret != SUCCESS) { - std::tie(ret, newSchemaMeta) = GetAppSchemaFromServer(hapInfo.user, hapInfo.bundleName); - } - if (ret != SUCCESS) { - MetaDataManager::GetInstance().DelMeta(schemaKey, true); - return ret; - } - - SchemaMeta schemaMeta; - if (MetaDataManager::GetInstance().LoadMeta(schemaKey, schemaMeta, true)) { - UpdateClearWaterMark(hapInfo, newSchemaMeta, schemaMeta); - } - MetaDataManager::GetInstance().SaveMeta(schemaKey, newSchemaMeta, true); - return SUCCESS; -} - -void CloudServiceImpl::UpdateClearWaterMark( - const HapInfo &hapInfo, const SchemaMeta &newSchemaMeta, const SchemaMeta &schemaMeta) -{ - if (newSchemaMeta.version == schemaMeta.version) { - return; - } - ZLOGI("update schemaMeta newVersion:%{public}d,oldVersion:%{public}d", newSchemaMeta.version, schemaMeta.version); - CloudMark metaData; - metaData.bundleName = hapInfo.bundleName; - metaData.userId = hapInfo.user; - metaData.index = hapInfo.instIndex; - metaData.deviceId = DmAdapter::GetInstance().GetLocalDevice().uuid; - - std::unordered_map dbMap; - for (const auto &database : schemaMeta.databases) { - dbMap[database.name] = database.version; - } - - for (const auto &database : newSchemaMeta.databases) { - if (dbMap.find(database.name) != dbMap.end() && database.version != dbMap[database.name]) { - metaData.storeId = database.name; - metaData.isClearWaterMark = true; - MetaDataManager::GetInstance().SaveMeta(metaData.GetKey(), metaData, true); - ZLOGI("clear watermark, storeId:%{public}s, newVersion:%{public}d, oldVersion:%{public}d", - Anonymous::Change(metaData.storeId).c_str(), database.version, dbMap[database.name]); - } - } -} - -std::pair CloudServiceImpl::GetSchemaFromHap(const HapInfo &hapInfo) -{ - SchemaMeta schemaMeta; - AppInfo info{ .bundleName = hapInfo.bundleName, .userId = hapInfo.user, .appIndex = hapInfo.instIndex }; - auto schemas = GetSchemaHelper::GetInstance().GetSchemaFromHap(CLOUD_SCHEMA, info); - for (auto &schema : schemas) { - if (schemaMeta.Unmarshall(schema)) { - return { SUCCESS, schemaMeta }; - } - } - ZLOGD("get schema from hap failed, bundleName:%{public}s", hapInfo.bundleName.c_str()); - return { ERROR, schemaMeta }; + return UpdateCloudInfoFromServer(user); } void CloudServiceImpl::GetSchema(const Event &event) @@ -1157,15 +1049,6 @@ void CloudServiceImpl::CloudShare(const Event &event) } } -void CloudServiceImpl::DoSync(const Event &event) -{ - auto &cloudEvent = static_cast(event); - auto &storeInfo = cloudEvent.GetStoreInfo(); - SyncManager::SyncInfo info(storeInfo.user, storeInfo.bundleName); - syncManager_.DoCloudSync(info); - return; -} - std::pair> CloudServiceImpl::PreShare( const StoreInfo &storeInfo, GenQuery &query) { diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.h b/services/distributeddataservice/service/cloud/cloud_service_impl.h index c1ec1dd099cb44a31eabce1bd26ef50a685672ad..1c50f2f15853aff7000078b244969973f9904bb7 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.h +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.h @@ -82,7 +82,6 @@ private: ~CloudStatic() override{}; int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) override; int32_t OnAppInstall(const std::string &bundleName, int32_t user, int32_t index) override; - int32_t OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index) override; }; class Factory { public: @@ -150,9 +149,9 @@ private: static std::pair GetCloudInfoFromMeta(int32_t userId); static std::pair GetCloudInfoFromServer(int32_t userId); static int32_t UpdateCloudInfoFromServer(int32_t user); - static std::pair GetAppSchemaFromServer(int32_t user, const std::string &bundleName); std::pair GetSchemaMeta(int32_t userId, const std::string &bundleName, int32_t instanceId); + std::pair GetAppSchemaFromServer(int32_t user, const std::string &bundleName); void UpgradeSchemaMeta(int32_t user, const SchemaMeta &schemaMeta); std::map ExecuteStatistics( const std::string &storeId, const CloudInfo &cloudInfo, const SchemaMeta &schemaMeta); @@ -162,7 +161,6 @@ private: void GetSchema(const Event &event); void CloudShare(const Event &event); - void DoSync(const Event &event); Task GenTask(int32_t retry, int32_t user, CloudSyncScene scene, Handles handles = { WORK_SUB }); Task GenSubTask(Task task, int32_t user); @@ -187,10 +185,6 @@ private: void Report(const std::string &faultType, DistributedDataDfx::Fault errCode, const std::string &bundleName, const std::string &appendix); - static std::pair GetSchemaFromHap(const HapInfo &hapInfo); - static int32_t UpdateSchemaFromHap(const HapInfo &hapInfo); - static void UpdateClearWaterMark( - const HapInfo &hapInfo, const SchemaMeta &newSchemaMeta, const SchemaMeta &schemaMeta); QueryLastResults AssembleLastResults(const std::vector &databases, const std::map &lastSyncInfos); diff --git a/services/distributeddataservice/service/rdb/rdb_general_store.cpp b/services/distributeddataservice/service/rdb/rdb_general_store.cpp index 754f258fb89577cbe40cfaa0d5fbd28dee158e81..35c6b72691dfb32344d2db502a37d2a4ef1775ef 100644 --- a/services/distributeddataservice/service/rdb/rdb_general_store.cpp +++ b/services/distributeddataservice/service/rdb/rdb_general_store.cpp @@ -23,7 +23,6 @@ #include "changeevent/remote_change_event.h" #include "cloud/asset_loader.h" #include "cloud/cloud_db.h" -#include "cloud/cloud_mark.h" #include "cloud/cloud_store_types.h" #include "cloud/schema_meta.h" #include "cloud_service.h" @@ -930,20 +929,6 @@ int32_t RdbGeneralStore::SetDistributedTables(const std::vector &ta if (exist) { delegate_->SetDistributedSchema(GetGaussDistributedSchema(database)); } - CloudMark metaData(storeInfo_); - if (MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), metaData, true) && metaData.isClearWaterMark) { - DistributedDB::ClearMetaDataOption option{ .mode = DistributedDB::ClearMetaDataMode::CLOUD_WATERMARK }; - auto ret = delegate_->ClearMetaData(option); - if (ret != DBStatus::OK) { - ZLOGE("clear watermark failed, err:%{public}d", ret); - return GeneralError::E_ERROR; - } - MetaDataManager::GetInstance().DelMeta(metaData.GetKey(), true); - auto event = std::make_unique(CloudEvent::UPGRADE_SCHEMA, storeInfo_); - EventCenter::GetInstance().PostEvent(std::move(event)); - ZLOGI("clear watermark success, bundleName:%{public}s, storeName:%{public}s", storeInfo_.bundleName.c_str(), - Anonymous::Change(storeInfo_.storeName).c_str()); - } return GeneralError::E_OK; } diff --git a/services/distributeddataservice/service/test/BUILD.gn b/services/distributeddataservice/service/test/BUILD.gn index 9b359e5aa7403c2de5dab19fa3a08745571c26f7..e75e940c4edd39f8c26a3fde883c8708705171e4 100755 --- a/services/distributeddataservice/service/test/BUILD.gn +++ b/services/distributeddataservice/service/test/BUILD.gn @@ -141,7 +141,6 @@ ohos_unittest("CloudDataTest") { deps = [ "${data_service_path}/adapter/account:distributeddata_account", "${data_service_path}/adapter/communicator:distributeddata_communicator", - "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", "../../framework:distributeddatasvcfwk", "mock:distributeddata_mock_static", "//third_party/googletest:gtest_main", @@ -236,7 +235,6 @@ ohos_unittest("CloudServiceImplTest") { deps = [ "${data_service_path}/adapter/account:distributeddata_account", "${data_service_path}/adapter/communicator:distributeddata_communicator", - "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", "../../framework:distributeddatasvcfwk", "mock:distributeddata_mock_static", "//third_party/googletest:gtest_main", @@ -1732,8 +1730,6 @@ group("unittest") { ":CloudDataTest", ":CloudServiceImplTest", ":CloudTest", - "ohos_test:copy_ohos_test", - "testCloud:testCloud", ] } diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 107a81cf98362b96e6094e54c123be676757e33c..4fff67a0257ab0dc53cbaa84a53a5bdc99204660 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -20,7 +20,6 @@ #include "account/account_delegate.h" #include "bootstrap.h" #include "checker_mock.h" -#include "cloud/cloud_mark.h" #include "cloud/change_event.h" #include "cloud/cloud_event.h" #include "cloud/cloud_last_sync_info.h" @@ -87,7 +86,6 @@ void AllocHapToken(const HapPolicyParams &policy) namespace OHOS::Test { namespace DistributedDataTest { -static constexpr const int32_t SCHEMA_VERSION = 101; static constexpr const int32_t EVT_USER = 102; static constexpr const char *TEST_TRACE_ID = "123456789"; static constexpr const char *TEST_CLOUD_BUNDLE = "test_cloud_bundleName"; @@ -96,7 +94,6 @@ static constexpr const char *TEST_CLOUD_STORE = "test_cloud_store"; static constexpr const char *TEST_CLOUD_STORE_1 = "test_cloud_store1"; static constexpr const char *TEST_CLOUD_ID = "test_cloud_id"; static constexpr const char *TEST_CLOUD_TABLE = "teat_cloud_table"; -static constexpr const char *COM_EXAMPLE_TEST_CLOUD = "com.example.testCloud"; static constexpr const char *TEST_CLOUD_DATABASE_ALIAS_1 = "test_cloud_database_alias_1"; static constexpr const char *TEST_CLOUD_DATABASE_ALIAS_2 = "test_cloud_database_alias_2"; static constexpr const char *PERMISSION_CLOUDDATA_CONFIG = "ohos.permission.CLOUDDATA_CONFIG"; @@ -104,7 +101,6 @@ static constexpr const char *PERMISSION_GET_NETWORK_INFO = "ohos.permission.GET_ static constexpr const char *PERMISSION_DISTRIBUTED_DATASYNC = "ohos.permission.DISTRIBUTED_DATASYNC"; static constexpr const char *PERMISSION_ACCESS_SERVICE_DM = "ohos.permission.ACCESS_SERVICE_DM"; static constexpr const char *PERMISSION_MANAGE_LOCAL_ACCOUNTS = "ohos.permission.MANAGE_LOCAL_ACCOUNTS"; -static constexpr const char *PERMISSION_GET_BUNDLE_INFO = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; PermissionDef GetPermissionDef(const std::string &permission) { PermissionDef def = { .permissionName = permission, @@ -270,13 +266,12 @@ void CloudDataTest::SetUpTestCase(void) .domain = "test.domain", .permList = { GetPermissionDef(PERMISSION_CLOUDDATA_CONFIG), GetPermissionDef(PERMISSION_GET_NETWORK_INFO), GetPermissionDef(PERMISSION_DISTRIBUTED_DATASYNC), GetPermissionDef(PERMISSION_ACCESS_SERVICE_DM), - GetPermissionDef(PERMISSION_MANAGE_LOCAL_ACCOUNTS), GetPermissionDef(PERMISSION_GET_BUNDLE_INFO) }, + GetPermissionDef(PERMISSION_MANAGE_LOCAL_ACCOUNTS) }, .permStateList = { GetPermissionStateFull(PERMISSION_CLOUDDATA_CONFIG), GetPermissionStateFull(PERMISSION_GET_NETWORK_INFO), GetPermissionStateFull(PERMISSION_DISTRIBUTED_DATASYNC), GetPermissionStateFull(PERMISSION_ACCESS_SERVICE_DM), - GetPermissionStateFull(PERMISSION_MANAGE_LOCAL_ACCOUNTS), - GetPermissionStateFull(PERMISSION_GET_BUNDLE_INFO)} }; + GetPermissionStateFull(PERMISSION_MANAGE_LOCAL_ACCOUNTS)} }; g_selfTokenID = GetSelfTokenID(); AllocHapToken(policy); size_t max = 12; @@ -2498,193 +2493,6 @@ HWTEST_F(CloudDataTest, GetPriorityLevel004, TestSize.Level1) rdbServiceImpl.DoCloudSync(param, option, memo, nullptr); } -/** -* @tc.name: UpdateSchemaFromHap001 -* @tc.desc: Test the UpdateSchemaFromHap with invalid user -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(CloudDataTest, UpdateSchemaFromHap001, TestSize.Level0) -{ - ASSERT_NE(cloudServiceImpl_, nullptr); - CloudData::CloudServiceImpl::HapInfo info = { .instIndex = 0, .bundleName = TEST_CLOUD_BUNDLE, .user = -1 }; - auto ret = cloudServiceImpl_->UpdateSchemaFromHap(info); - EXPECT_EQ(ret, Status::ERROR); -} - -/** -* @tc.name: UpdateSchemaFromHap002 -* @tc.desc: Test the UpdateSchemaFromHap with invalid bundleName -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(CloudDataTest, UpdateSchemaFromHap002, TestSize.Level0) -{ - ASSERT_NE(cloudServiceImpl_, nullptr); - CloudData::CloudServiceImpl::HapInfo info = { .instIndex = 0, .bundleName = "", .user = cloudInfo_.user }; - auto ret = cloudServiceImpl_->UpdateSchemaFromHap(info); - EXPECT_EQ(ret, Status::ERROR); -} - -/** -* @tc.name: UpdateSchemaFromHap003 -* @tc.desc: Test the UpdateSchemaFromHap with the schema application is not configured -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(CloudDataTest, UpdateSchemaFromHap003, TestSize.Level0) -{ - ASSERT_NE(cloudServiceImpl_, nullptr); - CloudData::CloudServiceImpl::HapInfo info = { - .instIndex = 0, .bundleName = TEST_CLOUD_BUNDLE, .user = cloudInfo_.user - }; - auto ret = cloudServiceImpl_->UpdateSchemaFromHap(info); - EXPECT_EQ(ret, Status::SUCCESS); - SchemaMeta schemaMeta; - std::string schemaKey = CloudInfo::GetSchemaKey(info.user, info.bundleName, info.instIndex); - ASSERT_TRUE(MetaDataManager::GetInstance().LoadMeta(schemaKey, schemaMeta, true)); - EXPECT_EQ(schemaMeta.version, schemaMeta_.version); -} - -/** -* @tc.name: UpdateSchemaFromHap004 -* @tc.desc: Test the UpdateSchemaFromHap with valid parameter -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(CloudDataTest, UpdateSchemaFromHap004, TestSize.Level0) -{ - ASSERT_NE(cloudServiceImpl_, nullptr); - CloudInfo::AppInfo exampleAppInfo; - exampleAppInfo.bundleName = COM_EXAMPLE_TEST_CLOUD; - exampleAppInfo.appId = COM_EXAMPLE_TEST_CLOUD; - exampleAppInfo.version = 1; - exampleAppInfo.cloudSwitch = true; - CloudInfo cloudInfo; - MetaDataManager::GetInstance().LoadMeta(cloudInfo_.GetKey(), cloudInfo, true); - cloudInfo.apps[COM_EXAMPLE_TEST_CLOUD] = std::move(exampleAppInfo); - MetaDataManager::GetInstance().SaveMeta(cloudInfo_.GetKey(), cloudInfo, true); - CloudData::CloudServiceImpl::HapInfo info = { - .instIndex = 0, .bundleName = COM_EXAMPLE_TEST_CLOUD, .user = cloudInfo_.user - }; - auto ret = cloudServiceImpl_->UpdateSchemaFromHap(info); - EXPECT_EQ(ret, Status::SUCCESS); - SchemaMeta schemaMeta; - std::string schemaKey = CloudInfo::GetSchemaKey(info.user, info.bundleName, info.instIndex); - ASSERT_TRUE(MetaDataManager::GetInstance().LoadMeta(schemaKey, schemaMeta, true)); - EXPECT_EQ(schemaMeta.version, SCHEMA_VERSION); -} - -/** -* @tc.name: UpdateClearWaterMark001 -* @tc.desc: Test UpdateClearWaterMark001 the database.version not found. -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(CloudDataTest, UpdateClearWaterMark001, TestSize.Level0) -{ - ASSERT_NE(cloudServiceImpl_, nullptr); - CloudData::CloudServiceImpl::HapInfo hapInfo = { - .instIndex = 0, .bundleName = TEST_CLOUD_BUNDLE, .user = cloudInfo_.user - }; - SchemaMeta::Database database; - database.name = TEST_CLOUD_STORE; - database.version = 1; - SchemaMeta schemaMeta; - schemaMeta.version = 1; - schemaMeta.databases.push_back(database); - - SchemaMeta::Database database1; - database1.name = TEST_CLOUD_STORE_1; - database1.version = 2; - SchemaMeta newSchemaMeta; - newSchemaMeta.version = 0; - newSchemaMeta.databases.push_back(database1); - cloudServiceImpl_->UpdateClearWaterMark(hapInfo, newSchemaMeta, schemaMeta); - - CloudMark metaData; - metaData.bundleName = hapInfo.bundleName; - metaData.userId = hapInfo.user; - metaData.index = hapInfo.instIndex; - metaData.deviceId = DmAdapter::GetInstance().GetLocalDevice().uuid; - metaData.storeId = database1.name; - ASSERT_FALSE(MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), metaData, true)); -} - -/** -* @tc.name: UpdateClearWaterMark002 -* @tc.desc: Test UpdateClearWaterMark002 the same database.version -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(CloudDataTest, UpdateClearWaterMark002, TestSize.Level0) -{ - ASSERT_NE(cloudServiceImpl_, nullptr); - CloudData::CloudServiceImpl::HapInfo hapInfo = { - .instIndex = 0, .bundleName = TEST_CLOUD_BUNDLE, .user = cloudInfo_.user - }; - SchemaMeta::Database database; - database.name = TEST_CLOUD_STORE; - database.version = 1; - SchemaMeta schemaMeta; - schemaMeta.version = 1; - schemaMeta.databases.push_back(database); - - SchemaMeta::Database database1; - database1.name = TEST_CLOUD_STORE; - database1.version = 1; - SchemaMeta newSchemaMeta; - newSchemaMeta.version = 0; - newSchemaMeta.databases.push_back(database1); - cloudServiceImpl_->UpdateClearWaterMark(hapInfo, newSchemaMeta, schemaMeta); - - CloudMark metaData; - metaData.bundleName = hapInfo.bundleName; - metaData.userId = hapInfo.user; - metaData.index = hapInfo.instIndex; - metaData.deviceId = DmAdapter::GetInstance().GetLocalDevice().uuid; - metaData.storeId = database1.name; - ASSERT_FALSE(MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), metaData, true)); -} - -/** -* @tc.name: UpdateClearWaterMark003 -* @tc.desc: Test UpdateClearWaterMark003 the different database.version -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(CloudDataTest, UpdateClearWaterMark003, TestSize.Level0) -{ - ASSERT_NE(cloudServiceImpl_, nullptr); - CloudData::CloudServiceImpl::HapInfo hapInfo = { - .instIndex = 0, .bundleName = TEST_CLOUD_BUNDLE, .user = cloudInfo_.user - }; - SchemaMeta::Database database; - database.name = TEST_CLOUD_STORE; - database.version = 1; - SchemaMeta schemaMeta; - schemaMeta.version = 1; - schemaMeta.databases.push_back(database); - - SchemaMeta::Database database1; - database1.name = TEST_CLOUD_STORE; - database1.version = 2; - SchemaMeta newSchemaMeta; - newSchemaMeta.version = 0; - newSchemaMeta.databases.push_back(database1); - cloudServiceImpl_->UpdateClearWaterMark(hapInfo, newSchemaMeta, schemaMeta); - - CloudMark metaData; - metaData.bundleName = hapInfo.bundleName; - metaData.userId = hapInfo.user; - metaData.index = hapInfo.instIndex; - metaData.deviceId = DmAdapter::GetInstance().GetLocalDevice().uuid; - metaData.storeId = database1.name; - ASSERT_TRUE(MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), metaData, true)); - EXPECT_TRUE(metaData.isClearWaterMark); - MetaDataManager::GetInstance().DelMeta(metaData.GetKey(), true); -} - /** * @tc.name: GetPrepareTraceId * @tc.desc: Test GetPrepareTraceId && GetUser diff --git a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn index 30cc77cc748c64e3ef674068fafafea32640ed01..228e7d6dc3c78e28e35cd3dc346b20cdd0e82aa7 100644 --- a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn @@ -111,7 +111,6 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { deps = [ "${data_service_path}/adapter/account:distributeddata_account", "${data_service_path}/adapter/network:distributeddata_network", - "${data_service_path}/adapter/schema_helper:distributeddata_schema_helper", "${data_service_path}/adapter/utils:distributeddata_utils", "${data_service_path}/framework:distributeddatasvcfwk", "${data_service_path}/service:distributeddatasvc", diff --git a/services/distributeddataservice/service/test/ohos_test/BUILD.gn b/services/distributeddataservice/service/test/ohos_test/BUILD.gn deleted file mode 100644 index d0140c7d02939e80f9f4bb2e475752787634a3d1..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/ohos_test/BUILD.gn +++ /dev/null @@ -1,22 +0,0 @@ -# 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. - -import("//build/ohos.gni") - -ohos_copy("copy_ohos_test") { - subsystem_name = "distributeddatamgr" - part_name = "datamgr_service" - sources = [ "./ohos_test.xml" ] - outputs = - [ "$root_out_dir/tests/unittest/datamgr_service/resource/ohos_test.xml" ] -} diff --git a/services/distributeddataservice/service/test/ohos_test/ohos_test.xml b/services/distributeddataservice/service/test/ohos_test/ohos_test.xml deleted file mode 100644 index 8586520c773ed0cc9a524e8a08084ed30a5aaa93..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/ohos_test/ohos_test.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/services/distributeddataservice/service/test/testCloud/AppScope/app.json b/services/distributeddataservice/service/test/testCloud/AppScope/app.json deleted file mode 100644 index 3bbd52d9937fa31936884fe5bf0cf388ca8a970a..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/AppScope/app.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "app": { - "bundleName": "com.example.testCloud", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true, - "minAPIVersion": 9, - "targetAPIVersion": 9 - } -} diff --git a/services/distributeddataservice/service/test/testCloud/AppScope/resources/base/element/string.json b/services/distributeddataservice/service/test/testCloud/AppScope/resources/base/element/string.json deleted file mode 100644 index 771eddc83c25bfc4545e549e8a5a7c350f8a5a2b..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "Extension" - } - ] -} diff --git a/services/distributeddataservice/service/test/testCloud/AppScope/resources/base/media/app_icon.png b/services/distributeddataservice/service/test/testCloud/AppScope/resources/base/media/app_icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/services/distributeddataservice/service/test/testCloud/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/services/distributeddataservice/service/test/testCloud/BUILD.gn b/services/distributeddataservice/service/test/testCloud/BUILD.gn deleted file mode 100644 index e4d86447f27b4c46bb8e810db739d1450f615e43..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/BUILD.gn +++ /dev/null @@ -1,45 +0,0 @@ -# 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. - -import("//build/ohos.gni") - -ohos_hap("testCloud") { - hap_profile = "entry/src/main/module.json" - hap_name = "testCloud" - subsystem_name = "distributeddatamgr" - part_name = "datamgr_service" - final_hap_path = - "$root_out_dir/tests/unittest/datamgr_service/resource/${hap_name}.hap" - testonly = true - deps = [ - ":testCloud_ets_assets", - ":testCloud_ets_resources", - ] - certificate_profile = "signature/openharmony_sx.p7b" -} - -ohos_js_assets("testCloud_ets_assets") { - source_dir = "entry/src/main/ets" - hap_profile = "entry/src/main/module.json" -} - -ohos_app_scope("testCloud_app_profile") { - app_profile = "AppScope/app.json" - sources = [ "AppScope/resources" ] -} - -ohos_resources("testCloud_ets_resources") { - sources = [ "entry/src/main/resources" ] - deps = [ ":testCloud_app_profile" ] - hap_profile = "entry/src/main/module.json" -} diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/Application/MyAbilityStage.ts b/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/Application/MyAbilityStage.ts deleted file mode 100644 index 19d67bae85fa2bd4f42362759c98a97718c6195e..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/Application/MyAbilityStage.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - */ - -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - } -} \ No newline at end of file diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/MainAbility/MainAbility.ts b/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100644 index f1a7bf8fb1af00b5bd000c714f06b6c0d692325c..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - - windowStage.loadContent("pages/index", (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) - }); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/pages/index.ets b/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/pages/index.ets deleted file mode 100644 index 33bf2fafb560ca599e45b0dd7e4b52a98dea65fd..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/ets/pages/index.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -@Entry -@Component -struct Index { - @State message: string = 'StartAbility Success' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(30) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/module.json b/services/distributeddataservice/service/test/testCloud/entry/src/main/module.json deleted file mode 100644 index 352fc3e154f7b5138f86186ea2a3a01fd68b8ba6..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/module.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "module": { - "name": "entry", - "type": "entry", - "srcEntrance": "./ets/Application/MyAbilityStage.ts", - "description": "$string:entry_desc", - "mainElement": "MainAbility", - "deviceTypes": [ - "default", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:MainAbility_desc", - "icon": "$media:icon", - "label": "$string:MainAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:white", - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } -} \ No newline at end of file diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/element/color.json b/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/element/color.json deleted file mode 100644 index 1bbc9aa9617e97c45440e1d3d66afc1154837012..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "white", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/element/string.json b/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 496f24f73704a62e0100d427ad898950983a99d4..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "entry_desc", - "value": "testCloud" - }, - { - "name": "MainAbility_desc", - "value": "testCloud" - }, - { - "name": "MainAbility_label", - "value": "testCloud" - } - ] -} \ No newline at end of file diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/media/icon.png b/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/profile/main_pages.json b/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index feec276e105eeb8d621c20aaf838f318b0a94150..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/index" - ] -} diff --git a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/rawfile/arkdata/cloud/cloud_schema.json b/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/rawfile/arkdata/cloud/cloud_schema.json deleted file mode 100644 index 97cc6153dab2d3a6cd7bdf32be0402553fecfddc..0000000000000000000000000000000000000000 --- a/services/distributeddataservice/service/test/testCloud/entry/src/main/resources/rawfile/arkdata/cloud/cloud_schema.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "bundleName": "com.example.testCloud", - "databases": [], - "metaVersion": 65536, - "version": 101 -} \ No newline at end of file diff --git a/services/distributeddataservice/service/test/testCloud/signature/openharmony_sx.p7b b/services/distributeddataservice/service/test/testCloud/signature/openharmony_sx.p7b deleted file mode 100644 index fd0a3916af7bc804ad185d9794693c17d641f487..0000000000000000000000000000000000000000 Binary files a/services/distributeddataservice/service/test/testCloud/signature/openharmony_sx.p7b and /dev/null differ