diff --git a/bundle.json b/bundle.json index 864b62204b9b0ad5c9dae87b10546fb801542de2..a1a42a9981a305988a877f32d2e7807e6bf24fbd 100644 --- a/bundle.json +++ b/bundle.json @@ -40,7 +40,7 @@ "syscap": [ "SystemCapability.Data.DATA_DISTRIBUTEDDATAMGR" ], - "features": [], + "features": [ "distributeddatamgr_power" ], "adapted_system_type": [ "standard" ], diff --git a/distributeddatamgr.gni b/distributeddatamgr.gni new file mode 100644 index 0000000000000000000000000000000000000000..d516d65125a14cbf16778815ddaafb540d6c4526 --- /dev/null +++ b/distributeddatamgr.gni @@ -0,0 +1,16 @@ +# 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 +# +# 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. + +declare_args() { + distributeddatamgr_power = true +} diff --git a/services/distributeddataservice/app/BUILD.gn b/services/distributeddataservice/app/BUILD.gn index bf1bfc8a58de8d03529b40dd57cdcd9e04e83de5..0d2e7e2918d329063963e21525c63528bb9a9e8f 100755 --- a/services/distributeddataservice/app/BUILD.gn +++ b/services/distributeddataservice/app/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/ohos.gni") import("//build/ohos_var.gni") +import("//foundation/distributeddatamgr/distributeddatamgr/distributeddatamgr.gni") group("build_module") { deps = [ ":distributeddataservice" ] @@ -135,7 +136,6 @@ ohos_shared_library("distributeddataservice") { external_deps = [ "ability_base:base", "ability_base:want", - "battery_manager_native:batterysrv_client", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "dataclassification:data_transit_mgr", @@ -144,11 +144,18 @@ ohos_shared_library("distributeddataservice") { "ipc:ipc_core", "os_account_standard:os_account_innerkits", "permission_standard:libpermissionsdk_standard", - "power_manager_native:powermgr_client", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", "startup_l2:syspara", ] + + if (distributeddatamgr_power) { + external_deps += [ + "battery_manager_native:batterysrv_client", + "power_manager_native:powermgr_client", + ] + defines = [ "SUPPORT_POWER" ] + } subsystem_name = "distributeddatamgr" } diff --git a/services/distributeddataservice/app/src/backup_handler.cpp b/services/distributeddataservice/app/src/backup_handler.cpp index 80202b83e684f922f096c204f5a1ed9773d997b7..17374d3f1033e5c3534ada45f4f24c47bc952913 100755 --- a/services/distributeddataservice/app/src/backup_handler.cpp +++ b/services/distributeddataservice/app/src/backup_handler.cpp @@ -21,15 +21,19 @@ #include #include #include "account_delegate.h" +#ifdef SUPPORT_POWER #include "battery_info.h" #include "battery_srv_client.h" +#endif #include "constant.h" #include "kv_store_delegate_manager.h" #include "kv_scheduler.h" #include "kvstore_data_service.h" #include "log_print.h" #include "kvstore_meta_manager.h" +#ifdef SUPPORT_POWER #include "power_mgr_client.h" +#endif #include "time_utils.h" #include "utils/crypto.h" @@ -366,6 +370,7 @@ bool BackupHandler::FileExists(const std::string &path) bool BackupHandler::CheckNeedBackup() { +#ifdef SUPPORT_POWER auto &batterySrvClient = PowerMgr::BatterySrvClient::GetInstance(); auto chargingStatus = batterySrvClient.GetChargingStatus(); if (chargingStatus != PowerMgr::BatteryChargeState::CHARGE_STATE_ENABLE) { @@ -391,6 +396,7 @@ bool BackupHandler::CheckNeedBackup() ZLOGE("no more than 10 hours since the last backup success."); return false; } +#endif return true; } diff --git a/services/distributeddataservice/app/test/BUILD.gn b/services/distributeddataservice/app/test/BUILD.gn index 9e5e85048cc4e33492fdf7d5c8bd77f0e490e13a..3b9798ccee2854d459190db4c623e3fc67d82648 100755 --- a/services/distributeddataservice/app/test/BUILD.gn +++ b/services/distributeddataservice/app/test/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import("//build/test.gni") +import("//foundation/distributeddatamgr/distributeddatamgr/distributeddatamgr.gni") module_output_path = "distributeddatamgr/distributeddataservice" @@ -82,18 +83,23 @@ ohos_unittest("KvStoreImplLogicalIsolationTest") { configs = [ ":module_private_config" ] external_deps = [ - "battery_manager_native:batterysrv_client", "dataclassification:data_transit_mgr", "hiviewdfx_hilog_native:libhilog", "huks:libhukssdk", "ipc:ipc_core", "os_account_standard:os_account_innerkits", "permission_standard:libpermissionsdk_standard", - "power_manager_native:powermgr_client", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", ] + if (distributeddatamgr_power) { + external_deps += [ + "battery_manager_native:batterysrv_client", + "power_manager_native:powermgr_client", + ] + } + kv_sources = [ "../../service/kv/user_delegate.cpp" ] sources += kv_sources @@ -153,18 +159,23 @@ ohos_unittest("KvStoreImplPhysicalIsolationTest") { configs = [ ":module_private_config" ] external_deps = [ - "battery_manager_native:batterysrv_client", "dataclassification:data_transit_mgr", "hiviewdfx_hilog_native:libhilog", "huks:libhukssdk", "ipc:ipc_core", "os_account_standard:os_account_innerkits", "permission_standard:libpermissionsdk_standard", - "power_manager_native:powermgr_client", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", ] + if (distributeddatamgr_power) { + external_deps = [ + "battery_manager_native:batterysrv_client", + "power_manager_native:powermgr_client", + ] + } + deps = [ "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter:distributeddata_adapter",