From 113f3a27714441cf3510863017cbbc4cd991041e Mon Sep 17 00:00:00 2001 From: liangZ15 Date: Sat, 26 Mar 2022 18:02:57 +0800 Subject: [PATCH] Signed-off-by: liangZ15 --- engine/BUILD.gn | 2 ++ engine/src/update_service_stub.cpp | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/engine/BUILD.gn b/engine/BUILD.gn index d1d73e0e..9d7d15a4 100755 --- a/engine/BUILD.gn +++ b/engine/BUILD.gn @@ -81,6 +81,8 @@ ohos_shared_library("updateservice") { "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", "startup_l2:syspara", + "ipc:ipc_single", + "access_token:libaccesstoken_sdk", ] part_name = "update_service" diff --git a/engine/src/update_service_stub.cpp b/engine/src/update_service_stub.cpp index 8bbbb1ae..12690956 100755 --- a/engine/src/update_service_stub.cpp +++ b/engine/src/update_service_stub.cpp @@ -13,9 +13,12 @@ * limitations under the License. */ -#include "update_service_stub.h" -#include "update_helper.h" +#include "accesstoken_kit.h" +#include "hap_token_info.h" +#include "ipc_skeleton.h" #include "securec.h" +#include "update_helper.h" +#include "update_service_stub.h" using namespace std; @@ -168,6 +171,19 @@ int32_t UpdateServiceStub::OnRemoteRequest(uint32_t code, {IUpdateService::REBOOT_INSTALL, RebootAndInstallStub}, }; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + Security::AccessToken::HapTokenInfo hapTokenInfoRes = {}; + + int re = Security::AccessToken::AccessTokenKit::GetHapTokenInfo(callerToken, hapTokenInfoRes); + ENGINE_LOGI("UpdateServiceStub GetHapTokenInfo re %d, bundle name %s", re, hapTokenInfoRes.bundleName.c_str()); + + if (code == IUpdateService::REBOOT_CLEAN) { + if (strcmp("com.ohos.settings", hapTokenInfoRes.bundleName.c_str()) != 0) { + ENGINE_LOGE("bundle name err %s", hapTokenInfoRes.bundleName.c_str()); + return -1; + } + } + ENGINE_LOGI("UpdateServiceStub OnRemoteRequest code %u", code); for (auto inter = requestFuncMap.begin(); inter != requestFuncMap.end(); inter++) { if (inter->first == code) { -- Gitee