diff --git a/interfaces/common/src/common_func.cpp b/interfaces/common/src/common_func.cpp index 8850178f63da956d8b4630c3d4c9c15fedfd37b4..7e23139f191854e94e18acbf27ba00d6de604bce 100644 --- a/interfaces/common/src/common_func.cpp +++ b/interfaces/common/src/common_func.cpp @@ -19,6 +19,7 @@ #include #include +#include "accesstoken_kit.h" #include "bundle_mgr_client.h" #include "bundle_mgr_proxy.h" #include "ipc_skeleton.h" @@ -76,8 +77,23 @@ bool CommonFunc::GetDirByBundleNameAndAppIndex(const std::string &bundleName, in return true; } +static bool IsSAProcesses() +{ + uint32_t selfToken = IPCSkeleton::GetSelfTokenID(); + auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(selfToken); + if (tokenType == Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE) { + LOGE("The Current Invoking Process Is An SA Process"); + return true; + } + return false; +} + string CommonFunc::GetSelfBundleName() { + if (IsSAProcesses()) { + LOGE("The Current Invoking Process Is An SA Process"); + return ""; + } sptr bundleMgrProxy = GetBundleMgrProxy(); if (!bundleMgrProxy) { LOGE("GetSelfBundleName: bundle mgr proxy is nullptr."); diff --git a/interfaces/innerkits/native/BUILD.gn b/interfaces/innerkits/native/BUILD.gn index 08a8d8cb39a01936346b560da3816dfcab3576f2..68096b93fc87ddab8d66bf7e6e82796994c33f28 100644 --- a/interfaces/innerkits/native/BUILD.gn +++ b/interfaces/innerkits/native/BUILD.gn @@ -103,6 +103,7 @@ ohos_shared_library("fileuri_native") { external_deps = [ "ability_base:zuri", + "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 3a96c145cde353a7467aa2e139221e18a3697381..101464af5eb122f028816d495fbef31feff74430 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -107,6 +107,7 @@ ohos_shared_library("fileuri") { external_deps = [ "ability_base:zuri", "ability_runtime:abilitykit_native", + "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils",