diff --git a/services/abilitymgr/include/mission_list_manager.h b/services/abilitymgr/include/mission_list_manager.h index ef11ffc55ad869c18aa3e2c625360ec45c932212..bb9c7ccbd403fcf3a893f9f7af8aaee114fefe49 100644 --- a/services/abilitymgr/include/mission_list_manager.h +++ b/services/abilitymgr/include/mission_list_manager.h @@ -353,6 +353,8 @@ public: int32_t IsValidMissionIds(const std::vector &missionIds, std::vector &results); + int DoAbilityForeground(std::shared_ptr &abilityRecord, uint32_t flag); + #ifdef SUPPORT_GRAPHICS public: /** diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 649aa5b80843140889691fdc46b7a6c90f8ab670..a491e13c9fa2d23522d5bb5adf0ad5d41449c45e 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -4850,7 +4850,7 @@ void AbilityManagerService::UpdateMissionSnapShot(const sptr& tok } auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall(); if (!isSaCall) { - if(!CheckCallingTokenId(BUNDLE_NAME_LAUNCHER, GetUserId())) { + if (!CheckCallingTokenId(BUNDLE_NAME_LAUNCHER, GetUserId())) { HILOG_ERROR("Not launcher called, not allowed."); return; } @@ -5487,16 +5487,8 @@ int AbilityManagerService::DoAbilityForeground(const sptr &token, return ERR_WOULD_BLOCK; } - if (abilityRecord->GetPendingState() == AbilityState::FOREGROUND) { - HILOG_DEBUG("pending state is FOREGROUND."); - abilityRecord->SetPendingState(AbilityState::FOREGROUND); - return ERR_OK; - } else { - HILOG_DEBUG("pending state is not FOREGROUND."); - abilityRecord->SetPendingState(AbilityState::FOREGROUND); - } - abilityRecord->ProcessForegroundAbility(flag); - return ERR_OK; + CHECK_POINTER_AND_RETURN(currentMissionListManager_, ERR_NO_INIT); + return currentMissionListManager_->DoAbilityForeground(abilityRecord, flag); } int AbilityManagerService::DoAbilityBackground(const sptr &token, uint32_t flag) diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 874b8cfaf63ce4ed044a95a70b98dfdf7eb1cf2b..5d71b7a9125a2ef5d426724a5d9a95291f97575c 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -1148,15 +1148,6 @@ int MissionListManager::DispatchForeground(const std::shared_ptr HILOG_WARN("Mission list mgr is invalid."); return; } - if (state == AbilityState::FOREGROUND_WINDOW_FREEZED) { - HILOG_INFO("Window was freezed."); - if (abilityRecord != nullptr) { - abilityRecord->SetAbilityState(AbilityState::BACKGROUND); - DelayedSingleton::GetInstance()->MoveToBackground(abilityRecord->GetToken()); - selfObj->TerminatePreviousAbility(abilityRecord); - } - return; - } selfObj->CompleteForegroundFailed(abilityRecord, state); }; handler->PostTask(task); @@ -1982,7 +1973,14 @@ void MissionListManager::CompleteForegroundFailed(const std::shared_ptrSetPendingState(AbilityState::INITIAL); + abilityRecord->SetAbilityState(AbilityState::BACKGROUND); + DelayedSingleton::GetInstance()->MoveToBackground(abilityRecord->GetToken()); + TerminatePreviousAbility(abilityRecord); + return; + } #ifdef SUPPORT_GRAPHICS if (state == AbilityState::FOREGROUND_INVALID_MODE) { abilityRecord->SetStartingWindow(false); @@ -3484,5 +3482,24 @@ void MissionListManager::NotifyStartAbilityResult(const AbilityRequest &abilityR abilityInfoCallback->NotifyStartAbilityResult(abilityRequest.want, result); } } + +int MissionListManager::DoAbilityForeground(std::shared_ptr &abilityRecord, uint32_t flag) +{ + std::lock_guard guard(managerLock_); + if (abilityRecord == nullptr) { + HILOG_ERROR("DoAbilityForeground failed, ability record is null."); + return ERR_INVALID_VALUE; + } + if (abilityRecord->GetPendingState() == AbilityState::FOREGROUND) { + HILOG_DEBUG("pending state is FOREGROUND."); + abilityRecord->SetPendingState(AbilityState::FOREGROUND); + return ERR_OK; + } else { + HILOG_DEBUG("pending state is not FOREGROUND."); + abilityRecord->SetPendingState(AbilityState::FOREGROUND); + } + abilityRecord->ProcessForegroundAbility(flag); + return ERR_OK; +} } // namespace AAFwk } // namespace OHOS