Issue:#IB184C

Description: app update, clone app follow in multiuser
Sig: SIG_ApplicaitonFramework
Feature or Bugfix: Bugfix
Binary Source: No
Signed-off-by: renjie84  renjie84@huawei.com

Signed-off-by: 任杰 <renjie84@huawei.com>
This commit is contained in:
任杰 2024-10-31 19:57:53 +08:00
parent 8088fa3eb7
commit 50ad7a1c12
2 changed files with 24 additions and 56 deletions

View File

@ -530,8 +530,8 @@ private:
ErrCode UpdateHapToken(bool needUpdate, InnerBundleInfo &newInfo);
ErrCode SetDirApl(const InnerBundleInfo &info);
ErrCode SetDirApl(
const std::string &bundleName, const std::string &CloneBundleName, const std::string &appPrivilegeLevel,
bool isPreInstallApp, const std::string &appProvisionType);
int32_t userId, const std::string &bundleName, const std::string &CloneBundleName,
const std::string &appPrivilegeLevel, bool isPreInstallApp, const std::string &appProvisionType);
/**
* @brief Check to set isRemovable true when install.
* @param newInfos Indicates all innerBundleInfo for all haps need to be installed.

View File

@ -2712,58 +2712,26 @@ ErrCode BaseBundleInstaller::ProcessDiffFiles(const AppqfInfo &appQfInfo, const
ErrCode BaseBundleInstaller::SetDirApl(const InnerBundleInfo &info)
{
for (const auto &el : ServiceConstants::BUNDLE_EL) {
std::string baseBundleDataDir = ServiceConstants::BUNDLE_APP_DATA_BASE_DIR +
el +
ServiceConstants::PATH_SEPARATOR +
std::to_string(userId_);
std::string baseDataDir = baseBundleDataDir + ServiceConstants::BASE + info.GetBundleName();
std::string databaseDataDir = baseBundleDataDir + ServiceConstants::DATABASE + info.GetBundleName();
bool isBaseExist = true;
bool isDatabaseExist = true;
ErrCode result = InstalldClient::GetInstance()->IsExistDir(baseDataDir, isBaseExist);
ErrCode dataResult = InstalldClient::GetInstance()->IsExistDir(databaseDataDir, isDatabaseExist);
if (result != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "IsExistDir error is %{public}d", result);
return result;
auto& bundleUserInfos = info.GetInnerBundleUserInfos();
for (const auto &userInfoPair : bundleUserInfos) {
auto &userInfo = userInfoPair.second;
const std::map<std::string, InnerBundleCloneInfo> &cloneInfos = userInfo.cloneInfos;
auto userId = userInfo.bundleUserInfo.userId;
ErrCode userRet = SetDirApl(userId, info.GetBundleName(), info.GetBundleName(),
info.GetAppPrivilegeLevel(), info.IsPreInstallApp(), info.GetBaseApplicationInfo().appProvisionType);
if (userRet != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER,
"fail to SetDirApl bundle dir, userId %{public}d, error is %{public}d", userId, userRet);
return userRet;
}
if (dataResult != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "IsExistDataDir error is %{public}d", dataResult);
return dataResult;
}
if (!isBaseExist || !isDatabaseExist) {
LOG_D(BMS_TAG_INSTALLER, "base %{public}s or data %{public}s is not exist", baseDataDir.c_str(),
databaseDataDir.c_str());
continue;
}
result = InstalldClient::GetInstance()->SetDirApl(
baseDataDir, info.GetBundleName(), info.GetAppPrivilegeLevel(), info.IsPreInstallApp(),
info.GetBaseApplicationInfo().appProvisionType == Constants::APP_PROVISION_TYPE_DEBUG);
if (result != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "fail to SetDirApl baseDir dir, error is %{public}d", result);
return result;
}
result = InstalldClient::GetInstance()->SetDirApl(
databaseDataDir, info.GetBundleName(), info.GetAppPrivilegeLevel(), info.IsPreInstallApp(),
info.GetBaseApplicationInfo().appProvisionType == Constants::APP_PROVISION_TYPE_DEBUG);
if (result != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "fail to SetDirApl databaseDir dir, error is %{public}d", result);
return result;
}
auto& bundleUserInfos = info.GetInnerBundleUserInfos();
for (const auto &userInfoPair : bundleUserInfos) {
auto &userInfo = userInfoPair.second;
const std::map<std::string, InnerBundleCloneInfo> &cloneInfos = userInfo.cloneInfos;
for (const auto &cloneInfoPair : cloneInfos) {
std::string cloneBundleName = BundleCloneCommonHelper::GetCloneDataDir(
info.GetBundleName(), cloneInfoPair.second.appIndex);
ErrCode cloneRet = this->SetDirApl(info.GetBundleName(), cloneBundleName, info.GetAppPrivilegeLevel(),
info.IsPreInstallApp(), info.GetBaseApplicationInfo().appProvisionType);
if (cloneRet != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "fail to SetDirApl clone bundle dir, error is %{public}d", cloneRet);
return result;
}
for (const auto &cloneInfoPair : cloneInfos) {
std::string cloneBundleName = BundleCloneCommonHelper::GetCloneDataDir(
info.GetBundleName(), cloneInfoPair.second.appIndex);
ErrCode cloneRet = this->SetDirApl(userId, info.GetBundleName(), cloneBundleName,
info.GetAppPrivilegeLevel(), info.IsPreInstallApp(), info.GetBaseApplicationInfo().appProvisionType);
if (cloneRet != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "fail to SetDirApl clone bundle dir, error is %{public}d", cloneRet);
return cloneRet;
}
}
}
@ -2771,14 +2739,14 @@ ErrCode BaseBundleInstaller::SetDirApl(const InnerBundleInfo &info)
}
ErrCode BaseBundleInstaller::SetDirApl(
const std::string &bundleName, const std::string &CloneBundleName, const std::string &appPrivilegeLevel,
bool isPreInstallApp, const std::string &appProvisionType)
int32_t userId, const std::string &bundleName, const std::string &CloneBundleName,
const std::string &appPrivilegeLevel, bool isPreInstallApp, const std::string &appProvisionType)
{
for (const auto &el : ServiceConstants::BUNDLE_EL) {
std::string baseBundleDataDir = ServiceConstants::BUNDLE_APP_DATA_BASE_DIR +
el +
ServiceConstants::PATH_SEPARATOR +
std::to_string(userId_);
std::to_string(userId);
std::string baseDataDir = baseBundleDataDir + ServiceConstants::BASE + CloneBundleName;
std::string databaseDataDir = baseBundleDataDir + ServiceConstants::DATABASE + CloneBundleName;
bool isBaseExist = true;