From 24dfa367c550225d16d34cffc913422b6eb3ebe5 Mon Sep 17 00:00:00 2001 From: yuwenze Date: Thu, 4 May 2023 13:45:55 +0000 Subject: [PATCH] fix UIAbility in foregrounding Signed-off-by: yuwenze Change-Id: If000ac0479ff36706ddb06b24f880aa8649b1d25 --- services/abilitymgr/include/ability_record.h | 6 ------ services/abilitymgr/src/ability_record.cpp | 1 - services/abilitymgr/src/mission_list_manager.cpp | 15 ++++----------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index e78a52d30b1..0ead20c455b 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -833,11 +833,6 @@ public: return recordId_; } - inline int64_t GetForegroundingTime() const - { - return foregroundingTime_; - } - void SetPendingState(AbilityState state); AbilityState GetPendingState() const; @@ -934,7 +929,6 @@ private: std::weak_ptr nextAbilityRecord_ = {}; // ability that started by this ability int64_t startTime_ = 0; // records first time of ability start int64_t restartTime_ = 0; // the time of last trying restart - int64_t foregroundingTime_ = 0; // the time of foregrounding to do bool isReady_ = false; // is ability thread attached? bool isWindowAttached_ = false; // Is window of this ability attached? bool isLauncherAbility_ = false; // is launcher? diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 2fd63a5067d..0142f3a220f 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -330,7 +330,6 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag) // schedule active after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. SetAbilityStateInner(AbilityState::FOREGROUNDING); - foregroundingTime_ = AbilityUtil::SystemTimeMillis(); lifeCycleStateInfo_.sceneFlag = sceneFlag; lifecycleDeal_->ForegroundNew(want_, lifeCycleStateInfo_, sessionInfo_); lifeCycleStateInfo_.sceneFlag = 0; diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 792a3531542..b64b968d4bf 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -40,7 +40,6 @@ constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME"; constexpr int32_t SINGLE_MAX_INSTANCE_COUNT = 128; constexpr int32_t MAX_INSTANCE_COUNT = 512; constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns -constexpr int64_t MAX_FOREGROUNDING_TIME = 60 * 1000; // 1 minute const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; const std::string DMS_MISSION_ID = "dmsMissionId"; const int DEFAULT_DMS_MISSION_ID = -1; @@ -132,16 +131,9 @@ int MissionListManager::StartAbility(AbilityRequest &abilityRequest) HILOG_DEBUG("current top: %{public}s, state: %{public}s", element.c_str(), AbilityRecord::ConvertAbilityState(state).c_str()); if (state == FOREGROUNDING) { - auto foregroundingTime = currentTopAbility->GetForegroundingTime(); - auto currentTime = AbilityUtil::SystemTimeMillis(); - if (currentTime - foregroundingTime > MAX_FOREGROUNDING_TIME) { - HILOG_INFO("Top ability:%{public}s is foregrounding and more than one minute.", element.c_str()); - OnTimeOut(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, currentTopAbility->GetAbilityRecordId()); - } else { - HILOG_INFO("Top ability:%{public}s is foregrounding, so enqueue ability for waiting.", element.c_str()); - EnqueueWaitingAbility(abilityRequest); - return START_ABILITY_WAITING; - } + HILOG_INFO("Top ability:%{public}s is foregrounding, so enqueue ability for waiting.", element.c_str()); + EnqueueWaitingAbility(abilityRequest); + return START_ABILITY_WAITING; } } @@ -1159,6 +1151,7 @@ int MissionListManager::DispatchForeground(const std::shared_ptr 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); } -- Gitee