diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 25aa589ee5..9a0b15597b 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -1471,13 +1471,12 @@ int AbilityManagerService::StartAbilityInner(StartAbilityWrapParam ¶m) return checkRet; } } - // Get caller token ID before StartAbilityInfoWrap constructor - int32_t callerTokenIdForPermission = static_cast(IPCSkeleton::GetCallingTokenID()); StartAbilityInfoWrap threadLocalInfo(param.want, validUserId, appIndex, param.callerToken); // Remove ATOMIC_SERVICE_SHARE_ROUTER if target is not atomic service or caller doesn't have permission if (StartAbilityUtils::startAbilityInfo != nullptr) { + int32_t callerTokenId = param.want.GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, 0); StartAbilityUtils::RemoveAtomicServiceShareRouterIfNeeded(param.want, - StartAbilityUtils::startAbilityInfo->abilityInfo, callerTokenIdForPermission); + StartAbilityUtils::startAbilityInfo->abilityInfo, callerTokenId); } auto shouldBlockFunc = [aams = shared_from_this()]() { return aams->ShouldBlockAllAppStart(); }; AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(param.want, param.requestCode, validUserId, @@ -2289,13 +2288,12 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St AbilityEventUtil::SendStartAbilityErrorEvent(eventInfo, checkRet, "CheckMultiInstanceAndAppClone failed"); return checkRet; } - // Get caller token ID before StartAbilityInfoWrap constructor - int32_t callerTokenIdForPermission = static_cast(IPCSkeleton::GetCallingTokenID()); StartAbilityInfoWrap threadLocalInfo(want, validUserId, appIndex, callerToken); // Remove ATOMIC_SERVICE_SHARE_ROUTER if target is not atomic service or caller doesn't have permission if (StartAbilityUtils::startAbilityInfo != nullptr) { + int32_t callerTokenId = want.GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, 0); StartAbilityUtils::RemoveAtomicServiceShareRouterIfNeeded(const_cast(want), - StartAbilityUtils::startAbilityInfo->abilityInfo, callerTokenIdForPermission); + StartAbilityUtils::startAbilityInfo->abilityInfo, callerTokenId); } auto shouldBlockFunc = [aams = shared_from_this()]() { return aams->ShouldBlockAllAppStart(); }; AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, requestCode, validUserId,