新增先杀后启动的查杀场景

Signed-off-by: lidongrui <lidongrui3@huawei.com>

Change-Id: Ib3f38b2ccd8480a0b6f6175c62ca33d12fafb23e
This commit is contained in:
lidongrui
2025-08-04 15:15:03 +08:00
parent 9a700a37e0
commit 8cb31c2cdc
29 changed files with 97 additions and 50 deletions
@@ -32,6 +32,7 @@ struct ExitReason : public Parcelable {
int32_t subReason = -1;
std::string exitMsg = "";
bool shouldKillForeground = true;
bool shouldSkipKillInStartup = false; // set true in low-memory, return ERR_KILL_APP_WHILE_STARTING and do not kill
bool ReadFromParcel(Parcel &parcel);
virtual bool Marshalling(Parcel &parcel) const override;
@@ -51,6 +51,7 @@ enum class ErrorLifecycleState {
ABILITY_STATE_DIED,
ABILITY_STATE_PERMISSION_UPDATE,
ABILITY_STATE_LOW_MEMORY_KILL,
ABILITY_STATE_SKIP_KILL_IN_STARTUP,
};
/**
@@ -118,7 +118,8 @@ public:
* @return ERR_OK, return back success, others fail.
*/
virtual int32_t KillProcessesByPids(const std::vector<int32_t> &pids,
const std::string &reason = "KillProcessesByPids", bool subProcess = false) = 0;
const std::string &reason = "KillProcessesByPids", bool subProcess = false,
bool isKillPrecedeStart = false) = 0;
/**
* Set child and parent relationship
@@ -106,7 +106,8 @@ public:
* @return ERR_OK, return back success, others fail.
*/
virtual int32_t KillProcessesByPids(const std::vector<int32_t> &pids,
const std::string &reason = "KillProcessesByPids", bool subProcess = false) override;
const std::string &reason = "KillProcessesByPids", bool subProcess = false,
bool isKillPrecedeStart = false) override;
/**
* Set child and parent relationship
@@ -139,7 +139,7 @@ public:
* @param subProcess, kill SubProcess or not.
*/
virtual AppMgrResultCode KillProcessesByPids(const std::vector<int32_t> &pids,
const std::string &reason = "KillProcessesByPids", bool subProcess = false);
const std::string &reason = "KillProcessesByPids", bool subProcess = false, bool isKillPrecedeStart = false);
/**
* Set child and parent relationship
@@ -276,7 +276,7 @@ void AmsMgrProxy::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnM
}
int32_t AmsMgrProxy::KillProcessesByPids(const std::vector<int32_t> &pids, const std::string &reason,
bool subProcess)
bool subProcess, bool isKillPrecedeStart)
{
TAG_LOGI(AAFwkTag::APPMGR, "start");
MessageParcel data;
@@ -305,6 +305,10 @@ int32_t AmsMgrProxy::KillProcessesByPids(const std::vector<int32_t> &pids, const
TAG_LOGE(AAFwkTag::APPMGR, "Write subProcess failed");
return ERR_FLATTEN_OBJECT;
}
if (!data.WriteBool(isKillPrecedeStart)) {
TAG_LOGE(AAFwkTag::APPMGR, "Write isKillPrecedeStart failed");
return ERR_FLATTEN_OBJECT;
}
int32_t ret =
SendTransactCmd(static_cast<uint32_t>(IAmsMgr::Message::KILL_PROCESSES_BY_PIDS), data, reply, option);
if (ret != NO_ERROR) {
@@ -344,7 +344,8 @@ ErrCode AmsMgrStub::HandleKillProcessesByPids(MessageParcel &data, MessageParcel
}
std::string reason = data.ReadString();
bool subProcess = data.ReadBool();
int32_t ret = KillProcessesByPids(pids, reason, subProcess);
bool isKillPrecedeStart = data.ReadBool();
int32_t ret = KillProcessesByPids(pids, reason, subProcess, isKillPrecedeStart);
reply.WriteInt32(ret);
return NO_ERROR;
}
@@ -262,13 +262,13 @@ AppMgrResultCode AppMgrClient::KillProcessesByUserId(int32_t userId, bool isNeed
}
AppMgrResultCode AppMgrClient::KillProcessesByPids(const std::vector<int32_t> &pids, const std::string &reason,
bool subProcess)
bool subProcess, bool isKillPrecedeStart)
{
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
if (service != nullptr) {
sptr<IAmsMgr> amsService = service->GetAmsMgr();
if (amsService != nullptr) {
int32_t ret = amsService->KillProcessesByPids(pids, reason, subProcess);
int32_t ret = amsService->KillProcessesByPids(pids, reason, subProcess, isKillPrecedeStart);
if (ret == ERR_OK) {
return AppMgrResultCode::RESULT_OK;
}
@@ -2707,7 +2707,7 @@ private:
void StartKeepAliveAppsInner(int32_t userId);
bool ProcessLowMemoryKill(int32_t pid, const ExitReason &reason);
bool ProcessLowMemoryKill(int32_t pid, const ExitReason &reason, bool isKillPrecedeStart);
struct StartSelfUIAbilityParam {
Want want;
@@ -2817,7 +2817,7 @@ private:
int32_t OpenLinkInner(const Want &want, sptr<IRemoteObject> callerToken, int32_t userId, int requestCode,
bool removeInsightIntentFlag);
int32_t KillProcessWithReasonInner(int32_t pid, const ExitReason &reason);
int32_t KillProcessWithReasonInner(int32_t pid, const ExitReason &reason, bool isKillPrecedeStart);
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
std::shared_ptr<BackgroundTaskObserver> bgtaskObserver_;
#endif
@@ -598,6 +598,16 @@ public:
return killReason_;
}
inline void SetIsKillPrecedeStart(bool isKillPrecedeStart)
{
isKillPrecedeStart_.store(isKillPrecedeStart);
}
inline bool IsKillPrecedeStart()
{
return isKillPrecedeStart_.load();
}
void PostCancelStartingWindowHotTask();
/**
@@ -1517,6 +1527,7 @@ private:
bool isPrepareTerminate_ = false;
std::string killReason_ = "";
std::atomic_bool isKillPrecedeStart_ = false;
std::shared_ptr<Want> launchWant_ = nullptr;
std::shared_ptr<Want> lastWant_ = nullptr;
std::atomic_bool isLastWantBackgroundDriven_ = false;
+1 -1
View File
@@ -241,7 +241,7 @@ public:
* @return ERR_OK, return back success, others fail.
*/
int32_t KillProcessesByPids(const std::vector<int32_t> &pids,
const std::string &reason = "KillProcessesByPids", bool subProcess = false);
const std::string &reason = "KillProcessesByPids", bool subProcess = false, bool isKillPrecedeStart = false);
/**
* Set child and parent relationship
@@ -391,7 +391,7 @@ public:
bool IsBundleStarting(pid_t pid);
void RecordPidKilling(pid_t pid, const std::string &reason);
void RecordPidKilling(pid_t pid, const std::string &reason, bool isKillPrecedeStart);
int32_t NotifyStartupExceptionBySCB(int32_t requestId, const std::string &reason);
@@ -11833,10 +11833,10 @@ int32_t AbilityManagerService::KillProcessWithPrepareTerminate(const std::vector
return uiAbilityManager->TryPrepareTerminateByPids(pids);
}
bool AbilityManagerService::ProcessLowMemoryKill(int32_t pid, const ExitReason &reason)
bool AbilityManagerService::ProcessLowMemoryKill(int32_t pid, const ExitReason &reason, bool isKillPrecedeStart)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
if (reason.reason != Reason::REASON_RESOURCE_CONTROL || reason.exitMsg != GlobalConstant::LOW_MEMORY_KILL) {
if (!isKillPrecedeStart) {
return false;
}
auto uiAbilityManager = GetUIAbilityManagerByUid(IPCSkeleton::GetCallingUid());
@@ -11848,7 +11848,7 @@ bool AbilityManagerService::ProcessLowMemoryKill(int32_t pid, const ExitReason &
return true;
}
// set ability record kill reason
uiAbilityManager->RecordPidKilling(pid, GlobalConstant::LOW_MEMORY_KILL);
uiAbilityManager->RecordPidKilling(pid, reason.exitMsg, isKillPrecedeStart);
return false;
}
@@ -11856,21 +11856,25 @@ int32_t AbilityManagerService::KillProcessWithReason(int32_t pid, const ExitReas
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
XCOLLIE_TIMER_LESS(__PRETTY_FUNCTION__);
bool isKillPrecedeStart =
(reason.reason == Reason::REASON_RESOURCE_CONTROL && reason.exitMsg == GlobalConstant::LOW_MEMORY_KILL) ||
reason.shouldSkipKillInStartup;
EventInfo eventInfo;
eventInfo.callerPid = IPCSkeleton::GetCallingPid();
eventInfo.pid = pid;
eventInfo.exitMsg = reason.exitMsg;
eventInfo.shouldKillForeground = reason.shouldKillForeground;
auto ret = KillProcessWithReasonInner(pid, reason);
auto ret = KillProcessWithReasonInner(pid, reason, isKillPrecedeStart);
TAG_LOGE(AAFwkTag::ABILITYMGR, "KillProcessWithReason ret: %{public}d, reason: %{public}s", ret,
reason.exitMsg.c_str());
if (reason.reason == Reason::REASON_RESOURCE_CONTROL && reason.exitMsg == GlobalConstant::LOW_MEMORY_KILL) {
if (isKillPrecedeStart) {
eventHelper_.SendKillProcessWithReasonEvent(ret, "KillProcessWithReason", eventInfo);
}
return ret;
}
int32_t AbilityManagerService::KillProcessWithReasonInner(int32_t pid, const ExitReason &reason)
int32_t AbilityManagerService::KillProcessWithReasonInner(int32_t pid, const ExitReason &reason,
bool isKillPrecedeStart)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
bool supportShell = AmsConfigurationParameter::GetInstance().IsSupportAAKillWithReason();
@@ -11891,7 +11895,7 @@ int32_t AbilityManagerService::KillProcessWithReasonInner(int32_t pid, const Exi
}
}
if (ProcessLowMemoryKill(pid, reason)) {
if (ProcessLowMemoryKill(pid, reason, isKillPrecedeStart)) {
// if app is already starting, return
TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}d is starting", pid);
return ERR_KILL_APP_WHILE_STARTING;
@@ -11903,7 +11907,7 @@ int32_t AbilityManagerService::KillProcessWithReasonInner(int32_t pid, const Exi
}
std::vector<int32_t> pidToBeKilled = { pid };
return IN_PROCESS_CALL(DelayedSingleton<AppScheduler>::GetInstance()->KillProcessesByPids(pidToBeKilled,
reason.exitMsg, true));
reason.exitMsg, true, isKillPrecedeStart));
}
int32_t AbilityManagerService::RegisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback)
+3 -2
View File
@@ -160,11 +160,12 @@ void AppScheduler::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawn
appMgrClient_->KillProcessesByUserId(userId, isNeedSendAppSpawnMsg, callback);
}
int32_t AppScheduler::KillProcessesByPids(const std::vector<int32_t> &pids, const std::string &reason, bool subProcess)
int32_t AppScheduler::KillProcessesByPids(const std::vector<int32_t> &pids, const std::string &reason, bool subProcess,
bool isKillPrecedeStart)
{
TAG_LOGI(AAFwkTag::ABILITYMGR, "call");
CHECK_POINTER_AND_RETURN(appMgrClient_, INNER_ERR);
int32_t ret = appMgrClient_->KillProcessesByPids(pids, reason, subProcess);
int32_t ret = appMgrClient_->KillProcessesByPids(pids, reason, subProcess, isKillPrecedeStart);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to KillProcessesByPids");
return ret;
+2
View File
@@ -43,6 +43,7 @@ bool ExitReason::ReadFromParcel(Parcel &parcel)
subReason = reasonData;
exitMsg = Str16ToStr8(parcel.ReadString16());
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, shouldKillForeground);
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, shouldSkipKillInStartup);
return true;
}
@@ -67,6 +68,7 @@ bool ExitReason::Marshalling(Parcel &parcel) const
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, subReason);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(exitMsg));
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, shouldKillForeground);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, shouldSkipKillInStartup);
return true;
}
} // namespace AppExecFwk
@@ -164,12 +164,13 @@ void UIAbilityLifecycleManager::RemoveStartingPid(pid_t pid)
TAG_LOGW(AAFwkTag::ABILITYMGR, "%{public}d not found", pid);
}
void UIAbilityLifecycleManager::RecordPidKilling(pid_t pid, const std::string &reason)
void UIAbilityLifecycleManager::RecordPidKilling(pid_t pid, const std::string &reason, bool isKillPrecedeStart)
{
std::lock_guard<ffrt::mutex> guard(sessionLock_);
for (const auto& [first, second] : sessionAbilityMap_) {
if (second && pid == second->GetPid()) {
second->SetKillReason(reason);
second->SetIsKillPrecedeStart(isKillPrecedeStart);
}
}
}
@@ -277,7 +278,7 @@ std::shared_ptr<AbilityRecord> UIAbilityLifecycleManager::GenerateAbilityRecord(
std::shared_ptr<AbilityRecord> uiAbilityRecord = nullptr;
auto iter = sessionAbilityMap_.find(sessionInfo->persistentId);
bool isLowMemKill = (iter != sessionAbilityMap_.end()) &&
(iter->second != nullptr) && (iter->second->GetKillReason() == GlobalConstant::LOW_MEMORY_KILL);
(iter->second != nullptr) && (iter->second->IsKillPrecedeStart());
if (iter == sessionAbilityMap_.end() || isLowMemKill) {
uiAbilityRecord = FindRecordFromTmpMap(abilityRequest);
auto abilityInfo = abilityRequest.abilityInfo;
@@ -2191,6 +2192,7 @@ void UIAbilityLifecycleManager::NotifySCBToHandleException(const std::shared_ptr
sptr<SessionInfo> info = abilityRecord->GetSessionInfo();
info->errorCode = errorCode;
info->errorReason = errorReason;
info->shouldSkipKillInStartup = abilityRecord->IsKillPrecedeStart();
Rosen::ExceptionInfo exceptionInfo;
exceptionInfo.needClearCallerLink = needClearCallerLink;
session->NotifySessionException(info, exceptionInfo);
@@ -2273,11 +2275,12 @@ void UIAbilityLifecycleManager::OnAbilityDied(std::shared_ptr<AbilityRecord> abi
NotifySCBToHandleException(abilityRecord,
static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_PERMISSION_UPDATE),
"kill process for permission update", needClearCallerLink);
} else if (abilityRecord->GetKillReason() == GlobalConstant::LOW_MEMORY_KILL) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "kill by low memory");
NotifySCBToHandleException(abilityRecord,
static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_LOW_MEMORY_KILL),
abilityRecord->GetKillReason());
} else if (abilityRecord->IsKillPrecedeStart()) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "Killing processes before application startup");
auto errCode = abilityRecord->GetKillReason() == GlobalConstant::LOW_MEMORY_KILL ?
static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_LOW_MEMORY_KILL) :
static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_SKIP_KILL_IN_STARTUP);
NotifySCBToHandleException(abilityRecord, errCode, abilityRecord->GetKillReason());
} else if (!abilityRecord->GetRestartAppFlag()) {
NotifySCBToHandleException(abilityRecord, static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_DIED),
"onAbilityDied");
+2 -1
View File
@@ -120,7 +120,8 @@ public:
* @return ERR_OK, return back success, others fail.
*/
virtual int32_t KillProcessesByPids(const std::vector<int32_t> &pids,
const std::string &reason = "KillProcessesByPids", bool subProcess = false) override;
const std::string &reason = "KillProcessesByPids", bool subProcess = false,
bool isKillPrecedeStart = false) override;
/**
* Set child and parent relationship
@@ -210,7 +210,7 @@ public:
* @return ERR_OK, return back success, others fail.
*/
virtual int32_t KillProcessesByPids(const std::vector<int32_t> &pids,
const std::string &reason = "KillProcessesByPids", bool subProcess = false);
const std::string &reason = "KillProcessesByPids", bool subProcess = false, bool isKillPrecedeStart = false);
/**
* KillProcessesInBatch, kill processes in batch;
@@ -982,7 +982,8 @@ public:
int32_t NotifyAppStatusByCommonEventName(const std::string &bundleName, const std::string &eventName,
const Want &want);
int32_t KillProcessByPid(const pid_t pid, const std::string& reason = "foundation");
int32_t KillProcessByPid(const pid_t pid, const std::string& reason = "foundation",
bool isKillPrecedeStart = false);
int32_t KillSubProcessBypidInner(const pid_t pid, const std::string &reason,
AAFwk::EventInfo &eventInfo);
@@ -2074,7 +2075,7 @@ private:
int32_t GetAllRunningInstanceKeysByBundleNameInner(const std::string &bundleName,
std::vector<std::string> &instanceKeys, int32_t userId);
int32_t KillProcessByPidInner(const pid_t pid, const std::string& reason,
const std::string& killReason, std::shared_ptr<AppRunningRecord> appRecord);
const std::string& killReason, std::shared_ptr<AppRunningRecord> appRecord, bool isKillPrecedeStart);
void SetKilledEventInfo(std::shared_ptr<AppRunningRecord> appRecord, AAFwk::EventInfo &eventInfo);
void AddToKillProcessMap(const std::string &processName);
bool IsAllowedNWebPreload(const std::string &processName);
@@ -1054,6 +1054,16 @@ public:
return killReason_;
}
inline void SetIsKillPrecedeStart(bool isKillPrecedeStart)
{
isKillPrecedeStart_.store(isKillPrecedeStart);
}
inline bool IsKillPrecedeStart() const
{
return isKillPrecedeStart_.load();
}
void AddAppLifecycleEvent(const std::string &msg);
void SetNWebPreload(const bool isAllowedNWebPreload);
@@ -1297,6 +1307,7 @@ private:
sptr<IRemoteObject> browserHost_;
std::shared_ptr<Configuration> delayConfiguration_ = std::make_shared<Configuration>();
std::string killReason_ = "";
std::atomic_bool isKillPrecedeStart_ = false;
int32_t rssValue_ = 0;
int32_t pssValue_ = 0;
bool reasonExist_ = false;
+2 -2
View File
@@ -243,7 +243,7 @@ void AmsMgrScheduler::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSp
}
int32_t AmsMgrScheduler::KillProcessesByPids(const std::vector<int32_t> &pids, const std::string &reason,
bool subProcess)
bool subProcess, bool isKillPrecedeStart)
{
if (!IsReady()) {
return ERR_INVALID_OPERATION;
@@ -256,7 +256,7 @@ int32_t AmsMgrScheduler::KillProcessesByPids(const std::vector<int32_t> &pids, c
return ERR_PERMISSION_DENIED;
}
return amsMgrServiceInner_->KillProcessesByPids(pids, reason, subProcess);
return amsMgrServiceInner_->KillProcessesByPids(pids, reason, subProcess, isKillPrecedeStart);
}
void AmsMgrScheduler::AttachPidToParent(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callerToken)
@@ -2964,7 +2964,7 @@ void AppMgrServiceInner::GetChildrenProcesses(const std::shared_ptr<AppRunningRe
}
#endif // SUPPORT_CHILD_PROCESS
int32_t AppMgrServiceInner::KillProcessByPid(const pid_t pid, const std::string& reason)
int32_t AppMgrServiceInner::KillProcessByPid(const pid_t pid, const std::string& reason, bool isKillPrecedeStart)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
if (!ProcessUtil::ProcessExist(pid)) {
@@ -2978,11 +2978,11 @@ int32_t AppMgrServiceInner::KillProcessByPid(const pid_t pid, const std::string&
appRecord->SetExitMsg(killReason);
}
TAG_LOGI(AAFwkTag::APPMGR, "kill reason=%{public}s, pid=%{public}d", reason.c_str(), pid);
return KillProcessByPidInner(pid, reason, killReason, appRecord);
return KillProcessByPidInner(pid, reason, killReason, appRecord, isKillPrecedeStart);
}
int32_t AppMgrServiceInner::KillProcessByPidInner(const pid_t pid, const std::string& reason,
const std::string& killReason, std::shared_ptr<AppRunningRecord> appRecord)
const std::string& killReason, std::shared_ptr<AppRunningRecord> appRecord, bool isKillPrecedeStart)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
AAFwk::RecordCostTimeUtil timeRecord("KillProcessByPidInner");
@@ -3008,6 +3008,7 @@ int32_t AppMgrServiceInner::KillProcessByPidInner(const pid_t pid, const std::st
AAFwk::EventInfo eventInfo;
SetKilledEventInfo(appRecord, eventInfo);
appRecord->SetKillReason(reason);
appRecord->SetIsKillPrecedeStart(isKillPrecedeStart);
if (ret >= 0) {
AddToKillProcessMap(appRecord->GetProcessName());
}
@@ -3570,14 +3571,14 @@ int32_t AppMgrServiceInner::KillSubProcessBypid(const pid_t pid, const std::stri
}
int32_t AppMgrServiceInner::KillProcessesByPids(const std::vector<int32_t> &pids, const std::string &reason,
bool subProcess)
bool subProcess, bool isKillPrecedeStart)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
int32_t ret = ERR_OK;
for (const auto& pid: pids) {
auto appRecord = GetAppRunningRecordByPid(pid);
if (appRecord != nullptr) {
ret = KillProcessByPid(pid, reason);
ret = KillProcessByPid(pid, reason, isKillPrecedeStart);
if (ret != ERR_OK) {
TAG_LOGW(AAFwkTag::APPMGR, "fail, pid:%{public}d", pid);
return ret;
+3 -3
View File
@@ -141,7 +141,7 @@ std::shared_ptr<AppRunningRecord> AppRunningManager::CheckAppRunningRecordIsExis
AppRunningManager::CheckAppProcessNameIsSame(pair.second, processName) &&
(pair.second->GetJointUserId() == jointUserId) && !(pair.second->IsTerminating()) &&
!(pair.second->IsKilling()) && !(pair.second->GetRestartAppFlag()) &&
(pair.second->GetKillReason() != AbilityRuntime::GlobalConstant::LOW_MEMORY_KILL);
!(pair.second->IsKillPrecedeStart());
};
auto appRunningMap = GetAppRunningRecordMap();
if (!jointUserId.empty()) {
@@ -157,7 +157,7 @@ std::shared_ptr<AppRunningRecord> AppRunningManager::CheckAppRunningRecordIsExis
!(appRecord->IsTerminating()) && !(appRecord->IsKilling()) && !(appRecord->GetRestartAppFlag()) &&
!(appRecord->IsUserRequestCleaning()) &&
!(appRecord->IsCaching() && appRecord->GetProcessCacheBlocked()) &&
appRecord->GetKillReason() != AbilityRuntime::GlobalConstant::LOW_MEMORY_KILL) {
!(appRecord->IsKillPrecedeStart())) {
auto appInfoList = appRecord->GetAppInfoList();
TAG_LOGD(AAFwkTag::APPMGR,
"appInfoList: %{public}zu, processName: %{public}s, specifiedProcessFlag: %{public}s, \
@@ -204,7 +204,7 @@ std::shared_ptr<AppRunningRecord> AppRunningManager::CheckAppRunningRecordForSpe
!(appRecord->IsTerminating()) && !(appRecord->IsKilling()) && !(appRecord->GetRestartAppFlag()) &&
!(appRecord->IsUserRequestCleaning()) &&
!(appRecord->IsCaching() && appRecord->GetProcessCacheBlocked()) &&
appRecord->GetKillReason() != AbilityRuntime::GlobalConstant::LOW_MEMORY_KILL) {
!(appRecord->IsKillPrecedeStart())) {
return appRecord;
}
}
@@ -69,7 +69,8 @@ public:
MOCK_METHOD1(IsWaitingDebugApp, bool(const std::string &bundleName));
MOCK_METHOD0(ClearNonPersistWaitingDebugFlag, void());
MOCK_METHOD0(IsMemorySizeSufficent, bool());
MOCK_METHOD3(KillProcessesByPids, int32_t(const std::vector<int32_t> &, const std::string &, bool subProcess));
MOCK_METHOD4(KillProcessesByPids, int32_t(const std::vector<int32_t> &pids, const std::string &reason,
bool subProcess, bool isKillPrecedeStart));
MockAmsMgrScheduler() : AmsMgrStub() {};
virtual ~MockAmsMgrScheduler() {};
@@ -389,7 +389,7 @@ public:
bool IsBundleStarting(pid_t pid);
void RecordPidKilling(pid_t pid, const std::string &reason);
void RecordPidKilling(pid_t pid, const std::string &reason, bool isKillPrecedeStart);
int32_t NotifyStartupExceptionBySCB(int32_t requestId, const std::string &reason);
@@ -41,7 +41,7 @@ void UIAbilityLifecycleManager::RemoveStartingPid(pid_t pid)
{
}
void UIAbilityLifecycleManager::RecordPidKilling(pid_t pid, const std::string &reason)
void UIAbilityLifecycleManager::RecordPidKilling(pid_t pid, const std::string &reason, bool isKillPrecedeStart)
{
}
@@ -391,7 +391,7 @@ public:
bool IsBundleStarting(pid_t pid);
void RecordPidKilling(pid_t pid, const std::string &reason);
void RecordPidKilling(pid_t pid, const std::string &reason, bool isKillPrecedeStart);
int32_t NotifyStartupExceptionBySCB(int32_t requestId, const std::string &reason);
@@ -44,7 +44,7 @@ void UIAbilityLifecycleManager::RemoveStartingPid(pid_t pid)
{
}
void UIAbilityLifecycleManager::RecordPidKilling(pid_t pid, const std::string &reason)
void UIAbilityLifecycleManager::RecordPidKilling(pid_t pid, const std::string &reason, bool isKillPrecedeStart)
{
}
@@ -1209,7 +1209,7 @@ HWTEST_F(AppMgrServiceInnerTest, KillProcessByPidInner_001, TestSize.Level2)
ASSERT_NE(appMgrServiceInner, nullptr);
pid_t pid = 99999999;
auto ret = appMgrServiceInner->KillProcessByPidInner(pid, "ReasonTdd", "KillReasonTdd", nullptr);
auto ret = appMgrServiceInner->KillProcessByPidInner(pid, "ReasonTdd", "KillReasonTdd", nullptr, false);
EXPECT_EQ(ret, AAFwk::ERR_KILL_PROCESS_NOT_EXIST);
TAG_LOGI(AAFwkTag::TEST, "KillProcessByPidInner_001 end");
}
@@ -1109,9 +1109,11 @@ HWTEST_F(UIAbilityLifecycleManagerSecondTest, RecordPidKilling_001, TestSize.Lev
mgr->sessionAbilityMap_ = sessionAbilityMap;
pid_t pid = 1;
std::string reason = "HelloWorld";
mgr->RecordPidKilling(pid, reason);
bool isKillPrecedeStart = true;
mgr->RecordPidKilling(pid, reason, isKillPrecedeStart);
EXPECT_EQ(mgr->sessionAbilityMap_[1]->killReason_, "HelloWorld");
EXPECT_EQ(mgr->sessionAbilityMap_[1]->isKillPrecedeStart_, true);
}
/**