From 272fd5eb5b2b85ee5b90498d7d4d76dc0f2beb02 Mon Sep 17 00:00:00 2001 From: liangZ15 Date: Sat, 26 Mar 2022 17:32:22 +0800 Subject: [PATCH 1/2] 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..fcf2f609 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 From ff1e79dad4055619e0dfbd0b89cd2eced979c688 Mon Sep 17 00:00:00 2001 From: liangZ15 Date: Sat, 26 Mar 2022 18:00:30 +0800 Subject: [PATCH 2/2] Signed-off-by: liangZ15 --- engine/src/update_service_stub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/src/update_service_stub.cpp b/engine/src/update_service_stub.cpp index fcf2f609..12690956 100755 --- a/engine/src/update_service_stub.cpp +++ b/engine/src/update_service_stub.cpp @@ -171,8 +171,8 @@ int32_t UpdateServiceStub::OnRemoteRequest(uint32_t code, {IUpdateService::REBOOT_INSTALL, RebootAndInstallStub}, }; - Security:AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - Security:AccessToken::HapTokenInfo hapTokenInfoRes = {}; + 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()); -- Gitee