!2253 使用编译宏,将ace_engine_standard组件对帐号的依赖隔离开来,没有帐号组件时,默认当前本地用户ID为0

Merge pull request !2253 from 张阿龙/master
This commit is contained in:
openharmony_ci
2022-04-20 08:03:22 +00:00
committed by Gitee
3 changed files with 33 additions and 3 deletions
+8
View File
@@ -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)
+4 -1
View File
@@ -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" ]
}
}
}
@@ -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<int32_t>& 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<PluginElement>& we
}
std::vector<int32_t> userIds;
ErrCode errCode = AccountSA::OsAccountManager::QueryActiveOsAccountIds(userIds);
ErrCode errCode = GetActiveAccountIds(userIds);
if (errCode != ERR_OK) {
pluginElement->HandleOnErrorEvent("1", "Query Active OsAccountIds failed!");
return packagePathStr;