应用配置常驻字段,只有主进程常驻生效

Signed-off-by: xia <xialiangwei1@huawei.com>
This commit is contained in:
xia
2024-05-25 14:17:40 +08:00
parent c40b319ac2
commit 0eff05ab34
3 changed files with 18 additions and 1 deletions
@@ -542,12 +542,16 @@ public:
bool IsEmptyKeepAliveApp() const;
bool IsMainProcess() const;
void SetEmptyKeepAliveAppState(bool isEmptyKeepAliveApp);
void SetKeepAliveEnableState(bool isKeepAliveEnable);
void SetSingleton(bool isSingleton);
void SetMainProcess(bool isMainProcess);
void SetStageModelState(bool isStageBasedModel);
std::list<std::shared_ptr<ModuleRunningRecord>> GetAllModuleRecord() const;
@@ -849,6 +853,7 @@ private:
bool isKeepAliveApp_ = false; // Only resident processes can be set to true, please choose carefully
bool isEmptyKeepAliveApp_ = false; // Only empty resident processes can be set to true, please choose carefully
bool isMainProcess_ = true; // Only MainProcess can be keepalive
bool isSingleton_ = false;
bool isStageBasedModel_ = false;
ApplicationState curState_ = ApplicationState::APP_STATE_CREATE; // current state of this process
@@ -634,6 +634,7 @@ void AppMgrServiceInner::LoadAbilityNoAppRecord(const std::shared_ptr<AppRunning
}
if (hapModuleInfo.isStageBasedModel && !IsMainProcess(appInfo, hapModuleInfo)) {
appRecord->SetEmptyKeepAliveAppState(false);
appRecord->SetMainProcess(false);
TAG_LOGI(AAFwkTag::APPMGR, "The process %{public}s will not keepalive", hapModuleInfo.process.c_str());
}
// As taskHandler_ is busy now, the task should be submit to other task queue.
@@ -3775,6 +3776,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap
}
if (hapModuleInfo.isStageBasedModel && !IsMainProcess(appInfo, hapModuleInfo)) {
appRecord->SetEmptyKeepAliveAppState(false);
appRecord->SetMainProcess(false);
TAG_LOGD(AAFwkTag::APPMGR, "The process %{public}s will not keepalive", hapModuleInfo.process.c_str());
}
auto wantPtr = std::make_shared<AAFwk::Want>(want);
+11 -1
View File
@@ -1370,7 +1370,7 @@ bool AppRunningRecord::IsTerminating()
bool AppRunningRecord::IsKeepAliveApp() const
{
return isKeepAliveApp_ && isSingleton_;
return isKeepAliveApp_ && isSingleton_ && isMainProcess_;
}
void AppRunningRecord::SetKeepAliveEnableState(bool isKeepAliveEnable)
@@ -1388,6 +1388,16 @@ void AppRunningRecord::SetEmptyKeepAliveAppState(bool isEmptyKeepAliveApp)
isEmptyKeepAliveApp_ = isEmptyKeepAliveApp;
}
bool AppRunningRecord::IsMainProcess() const
{
return isMainProcess_;
}
void AppRunningRecord::SetMainProcess(bool isMainProcess)
{
isMainProcess_ = isMainProcess;
}
void AppRunningRecord::SetSingleton(bool isSingleton)
{
isSingleton_ = isSingleton;