!7257 [包管理] [分身相关] 分身级联相关

Merge pull request !7257 from chthollystar/master
This commit is contained in:
openharmony_ci 2024-10-18 11:11:10 +00:00 committed by Gitee
commit e9b49741ee
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 41 additions and 0 deletions

View File

@ -1415,6 +1415,10 @@ public:
void SetAccessTokenIdEx(const Security::AccessToken::AccessTokenIDEx accessTokenIdEx, const int32_t userId);
void SetAccessTokenIdExWithAppIndex(
const Security::AccessToken::AccessTokenIDEx accessTokenIdEx,
const int32_t userId, const int32_t appIndex);
void SetIsNewVersion(bool flag)
{
isNewVersion_ = flag;

View File

@ -65,6 +65,7 @@
#include "storage_manager_proxy.h"
#endif
#include "iservice_registry.h"
#include "inner_bundle_clone_common.h"
namespace OHOS {
namespace AppExecFwk {
@ -5870,6 +5871,20 @@ ErrCode BaseBundleInstaller::UpdateHapToken(bool needUpdate, InnerBundleInfo &ne
if (needUpdate) {
newInfo.SetAccessTokenIdEx(accessTokenIdEx, uerInfo.second.bundleUserInfo.userId);
}
const std::map<std::string, InnerBundleCloneInfo> &cloneInfos = uerInfo.second.cloneInfos;
for (const auto &cloneInfoPair : cloneInfos) {
Security::AccessToken::AccessTokenIDEx cloneAccessTokenIdEx;
cloneAccessTokenIdEx.tokenIDEx = cloneInfoPair.second.accessTokenIdEx;
if (BundlePermissionMgr::UpdateHapToken(cloneAccessTokenIdEx, newInfo) != ERR_OK) {
LOG_NOFUNC_E(BMS_TAG_INSTALLER, "UpdateHapToken failed %{public}s", bundleName_.c_str());
return ERR_APPEXECFWK_INSTALL_GRANT_REQUEST_PERMISSIONS_FAILED;
}
if (needUpdate) {
newInfo.SetAccessTokenIdExWithAppIndex(cloneAccessTokenIdEx,
uerInfo.second.bundleUserInfo.userId, cloneInfoPair.second.appIndex);
}
}
}
if (needUpdate && !dataMgr_->UpdateInnerBundleInfo(newInfo)) {
LOG_NOFUNC_E(BMS_TAG_INSTALLER, "save UpdateInnerBundleInfo failed %{publlic}s", bundleName_.c_str());

View File

@ -2859,6 +2859,28 @@ void InnerBundleInfo::SetAccessTokenIdEx(
infoItem->second.accessTokenIdEx = accessTokenIdEx.tokenIDEx;
}
void InnerBundleInfo::SetAccessTokenIdExWithAppIndex(
const Security::AccessToken::AccessTokenIDEx accessTokenIdEx,
const int32_t userId, const int32_t appIndex)
{
auto& key = NameAndUserIdToKey(GetBundleName(), userId);
auto infoItem = innerBundleUserInfos_.find(key);
if (infoItem == innerBundleUserInfos_.end()) {
return;
}
auto& userInfo = infoItem->second;
std::map<std::string, InnerBundleCloneInfo> &cloneInfos = userInfo.cloneInfos;
auto cloneKey = InnerBundleUserInfo::AppIndexToKey(appIndex);
auto cloneItem = cloneInfos.find(cloneKey);
if (cloneItem == cloneInfos.end()) {
return;
}
cloneItem->second.accessTokenId = accessTokenIdEx.tokenIdExStruct.tokenID;
cloneItem->second.accessTokenIdEx = accessTokenIdEx.tokenIDEx;
}
void InnerBundleInfo::SetkeyId(const int32_t userId, const std::string &keyId)
{
if (keyId.empty()) {