diff --git a/README.md b/README.md index 899bb077..c8c4e88a 100755 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ DistributedDeviceProfileClient::GetInstance().DeleteDeviceProfile(serviceId); ```c++ // 定义同步模式和范围 SyncOptions syncOption; -syncOption.SetSyncMode((OHOS::DistributedKv::SyncMode)atoi(mode.c_str())); +syncOption.SetSyncMode((OHOS::DeviceProfile::SyncMode)atoi(mode.c_str())); for (const auto& deviceId : deviceIds) { syncOption.AddDevice(deviceId); } diff --git a/README_zh.md b/README_zh.md index 899bb077..c8c4e88a 100755 --- a/README_zh.md +++ b/README_zh.md @@ -135,7 +135,7 @@ DistributedDeviceProfileClient::GetInstance().DeleteDeviceProfile(serviceId); ```c++ // 定义同步模式和范围 SyncOptions syncOption; -syncOption.SetSyncMode((OHOS::DistributedKv::SyncMode)atoi(mode.c_str())); +syncOption.SetSyncMode((OHOS::DeviceProfile::SyncMode)atoi(mode.c_str())); for (const auto& deviceId : deviceIds) { syncOption.AddDevice(deviceId); } diff --git a/interfaces/innerkits/core/BUILD.gn b/interfaces/innerkits/core/BUILD.gn index 55019986..1d40b834 100755 --- a/interfaces/innerkits/core/BUILD.gn +++ b/interfaces/innerkits/core/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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 @@ -16,21 +16,19 @@ import("//build/ohos_var.gni") device_profile_path = "//foundation/deviceprofile/device_profile_core" device_profile_service = "${device_profile_path}/services/core" -distributed_datamgr_innerkits = - "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits" config("distributed_device_profile_client_config") { visibility = [ ":*" ] include_dirs = [ "include", "${device_profile_path}/common/include", - "${distributed_datamgr_innerkits}/distributeddata/include", "//third_party/json/include", ] } ohos_shared_library("distributed_device_profile_client") { install_enable = true + sources = [ "${device_profile_path}/common/src/device_profile_utils.cpp", "${device_profile_service}/src/profile_change_notification.cpp", @@ -44,18 +42,14 @@ ohos_shared_library("distributed_device_profile_client") { public_configs = [ ":distributed_device_profile_client_config" ] - deps = [ + public_deps = [ + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//utils/native/base:utils", ] - - public_deps = [ "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler" ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] part_name = "device_profile_core" subsystem_name = "deviceprofile" diff --git a/interfaces/innerkits/core/include/sync_options.h b/interfaces/innerkits/core/include/sync_options.h index 5da05957..56f3965e 100755 --- a/interfaces/innerkits/core/include/sync_options.h +++ b/interfaces/innerkits/core/include/sync_options.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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,33 +13,40 @@ * limitations under the License. */ -#ifndef OHOS_SYNC_OPERATION_H -#define OHOS_SYNC_OPERATION_H +#ifndef OHOS_DEVICE_PROFILE_SYNC_OPTIONS_H +#define OHOS_DEVICE_PROFILE_SYNC_OPTIONS_H #include + #include "parcel.h" -#include "types.h" namespace OHOS { namespace DeviceProfile { +// must keep same with DistributedKv::SyncMode +enum class SyncMode { + PULL, + PUSH, + PUSH_PULL, +}; + class SyncOptions : public Parcelable { public: SyncOptions() = default; ~SyncOptions() = default; const std::list& GetDeviceList() const; - DistributedKv::SyncMode GetSyncMode() const; + SyncMode GetSyncMode() const; void AddDevice(const std::string& deviceId); - void SetSyncMode(DistributedKv::SyncMode mode); + void SetSyncMode(SyncMode mode); bool Marshalling(Parcel& parcel) const override; bool Unmarshalling(Parcel& parcel); private: - DistributedKv::SyncMode syncMode_ {DistributedKv::SyncMode::PUSH}; + SyncMode syncMode_ {SyncMode::PUSH}; std::list syncDevIds_; }; } // namespace DeviceProfile } // namespace OHOS -#endif // OHOS_SYNC_OPERATION_H \ No newline at end of file +#endif // OHOS_DEVICE_PROFILE_SYNC_OPTIONS_H \ No newline at end of file diff --git a/ohos.build b/ohos.build index fbe4cde9..2394f9eb 100755 --- a/ohos.build +++ b/ohos.build @@ -32,4 +32,4 @@ } }, "subsystem": "deviceprofile" -} \ No newline at end of file +} diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index f06723f4..d2789c3d 100755 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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 @@ -16,8 +16,8 @@ import("//build/ohos_var.gni") device_profile_path = "//foundation/deviceprofile/device_profile_core" device_profile_innerkits = "${device_profile_path}/interfaces/innerkits" -distributed_datamgr_innerkits = - "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits" +device_profile_common_sources = + [ "${device_profile_path}/common/src/device_profile_utils.cpp" ] config("device_profile_core_config") { visibility = [ ":*" ] @@ -29,14 +29,10 @@ config("device_profile_core_config") { "include/subscribemanager", "${device_profile_path}/common/include", "${device_profile_innerkits}/core/include", - "${distributed_datamgr_innerkits}/distributeddata/include", "//third_party/json/include", ] } -dp_common_sources = - [ "${device_profile_path}/common/src/device_profile_utils.cpp" ] - ohos_shared_library("distributed_device_profile") { install_enable = true sources = [ @@ -66,25 +62,20 @@ ohos_shared_library("distributed_device_profile") { "src/subscribemanager/subscriber_death_recipient.cpp", "src/sync_options.cpp", ] - - sources += dp_common_sources + sources += device_profile_common_sources configs = [ ":device_profile_core_config" ] - deps = [ - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara", - "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", - "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", - "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", - "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", - "//utils/native/base:utils", - ] - external_deps = [ + "appexecfwk_standard:libeventhandler", + "distributeddatamgr:distributeddata_inner", "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "utils_base:utils", ] part_name = "device_profile_core" diff --git a/services/core/include/dbstorage/device_profile_storage.h b/services/core/include/dbstorage/device_profile_storage.h index 24cd615e..69d19f56 100755 --- a/services/core/include/dbstorage/device_profile_storage.h +++ b/services/core/include/dbstorage/device_profile_storage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -19,6 +19,8 @@ #include #include +#include "sync_options.h" + #include "distributed_kv_data_manager.h" #include "event_handler.h" #include "kvstore_observer.h" @@ -46,7 +48,7 @@ public: virtual int32_t PutDeviceProfileBatch(const std::vector& keys, const std::vector& values); virtual int32_t SyncDeviceProfile(const std::vector& deviceIdList, - DistributedKv::SyncMode syncMode); + SyncMode syncMode); virtual int32_t RegisterSyncCallback(const std::shared_ptr& sycnCb); virtual int32_t UnRegisterSyncCallback(); diff --git a/services/core/include/dbstorage/online_sync_table.h b/services/core/include/dbstorage/online_sync_table.h index eb5627ac..a1457129 100755 --- a/services/core/include/dbstorage/online_sync_table.h +++ b/services/core/include/dbstorage/online_sync_table.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -30,7 +30,7 @@ public: void Init() override; int32_t RegisterSyncCallback(const std::shared_ptr& sycnCb) override; int32_t UnRegisterSyncCallback() override; - int32_t SyncDeviceProfile(const std::vector& deviceIds, DistributedKv::SyncMode syncMode) override; + int32_t SyncDeviceProfile(const std::vector& deviceIds, SyncMode syncMode) override; void SyncCompleted(const std::map& results) override; void NotifySyncCompleted(const std::map& results); diff --git a/services/core/src/dbstorage/device_profile_storage.cpp b/services/core/src/dbstorage/device_profile_storage.cpp index f49931f7..55718b69 100755 --- a/services/core/src/dbstorage/device_profile_storage.cpp +++ b/services/core/src/dbstorage/device_profile_storage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -246,14 +246,14 @@ int32_t DeviceProfileStorage::DeleteDeviceProfile(const std::string& key) } int32_t DeviceProfileStorage::SyncDeviceProfile(const std::vector& deviceIdList, - DistributedKv::SyncMode syncMode) + SyncMode syncMode) { HILOGI("called"); std::unique_lock writeLock(storageLock_); if (kvStorePtr_ == nullptr) { return ERR_DP_INVALID_PARAMS; } - Status status = kvStorePtr_->Sync(deviceIdList, syncMode); + Status status = kvStorePtr_->Sync(deviceIdList, static_cast(syncMode)); if (status != Status::SUCCESS) { HILOGE("sync failed, error = %{public}d", status); } diff --git a/services/core/src/dbstorage/online_sync_table.cpp b/services/core/src/dbstorage/online_sync_table.cpp index 9bb4f912..a6624507 100755 --- a/services/core/src/dbstorage/online_sync_table.cpp +++ b/services/core/src/dbstorage/online_sync_table.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -75,7 +75,7 @@ int32_t OnlineSyncTable::UnRegisterSyncCallback() } int32_t OnlineSyncTable::SyncDeviceProfile(const std::vector& deviceIds, - DistributedKv::SyncMode syncMode) + SyncMode syncMode) { HILOGI("called"); auto syncTask = [this, deviceIds = std::move(deviceIds), syncMode]() { diff --git a/services/core/src/sync_options.cpp b/services/core/src/sync_options.cpp index 5456c87e..a3470a81 100755 --- a/services/core/src/sync_options.cpp +++ b/services/core/src/sync_options.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -34,12 +34,12 @@ void SyncOptions::AddDevice(const std::string& deviceId) syncDevIds_.emplace_back(deviceId); } -DistributedKv::SyncMode SyncOptions::GetSyncMode() const +SyncMode SyncOptions::GetSyncMode() const { return syncMode_; } -void SyncOptions::SetSyncMode(DistributedKv::SyncMode mode) +void SyncOptions::SetSyncMode(SyncMode mode) { syncMode_ = mode; } @@ -58,7 +58,7 @@ bool SyncOptions::Unmarshalling(Parcel& parcel) { int32_t mode = 0; PARCEL_READ_HELPER_RET(parcel, Int32, mode, false); - syncMode_ = static_cast(mode); + syncMode_ = static_cast(mode); int32_t size = 0; PARCEL_READ_HELPER_RET(parcel, Int32, size, false); for (int32_t i = 0; i < size; i++) { diff --git a/services/core/test/BUILD.gn b/services/core/test/BUILD.gn index c613466f..6ebe735f 100755 --- a/services/core/test/BUILD.gn +++ b/services/core/test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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 @@ -26,28 +26,23 @@ device_profile_configs = device_profile_deps = [ "${device_profile_innerkits}/core:distributed_device_profile_client", - "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", - "//utils/native/base:utils", + "//third_party/googletest:gtest_main", ] device_profile_external_deps = [ + "appexecfwk_standard:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "utils_base:utils", ] -device_profile_public_deps = [ "//third_party/googletest:gtest_main" ] - ohos_unittest("profile_crud_test") { module_out_path = module_output_path sources = [ "unittest/profile_crud_test.cpp" ] configs = device_profile_configs deps = device_profile_deps - if (is_standard_system) { - external_deps = device_profile_external_deps - public_deps = device_profile_public_deps - } + external_deps = device_profile_external_deps } ohos_unittest("event_subscribe_test") { @@ -56,10 +51,7 @@ ohos_unittest("event_subscribe_test") { sources = [ "unittest/event_subscribe_test.cpp" ] configs = device_profile_configs deps = device_profile_deps - if (is_standard_system) { - external_deps = device_profile_external_deps - public_deps = device_profile_public_deps - } + external_deps = device_profile_external_deps } group("unittest") { diff --git a/tools/dp/BUILD.gn b/tools/dp/BUILD.gn index 11d08f8e..b85f71a7 100755 --- a/tools/dp/BUILD.gn +++ b/tools/dp/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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 @@ -15,38 +15,29 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") device_profile_path = "//foundation/deviceprofile/device_profile_core" -device_profile_innerkits = "${device_profile_path}/interfaces/innerkits" -device_profile_configs = [ - "${device_profile_innerkits}/core:distributed_device_profile_client_config", -] + +config("dp_tools_config") { + visibility = [ ":*" ] + include_dirs = [ "include" ] +} ohos_executable("dp") { install_enable = true - configs = [] - - configs += device_profile_configs - - include_dirs = [ - "include", - "//third_party/json/include", - ] + configs = [ ":dp_tools_config" ] sources = [ - "${device_profile_path}/tools/dp/src/dp_command.cpp", - "${device_profile_path}/tools/dp/src/main.cpp", - "${device_profile_path}/tools/dp/src/shell_command.cpp", - ] - - deps = [ - "${device_profile_innerkits}/core:distributed_device_profile_client", - "//utils/native/base:utils", + "src/dp_command.cpp", + "src/main.cpp", + "src/shell_command.cpp", ] + deps = [ "${device_profile_path}/interfaces/innerkits/core:distributed_device_profile_client" ] external_deps = [ "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", + "utils_base:utils", ] part_name = "device_profile_core" diff --git a/tools/dp/src/dp_command.cpp b/tools/dp/src/dp_command.cpp index 9088a325..dc052916 100755 --- a/tools/dp/src/dp_command.cpp +++ b/tools/dp/src/dp_command.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -216,7 +216,7 @@ ErrCode DpShellCommand::SyncCommand() if (result == ERR_OK) { SyncOptions syncOption; - syncOption.SetSyncMode((OHOS::DistributedKv::SyncMode)atoi(mode.c_str())); + syncOption.SetSyncMode((OHOS::DeviceProfile::SyncMode)atoi(mode.c_str())); for (const auto& deviceId : deviceIds) { syncOption.AddDevice(deviceId); }