From ce15bf3badf072edeb0cf66deb75997f08daae9b Mon Sep 17 00:00:00 2001 From: brorZha Date: Wed, 8 Jul 2026 14:17:44 +0800 Subject: [PATCH] fix hltb Signed-off-by: brorZha --- utils/include/wm_common_inner.h | 1 + .../include/scene_session_manager.h | 3 ++- .../src/scene_session_manager.cpp | 12 +++++++----- wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 19 +++++++++++++++++-- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index 81715b5d63..926904cd00 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -40,6 +40,7 @@ enum class WindowStateChangeReason : uint32_t { USER_SWITCH, ABILITY_CALL, ABILITY_HOOK, + PC_APP_IN_PAD, }; enum class WindowUpdateReason : uint32_t { diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 7604623c78..e2515db4cc 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1278,7 +1278,8 @@ private: */ WMError ShiftAppWindowPointerEventInner( int32_t sourceWindowId, int32_t targetWindowId, DisplayId targetDisplayId, int32_t fingerId); - WSError StartOrMinimizePcAppInPadUIAbilityBySCB(const sptr& sceneSession, bool isBackground); + WSError StartOrMinimizePcAppInPadUIAbilityBySCB(const sptr& sceneSession, bool isBackground, + WindowStateChangeReason reason = WindowStateChangeReason::NORMAL); /* * Window Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 36e69e3ac2..3db1ea57c6 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2803,12 +2803,14 @@ void SceneSessionManager::SchedulePcAppInPadLifecycleByPersistentId(bool isBackg if (!isPcAppInPad) { return; } - StartOrMinimizePcAppInPadUIAbilityBySCB(sceneSession, isBackground); + StartOrMinimizePcAppInPadUIAbilityBySCB(sceneSession, isBackground, + WindowStateChangeReason::PC_APP_IN_PAD); }; return taskScheduler_->PostAsyncTask(task, __func__); } -WSError SceneSessionManager::StartOrMinimizePcAppInPadUIAbilityBySCB(const sptr& sceneSession, bool isBackground) +WSError SceneSessionManager::StartOrMinimizePcAppInPadUIAbilityBySCB(const sptr& sceneSession, bool isBackground, + WindowStateChangeReason reason) { auto sessionState = sceneSession->GetSessionState(); auto isInvalidMainSession = sessionState == SessionState::STATE_DISCONNECT || @@ -2837,12 +2839,12 @@ WSError SceneSessionManager::StartOrMinimizePcAppInPadUIAbilityBySCB(const sptr< } } else { TLOGI(WmsLogTag::WMS_LIFE, - "StartPcAppInPadUIAbilityBySCB with persistentId: %{public}d, type: %{public}d, state: %{public}d", persistentId, - sceneSession->GetWindowType(), sceneSession->GetSessionState()); + "StartPcAppInPadUIAbilityBySCB with persistentId: %{public}d, type: %{public}d, state: %{public}d," + "reason:%{public}u", persistentId,sceneSession->GetWindowType(), sceneSession->GetSessionState(), reason); bool isColdStart = false; abilitySessionInfo->isNewWant = false; int32_t errCode = StartUIAbilityBySCBTimeoutCheck(sceneSession, - abilitySessionInfo, static_cast(WindowStateChangeReason::NORMAL), isColdStart); + abilitySessionInfo, static_cast(reason), isColdStart); if (errCode != ERR_OK) { TLOGE(WmsLogTag::WMS_LIFE, "start failed! errCode: %{public}d", errCode); RecordLifeCycleExceptionEvent(sceneSession, errCode, diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 67ce954384..38e9e7cb22 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -790,6 +790,7 @@ private: void NotifyFreeMultiWindowModeResume(); std::string TransferLifeCycleEventToString(LifeCycleEvent type) const; WindowLifeCycleInfo GetWindowLifecycleInfo() const; + bool isNeedWindowShow(uint32_t reason); /** * Window Transition Animation For PC diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 84cd24febc..979b5dc4ea 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2153,14 +2153,29 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool w return Show(reason, withAnimation, withFocus, false, requestId, scbRequestId); } -WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool withFocus, bool waitAttach, - int32_t requestId, int32_t scbRequestId) +WMError WindowSceneSessionImpl::isNeedWindowShow(uint32_t reason) { if (reason == static_cast(WindowStateChangeReason::USER_SWITCH)) { TLOGI(WmsLogTag::WMS_MULTI_USER, "Switch to current user, NotifyAfterForeground"); NotifyAfterForeground(true, false); NotifyAfterDidForeground(reason); RecordWindowLifecycleChange("user switch show"); + return true; + } + if (reason == static_cast(WindowStateChangeReason::PC_APP_IN_PAD)) { + TLOGI(WmsLogTag::WMS_MULTI, "id: %{public}d, PcAppInPad when unlock.", GetPersistentId()); + NotifyAfterForeground(true, false); + NotifyAfterDidForeground(reason); + RecordWindowLifecycleChange("PcAppInPad when unlock"); + return true; + } + return false; +} + +WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool withFocus, bool waitAttach, + int32_t requestId, int32_t scbRequestId) +{ + if (isNeedWindowShow(reason)) { return WMError::WM_OK; } const auto type = GetType();