diff --git a/interfaces/innerkits/app_distributeddata/include/visibility.h b/interfaces/innerkits/app_distributeddata/include/visibility.h index 2ffb65244c7345fa10aa830da1476e09e4d9fef8..a5c2669c888b322f43f0c0864b2209c5a39246e0 100644 --- a/interfaces/innerkits/app_distributeddata/include/visibility.h +++ b/interfaces/innerkits/app_distributeddata/include/visibility.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 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 @@ -12,16 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OHOS_DISTRIBUTED_DATA_INTERFACE_APP_DISTRIBUTEDDATA_INCLUDE_COMMON_VISIBILITY_H +#define OHOS_DISTRIBUTED_DATA_INTERFACE_APP_DISTRIBUTEDDATA_INCLUDE_COMMON_VISIBILITY_H -#ifndef KVSTORE_API -#ifdef _WIN32 - #ifdef DB_DLL_EXPORT - #define KVSTORE_API __declspec(dllexport) - #else - #define KVSTORE_API - #endif -#else - #define KVSTORE_API __attribute__ ((visibility ("default"))) +#ifndef API_EXPORT +#define API_EXPORT __attribute__((visibility("default"))) #endif +#ifndef KVSTORE_API +#define KVSTORE_API API_EXPORT #endif +#endif // OHOS_DISTRIBUTED_DATA_INTERFACE_APP_DISTRIBUTEDDATA_INCLUDE_COMMON_VISIBILITY_H diff --git a/services/distributeddataservice/adapter/security/BUILD.gn b/services/distributeddataservice/adapter/security/BUILD.gn index 4ca34ef5ccda3ed239fe12fb3d1d749c5522a065..5b0f6a3a272286cabe598da297913226313bdad3 100755 --- a/services/distributeddataservice/adapter/security/BUILD.gn +++ b/services/distributeddataservice/adapter/security/BUILD.gn @@ -15,7 +15,6 @@ import("//build/ohos.gni") ohos_static_library("distributeddata_security_static") { sources = [ - "src/block_integer.cpp", "src/security.cpp", "src/security_adapter.cpp", "src/sensitive.cpp", @@ -28,10 +27,13 @@ ohos_static_library("distributeddata_security_static") { "../include/log", "../include/security", "../include/communicator", + "//foundation/distributeddatamgr/distributeddatamgr/frameworks/common", "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/app_distributeddata/include", + "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/framework/include", ] deps = [ + "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/framework:distributeddatasvcfwk", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/libs/distributeddb:distributeddb", "//utils/native/base:utils", ] diff --git a/services/distributeddataservice/adapter/security/src/security.cpp b/services/distributeddataservice/adapter/security/src/security.cpp index 05f95e918ef3f95b11f8c87ab38a0ec96c6eb9e7..7ab087ff89f2b3066784a83f41d7e6c8d48e1242 100755 --- a/services/distributeddataservice/adapter/security/src/security.cpp +++ b/services/distributeddataservice/adapter/security/src/security.cpp @@ -14,19 +14,22 @@ */ #include "security.h" + #include #include + #include "communication_provider.h" #include "constant.h" -#include "sensitive.h" #include "log_print.h" -#include "block_integer.h" #include "ohos_account_kits.h" +#include "sensitive.h" +#include "utils/block_integer.h" #undef LOG_TAG #define LOG_TAG "SecurityAdapter" namespace OHOS::DistributedKv { using namespace DistributedDB; +using BlockInteger = OHOS::DistributedData::BlockInteger; std::atomic_bool Security::isInitialized_ = true; const char * const Security::LABEL_VALUES[S4 + 1] = {}; const char * const Security::DATA_DE[] = { nullptr }; diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index b59f3ea407600d10dab1add57cf7a21feeef0438..98135ed8e223d85228cd59941ea5fa146c09ebff 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -16,12 +16,14 @@ #define LOG_TAG "KvStoreDataService" #include "kvstore_data_service.h" -#include + #include #include #include -#include #include +#include +#include + #include "auto_launch_export.h" #include "bootstrap.h" #include "checker/checker_manager.h" @@ -41,10 +43,11 @@ #include "permission/permission_kit.h" #include "permission_validator.h" #include "process_communicator_impl.h" -#include "reporter.h" #include "rdb_service_impl.h" +#include "reporter.h" #include "system_ability_definition.h" #include "uninstaller/uninstaller.h" +#include "utils/block_integer.h" #include "utils/crypto.h" namespace OHOS::DistributedKv { @@ -812,6 +815,15 @@ void KvStoreDataService::OnStart() void KvStoreDataService::StartService() { + static constexpr int32_t RETRY_TIMES = 10; + static constexpr int32_t RETRY_INTERVAL = 500; // unit is ms + for (BlockInteger retry(RETRY_INTERVAL); retry < RETRY_TIMES; ++retry) { + if (!DeviceKvStoreImpl::GetLocalDeviceId().empty()) { + break; + } + ZLOGE("GetLocalDeviceId failed, reties: %{public}d", static_cast(retry)); + } + // register this to ServiceManager. bool ret = SystemAbility::Publish(this); if (!ret) { diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn index 92907a77728068f95ced5d858e4bd0f91da8122e..60f591ddfe101009707441c35b50e49e1fc68288 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -38,6 +38,7 @@ ohos_shared_library("distributeddatasvcfwk") { "metadata/secret_key_meta_data.cpp", "metadata/store_meta_data.cpp", "serializable/serializable.cpp", + "utils/block_integer.cpp", "utils/constant.cpp", "utils/crypto.cpp", ] @@ -49,7 +50,6 @@ ohos_shared_library("distributeddatasvcfwk") { ldflags = [ "-Wl,--exclude-libs,libcrypto_static.a" ] deps = [ - "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", "//third_party/openssl:libcrypto_static", "//utils/native/base:utils", ] diff --git a/services/distributeddataservice/framework/checker/checker_manager.cpp b/services/distributeddataservice/framework/checker/checker_manager.cpp index 1b62d65109a8c225110957da892a2e908dec9223..f0a7c316a50df1c462eca1d15e9fb3b242d93e15 100644 --- a/services/distributeddataservice/framework/checker/checker_manager.cpp +++ b/services/distributeddataservice/framework/checker/checker_manager.cpp @@ -13,8 +13,6 @@ * limitations under the License. */ #include "checker/checker_manager.h" -#include "account/account_delegate.h" -using namespace OHOS::DistributedKv; namespace OHOS { namespace DistributedData { CheckerManager &CheckerManager::GetInstance() diff --git a/services/distributeddataservice/framework/include/checker/checker_manager.h b/services/distributeddataservice/framework/include/checker/checker_manager.h index e703a46ed72732f010148608bf1f3f606d547d16..938730a9d1eba010cbf54b765d2c4ea25295facf 100644 --- a/services/distributeddataservice/framework/include/checker/checker_manager.h +++ b/services/distributeddataservice/framework/include/checker/checker_manager.h @@ -15,6 +15,7 @@ #ifndef OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CHECKER_CHECKER_MANAGER_H #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CHECKER_CHECKER_MANAGER_H +#include #include "visibility.h" #include "concurrent_map.h" namespace OHOS { diff --git a/services/distributeddataservice/adapter/security/src/block_integer.h b/services/distributeddataservice/framework/include/utils/block_integer.h old mode 100755 new mode 100644 similarity index 44% rename from services/distributeddataservice/adapter/security/src/block_integer.h rename to services/distributeddataservice/framework/include/utils/block_integer.h index 62ed8b4dbf326d2a11197b9d306925af52cd00b9..ca8733cc386637f47a98f891ea51fe14b381c9c8 --- a/services/distributeddataservice/adapter/security/src/block_integer.h +++ b/services/distributeddataservice/framework/include/utils/block_integer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 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 @@ -13,41 +13,36 @@ * limitations under the License. */ -#ifndef OHOS_BLOCK_INTEGER_H -#define OHOS_BLOCK_INTEGER_H - +#ifndef OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_UTILS_BLOCK_INTEGER_H +#define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_UTILS_BLOCK_INTEGER_H +#include "visibility.h" +namespace OHOS::DistributedData { class BlockInteger { public: - explicit BlockInteger(int interval) - : interval_(interval) - { - }; - BlockInteger(const BlockInteger &integer) - : interval_(integer.interval_), value_(integer.value_) - { - }; - BlockInteger &operator=(const BlockInteger &integer) = default; + API_EXPORT explicit BlockInteger(int interval) : interval_(interval) {}; + API_EXPORT BlockInteger(const BlockInteger &integer) : interval_(integer.interval_), value_(integer.value_) {}; + API_EXPORT BlockInteger &operator=(const BlockInteger &integer) = default; - ~BlockInteger() = default; + API_EXPORT ~BlockInteger() = default; - operator int () const + API_EXPORT operator int() const { return value_; } - bool operator < (int other) const + API_EXPORT bool operator<(int other) const { return value_ < other; } - BlockInteger &operator=(int value); + API_EXPORT BlockInteger &operator=(int value); - BlockInteger &operator++(); + API_EXPORT BlockInteger &operator++(); + + API_EXPORT BlockInteger operator++(int); - BlockInteger operator++(int); private: int interval_ = 0; int value_ = 0; }; - - -#endif // OHOS_BLOCK_INTEGER_H +} +#endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_UTILS_BLOCK_INTEGER_H diff --git a/services/distributeddataservice/adapter/security/src/block_integer.cpp b/services/distributeddataservice/framework/utils/block_integer.cpp old mode 100755 new mode 100644 similarity index 90% rename from services/distributeddataservice/adapter/security/src/block_integer.cpp rename to services/distributeddataservice/framework/utils/block_integer.cpp index 8c800cca8efe02976637c57c49ee6888b9e373ee..536e525fff9fb53b7a1a91d463842a04619fc045 --- a/services/distributeddataservice/adapter/security/src/block_integer.cpp +++ b/services/distributeddataservice/framework/utils/block_integer.cpp @@ -12,10 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "block_integer.h" +#include "utils/block_integer.h" #include +namespace OHOS::DistributedData { BlockInteger &BlockInteger::operator++() { value_++; @@ -37,3 +37,4 @@ BlockInteger &BlockInteger::operator=(int value) value_ = value; return *this; } +} \ No newline at end of file