From 0882a84fb832d25e59abed725017b5c6a70743c2 Mon Sep 17 00:00:00 2001 From: sunhaiyang Date: Fri, 5 May 2023 09:55:46 +0800 Subject: [PATCH] SceneBoard adapt Change-Id: I73a89c0e646176adfa1a43c91cccbe42d5b09692 --- appexecfwk.gni | 6 ++++ services/bundlemgr/BUILD.gn | 5 ++++ .../bundle_mgr_service_event_handler.h | 1 + .../src/bundle_mgr_service_event_handler.cpp | 28 +++++++++++++++++++ .../bms_ability_manager_helper_test/BUILD.gn | 6 ++++ 5 files changed, 46 insertions(+) diff --git a/appexecfwk.gni b/appexecfwk.gni index 9becdc043..aed2e064e 100644 --- a/appexecfwk.gni +++ b/appexecfwk.gni @@ -57,6 +57,7 @@ declare_args() { hicollie_enable = true hisysevent_enable = true use_pre_bundle_profile = true + window_enable = true if (defined(global_parts_info) && !defined(global_parts_info.ability_ability_runtime)) { @@ -111,6 +112,11 @@ declare_args() { !defined(global_parts_info.hiviewdfx_hisysevent_native)) { hisysevent_enable = false } + + if (defined(global_parts_info) && + !defined(global_parts_info.window_window_manager)) { + window_enable = false + } } print("bundle_framework_graphics = " + "$bundle_framework_graphics") diff --git a/services/bundlemgr/BUILD.gn b/services/bundlemgr/BUILD.gn index 4cf2ef753..03a09b806 100644 --- a/services/bundlemgr/BUILD.gn +++ b/services/bundlemgr/BUILD.gn @@ -237,6 +237,11 @@ ohos_shared_library("libbms") { "syscap_codec:syscap_interface_shared", ] + if (window_enable) { + external_deps += [ "window_manager:libwsutils" ] + defines += [ "WINDOW_ENABLE" ] + } + if (distributed_bundle_framework) { external_deps += [ "distributed_bundle_framework:dbms_fwk" ] defines += [ "DISTRIBUTED_BUNDLE_FRAMEWORK" ] diff --git a/services/bundlemgr/include/bundle_mgr_service_event_handler.h b/services/bundlemgr/include/bundle_mgr_service_event_handler.h index 34cdbacf8..7aa997104 100644 --- a/services/bundlemgr/include/bundle_mgr_service_event_handler.h +++ b/services/bundlemgr/include/bundle_mgr_service_event_handler.h @@ -450,6 +450,7 @@ private: void UpdateTrustedPrivilegeCapability(const PreBundleConfigInfo &preBundleConfigInfo); #endif + void HandleSceneBoard() const; // Used to save the information parsed by Hap in the scanned directory. std::map> hapParseInfoMap_; // Used to save application information that already exists in the Db. diff --git a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp index 7735a9ddf..352895ec1 100644 --- a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp +++ b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp @@ -37,6 +37,9 @@ #include "installd_client.h" #include "parameter.h" #include "perf_profile.h" +#ifdef WINDOW_ENABLE +#include "scene_board_judgement.h" +#endif #include "status_receiver_host.h" #include "system_bundle_installer.h" #ifdef BUNDLE_FRAMEWORK_QUICK_FIX @@ -46,6 +49,9 @@ namespace OHOS { namespace AppExecFwk { namespace { +const std::string SYSTEM_UI_BUNDLE_NAME = "com.ohos.systemui"; +const std::string LAUNCHER_BUNDLE_NAME = "com.ohos.launcher"; +const std::string SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard"; const std::string APP_SUFFIX = "/app"; const std::string TEMP_PREFIX = "temp_"; const std::string MODULE_PREFIX = "module_"; @@ -230,6 +236,7 @@ void BMSEventHandler::AfterBmsStart() DelayedSingleton::GetInstance()->CheckAllUser(); BundlePermissionMgr::UnInit(); SetAllInstallFlag(); + HandleSceneBoard(); DelayedSingleton::GetInstance()->RegisterService(); EventReport::SendScanSysEvent(BMSEventType::BOOT_SCAN_END); ClearCache(); @@ -1617,5 +1624,26 @@ void BMSEventHandler::AddStockAppProvisionInfoByOTA(const std::string &bundleNam APP_LOGE("AddAppProvisionInfo failed, bundleName:%{public}s", bundleName.c_str()); } } + +void BMSEventHandler::HandleSceneBoard() const +{ +#ifdef WINDOW_ENABLE + APP_LOGD("begin to HandleSceneBoard"); + auto dataMgr = DelayedSingleton::GetInstance()->GetDataMgr(); + if (dataMgr == nullptr) { + APP_LOGE("dataMgr is null"); + return; + } + bool sceneBoardEnable = Rosen::SceneBoardJudgement::IsSceneBoardEnabled(); + APP_LOGD("sceneBoardEnable : %{public}d", sceneBoardEnable); + dataMgr->SetApplicationEnabled(SCENE_BOARD_BUNDLE_NAME, sceneBoardEnable, Constants::DEFAULT_USERID); + dataMgr->SetApplicationEnabled(SYSTEM_UI_BUNDLE_NAME, !sceneBoardEnable, Constants::DEFAULT_USERID); + std::set userIds = dataMgr->GetAllUser(); + std::for_each(userIds.cbegin(), userIds.cend(), [dataMgr, sceneBoardEnable](const int32_t userId) { + dataMgr->SetApplicationEnabled(LAUNCHER_BUNDLE_NAME, !sceneBoardEnable, userId); + }); + APP_LOGD("HandleSceneBoard finish"); +#endif +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn index d3adb5fa6..70bfd554b 100644 --- a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn @@ -64,6 +64,12 @@ ohos_unittest("BmsAbilityManagerHelperTest") { external_deps += [ "multimedia_image_framework:image_native" ] } defines = [] + + if (window_enable) { + external_deps += [ "window_manager:libwsutils" ] + defines += [ "WINDOW_ENABLE" ] + } + if (configpolicy_enable) { external_deps += [ "config_policy:configpolicy_util" ] defines += [ "CONFIG_POLOCY_ENABLE" ] -- Gitee