diff --git a/engine/BUILD.gn b/engine/BUILD.gn index d1d73e0edf497596ab605758973a62ad1b36f481..9d7d15a4de205438184ec7fdfa71ecd01dc33fb7 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 f170a2f984a9ea499741b553e94a677df39c1657..9a1bb3dc5f9e1a63e2f992585d8e4ae7dbbff04f 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) {