diff --git a/appexecfwk.gni b/appexecfwk.gni index 5d36e2dc..1cad16bc 100644 --- a/appexecfwk.gni +++ b/appexecfwk.gni @@ -28,6 +28,7 @@ declare_args() { account_enable = true configpolicy_enable = true device_manager_enable = true + global_resmgr_enable = true hicollie_enable = true if (defined(global_parts_info) && @@ -52,9 +53,14 @@ declare_args() { device_manager_enable = false } + if (defined(global_parts_info) && + !defined(global_parts_info.global_resmgr_standard)) { + device_manager_enable = false + } + if (defined(global_parts_info) && !defined(global_parts_info.hiviewdfx_hicollie_native)) { - hicollie_enable = false + global_resmgr_enable = false } if (defined(global_parts_info) && @@ -70,6 +76,7 @@ declare_args() { print("account_enable = " + "$account_enable") print("configpolicy_enable = " + "$configpolicy_enable") print("device_manager_enable = " + "$device_manager_enable") + print("global_resmgr_enable = " + "$global_resmgr_enable") print("hicollie_enable = " + "$hicollie_enable") print("support_jsapi = " + "$support_jsapi") } diff --git a/interfaces/innerkits/appexecfwk_core/BUILD.gn b/interfaces/innerkits/appexecfwk_core/BUILD.gn index d972784a..076976f8 100644 --- a/interfaces/innerkits/appexecfwk_core/BUILD.gn +++ b/interfaces/innerkits/appexecfwk_core/BUILD.gn @@ -72,17 +72,20 @@ ohos_shared_library("appexecfwk_core") { "ces_standard:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", - "resmgr_standard:global_resmgr", "samgr_standard:samgr_proxy", "utils_base:utils", ] if (bundle_framework_graphics) { defines += [ "SUPPORT_GRAPHICS" ] - external_deps += [ "multimedia_image_standard:image_native" ] } + if (global_resmgr_enable) { + defines += [ "GLOBAL_RESMGR_ENABLE" ] + external_deps += [ "resmgr_standard:global_resmgr" ] + } + subsystem_name = "appexecfwk" part_name = "bundle_framework" } diff --git a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_client_impl.h b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_client_impl.h index 978ae697..e382245e 100644 --- a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_client_impl.h +++ b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_client_impl.h @@ -22,7 +22,9 @@ #include "bundle_mgr_interface.h" #include "extension_ability_info.h" #include "hap_module_info.h" +#ifdef GLOBAL_RESMGR_ENABLE #include "resource_manager.h" +#endif namespace OHOS { namespace AppExecFwk { @@ -45,9 +47,11 @@ private: ErrCode Connect(); bool GetResProfileByMetadata(const std::vector &metadata, const std::string &metadataName, const std ::string &resourcePath, std::vector &profileInfos) const; +#ifdef GLOBAL_RESMGR_ENABLE std::shared_ptr InitResMgr(const std::string &resourcePath) const; bool GetResFromResMgr(const std::string &resName, const std::shared_ptr &resMgr, std::vector &profileInfos) const; +#endif bool IsFileExisted(const std::string &filePath, const std::string &suffix) const; bool TransformFileToJsonString(const std::string &resPath, std::string &profile) const; diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp index 44233ffd..8e737a23 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp @@ -26,7 +26,9 @@ #include "nlohmann/json.hpp" #include "system_ability_definition.h" +#ifdef GLOBAL_RESMGR_ENABLE using namespace OHOS::Global::Resource; +#endif namespace OHOS { namespace AppExecFwk { @@ -146,6 +148,7 @@ std::vector BundleMgrClientImpl::GetAccessibleAppCodePaths(int32_t bool BundleMgrClientImpl::GetResProfileByMetadata(const std::vector &metadata, const std::string &metadataName, const std ::string &resourcePath, std::vector &profileInfos) const { +#ifdef GLOBAL_RESMGR_ENABLE if (metadata.empty()) { APP_LOGE("GetResProfileByMetadata failed due to empty metadata"); return false; @@ -176,8 +179,13 @@ bool BundleMgrClientImpl::GetResProfileByMetadata(const std::vector &m } return true; +#else + APP_LOGW("GLOBAL_RESMGR_ENABLE is false"); + return false; +#endif } +#ifdef GLOBAL_RESMGR_ENABLE std::shared_ptr BundleMgrClientImpl::InitResMgr(const std::string &resourcePath) const { APP_LOGD("InitResMgr begin"); @@ -234,6 +242,7 @@ bool BundleMgrClientImpl::GetResFromResMgr(const std::string &resName, const std profileInfos.emplace_back(profile); return true; } +#endif bool BundleMgrClientImpl::IsFileExisted(const std::string &filePath, const std::string &suffix) const { diff --git a/services/bundlemgr/BUILD.gn b/services/bundlemgr/BUILD.gn index b8130913..15f6c29a 100644 --- a/services/bundlemgr/BUILD.gn +++ b/services/bundlemgr/BUILD.gn @@ -187,7 +187,6 @@ ohos_shared_library("libbms") { "hiviewdfx_hilog_native:libhilog", "init:libbegetutil", "ipc:ipc_core", - "resmgr_standard:global_resmgr", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", "startup_l2:syspara", @@ -234,6 +233,11 @@ ohos_shared_library("libbms") { defines += [ "DEVICE_MANAGER_ENABLE" ] } + if (global_resmgr_enable) { + defines += [ "GLOBAL_RESMGR_ENABLE" ] + external_deps += [ "resmgr_standard:global_resmgr" ] + } + if (hicollie_enable) { external_deps += [ "hicollie_native:libhicollie" ] defines += [ "HICOLLIE_ENABLE" ] diff --git a/services/bundlemgr/include/bundle_data_mgr.h b/services/bundlemgr/include/bundle_data_mgr.h index c9319c67..4318b89d 100644 --- a/services/bundlemgr/include/bundle_data_mgr.h +++ b/services/bundlemgr/include/bundle_data_mgr.h @@ -41,7 +41,9 @@ #include "pixel_map.h" #endif #include "preinstall_data_storage.h" +#ifdef GLOBAL_RESMGR_ENABLE #include "resource_manager.h" +#endif #include "target_ability_info.h" namespace OHOS { @@ -818,8 +820,10 @@ private: std::vector &extensionInfos) const; void GetMatchExtensionInfos(const Want &want, int32_t flags, const int32_t &userId, const InnerBundleInfo &info, std::vector &einfos) const; +#ifdef GLOBAL_RESMGR_ENABLE std::shared_ptr GetResourceManager( const AppExecFwk::BundleInfo &bundleInfo) const; +#endif #ifdef SUPPORT_GRAPHICS std::shared_ptr LoadImageFile(const std::string &path) const; #endif diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 01e8d0c6..f5dfb226 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -1172,6 +1172,7 @@ bool BundleDataMgr::QueryKeepAliveBundleInfos(std::vector &bundleInf std::string BundleDataMgr::GetAbilityLabel(const std::string &bundleName, const std::string &className) const { +#ifdef GLOBAL_RESMGR_ENABLE std::lock_guard lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); @@ -1209,6 +1210,10 @@ std::string BundleDataMgr::GetAbilityLabel(const std::string &bundleName, const } else { return abilityLabel; } +#else + APP_LOGW("GLOBAL_RESMGR_ENABLE is false"); + return nullptr; +#endif } bool BundleDataMgr::GetHapModuleInfo( @@ -1606,6 +1611,7 @@ std::string BundleDataMgr::GetAbilityIcon(const std::string &bundleName, const s std::shared_ptr BundleDataMgr::GetAbilityPixelMapIcon(const std::string &bundleName, const std::string &abilityName) const { +#ifdef GLOBAL_RESMGR_ENABLE std::lock_guard lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); @@ -1644,6 +1650,10 @@ std::shared_ptr BundleDataMgr::GetAbilityPixelMapIcon(const std return nullptr; } return pixelMapPtr; +#else + APP_LOGW("GLOBAL_RESMGR_ENABLE is false"); + return nullptr; +#endif } #endif @@ -2827,6 +2837,7 @@ void BundleDataMgr::GetAllUriPrefix(std::vector &uriPrefixList, int } } +#ifdef GLOBAL_RESMGR_ENABLE std::shared_ptr BundleDataMgr::GetResourceManager( const AppExecFwk::BundleInfo &bundleInfo) const { @@ -2845,6 +2856,7 @@ std::shared_ptr BundleDataMgr::GetResourceMan resourceManager->UpdateResConfig(*resConfig); return resourceManager; } +#endif #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL bool BundleDataMgr::GetRemovableBundleNameVec(std::map& bundlenameAndUids)