From 77674612427e7454fcddecbeef641d1222f7c0cf Mon Sep 17 00:00:00 2001 From: jsj Date: Sat, 26 Feb 2022 07:10:38 +0000 Subject: [PATCH] IssueNo:#I4VDTQ Description: Fix the problem of incorrect application status after unlocking the screen Sig:SIG_ApplicationFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: jsj Change-Id: I3210dad067cd1ff87b39e611aa083a0f2804efae --- .../ability_manager/include/lifecycle_state_info.h | 1 + services/abilitymgr/include/ability_record.h | 4 ++-- services/abilitymgr/src/ability_manager_service.cpp | 5 ++--- services/abilitymgr/src/ability_record.cpp | 8 +++++--- services/abilitymgr/src/mission_list_manager.cpp | 3 ++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/interfaces/innerkits/ability_manager/include/lifecycle_state_info.h b/interfaces/innerkits/ability_manager/include/lifecycle_state_info.h index e77bbbb968b..6d71d1565d5 100644 --- a/interfaces/innerkits/ability_manager/include/lifecycle_state_info.h +++ b/interfaces/innerkits/ability_manager/include/lifecycle_state_info.h @@ -55,6 +55,7 @@ struct LifeCycleStateInfo : public Parcelable { LaunchParam launchParam; bool useNewMission = false; uint32_t sceneFlag = 0; + uint32_t sceneFlagBak = 0; bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index e5e73f0345d..d0d06597a3e 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -214,13 +214,13 @@ public: * foreground the ability. * */ - void ForegroundAbility(); + void ForegroundAbility(uint32_t sceneFlag = 0); /** * process request of foregrounding the ability. * */ - void ProcessForegroundAbility(); + void ProcessForegroundAbility(uint32_t sceneFlag = 0); /** * move the ability to back ground. diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index acc83574cc3..1128528296f 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -4291,9 +4291,8 @@ int AbilityManagerService::DoAbilityForeground(const sptr &token, return ERR_WOULD_BLOCK; } - abilityRecord->lifeCycleStateInfo_.sceneFlag = flag; - abilityRecord->ForegroundAbility(); - abilityRecord->lifeCycleStateInfo_.sceneFlag = SCENE_FLAG_NORMAL; + abilityRecord->lifeCycleStateInfo_.sceneFlagBak = flag; + abilityRecord->ProcessForegroundAbility(flag); return ERR_OK; } diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 1ad07a5d08a..61fcb01572e 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -193,7 +193,7 @@ int AbilityRecord::LoadAbility() token_, callerToken_, abilityInfo_, applicationInfo_, want_); } -void AbilityRecord::ForegroundAbility() +void AbilityRecord::ForegroundAbility(uint32_t sceneFlag) { BYTRACE_NAME(BYTRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); HILOG_INFO("ForegroundAbility."); @@ -204,7 +204,9 @@ void AbilityRecord::ForegroundAbility() // schedule active after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. currentState_ = AbilityState::FOREGROUNDING_NEW; + lifeCycleStateInfo_.sceneFlag = sceneFlag; lifecycleDeal_->ForegroundNew(want_, lifeCycleStateInfo_); + lifeCycleStateInfo_.sceneFlag = 0; // update ability state to appMgr service when restart if (IsNewWant()) { @@ -216,7 +218,7 @@ void AbilityRecord::ForegroundAbility() } } -void AbilityRecord::ProcessForegroundAbility() +void AbilityRecord::ProcessForegroundAbility(uint32_t sceneFlag) { std::string element = GetWant().GetElement().GetURI(); HILOG_DEBUG("ability record: %{public}s", element.c_str()); @@ -228,7 +230,7 @@ void AbilityRecord::ProcessForegroundAbility() DelayedSingleton::GetInstance()->MoveToForground(token_); } else { HILOG_DEBUG("Activate %{public}s", element.c_str()); - ForegroundAbility(); + ForegroundAbility(sceneFlag); } } else { LoadAbility(); diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 356412be329..8f29dc705fc 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -588,7 +588,8 @@ void MissionListManager::OnAbilityRequestDone(const sptr &token, CHECK_POINTER(abilityRecord); std::string element = abilityRecord->GetWant().GetElement().GetURI(); HILOG_DEBUG("ability: %{public}s", element.c_str()); - abilityRecord->ForegroundAbility(); + abilityRecord->ForegroundAbility(abilityRecord->lifeCycleStateInfo_.sceneFlagBak); + abilityRecord->lifeCycleStateInfo_.sceneFlagBak = 0; } } -- Gitee