diff --git a/ace_config.gni b/ace_config.gni index 41fe5628..39713eac 100644 --- a/ace_config.gni +++ b/ace_config.gni @@ -127,6 +127,14 @@ if (enable_dump_drawcmd) { ace_common_defines += [ "DUMP_DRAW_CMD" ] } +if (!defined(global_parts_info) || + defined(global_parts_info.account_os_account_standard)) { + os_account_exists = true + ace_common_defines += [ "OS_ACCOUNT_EXISTS" ] +} else { + os_account_exists = false +} + ace_platforms = [] _ace_adapter_dir = rebase_path("$ace_root/adapter", root_build_dir) diff --git a/frameworks/core/components/plugin/BUILD.gn b/frameworks/core/components/plugin/BUILD.gn index ca8020cc..2e8ddbb9 100644 --- a/frameworks/core/components/plugin/BUILD.gn +++ b/frameworks/core/components/plugin/BUILD.gn @@ -52,7 +52,10 @@ build_component("plugin") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "ipc:ipc_core", - "os_account_standard:os_account_innerkits", ] + + if (os_account_exists) { + external_deps += [ "os_account_standard:os_account_innerkits" ] + } } } diff --git a/frameworks/core/components/plugin/plugin_element.cpp b/frameworks/core/components/plugin/plugin_element.cpp index e3d05905..737dcbe7 100644 --- a/frameworks/core/components/plugin/plugin_element.cpp +++ b/frameworks/core/components/plugin/plugin_element.cpp @@ -16,8 +16,9 @@ #include "core/components/plugin/plugin_element.h" #include "flutter/lib/ui/ui_dart_state.h" +#ifdef OS_ACCOUNT_EXISTS #include "os_account_manager.h" - +#endif // OS_ACCOUNT_EXISTS #include "core/common/plugin_manager.h" #include "frameworks/base/utils/string_utils.h" #include "frameworks/core/components/plugin/plugin_component.h" @@ -26,6 +27,24 @@ #include "frameworks/core/components/plugin/resource/plugin_manager_delegate.h" namespace OHOS::Ace { +namespace { +#ifndef OS_ACCOUNT_EXISTS +constexpr int32_t DEFAULT_OS_ACCOUNT_ID = 0; // 0 is the default id when there is no os_account part +#endif // OS_ACCOUNT_EXISTS + +ErrCode GetActiveAccountIds(std::vector& userIds) +{ + userIds.clear(); +#ifdef OS_ACCOUNT_EXISTS + return AccountSA::OsAccountManager::QueryActiveOsAccountIds(userIds); +#else // OS_ACCOUNT_EXISTS + LOGE("os account part not exists, use default id."); + userIds.push_back(DEFAULT_OS_ACCOUNT_ID); + return ERR_OK; +#endif // OS_ACCOUNT_EXISTS +} +} // namespace + PluginElement::~PluginElement() { PluginManager::GetInstance().RemovePluginParentContainer(pluginSubContainerId_); @@ -322,7 +341,7 @@ std::string PluginElement::GetPackagePathByWant(const WeakPtr& we } std::vector userIds; - ErrCode errCode = AccountSA::OsAccountManager::QueryActiveOsAccountIds(userIds); + ErrCode errCode = GetActiveAccountIds(userIds); if (errCode != ERR_OK) { pluginElement->HandleOnErrorEvent("1", "Query Active OsAccountIds failed!"); return packagePathStr;