diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 4889b94486632fbb0a8af7f3d7993e0bcd0ccfc9..effbacf693d27f12115bf11631ef2d8c54986960 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 841ef9230163d5075b786405f6e62b1aca18f43d..cfacdb997c683ed411749e58ccc9d0df3fb0dc1f 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 793a743b924499dad3f9011ed647b71a8aae36c4..1e4abcd2cd17f2a1597c4f09e65abbf12c955d6e 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 d2b460fbd2f0c3edc6daedda3e2c2a2fed97f400..fc9b9028d87b63b79f3a84f4bbf5da31fbb59924 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);