diff --git a/appexecfwk.gni b/appexecfwk.gni index 5ffe837c9bc84b4c0b0e125b1271ae0823253cb4..9a586fd72a27a7f49d3cda2558073093df41871f 100644 --- a/appexecfwk.gni +++ b/appexecfwk.gni @@ -23,12 +23,19 @@ tools_path = "${appexecfwk_path}/tools" declare_args() { bundle_framework_graphics = true + account_enable = true + configpolicy_enable = true device_manager_enable = true hicollie_enable = true if (defined(global_parts_info) && - !defined(global_parts_info.hiviewdfx_hicollie_native)) { - hicollie_enable = false + !defined(global_parts_info.account_os_account_standard)) { + account_enable = false + } + + if (defined(global_parts_info) && + !defined(global_parts_info.customization_config_policy)) { + configpolicy_enable = false } if (defined(global_parts_info) && @@ -36,14 +43,15 @@ declare_args() { device_manager_enable = false } + if (defined(global_parts_info) && + !defined(global_parts_info.hiviewdfx_hicollie_native)) { + hicollie_enable = false + } + print("bundle_framework_graphics = " + "$bundle_framework_graphics") + print("account_enable = " + "$account_enable") + print("configpolicy_enable = " + "$configpolicy_enable") print("device_manager_enable = " + "$device_manager_enable") print("hicollie_enable = " + "$hicollie_enable") print("support_jsapi = " + "$support_jsapi") } - -configpolicy_enable = true -if (defined(global_parts_info) && - !defined(global_parts_info.customization_config_policy)) { - configpolicy_enable = false -} diff --git a/services/bundlemgr/BUILD.gn b/services/bundlemgr/BUILD.gn index e16651b9108344cb96ed047b3aea439e2464147d..883150a115f77e40815e1ceb7f298a9ee5316122 100644 --- a/services/bundlemgr/BUILD.gn +++ b/services/bundlemgr/BUILD.gn @@ -127,6 +127,7 @@ ohos_shared_library("libbms") { ] sources = [ + "src/account_helper.cpp", "src/bundle_clone_mgr.cpp", "src/bundle_data_mgr.cpp", "src/bundle_data_storage.cpp", @@ -176,13 +177,17 @@ ohos_shared_library("libbms") { "hiviewdfx_hilog_native:libhilog", "init:libbegetutil", "ipc:ipc_core", - "os_account_standard:os_account_innerkits", "resmgr_standard:global_resmgr", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", "startup_l2:syspara", ] + if (account_enable) { + external_deps += [ "os_account_standard:os_account_innerkits" ] + defines += [ "ACCOUNT_ENABLE" ] + } + if (configpolicy_enable) { external_deps += [ "config_policy:configpolicy_util" ] defines += [ "CONFIG_POLOCY_ENABLE" ] diff --git a/services/bundlemgr/include/account_helper.h b/services/bundlemgr/include/account_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..8a040be9e29346103b7ca28e28595e9ff0917f86 --- /dev/null +++ b/services/bundlemgr/include/account_helper.h @@ -0,0 +1,27 @@ +/* + * 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. + */ + +#ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_ACCOUNT_HELPER_H +#define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_ACCOUNT_HELPER_H + +namespace OHOS { +namespace AppExecFwk { +class AccountHelper { +public: + static int IsOsAccountExists(const int id, bool &isOsAccountExists); +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_ACCOUNT_HELPER_H diff --git a/services/bundlemgr/src/account_helper.cpp b/services/bundlemgr/src/account_helper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e0c0df1f37be43287e2a416f0746a67aa685c868 --- /dev/null +++ b/services/bundlemgr/src/account_helper.cpp @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#include "account_helper.h" + +#include "app_log_wrapper.h" + +#ifdef ACCOUNT_ENABLE +#include "os_account_manager.h" +#endif + +namespace OHOS { +namespace AppExecFwk { +int AccountHelper::IsOsAccountExists(const int id, bool &isOsAccountExists) +{ +#ifdef ACCOUNT_ENABLE + return AccountSA::OsAccountManager::IsOsAccountExists(id, isOsAccountExists); +#else + APP_LOGI("ACCOUNT_ENABLE is false"); + // ACCOUNT_ENABLE is false, do nothing and return -1. + return -1; +#endif +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/services/bundlemgr/src/bundle_mgr_service.cpp b/services/bundlemgr/src/bundle_mgr_service.cpp index b169994aaedb15d3e8f69990100e029cdb2b81ba..8644e24587f614dd1841f17efc04a3b460bca7c6 100644 --- a/services/bundlemgr/src/bundle_mgr_service.cpp +++ b/services/bundlemgr/src/bundle_mgr_service.cpp @@ -15,10 +15,10 @@ #include "bundle_mgr_service.h" +#include "account_helper.h" #include "app_log_wrapper.h" #include "bundle_constants.h" #include "datetime_ex.h" -#include "os_account_manager.h" #include "perf_profile.h" #include "system_ability_definition.h" #include "system_ability_helper.h" @@ -245,7 +245,7 @@ void BundleMgrService::CheckAllUser() std::set userIds = dataMgr_->GetAllUser(); for (auto userId : userIds) { bool isExists = false; - if (AccountSA::OsAccountManager::IsOsAccountExists(userId, isExists) != ERR_OK) { + if (AccountHelper::IsOsAccountExists(userId, isExists) != ERR_OK) { APP_LOGE("Failed to query whether the user(%{public}d) exists.", userId); continue; } diff --git a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn index 105dd7f3a486321d0f4f7c3394741ac8f2b29ae9..92b8e2c654b1773ebd4d7c063d82af86a4c2a6e4 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn @@ -26,6 +26,7 @@ ohos_unittest("BmsBundleAccessTokenIdTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn index a6a6b4f11e834c63c65b83c093e4d9ad1c89bb75..47c6107197346312641f7846cb5a61187f51f97d 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn @@ -27,6 +27,7 @@ ohos_unittest("BmsBundleCloneTest") { "${innerkits_path}/appexecfwk_base/src/bundle_info.cpp", "${innerkits_path}/appexecfwk_base/src/compatible_ability_info.cpp", "${innerkits_path}/appexecfwk_base/src/compatible_application_info.cpp", + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn index bdb3d5e6f54fb9344c9d601ff42ed78c51d87d15..f1701952c04490a5c32beb0d1bb27ba482bc27a7 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn @@ -26,6 +26,7 @@ ohos_unittest("BmsBundleInstallerTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", @@ -126,6 +127,7 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn index 08b915abac7c66f6c1b7ffc3a1081e99e25bb9cc..ed59abe1ac005773b328734ab09e2294c2535dfe 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn @@ -26,6 +26,7 @@ ohos_unittest("BmsBundleKitServiceTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn index ae5c02d8008feabfe19f6de9ddb65e9ecc238857..a365dc1c5a77e7855f2083dc420468f6f4e5afdd 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn @@ -29,6 +29,7 @@ ohos_unittest("BmsBundlePermissionGrantTest") { "${innerkits_path}/appexecfwk_base/src/application_info.cpp", "${innerkits_path}/appexecfwk_base/src/bundle_info.cpp", "${innerkits_path}/appexecfwk_base/src/bundle_user_info.cpp", + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn index 109c27e395a76b2c46ab3c4ba928a9c4b0c2123b..8904e95ee9b1e643ce72cedb4c405cc134739ed3 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn @@ -30,6 +30,7 @@ ohos_unittest("BmsBundleUninstallerTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn index 1e867653e39d2289e24ce595a7758b708096501f..c2847368481b181b6c9cf194d7987a7f13b08452 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn @@ -33,6 +33,7 @@ ohos_unittest("BmsBundleUpdaterTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn index be68d1d6322bb3fdcb900deb092e6f08d3a2c8fe..e9b39b5df0d1bc59f61a9eab7caf057f7ef26fe1 100644 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn @@ -30,6 +30,7 @@ ohos_unittest("BmsDataMgrTest") { "//third_party/jsoncpp/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn index 6edba19cebb5c59d8d6a0d21e3c8da71cccc8bb3..caf0618f31a6920e92faf3c0b2a280bf2c9193ce 100644 --- a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn @@ -23,6 +23,7 @@ ohos_unittest("BmsServiceBundleScanTest") { module_out_path = module_output_path include_dirs = [ "//third_party/jsoncpp/include" ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn index 9aa1236c0b813a55f92d46384ff4bb26b1b7adee..85de01c2250510bac3dd473c698a319f352df293 100644 --- a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn @@ -23,6 +23,7 @@ ohos_unittest("BmsServiceStartupTest") { module_out_path = module_output_path include_dirs = [ "//third_party/jsoncpp/include" ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn b/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn index d67833dd9d0435f953814f4bde8310db68192326..ae3e26f7f83cb1bbbb05f5bf1e009cd644420378 100644 --- a/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn +++ b/services/test/moduletest/common/bms/bundle_installer_test/BUILD.gn @@ -39,6 +39,7 @@ ohos_moduletest("BmsBundleInstallerModuleTest") { ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn b/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn index c020af882d0bafea3ae7d8cd20e97dee519de2de..15f71c68c9ef3e9dba975e5147640b673c1f7e99 100644 --- a/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn +++ b/services/test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn @@ -37,6 +37,7 @@ ohos_moduletest("BmsBundleUninstallerModuleTest") { ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp", diff --git a/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn b/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn index 4288d7ef53b10fbec85f38d0d30fd580613cc75f..d65da6cb9cfa946a20eab481ebbe834fd0831e60 100644 --- a/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn +++ b/services/test/moduletest/common/bms/service_start_process_test/BUILD.gn @@ -28,6 +28,7 @@ ohos_moduletest("BmsServiceStartModuleTest") { ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${services_path}/bundlemgr/src/bms_device_manager.cpp", "${services_path}/bundlemgr/src/bundle_clone_mgr.cpp", "${services_path}/bundlemgr/src/bundle_data_mgr.cpp",