!11665 批量查杀进程--对被杀进程的所有启动请求进行拦截

Merge pull request !11665 from 杨旭光/refactor/kill-pids-batch
This commit is contained in:
openharmony_ci 2024-11-21 09:36:56 +00:00 committed by Gitee
commit baa6973434
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 3 additions and 22 deletions

View File

@ -104,8 +104,7 @@
"zlib"
],
"third_party": [
"libjpeg-turbo",
"googletest"
"libjpeg-turbo"
]
},
"build": {

View File

@ -1931,8 +1931,6 @@ private:
std::atomic<int32_t> willKillPidsNum_ = 0;
std::shared_ptr<AAFwk::TaskHandlerWrap> delayKillTaskHandler_;
std::unordered_set<std::string> nwebPreloadSet_ {};
ffrt::mutex killedBundleSetMutex_;
std::set<std::string> killedBundleSet_;
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -628,13 +628,6 @@ void AppMgrServiceInner::LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, s
TAG_LOGE(AAFwkTag::APPMGR, "checkLoadAbilityConditions fail");
return;
}
{
std::lock_guard lock(killedBundleSetMutex_);
if (killedBundleSet_.find(abilityInfo->bundleName) != killedBundleSet_.end()) {
TAG_LOGW(AAFwkTag::APPMGR, "%{public}s is being killed", abilityInfo->bundleName.c_str());
return;
}
}
if (abilityInfo->type == AbilityType::PAGE) {
std::string entry = "AppMgrServiceInner::LoadAbility";
AbilityRuntime::FreezeUtil::GetInstance().AddLifecycleEvent(loadParam->token, entry);
@ -2926,25 +2919,16 @@ int32_t AppMgrServiceInner::KillProcessesInBatch(const std::vector<int32_t> &pid
TAG_LOGE(AAFwkTag::APPMGR, "not supported.");
return AAFwk::ERR_CAPABILITY_NOT_SUPPORT;
}
std::vector<int32_t> killPids;
for (const auto& pid: pids) {
auto appRecord = GetAppRunningRecordByPid(pid);
if (appRecord == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "appRecord null");
continue;
}
killPids.emplace_back(pid);
std::string bundleName = appRecord->GetBundleName();
{
std::lock_guard lock(killedBundleSetMutex_);
killedBundleSet_.insert(bundleName);
}
}
std::lock_guard lock(killedBundleSetMutex_);
for (const auto& pid: killPids) {
std::string callerKey = std::to_string(pid) + ":" + std::to_string(appRecord->GetUid());
KillingProcessManager::GetInstance().AddKillingCallerKey(callerKey);
(void)KillProcessByPid(pid, "KillProcessesInBatch");
}
killedBundleSet_.clear();
return ERR_OK;
}