mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-19 06:47:09 +00:00
commit
6c286c6cc9
@ -521,6 +521,7 @@ public:
|
||||
|
||||
using Closure = std::function<void()>;
|
||||
void PostTask(std::string msg, int64_t timeOut, const Closure &task);
|
||||
void RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObject>& token) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -177,6 +177,8 @@ public:
|
||||
|
||||
const std::shared_ptr<ApplicationInfo> GetAppInfo();
|
||||
|
||||
bool RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObject>& token) const;
|
||||
|
||||
private:
|
||||
void SendEvent(uint32_t msg, int64_t timeOut, const std::shared_ptr<AbilityRunningRecord> &abilityRecord);
|
||||
|
||||
|
@ -375,19 +375,17 @@ void AppRunningManager::TerminateAbility(const sptr<IRemoteObject> &token, bool
|
||||
HILOG_ERROR("appRecord is nullptr.");
|
||||
return;
|
||||
}
|
||||
bool isLastAbilityRecord = appRecord->IsLastAbilityRecord(token);
|
||||
bool isClearMission = (clearMissionFlag && appMgrServiceInner != nullptr);
|
||||
if (isClearMission) {
|
||||
isLastAbilityRecord = appRecord->IsLastPageAbilityRecord(token);
|
||||
}
|
||||
appRecord->TerminateAbility(token, false);
|
||||
|
||||
auto isLastAbility =
|
||||
clearMissionFlag ? appRecord->IsLastPageAbilityRecord(token) : appRecord->IsLastAbilityRecord(token);
|
||||
auto isKeepAliveApp = appRecord->IsKeepAliveApp();
|
||||
auto isLauncherApp = appRecord->GetApplicationInfo()->isLauncherApp;
|
||||
if (isLastAbilityRecord && !isKeepAliveApp && !isLauncherApp) {
|
||||
if (isLastAbility && !isKeepAliveApp && !isLauncherApp) {
|
||||
HILOG_DEBUG("The ability is the last in the app:%{public}s.", appRecord->GetName().c_str());
|
||||
appRecord->SetTerminating();
|
||||
if (isClearMission) {
|
||||
if (clearMissionFlag && appMgrServiceInner != nullptr) {
|
||||
appRecord->RemoveTerminateAbilityTimeoutTask(token);
|
||||
HILOG_DEBUG("The ability is the last, kill application");
|
||||
auto pid = appRecord->GetPriorityObject()->GetPid();
|
||||
auto result = appMgrServiceInner->KillProcessByPid(pid);
|
||||
|
@ -1148,5 +1148,15 @@ bool AppRunningRecord::IsKilling() const
|
||||
{
|
||||
return isKilling_;
|
||||
}
|
||||
|
||||
void AppRunningRecord::RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObject>& token) const
|
||||
{
|
||||
auto moduleRecord = GetModuleRunningRecordByToken(token);
|
||||
if (!moduleRecord) {
|
||||
HILOG_ERROR("can not find module record");
|
||||
return;
|
||||
}
|
||||
(void)moduleRecord->RemoveTerminateAbilityTimeoutTask(token);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -294,19 +294,24 @@ void ModuleRunningRecord::AbilityTerminated(const sptr<IRemoteObject> &token)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!eventHandler_) {
|
||||
HILOG_ERROR("eventHandler_ is nullptr");
|
||||
return;
|
||||
if (RemoveTerminateAbilityTimeoutTask(token)) {
|
||||
terminateAbilitys_.erase(token);
|
||||
}
|
||||
}
|
||||
|
||||
bool ModuleRunningRecord::RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObject>& token) const
|
||||
{
|
||||
auto abilityRecord = GetAbilityByTerminateLists(token);
|
||||
if (!abilityRecord) {
|
||||
HILOG_ERROR("ModuleRunningRecord::AbilityTerminated can not find ability record");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (!eventHandler_) {
|
||||
HILOG_ERROR("eventHandler_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
eventHandler_->RemoveEvent(AMSEventHandler::TERMINATE_ABILITY_TIMEOUT_MSG, abilityRecord->GetEventId());
|
||||
terminateAbilitys_.erase(token);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModuleRunningRecord::SetAppMgrServiceInner(const std::weak_ptr<AppMgrServiceInner> &inner)
|
||||
|
Loading…
Reference in New Issue
Block a user