!6191 分身更新卸载调用元能力接口

Merge pull request !6191 from Zhou Shihui/clone
This commit is contained in:
openharmony_ci 2024-06-25 09:45:39 +00:00 committed by Gitee
commit 961811e94d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 41 additions and 17 deletions

View File

@ -29,7 +29,7 @@ public:
};
static bool UninstallApplicationProcesses(
const std::string &bundleName, const int uid, bool isUpgradeApp = false);
const std::string &bundleName, const int uid, bool isUpgradeApp = false, int32_t appIndex = 0);
static int IsRunning(const std::string bundleName, const int bundleUid);
static int IsRunning(const std::string bundleName);
};

View File

@ -51,9 +51,9 @@ public:
* @param uid uid of bundle.
* @return Returns ERR_OK on success, others on failure.
*/
static int UninstallApp(const std::string &bundleName, int32_t uid);
static int UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex);
static int UpgradeApp(const std::string &bundleName, int32_t uid);
static int UpgradeApp(const std::string &bundleName, int32_t uid, int32_t appIndex);
static bool UnloadSystemAbility(const int32_t systemAbilityId);
};

View File

@ -30,19 +30,19 @@
namespace OHOS {
namespace AppExecFwk {
bool AbilityManagerHelper::UninstallApplicationProcesses(
const std::string &bundleName, const int uid, bool isUpgradeApp)
const std::string &bundleName, const int uid, bool isUpgradeApp, int32_t appIndex)
{
#ifdef ABILITY_RUNTIME_ENABLE
APP_LOGI("uninstall kill running processes, app name is %{public}s, isUpgradeApp : %{public}d",
bundleName.c_str(), isUpgradeApp);
int ret = 0;
if (isUpgradeApp) {
ret = SystemAbilityHelper::UpgradeApp(bundleName, uid);
ret = SystemAbilityHelper::UpgradeApp(bundleName, uid, appIndex);
} else {
ret = SystemAbilityHelper::UninstallApp(bundleName, uid);
ret = SystemAbilityHelper::UninstallApp(bundleName, uid, appIndex);
}
if (ret != 0) {
APP_LOGE("kill application process failed uid : %{public}d", uid);
APP_LOGE("kill application process failed uid: %{public}d, appIndex: %{public}d", uid, appIndex);
return false;
}
return true;

View File

@ -2157,6 +2157,17 @@ ErrCode BaseBundleInstaller::ProcessModuleUpdate(InnerBundleInfo &newInfo,
LOG_E(BMS_TAG_INSTALLER, "fail to kill running application");
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
InnerBundleUserInfo userInfo;
if (!oldInfo.GetInnerBundleUserInfo(userId_, userInfo)) {
LOG_E(BMS_TAG_INSTALLER, "the origin application is not installed at current user");
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
for (auto &cloneInfo : userInfo.cloneInfos) {
if (!AbilityManagerHelper::UninstallApplicationProcesses(
oldInfo.GetApplicationName(), cloneInfo.second.uid, true, std::stoi(cloneInfo.first))) {
LOG_E(BMS_TAG_INSTALLER, "fail to kill clone application");
}
}
}
oldInfo.SetInstallMark(bundleName_, modulePackage_, InstallExceptionStatus::UPDATING_EXISTED_START);
@ -3979,6 +3990,17 @@ ErrCode BaseBundleInstaller::UninstallLowerVersionFeature(const std::vector<std:
info.GetApplicationName(), info.GetUid(userId_), true)) {
LOG_W(BMS_TAG_INSTALLER, "can not kill process");
}
InnerBundleUserInfo userInfo;
if (!info.GetInnerBundleUserInfo(userId_, userInfo)) {
LOG_W(BMS_TAG_INSTALLER, "the origin application is not installed at current user");
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
for (auto &cloneInfo : userInfo.cloneInfos) {
if (!AbilityManagerHelper::UninstallApplicationProcesses(
info.GetApplicationName(), cloneInfo.second.uid, true, std::stoi(cloneInfo.first))) {
LOG_W(BMS_TAG_INSTALLER, "fail to kill clone application");
}
}
}
std::vector<std::string> moduleVec = info.GetModuleNameVec();

View File

@ -259,9 +259,8 @@ ErrCode BundleCloneInstaller::ProcessCloneBundleUninstall(const std::string &bun
APP_LOGE("the user %{public}d does not exist when install clone application.", userId);
return ERR_APPEXECFWK_CLONE_UNINSTALL_USER_NOT_EXIST;
}
ScopeGuard bundleEnabledGuard([&] { dataMgr_->EnableBundle(bundleName); });
InnerBundleInfo info;
bool isExist = dataMgr_->GetInnerBundleInfo(bundleName, info);
bool isExist = dataMgr_->FetchInnerBundleInfo(bundleName, info);
if (!isExist) {
APP_LOGE("the bundle is not installed");
return ERR_APPEXECFWK_CLONE_UNINSTALL_APP_NOT_EXISTED;
@ -278,6 +277,9 @@ ErrCode BundleCloneInstaller::ProcessCloneBundleUninstall(const std::string &bun
}
uid_ = it->second.uid;
accessTokenId_ = it->second.accessTokenId;
if (!AbilityManagerHelper::UninstallApplicationProcesses(bundleName, uid_, false, appIndex)) {
APP_LOGE("fail to kill running application");
}
if (dataMgr_->RemoveCloneBundle(bundleName, userId, appIndex)) {
APP_LOGE("RemoveCloneBundle failed");
return ERR_APPEXECFWK_CLONE_UNINSTALL_INTERNAL_ERROR;

View File

@ -61,7 +61,7 @@ bool SystemAbilityHelper::RemoveSystemAbility(const int32_t systemAbilityId)
return false;
}
int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid)
int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex)
{
#ifdef ABILITY_RUNTIME_ENABLE
sptr<AAFwk::IAbilityManager> abilityMgrProxy =
@ -71,7 +71,7 @@ int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid
return -1;
}
std::string identity = IPCSkeleton::ResetCallingIdentity();
auto ret = abilityMgrProxy->UninstallApp(bundleName, uid);
auto ret = abilityMgrProxy->UninstallApp(bundleName, uid, appIndex);
IPCSkeleton::SetCallingIdentity(identity);
return ret;
#else
@ -79,7 +79,7 @@ int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid
#endif
}
int SystemAbilityHelper::UpgradeApp(const std::string &bundleName, int32_t uid)
int SystemAbilityHelper::UpgradeApp(const std::string &bundleName, int32_t uid, int32_t appIndex)
{
#ifdef ABILITY_RUNTIME_ENABLE
sptr<AAFwk::IAbilityManager> abilityMgrProxy =
@ -89,7 +89,7 @@ int SystemAbilityHelper::UpgradeApp(const std::string &bundleName, int32_t uid)
return -1;
}
std::string identity = IPCSkeleton::ResetCallingIdentity();
auto ret = abilityMgrProxy->UpgradeApp(bundleName, uid, KILL_REASON);
auto ret = abilityMgrProxy->UpgradeApp(bundleName, uid, KILL_REASON, appIndex);
IPCSkeleton::SetCallingIdentity(identity);
return ret;
#else

View File

@ -57,12 +57,12 @@ bool SystemAbilityHelper::RemoveSystemAbility(const int32_t systemAbilityId)
return true;
}
int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid)
int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex)
{
return 0;
}
int SystemAbilityHelper::UpgradeApp(const std::string &bundleName, int32_t uid)
int SystemAbilityHelper::UpgradeApp(const std::string &bundleName, int32_t uid, int32_t appIndex)
{
return 0;
}

View File

@ -55,12 +55,12 @@ bool SystemAbilityHelper::RemoveSystemAbility(const int32_t systemAbilityId)
return true;
}
int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid)
int SystemAbilityHelper::UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex)
{
return 0;
}
int SystemAbilityHelper::UpgradeApp(const std::string &bundleName, int32_t uid)
int SystemAbilityHelper::UpgradeApp(const std::string &bundleName, int32_t uid, int32_t appIndex)
{
return 0;
}