From 895da4dea18055558a8e431c035de1004f29ed29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=97?= Date: Fri, 29 Aug 2025 16:27:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=84=A6=E7=82=B9=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡晗 --- .../include/scene_session_manager.h | 2 +- .../src/scene_session_manager.cpp | 31 ++++++++++--------- .../unittest/scene_session_manager_test10.cpp | 14 ++++----- wm/src/window_session_impl.cpp | 3 ++ 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 4889b94486..effbacf693 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -785,7 +785,7 @@ private: bool MissionChanged(const sptr& prevSession, const sptr& currSession); std::string GetAllSessionFocusInfo(); void RegisterRequestFocusStatusNotifyManagerFunc(const sptr& sceneSession); - void ProcessUpdateLastFocusedAppId(const std::vector& zOrderList); + void ProcessUpdateLastFocusedAppId(const std::vector>& zOrderList); WSError ProcessDialogRequestFocusImmdediately(const sptr& sceneSession); WSError ProcessModalTopmostRequestFocusImmdediately(const sptr& sceneSession); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 841ef92301..cfacdb997c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6570,10 +6570,6 @@ void SceneSessionManager::UpdateFocusStatus(DisplayId displayId, const sptr& preSceneSession, const sptr& currSceneSession, bool isProactiveUnfocus) { - if (preSceneSession == nullptr || currSceneSession == nullptr) { - TLOGE(WmsLogTag::WMS_FOCUS, "sceneSession is nullptr"); - return; - } auto focusGroup = windowFocusController_->GetFocusGroup(displayId); if (focusGroup == nullptr) { TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); @@ -6584,6 +6580,10 @@ void SceneSessionManager::UpdateHighlightStatus(DisplayId displayId, const sptr< TLOGD(WmsLogTag::WMS_FOCUS, "proactiveUnfocus"); RemoveHighlightSessionIds(preSceneSession); } + if (currSceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "currSceneSession is nullptr"); + return; + } if (currSceneSession->GetSessionProperty()->GetExclusivelyHighlighted()) { TLOGD(WmsLogTag::WMS_FOCUS, "exclusively highlighted"); SetHighlightSessionIds(currSceneSession, needBlockHighlightNotify); @@ -8364,7 +8364,7 @@ void SceneSessionManager::GetCollaboratorAbilityInfos(const std::vectorabilityInfos[0]; } else { @@ -8382,7 +8382,7 @@ void SceneSessionManager::GetCollaboratorAbilityInfos(const std::vector lock(nextFlushCompletedMutex_); nextFlushCompletedCV_.notify_all(); } - std::vector startingAppZOrderList; + std::vector> appZOrderList; processingFlushUIParams_.store(true); { std::shared_lock lock(sceneSessionMapMutex_); @@ -11023,9 +11023,11 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapGetPersistentId()); iter != uiParams.end()) { if ((systemConfig_.IsPhoneWindow() || (systemConfig_.IsPadWindow() && !systemConfig_.IsFreeMultiWindowMode())) && - sceneSession->GetStartingBeforeVisible() && sceneSession->IsAppSession()) { - startingAppZOrderList.push_back(iter->second.zOrder_); - sceneSession->SetStartingBeforeVisible(false); + sceneSession->IsAppSession()) { + if (!sceneSession->IsVisible()) { + appZOrderList.push_back(std::make_pair(0, iter->second.zOrder_)); + } + appZOrderList.push_back(std::make_pair(sceneSession->GetZOrder(), iter->second.zOrder_)); } sessionMapDirty_ |= sceneSession->UpdateUIParam(iter->second); } else { @@ -11045,7 +11047,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_map& zOrderList) +void SceneSessionManager::ProcessUpdateLastFocusedAppId(const std::vector>& zOrderList) { auto focusGroup = windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); if (focusGroup == nullptr) { @@ -11090,8 +11092,9 @@ void SceneSessionManager::ProcessUpdateLastFocusedAppId(const std::vectorGetZOrder(); - auto it = std::find_if(zOrderList.begin(), zOrderList.end(), [lastFocusedAppZOrder](uint32_t zOrder) { - return zOrder > lastFocusedAppZOrder; + auto it = std::find_if(zOrderList.begin(), zOrderList.end(), [lastFocusedAppZOrder] + (const std::pair& pair) { + return pair.first < lastFocusedAppZOrder && pair.second > lastFocusedAppZOrder; }); if (it != zOrderList.end()) { TLOGD(WmsLogTag::WMS_FOCUS, "clear with high zOrder app visible"); diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 793a743b92..1e4abcd2cd 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -971,7 +971,7 @@ HWTEST_F(SceneSessionManagerTest10, TestEraseSceneSessionAndMarkDirtyLocked_03, HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | SmallTest | Level1) { ssm_->sceneSessionMap_.clear(); - std::vector zOrderList; + std::vector> zOrderList; ssm_->windowFocusController_->UpdateFocusedAppSessionId(DEFAULT_DISPLAY_ID, INVALID_SESSION_ID); ssm_->ProcessUpdateLastFocusedAppId(zOrderList); @@ -987,7 +987,7 @@ HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | Sm ssm_->ProcessUpdateLastFocusedAppId(zOrderList); ASSERT_EQ(1, focusGroup->GetLastFocusedAppSessionId()); - zOrderList.push_back(103); + zOrderList.push_back(std::make_pair(100, 103)); ssm_->ProcessUpdateLastFocusedAppId(zOrderList); ASSERT_EQ(INVALID_SESSION_ID, focusGroup->GetLastFocusedAppSessionId()); } @@ -1374,23 +1374,23 @@ HWTEST_F(SceneSessionManagerTest10, RefreshAllAppUseControlMap, TestSize.Level1) AppUseControlInfo appUseControlInfo; appUseControlInfo.bundleName_ = "app_bundle_name"; ssm_->RefreshAllAppUseControlMap(appUseControlInfo, ControlAppType::APP_LOCK); - + appUseControlInfo.isNeedControl_ = true; ssm_->RefreshAllAppUseControlMap(appUseControlInfo, ControlAppType::APP_LOCK); EXPECT_EQ(1, SceneSession::GetAllAppUseControlMap().size()); - + appUseControlInfo.isNeedControl_ = false; ssm_->RefreshAllAppUseControlMap(appUseControlInfo, ControlAppType::APP_LOCK); EXPECT_EQ(0, SceneSession::GetAllAppUseControlMap().size()); - + appUseControlInfo.isNeedControl_ = false; appUseControlInfo.isControlRecentOnly_ = true; ssm_->RefreshAllAppUseControlMap(appUseControlInfo, ControlAppType::APP_LOCK); - + appUseControlInfo.isNeedControl_ = true; appUseControlInfo.isControlRecentOnly_ = true; ssm_->RefreshAllAppUseControlMap(appUseControlInfo, ControlAppType::PARENT_CONTROL); - + appUseControlInfo.isNeedControl_ = false; appUseControlInfo.isControlRecentOnly_ = false; ssm_->RefreshAllAppUseControlMap(appUseControlInfo, ControlAppType::APP_LOCK); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index d2b460fbd2..fc9b9028d8 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1567,6 +1567,9 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap state_); return WMError::WM_ERROR_INVALID_WINDOW; } + if (GetUIContentSharedPtr() != nullptr) { + shouldReNotifyHighlight_ = true; + } NotifySetUIContentComplete(); OHOS::Ace::UIContentErrorCode aceRet = OHOS::Ace::UIContentErrorCode::NO_ERRORS; WMError initUIContentRet = InitUIContent(contentInfo, env, storage, setUIContentType, restoreType, ability, aceRet); -- Gitee