From ac89fd7e8e553cf36943129a8a7ab28d16f49368 Mon Sep 17 00:00:00 2001 From: changzheng6 Date: Sat, 26 Mar 2022 15:19:58 +0800 Subject: [PATCH 1/5] modify bms dep Signed-off-by: changzheng6 --- appexecfwk.gni | 24 ++++++++---- services/bundlemgr/BUILD.gn | 7 +++- services/bundlemgr/include/account_helper.h | 27 ++++++++++++++ services/bundlemgr/src/account_helper.cpp | 37 +++++++++++++++++++ services/bundlemgr/src/bundle_mgr_service.cpp | 4 +- 5 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 services/bundlemgr/include/account_helper.h create mode 100644 services/bundlemgr/src/account_helper.cpp diff --git a/appexecfwk.gni b/appexecfwk.gni index 5ffe837c9b..aec7b2a7a3 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,17 @@ 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 e16651b910..883150a115 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 0000000000..8a040be9e2 --- /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 0000000000..e0c0df1f37 --- /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 b169994aae..8644e24587 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; } -- Gitee From 7628c3c40f63733cfce276f322f51326f61b4f9f Mon Sep 17 00:00:00 2001 From: changzheng6 Date: Sat, 26 Mar 2022 15:23:00 +0800 Subject: [PATCH 2/5] modify bms dep Signed-off-by: changzheng6 --- appexecfwk.gni | 2 -- 1 file changed, 2 deletions(-) diff --git a/appexecfwk.gni b/appexecfwk.gni index aec7b2a7a3..9a586fd72a 100644 --- a/appexecfwk.gni +++ b/appexecfwk.gni @@ -55,5 +55,3 @@ declare_args() { print("hicollie_enable = " + "$hicollie_enable") print("support_jsapi = " + "$support_jsapi") } - - -- Gitee From 0017fb01f88435e872eb2afa3387201ec380ef8b Mon Sep 17 00:00:00 2001 From: changzheng6 Date: Sat, 26 Mar 2022 16:07:42 +0800 Subject: [PATCH 3/5] modify bms dep Signed-off-by: changzheng6 --- .../test/unittest/bms_bundle_accesstokenid_test/BUILD.gn | 1 + services/bundlemgr/test/unittest/bms_bundle_clone_test/BUILD.gn | 1 + .../bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn | 2 ++ .../test/unittest/bms_bundle_kit_service_test/BUILD.gn | 1 + .../test/unittest/bms_bundle_permission_grant_test/BUILD.gn | 1 + .../test/unittest/bms_bundle_uninstaller_test/BUILD.gn | 1 + .../bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn | 1 + services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn | 1 + .../test/unittest/bms_service_bundle_scan_test/BUILD.gn | 1 + .../bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn | 1 + 10 files changed, 11 insertions(+) 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 105dd7f3a4..92b8e2c654 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 a6a6b4f11e..47c6107197 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 bdb3d5e6f5..f1701952c0 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 08b915abac..ed59abe1ac 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 ae5c02d800..145aaa6ffe 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 @@ -25,6 +25,7 @@ ohos_unittest("BmsBundlePermissionGrantTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ + "${services_path}/bundlemgr/src/account_helper.cpp", "${innerkits_path}/appexecfwk_base/src/ability_info.cpp", "${innerkits_path}/appexecfwk_base/src/application_info.cpp", "${innerkits_path}/appexecfwk_base/src/bundle_info.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 109c27e395..8904e95ee9 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 1e867653e3..c284736848 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 be68d1d632..e9b39b5df0 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 6edba19ceb..caf0618f31 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 9aa1236c0b..85de01c225 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", -- Gitee From 5afdd14da251fecf508f9f0c9345350a629b5adf Mon Sep 17 00:00:00 2001 From: changzheng6 Date: Sat, 26 Mar 2022 16:10:57 +0800 Subject: [PATCH 4/5] modify bms dep Signed-off-by: changzheng6 --- .../test/moduletest/common/bms/bundle_installer_test/BUILD.gn | 1 + .../test/moduletest/common/bms/bundle_uninstall_test/BUILD.gn | 1 + .../moduletest/common/bms/service_start_process_test/BUILD.gn | 1 + 3 files changed, 3 insertions(+) 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 d67833dd9d..ae3e26f7f8 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 c020af882d..15f71c68c9 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 4288d7ef53..d65da6cb9c 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", -- Gitee From 14f78e364ba89839594145fd5b338c20227d7e51 Mon Sep 17 00:00:00 2001 From: changzheng6 Date: Sat, 26 Mar 2022 16:25:21 +0800 Subject: [PATCH 5/5] modify bms dep Signed-off-by: changzheng6 --- .../test/unittest/bms_bundle_permission_grant_test/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 145aaa6ffe..a365dc1c5a 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 @@ -25,11 +25,11 @@ ohos_unittest("BmsBundlePermissionGrantTest") { "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", ] sources = [ - "${services_path}/bundlemgr/src/account_helper.cpp", "${innerkits_path}/appexecfwk_base/src/ability_info.cpp", "${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", -- Gitee