From 97764ee22b65b2635697110c35ea031ecae40178 Mon Sep 17 00:00:00 2001 From: ZHOUHUAYU Date: Thu, 9 Jan 2025 10:51:48 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ZHOUHUAYU --- interfaces/innerkits/wm/window.h | 10 ++++ utils/include/wm_common_inner.h | 1 + .../src/scene_session_manager.cpp | 15 ++++-- wm/include/window_session_impl.h | 2 + wm/src/window_scene_session_impl.cpp | 7 ++- wm/src/window_session_impl.cpp | 48 +++++++++++++++++ wm/test/mock/mock_window.h | 2 + .../window_scene_session_impl_test5.cpp | 54 +++++++++++++++++++ 8 files changed, 133 insertions(+), 6 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 735b6bf3fa..9ddf75da94 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -142,6 +142,16 @@ public: * @brief Notify caller that window is destroyed. */ virtual void AfterDestroyed() {} + + /** + * @brief Notify caller that window is paused. + */ + virtual void AfterDidForeground() {} + + /** + * @brief Notify caller that window is destroyed. + */ + virtual void AfterDidBackground() {} }; /** diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index ba1f8b3ee0..b55acf37a4 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -37,6 +37,7 @@ enum class WindowStateChangeReason : uint32_t { KEYGUARD, TOGGLING, USER_SWITCH, + ABILITY_CALL, }; enum class WindowUpdateReason : uint32_t { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1045875755..c26034a258 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2379,7 +2379,8 @@ int32_t SceneSessionManager::StartUIAbilityBySCB(sptr& sceneSessio int32_t SceneSessionManager::StartUIAbilityBySCB(sptr& abilitySessionInfo) { bool isColdStart = false; - return AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(abilitySessionInfo, isColdStart); + return AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(abilitySessionInfo, isColdStart, + static_cast(WindowStateChangeReason::ABILITY_CALL)); } int32_t SceneSessionManager::ChangeUIAbilityVisibilityBySCB(const sptr& sceneSession, @@ -2442,7 +2443,8 @@ WSError SceneSessionManager::RequestSceneSessionActivationInner( if (!systemConfig_.backgroundswitch || sceneSession->GetSessionProperty()->GetIsAppSupportPhoneInPc()) { TLOGI(WmsLogTag::WMS_MAIN, "Begin StartUIAbility: %{public}d system: %{public}u", persistentId, static_cast(sceneSession->GetSessionInfo().isSystem_)); - errCode = AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(sceneSessionInfo, isColdStart); + errCode = AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(sceneSessionInfo, isColdStart, + static_cast(WindowStateChangeReason::ABILITY_CALL)); } else { TLOGI(WmsLogTag::WMS_MAIN, "Background switch on, isNewActive %{public}d state %{public}u", isNewActive, sceneSession->GetSessionState()); @@ -2450,7 +2452,8 @@ WSError SceneSessionManager::RequestSceneSessionActivationInner( sceneSession->GetSessionState() == SessionState::STATE_END) { TLOGI(WmsLogTag::WMS_MAIN, "Call StartUIAbility: %{public}d system: %{public}u", persistentId, static_cast(sceneSession->GetSessionInfo().isSystem_)); - errCode = AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(sceneSessionInfo, isColdStart); + errCode = AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(sceneSessionInfo, isColdStart, + static_cast(WindowStateChangeReason::ABILITY_CALL)); } else { TLOGI(WmsLogTag::WMS_MAIN, "NotifySessionForeground: %{public}d", persistentId); sceneSession->NotifySessionForeground(1, true); @@ -2590,9 +2593,11 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptr(sceneSession->GetSessionInfo().isSystem_)); auto sceneSessionInfo = SetAbilitySessionInfo(sceneSession); if (!isDelegator) { - AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB(sceneSessionInfo); + AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB(sceneSessionInfo, false, + static_cast(WindowStateChangeReason::ABILITY_CALL)); } else { - AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB(sceneSessionInfo, true); + AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB(sceneSessionInfo, true, + static_cast(WindowStateChangeReason::ABILITY_CALL)); } } diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index f68aba7c09..db4560b95e 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -221,6 +221,8 @@ public: int32_t GetFloatingWindowParentId(); void NotifyAfterForeground(bool needNotifyListeners = true, bool needNotifyUiContent = true); void NotifyAfterBackground(bool needNotifyListeners = true, bool needNotifyUiContent = true); + void NotifyAfterDidForeground(uint32_t reason = 0); + void NotifyAfterDidBackground(uint32_t reason = 0); void NotifyForegroundFailed(WMError ret); void NotifyBackgroundFailed(WMError ret); WSError MarkProcessed(int32_t eventId) override; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 89c23cc2bb..2af4070c65 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1125,6 +1125,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool w if (reason == static_cast(WindowStateChangeReason::USER_SWITCH)) { TLOGI(WmsLogTag::WMS_MULTI_USER, "Switch to current user, NotifyAfterForeground"); NotifyAfterForeground(true, false); + NotifyAfterDidForeground(reason); return WMError::WM_OK; } const auto type = GetType(); @@ -1144,12 +1145,13 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool w property_->SetDecorEnable(isDecorEnable); if (state_ == WindowState::STATE_SHOWN) { - TLOGD(WmsLogTag::WMS_LIFE, "window is already shown [name:%{public}s, id:%{public}d, type: %{public}u]", + TLOGI(WmsLogTag::WMS_LIFE, "window is already shown [name:%{public}s, id:%{public}d, type: %{public}u]", property_->GetWindowName().c_str(), property_->GetPersistentId(), type); if (WindowHelper::IsMainWindow(type)) { hostSession->RaiseAppMainWindowToTop(); } NotifyAfterForeground(true, false); + NotifyAfterDidForeground(reason); RefreshNoInteractionTimeoutMonitor(); return WMError::WM_OK; } @@ -1203,6 +1205,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool w state_ = WindowState::STATE_SHOWN; requestState_ = WindowState::STATE_SHOWN; NotifyAfterForeground(true, true); + NotifyAfterDidForeground(reason); RefreshNoInteractionTimeoutMonitor(); TLOGI(WmsLogTag::WMS_LIFE, "Window show success [name:%{public}s, id:%{public}d, type:%{public}u]", property_->GetWindowName().c_str(), GetPersistentId(), type); @@ -1233,6 +1236,7 @@ WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool i if (reason == static_cast(WindowStateChangeReason::USER_SWITCH)) { TLOGI(WmsLogTag::WMS_MULTI_USER, "Switch to another user, NotifyAfterBackground"); NotifyAfterBackground(true, false); + NotifyAfterDidBackground(reason); return WMError::WM_OK; } @@ -1283,6 +1287,7 @@ WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool i if (res == WMError::WM_OK) { // update sub window state if this is main window UpdateSubWindowState(type); + NotifyAfterDidBackground(reason); state_ = WindowState::STATE_HIDDEN; requestState_ = WindowState::STATE_HIDDEN; if (!interactive_) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 41fccbe5bd..8986beb1c7 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3235,6 +3235,30 @@ void WindowSessionImpl::NotifyAfterForeground(bool needNotifyListeners, bool nee } } +void WindowSessionImpl::NotifyAfterDidForeground(uint32_t reason) +{ + TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d", reason); + if (reason == static_cast(WindowStateChangeReason::USER_SWITCH) || + reason == static_cast(WindowStateChangeReason::ABILITY_CALL)) { + if (handler_ == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "handler is nullptr"); + return; + } + const char* const where = __func__; + handler_->PostTask([weak = wptr(this), where] { + auto window = weak.promote(); + if (window == nullptr) { + TLOGNI(WmsLogTag::WMS_LIFE, "{public}s window is nullptr", where); + return; + } + TLOGNI(WmsLogTag::WMS_LIFE, "{public}s execute", where); + auto lifecycleListeners = window->GetListeners(); + CALL_LIFECYCLE_LISTENER(AfterDidForeground, lifecycleListeners); + }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); + } + return; +} + void WindowSessionImpl::NotifyAfterBackground(bool needNotifyListeners, bool needNotifyUiContent) { if (needNotifyListeners) { @@ -3259,6 +3283,30 @@ void WindowSessionImpl::NotifyAfterBackground(bool needNotifyListeners, bool nee } } +void WindowSessionImpl::NotifyAfterDidBackground(uint32_t reason) +{ + TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d", reason); + if (reason == static_cast(WindowStateChangeReason::USER_SWITCH) || + reason == static_cast(WindowStateChangeReason::ABILITY_CALL)) { + if (handler_ == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "handler is nullptr"); + return; + } + const char* const where = __func__; + handler_->PostTask([weak = wptr(this), where] { + auto window = weak.promote(); + if (window == nullptr) { + TLOGNI(WmsLogTag::WMS_LIFE, "{public}s window is nullptr", where); + return; + } + TLOGNI(WmsLogTag::WMS_LIFE, "{public}s execute", where); + auto lifecycleListeners = window->GetListeners(); + CALL_LIFECYCLE_LISTENER(AfterDidBackground, lifecycleListeners); + }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); + } + return; +} + static void RequestInputMethodCloseKeyboard(bool isNeedKeyboard, bool keepKeyboardFlag) { if (!isNeedKeyboard && !keepKeyboardFlag) { diff --git a/wm/test/mock/mock_window.h b/wm/test/mock/mock_window.h index e9848a324c..ef4a1de96e 100644 --- a/wm/test/mock/mock_window.h +++ b/wm/test/mock/mock_window.h @@ -41,6 +41,8 @@ public: MOCK_METHOD0(AfterResumed, void(void)); MOCK_METHOD0(AfterPaused, void(void)); MOCK_METHOD0(AfterDestroyed, void(void)); + MOCK_METHOD0(AfterDidForeground, void(void)); + MOCK_METHOD0(AfterDidBackground, void(void)); }; class MockAvoidAreaChangedListener : public IAvoidAreaChangedListener { diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index 9fd52e0a82..c37ff7c4cf 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -20,9 +20,11 @@ #include "display_info.h" #include "mock_session.h" #include "mock_uicontent.h" +#include "mock_window.h" #include "mock_window_adapter.h" #include "pointer_event.h" #include "singleton_mocker.h" +#include "wm_common_inner.h" #include "window_scene_session_impl.h" #include "window_session_impl.h" using namespace testing; @@ -696,6 +698,58 @@ HWTEST_F(WindowSceneSessionImplTest5, UpdateSystemBarProperties, Function | Smal std::unordered_map systemBarPropertyFlags; ASSERT_EQ(WMError::WM_OK, window->UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags)); } + +/** + * @tc.name: NotifyAfterDidForeground + * @tc.desc: NotifyAfterDidForeground + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, NotifyAfterDidForeground, Function | SmallTest | Level2) +{ + sptr mockListener = sptr::MakeSptr(); + sptr listener = static_cast>(mockListener); + + sptr option = sptr::MakeSptr(); + option->SetWindowName("Test"); + option->SetDisplayId(0); + + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(1); + window->hostSession_ = session; + window->RegisterLifeCycleListener(listener); + + EXPECT_CALL(*mockListener, AfterDidForeground()).Times(1); + ASSERT_EQ(WMError::WM_OK, window->Show(static_cast(WindowStateChangeReason::ABILITY_CALL), false)); +} + +/** + * @tc.name: NotifyAfterDidBackground + * @tc.desc: NotifyAfterDidBackground + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, NotifyAfterDidBackground, Function | SmallTest | Level2) +{ + sptr mockListener = sptr::MakeSptr(); + sptr listener = static_cast>(mockListener); + + sptr option = sptr::MakeSptr(); + option->SetWindowName("Test"); + option->SetDisplayId(0); + + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(1); + window->hostSession_ = session; + window->RegisterLifeCycleListener(listener); + + EXPECT_CALL(*mockListener, AfterDidBackground()).Times(1); + ASSERT_EQ(WMError::WM_OK, window->Hide(static_cast(WindowStateChangeReason::ABILITY_CALL), false, false)); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 2f29483406714b9b1e097aa5376f4a8d96a5ae96 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Thu, 9 Jan 2025 15:42:05 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- wm/src/window_session_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 8986beb1c7..d9b689ef3e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3248,10 +3248,10 @@ void WindowSessionImpl::NotifyAfterDidForeground(uint32_t reason) handler_->PostTask([weak = wptr(this), where] { auto window = weak.promote(); if (window == nullptr) { - TLOGNI(WmsLogTag::WMS_LIFE, "{public}s window is nullptr", where); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); return; } - TLOGNI(WmsLogTag::WMS_LIFE, "{public}s execute", where); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); auto lifecycleListeners = window->GetListeners(); CALL_LIFECYCLE_LISTENER(AfterDidForeground, lifecycleListeners); }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); @@ -3296,10 +3296,10 @@ void WindowSessionImpl::NotifyAfterDidBackground(uint32_t reason) handler_->PostTask([weak = wptr(this), where] { auto window = weak.promote(); if (window == nullptr) { - TLOGNI(WmsLogTag::WMS_LIFE, "{public}s window is nullptr", where); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); return; } - TLOGNI(WmsLogTag::WMS_LIFE, "{public}s execute", where); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); auto lifecycleListeners = window->GetListeners(); CALL_LIFECYCLE_LISTENER(AfterDidBackground, lifecycleListeners); }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); -- Gitee From 9c299b3f7563fc72017a97e853a5c5fe2f1fb646 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Thu, 9 Jan 2025 15:45:14 +0800 Subject: [PATCH 03/22] =?UTF-8?q?lambda=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E7=BC=A9=E8=BF=9B=E5=AF=B9=E9=BD=90=E6=96=B9=E5=BC=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- wm/src/window_session_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index d9b689ef3e..d7b4648c5b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3254,7 +3254,7 @@ void WindowSessionImpl::NotifyAfterDidForeground(uint32_t reason) TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); auto lifecycleListeners = window->GetListeners(); CALL_LIFECYCLE_LISTENER(AfterDidForeground, lifecycleListeners); - }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); + }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } return; } @@ -3302,7 +3302,7 @@ void WindowSessionImpl::NotifyAfterDidBackground(uint32_t reason) TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); auto lifecycleListeners = window->GetListeners(); CALL_LIFECYCLE_LISTENER(AfterDidBackground, lifecycleListeners); - }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); + }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } return; } -- Gitee From 43c2c0b88c96b271d504ce802a0d19cc7ef85a15 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Mon, 13 Jan 2025 21:00:23 +0800 Subject: [PATCH 04/22] =?UTF-8?q?closeuiability=E6=96=B0=E5=A2=9Ereason?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- window_scene/session_manager/src/scene_session_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c26034a258..d7e2e208a8 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2871,9 +2871,11 @@ WSError SceneSessionManager::RequestSceneSessionDestructionInner(sptrGetSessionInfo().isSystem_); if (isForceClean) { - AAFwk::AbilityManagerClient::GetInstance()->CleanUIAbilityBySCB(sceneSessionInfo, isUserRequestedExit); + AAFwk::AbilityManagerClient::GetInstance()->CleanUIAbilityBySCB(sceneSessionInfo, isUserRequestedExit, + static_cast(WindowStateChangeReason::ABILITY_CALL)); } else { - AAFwk::AbilityManagerClient::GetInstance()->CloseUIAbilityBySCB(sceneSessionInfo, isUserRequestedExit); + AAFwk::AbilityManagerClient::GetInstance()->CloseUIAbilityBySCB(sceneSessionInfo, isUserRequestedExit, + static_cast(WindowStateChangeReason::ABILITY_CALL)); } sceneSession->SetSessionInfoAncoSceneState(AncoSceneState::DEFAULT_STATE); if (needRemoveSession) { -- Gitee From 446f531e43c4fd969f1a9bcb2eb6d895ff300fb4 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 14 Jan 2025 11:11:40 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=E6=94=B9=E4=B8=BA=E6=9E=9A=E4=B8=BE=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- wm/include/window_session_impl.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index db4560b95e..eed77911c5 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -39,6 +39,7 @@ #include "window_helper.h" #include "window_option.h" #include "wm_common.h" +#include "wm_common_inner.h" namespace OHOS { namespace Rosen { @@ -221,8 +222,8 @@ public: int32_t GetFloatingWindowParentId(); void NotifyAfterForeground(bool needNotifyListeners = true, bool needNotifyUiContent = true); void NotifyAfterBackground(bool needNotifyListeners = true, bool needNotifyUiContent = true); - void NotifyAfterDidForeground(uint32_t reason = 0); - void NotifyAfterDidBackground(uint32_t reason = 0); + void NotifyAfterDidForeground(uint32_t reason = static_cast(WindowStateChangeReason::NORMAL)); + void NotifyAfterDidBackground(uint32_t reason = static_cast(WindowStateChangeReason::NORMAL)); void NotifyForegroundFailed(WMError ret); void NotifyBackgroundFailed(WMError ret); WSError MarkProcessed(int32_t eventId) override; -- Gitee From 87a45439f18eb45b636b6be6e2b0dc09a8039ed8 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 14 Jan 2025 15:36:15 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- interfaces/innerkits/wm/window.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 9ddf75da94..777ac8260b 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -144,12 +144,12 @@ public: virtual void AfterDestroyed() {} /** - * @brief Notify caller that window is paused. + * @brief Notify caller that window is already foreground. */ virtual void AfterDidForeground() {} /** - * @brief Notify caller that window is destroyed. + * @brief Notify caller that window is already background. */ virtual void AfterDidBackground() {} }; -- Gitee From a4efddc514f3d8911dd355f203299f710332b781 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Mon, 24 Feb 2025 20:23:43 +0800 Subject: [PATCH 07/22] =?UTF-8?q?resume=E5=92=8Cpause=E4=B8=B2=E8=A1=8C?= =?UTF-8?q?=E4=BF=9D=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- interfaces/innerkits/wm/window_scene.h | 7 +++++ .../include/zidl/session_stage_interface.h | 1 + .../zidl/session_stage_ipc_interface_code.h | 1 + .../include/zidl/session_stage_proxy.h | 1 + .../include/zidl/session_stage_stub.h | 1 + .../src/zidl/session_stage_proxy.cpp | 31 +++++++++++++++++++ .../container/src/zidl/session_stage_stub.cpp | 11 +++++++ .../session/host/include/scene_session.h | 2 ++ .../session/host/src/scene_session.cpp | 8 +++++ .../src/scene_session_manager.cpp | 14 +++++++++ wm/include/window_scene_session_impl.h | 7 +++++ wm/include/window_session_impl.h | 3 +- wm/src/window_scene.cpp | 12 +++++++ wm/src/window_scene_session_impl.cpp | 20 ++++++++++++ wm/src/window_session_impl.cpp | 6 +++- 15 files changed, 123 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/wm/window_scene.h b/interfaces/innerkits/wm/window_scene.h index 2933899c71..65c4893e8a 100644 --- a/interfaces/innerkits/wm/window_scene.h +++ b/interfaces/innerkits/wm/window_scene.h @@ -115,6 +115,13 @@ public: */ WMError GoDestroy(); + /** + * Window go resume. + * + * @return the error code of window + */ + WMError GoDestroy(); + /** * Window handle new want. * diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index b5308fdd7b..7c9c034417 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -243,6 +243,7 @@ public: virtual WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) = 0; virtual void NotifyWindowCrossAxisChange(CrossAxisState state) = 0; virtual WSError NotifyWindowAttachStateChange(bool isAttach) { return WSError::WS_DO_NOTHING; } + virtual uint32_t GetTargetAPIVersion() { return 0; } }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 3f1e7f6aca..94f6c1922c 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -60,6 +60,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_DENSITY_UNIQUE, TRANS_ID_NOTIFY_SESSION_FULLSCREEN, TRANS_ID_NOTIFY_SINGLE_HAND_TRANSFORM, + TRANS_ID_GET_TARGET_API_VERSION, // Extension TRANS_ID_SEND_EXTENSION_DATA, diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 5f20185a5a..55d55f5377 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -76,6 +76,7 @@ public: WSError NotifyCompatibleModeEnableInPad(bool enable) override; void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) override; void NotifySessionFullScreen(bool fullScreen) override; + uint32_t GetTargetAPIVersion() override; // UIExtension WSError NotifyDumpInfo(const std::vector& params, std::vector& info) override; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index c6e53da460..a7d5c60d97 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -86,6 +86,7 @@ private: int HandleNotifyWindowCrossAxisChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyPipSizeChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyWindowAttachStateChange(MessageParcel& data, MessageParcel& reply); + int HandleGetTargetAPIVersion(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index cd6780fbd1..c335ae4ca7 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -30,6 +30,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStageProxy"}; constexpr int32_t MAX_INFO_SIZE = 50; constexpr size_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M +constexpr uint32_t DEFAULT_VERSION = 0; bool CopyBufferFromRawData(void*& buffer, size_t size, const void* data) { @@ -1665,4 +1666,34 @@ WSError SessionStageProxy::NotifyWindowAttachStateChange(bool isAttach) } return WSError::WS_OK; } + +uint32_t SessionStageProxy::GetTargetAPIVersion() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed"); + return DEFAULT_VERSION; + } + + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "remote is null"); + return DEFAULT_VERSION; + } + if (remote->SendRequest(static_cast( + SessionStageInterfaceCode::TRANS_ID_GET_TARGET_API_VERSION), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed"); + return DEFAULT_VERSION; + } + + uint32_t version; + if (!reply.ReadUint32(version)) { + TLOGE(WmsLogTag::WMS_LIFE, "read version failed"); + return DEFAULT_VERSION; + } + return version; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index 881fd73409..ca437eb988 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -200,6 +200,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleNotifyPipSizeChange(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE): return HandleNotifyWindowAttachStateChange(data, reply); + case static_cast(SessionStageInterfaceCode::TRANS_ID_GET_TARGET_API_VERSION): + return HandleGetTargetAPIVersion(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -840,4 +842,13 @@ int SessionStageStub::HandleNotifyWindowAttachStateChange(MessageParcel& data, M return ERR_NONE; } +int SessionStageStub::HandleGetTargetAPIVersion(MessageParcel& data, MessageParcel& reply) +{ + uint32_t version = GetTargetAPIVersion(); + if (!reply.WriteUint32(version)) { + TLOGE(WmsLogTag::WMS_LIFE, "write version fail"); + return ERR_TRANSACTION_FAILED; + } + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index e7b5d262b0..40157d719f 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -517,6 +517,8 @@ public: static uint32_t GetWindowDragHotAreaType(DisplayId displayId, uint32_t type, int32_t pointerX, int32_t pointerY); static void AddOrUpdateWindowDragHotArea(DisplayId displayId, uint32_t type, const WSRect& area); WSError UpdateRectChangeListenerRegistered(bool isRegister) override; + uint32_t GetTargetAPIVersion(); + bool UpdateInteractiveInner(bool interactive); /* * Window Decor diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 419cc1a37c..85b3a7e8ba 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -74,6 +74,7 @@ constexpr WSRectF VELOCITY_RELOCATION_TO_BOTTOM = {0.0f, 10.0f, 0.0f, 0.0f}; constexpr int32_t API_VERSION_16 = 16; constexpr int32_t HOOK_SYSTEM_BAR_HEIGHT = 40; constexpr int32_t HOOK_AI_BAR_HEIGHT = 28; +constexpr uint32_t DEFAULT_VERSION = 0; bool CheckIfRectElementIsTooLarge(const WSRect& rect) { @@ -6850,5 +6851,12 @@ void SceneSession::SetSidebarMaskColorModifier(bool needBlur) } else { maskColorValue_->Set(Rosen::RSColor::FromArgbInt(snapshotMaskColor_)); } +uint32_t SceneSession::GetTargetAPIVersion() +{ + if (!sessionStage_) { + TLOGE(WmsLogTag::WMS_LIFE, "sessionStage_ is nullptr, id: %{public}d", GetPersistentId()); + return DEFAULT_API_VERSION; + } + return sessionStage_->GetTargetAPIVersion(); } } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index d7e2e208a8..72a5def597 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -134,6 +134,7 @@ constexpr int32_t MAX_LOCK_STATUS_CACHE_SIZE = 1000; constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PC = 24; constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PAD = 8; constexpr std::size_t MAX_SNAPSHOT_IN_RECENT_PHONE = 3; +constexpr uint32_t LIFECYCLE_ISOLATE_VERSION = 16; const std::map STRING_TO_DISPLAY_ORIENTATION_MAP = { {"unspecified", OHOS::AppExecFwk::DisplayOrientation::UNSPECIFIED}, @@ -2565,6 +2566,11 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION) { + TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); + sceneSession->UpdateInteractiveInner(false); + } sceneSession->SetActive(false); if (isToDesktop) { @@ -2816,6 +2822,10 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrSetRemoveSnapshotCallback([this, persistentId]() { this->RemoveSnapshotFromCache(persistentId); }); + if (sceneSession->GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION) { + TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); + sceneSession->UpdateInteractiveInner(false); + } sceneSession->DisconnectTask(false, isSaveSnapshot); if (!GetSceneSession(persistentId)) { TLOGNE(WmsLogTag::WMS_MAIN, "Destruct session invalid by %{public}d", persistentId); @@ -4062,6 +4072,10 @@ WSError SceneSessionManager::StartOrMinimizeUIAbilityBySCB(const sptrGetWindowType(), sceneSession->GetSessionState()); bool isFromUser = false; + if (sceneSession->GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION) { + TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); + sceneSession->UpdateInteractiveInner(false); + } int32_t errCode = AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB( abilitySessionInfo, isFromUser, static_cast(WindowStateChangeReason::USER_SWITCH)); if (errCode == ERR_OK) { diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 4cce9ecc1e..abd8d65716 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -39,6 +39,7 @@ public: void StartMove() override; bool IsStartMoving() override; WindowMode GetWindowMode() const override; + void Resume() override; /* * Window Layout @@ -412,6 +413,12 @@ private: static std::mutex windowAttachStateChangeListenerMutex_; sptr windowAttachStateChangeListener_; WSError NotifyWindowAttachStateChange(bool isAttach) override; + + /* + * Window Lifecycle + */ + bool isColdStart_ = true; + void NotifyPcModeResume(); }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index eed77911c5..b63fe9125f 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -125,7 +125,7 @@ public: WMError SetSubWindowModal(bool isModal, ModalityType modalityType = ModalityType::WINDOW_MODALITY) override; WMError SetWindowModal(bool isModal) override; void SetTargetAPIVersion(uint32_t targetAPIVersion); - uint32_t GetTargetAPIVersion() const; + uint32_t GetTargetAPIVersion() override; WMError SetWindowType(WindowType type) override; WMError SetBrightness(float brightness) override; @@ -513,6 +513,7 @@ protected: */ bool hasFirstNotifyInteractive_ = false; bool interactive_ = true; + bool isDidForeground_ = false; /* * Window Layout diff --git a/wm/src/window_scene.cpp b/wm/src/window_scene.cpp index ada362d55a..514f3d8cff 100644 --- a/wm/src/window_scene.cpp +++ b/wm/src/window_scene.cpp @@ -159,6 +159,18 @@ WMError WindowScene::GoForeground(uint32_t reason) return mainWindow->Show(reason); } +WMError WindowScene::GoResume() +{ + TLOGI(WmsLogTag::WMS_MAIN, "in"); + auto mainWindow = GetMainWindow(); + if (mainWindow == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "failed, because main window is null"); + return WMError::WM_ERROR_NULLPTR; + } + mainWindow->Resume(); + return WMError::WM_OK; +} + WMError WindowScene::GoBackground(uint32_t reason) { TLOGI(WmsLogTag::WMS_MAIN, "reason: %{public}u", reason); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 2af4070c65..c5bb9c941d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1206,6 +1206,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool w requestState_ = WindowState::STATE_SHOWN; NotifyAfterForeground(true, true); NotifyAfterDidForeground(reason); + NotifyPcModeResume(); RefreshNoInteractionTimeoutMonitor(); TLOGI(WmsLogTag::WMS_LIFE, "Window show success [name:%{public}s, id:%{public}d, type:%{public}u]", property_->GetWindowName().c_str(), GetPersistentId(), type); @@ -1231,6 +1232,25 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardViewMode mode) return Show(); } +void WindowSceneSessionImpl::NotifyPcModeResume() +{ + if (GetTargetAPIVersion() >= API_VERSION_16 && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { + isDidForeground_ = true; + NotifyForegroundInteractiveStatus(true); + } + return; +} + +void WindowSceneSessionImpl::Resume() +{ + if (GetTargetAPIVersion() >= API_VERSION_16) { + isDidForeground_ = true; + isColdStart_ = false; + NotifyForegroundInteractiveStatus(true); + } + return; +} + WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) { if (reason == static_cast(WindowStateChangeReason::USER_SWITCH)) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index d7b4648c5b..935c53d963 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -61,6 +61,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionImpl"}; constexpr int32_t FORCE_SPLIT_MODE = 5; constexpr int32_t API_VERSION_15 = 15; +constexpr uint32_t LIFECYCLE_ISOLATE_VERSION = 16; /* * DFX @@ -1175,6 +1176,9 @@ void WindowSessionImpl::NotifyForegroundInteractiveStatus(bool interactive) } if (state_ == WindowState::STATE_SHOWN) { if (interactive) { + if (GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION && !isDidForeground_) { + return; + } NotifyAfterResumed(); } else { NotifyAfterPaused(); @@ -5138,7 +5142,7 @@ void WindowSessionImpl::SetTargetAPIVersion(uint32_t targetAPIVersion) targetAPIVersion_ = targetAPIVersion; } -uint32_t WindowSessionImpl::GetTargetAPIVersion() const +uint32_t WindowSessionImpl::GetTargetAPIVersion() { return targetAPIVersion_; } -- Gitee From f0ff2c8d302879e3c0a910a61aee74af8b6a605d Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 25 Feb 2025 09:35:09 +0800 Subject: [PATCH 08/22] bugfix Signed-off-by: hust_5u --- interfaces/innerkits/wm/window_scene.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window_scene.h b/interfaces/innerkits/wm/window_scene.h index 65c4893e8a..837827b964 100644 --- a/interfaces/innerkits/wm/window_scene.h +++ b/interfaces/innerkits/wm/window_scene.h @@ -120,7 +120,7 @@ public: * * @return the error code of window */ - WMError GoDestroy(); + WMError GoResume(); /** * Window handle new want. -- Gitee From f6f4f1767b9cfc041d051a4c3959fd1e3f4fc165 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 25 Feb 2025 10:58:31 +0800 Subject: [PATCH 09/22] bugfix Signed-off-by: hust_5u --- window_scene/session/host/include/scene_session.h | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 40157d719f..76b4c7e6d7 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -518,7 +518,6 @@ public: static void AddOrUpdateWindowDragHotArea(DisplayId displayId, uint32_t type, const WSRect& area); WSError UpdateRectChangeListenerRegistered(bool isRegister) override; uint32_t GetTargetAPIVersion(); - bool UpdateInteractiveInner(bool interactive); /* * Window Decor -- Gitee From 024d390a18adc1fa35a8ac54a762382c3bf21540 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 25 Feb 2025 16:18:18 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=AE=E5=93=A5?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- interfaces/innerkits/wm/window.h | 7 +++++++ wm/src/window_scene_session_impl.cpp | 5 +++-- wm/src/window_session_impl.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 777ac8260b..981c3c5cb9 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1061,6 +1061,13 @@ public: virtual WMError Show(uint32_t reason = 0, bool withAnimation = false, bool withFocus = true) { return WMError::WM_OK; } + /** + * @brief resume window + * + * @return WMError + */ + virtual WMError Resume() { return WMError::WM_OK; } + /** * @brief Hide window * diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index c5bb9c941d..14cda79b50 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1234,11 +1234,12 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardViewMode mode) void WindowSceneSessionImpl::NotifyPcModeResume() { + TLOGI(WmsLogTag::WMS_LIFE, "api version %{public}d, IsPcMode {public}d, isColdStart %{public}d", + GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode, isColdStart_); if (GetTargetAPIVersion() >= API_VERSION_16 && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { isDidForeground_ = true; NotifyForegroundInteractiveStatus(true); } - return; } void WindowSceneSessionImpl::Resume() @@ -1246,9 +1247,9 @@ void WindowSceneSessionImpl::Resume() if (GetTargetAPIVersion() >= API_VERSION_16) { isDidForeground_ = true; isColdStart_ = false; + TLOGI(WmsLogTag::WMS_LIFE, "in"); NotifyForegroundInteractiveStatus(true); } - return; } WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 935c53d963..2aa47c7398 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3252,7 +3252,7 @@ void WindowSessionImpl::NotifyAfterDidForeground(uint32_t reason) handler_->PostTask([weak = wptr(this), where] { auto window = weak.promote(); if (window == nullptr) { - TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); return; } TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); -- Gitee From 719a69957248f6da71acbcfdc64580d989440928 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 25 Feb 2025 17:24:57 +0800 Subject: [PATCH 11/22] bugfix Signed-off-by: hust_5u --- interfaces/innerkits/wm/window.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 981c3c5cb9..f65dfb5aad 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1066,7 +1066,7 @@ public: * * @return WMError */ - virtual WMError Resume() { return WMError::WM_OK; } + virtual void Resume() {} /** * @brief Hide window -- Gitee From fafa0f62cd8e7876ac89ad7c28f9b2eb0fa23b74 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 25 Feb 2025 21:15:21 +0800 Subject: [PATCH 12/22] bugfix Signed-off-by: hust_5u --- window_scene/session/host/src/scene_session.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 85b3a7e8ba..816da5143d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -6851,6 +6851,8 @@ void SceneSession::SetSidebarMaskColorModifier(bool needBlur) } else { maskColorValue_->Set(Rosen::RSColor::FromArgbInt(snapshotMaskColor_)); } +} + uint32_t SceneSession::GetTargetAPIVersion() { if (!sessionStage_) { -- Gitee From c0d6afe9800bac04a9cee31394318e7d3e11c572 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 25 Feb 2025 21:44:17 +0800 Subject: [PATCH 13/22] bugfix Signed-off-by: hust_5u --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 14cda79b50..709e0541b3 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1235,7 +1235,7 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardViewMode mode) void WindowSceneSessionImpl::NotifyPcModeResume() { TLOGI(WmsLogTag::WMS_LIFE, "api version %{public}d, IsPcMode {public}d, isColdStart %{public}d", - GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode, isColdStart_); + GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode(), isColdStart_); if (GetTargetAPIVersion() >= API_VERSION_16 && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { isDidForeground_ = true; NotifyForegroundInteractiveStatus(true); -- Gitee From 44e3f413ecac7e4c16ed6d6503b26723405c4e15 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Tue, 25 Feb 2025 22:18:33 +0800 Subject: [PATCH 14/22] bugfix Signed-off-by: hust_5u --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 709e0541b3..40de02beca 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1234,7 +1234,7 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardViewMode mode) void WindowSceneSessionImpl::NotifyPcModeResume() { - TLOGI(WmsLogTag::WMS_LIFE, "api version %{public}d, IsPcMode {public}d, isColdStart %{public}d", + TLOGI(WmsLogTag::WMS_LIFE, "api version %{public}u, IsPcMode {public}d, isColdStart %{public}d", GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode(), isColdStart_); if (GetTargetAPIVersion() >= API_VERSION_16 && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { isDidForeground_ = true; -- Gitee From 7c0329661b3aa6a7af19126a1ae2ed6bfec5d0a0 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Wed, 26 Feb 2025 17:04:15 +0800 Subject: [PATCH 15/22] =?UTF-8?q?=E8=8E=B7=E5=8F=96api=20version=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- .../common/include/window_session_property.h | 3 ++ .../common/src/window_session_property.cpp | 11 +++++++ .../include/zidl/session_stage_interface.h | 1 - .../zidl/session_stage_ipc_interface_code.h | 1 - .../include/zidl/session_stage_proxy.h | 1 - .../include/zidl/session_stage_stub.h | 1 - .../src/zidl/session_stage_proxy.cpp | 31 ------------------- .../container/src/zidl/session_stage_stub.cpp | 12 ------- .../session/host/include/scene_session.h | 1 - .../session/host/src/scene_session.cpp | 10 ------ .../src/scene_session_manager.cpp | 6 ++-- wm/include/window_scene_session_impl.h | 2 +- wm/include/window_session_impl.h | 2 +- wm/src/window_scene_session_impl.cpp | 4 +-- wm/src/window_session_impl.cpp | 2 +- .../window_scene_session_impl_test5.cpp | 27 ++++++++++++++++ 16 files changed, 49 insertions(+), 66 deletions(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index cf75e50a69..cb2efafdeb 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -206,6 +206,8 @@ public: void Read(Parcel& parcel, WSPropertyChangeAction action); void SetFullScreenStart(bool fullScreenStart); bool GetFullScreenStart() const; + void SetApiVersion(uint32_t version); + uint32_t GetApiVersion() const; /* * Sub Window @@ -416,6 +418,7 @@ private: uint8_t backgroundAlpha_ = 0xff; // default alpha is opaque. mutable std::mutex atomicServiceMutex_; bool isAtomicService_ = false; + uint32_t apiVersion_ = 0; /* * Sub Window diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 65606b688c..27199830db 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -1388,6 +1388,7 @@ void WindowSessionProperty::CopyFrom(const sptr& property isExclusivelyHighlighted_ = property->isExclusivelyHighlighted_; cornerRadius_ = property->cornerRadius_; isAtomicService_ = property->isAtomicService_; + apiVersion_ = property->apiVersion_; } bool WindowSessionProperty::Write(Parcel& parcel, WSPropertyChangeAction action) @@ -1933,5 +1934,15 @@ bool WindowSessionProperty::IsConstrainedModal() const { return isConstrainedModal_; } + +void WindowSessionProperty::SetApiVersion(uint32_t version) +{ + apiVersion_ = version; +} + +uint32_t WindowSessionProperty::GetApiVersion() const +{ + return apiVersion_; +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 7c9c034417..b5308fdd7b 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -243,7 +243,6 @@ public: virtual WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) = 0; virtual void NotifyWindowCrossAxisChange(CrossAxisState state) = 0; virtual WSError NotifyWindowAttachStateChange(bool isAttach) { return WSError::WS_DO_NOTHING; } - virtual uint32_t GetTargetAPIVersion() { return 0; } }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 94f6c1922c..3f1e7f6aca 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -60,7 +60,6 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_DENSITY_UNIQUE, TRANS_ID_NOTIFY_SESSION_FULLSCREEN, TRANS_ID_NOTIFY_SINGLE_HAND_TRANSFORM, - TRANS_ID_GET_TARGET_API_VERSION, // Extension TRANS_ID_SEND_EXTENSION_DATA, diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 55d55f5377..5f20185a5a 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -76,7 +76,6 @@ public: WSError NotifyCompatibleModeEnableInPad(bool enable) override; void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) override; void NotifySessionFullScreen(bool fullScreen) override; - uint32_t GetTargetAPIVersion() override; // UIExtension WSError NotifyDumpInfo(const std::vector& params, std::vector& info) override; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index a7d5c60d97..c6e53da460 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -86,7 +86,6 @@ private: int HandleNotifyWindowCrossAxisChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyPipSizeChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyWindowAttachStateChange(MessageParcel& data, MessageParcel& reply); - int HandleGetTargetAPIVersion(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index c335ae4ca7..cd6780fbd1 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -30,7 +30,6 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStageProxy"}; constexpr int32_t MAX_INFO_SIZE = 50; constexpr size_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M -constexpr uint32_t DEFAULT_VERSION = 0; bool CopyBufferFromRawData(void*& buffer, size_t size, const void* data) { @@ -1666,34 +1665,4 @@ WSError SessionStageProxy::NotifyWindowAttachStateChange(bool isAttach) } return WSError::WS_OK; } - -uint32_t SessionStageProxy::GetTargetAPIVersion() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!data.WriteInterfaceToken(GetDescriptor())) { - TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed"); - return DEFAULT_VERSION; - } - - sptr remote = Remote(); - if (remote == nullptr) { - TLOGE(WmsLogTag::WMS_LIFE, "remote is null"); - return DEFAULT_VERSION; - } - if (remote->SendRequest(static_cast( - SessionStageInterfaceCode::TRANS_ID_GET_TARGET_API_VERSION), - data, reply, option) != ERR_NONE) { - TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed"); - return DEFAULT_VERSION; - } - - uint32_t version; - if (!reply.ReadUint32(version)) { - TLOGE(WmsLogTag::WMS_LIFE, "read version failed"); - return DEFAULT_VERSION; - } - return version; -} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index ca437eb988..44c3fbb583 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -200,8 +200,6 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleNotifyPipSizeChange(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE): return HandleNotifyWindowAttachStateChange(data, reply); - case static_cast(SessionStageInterfaceCode::TRANS_ID_GET_TARGET_API_VERSION): - return HandleGetTargetAPIVersion(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -841,14 +839,4 @@ int SessionStageStub::HandleNotifyWindowAttachStateChange(MessageParcel& data, M NotifyWindowAttachStateChange(isAttach); return ERR_NONE; } - -int SessionStageStub::HandleGetTargetAPIVersion(MessageParcel& data, MessageParcel& reply) -{ - uint32_t version = GetTargetAPIVersion(); - if (!reply.WriteUint32(version)) { - TLOGE(WmsLogTag::WMS_LIFE, "write version fail"); - return ERR_TRANSACTION_FAILED; - } - return ERR_NONE; -} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 76b4c7e6d7..e7b5d262b0 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -517,7 +517,6 @@ public: static uint32_t GetWindowDragHotAreaType(DisplayId displayId, uint32_t type, int32_t pointerX, int32_t pointerY); static void AddOrUpdateWindowDragHotArea(DisplayId displayId, uint32_t type, const WSRect& area); WSError UpdateRectChangeListenerRegistered(bool isRegister) override; - uint32_t GetTargetAPIVersion(); /* * Window Decor diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 816da5143d..419cc1a37c 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -74,7 +74,6 @@ constexpr WSRectF VELOCITY_RELOCATION_TO_BOTTOM = {0.0f, 10.0f, 0.0f, 0.0f}; constexpr int32_t API_VERSION_16 = 16; constexpr int32_t HOOK_SYSTEM_BAR_HEIGHT = 40; constexpr int32_t HOOK_AI_BAR_HEIGHT = 28; -constexpr uint32_t DEFAULT_VERSION = 0; bool CheckIfRectElementIsTooLarge(const WSRect& rect) { @@ -6852,13 +6851,4 @@ void SceneSession::SetSidebarMaskColorModifier(bool needBlur) maskColorValue_->Set(Rosen::RSColor::FromArgbInt(snapshotMaskColor_)); } } - -uint32_t SceneSession::GetTargetAPIVersion() -{ - if (!sessionStage_) { - TLOGE(WmsLogTag::WMS_LIFE, "sessionStage_ is nullptr, id: %{public}d", GetPersistentId()); - return DEFAULT_API_VERSION; - } - return sessionStage_->GetTargetAPIVersion(); -} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 72a5def597..3fb85bdcf8 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2567,7 +2567,7 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION) { + if (sceneSession->GetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } @@ -2822,7 +2822,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrSetRemoveSnapshotCallback([this, persistentId]() { this->RemoveSnapshotFromCache(persistentId); }); - if (sceneSession->GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION) { + if (sceneSession->GetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } @@ -4072,7 +4072,7 @@ WSError SceneSessionManager::StartOrMinimizeUIAbilityBySCB(const sptrGetWindowType(), sceneSession->GetSessionState()); bool isFromUser = false; - if (sceneSession->GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION) { + if (sceneSession->GetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index abd8d65716..f5505fff86 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -418,7 +418,7 @@ private: * Window Lifecycle */ bool isColdStart_ = true; - void NotifyPcModeResume(); + void NotifyFreeMultiWindowModeResume(); }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index b63fe9125f..344109c1fb 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -125,7 +125,7 @@ public: WMError SetSubWindowModal(bool isModal, ModalityType modalityType = ModalityType::WINDOW_MODALITY) override; WMError SetWindowModal(bool isModal) override; void SetTargetAPIVersion(uint32_t targetAPIVersion); - uint32_t GetTargetAPIVersion() override; + uint32_t GetTargetAPIVersion() const; WMError SetWindowType(WindowType type) override; WMError SetBrightness(float brightness) override; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 40de02beca..91c88562a6 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1206,7 +1206,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation, bool w requestState_ = WindowState::STATE_SHOWN; NotifyAfterForeground(true, true); NotifyAfterDidForeground(reason); - NotifyPcModeResume(); + NotifyFreeMultiWindowModeResume(); RefreshNoInteractionTimeoutMonitor(); TLOGI(WmsLogTag::WMS_LIFE, "Window show success [name:%{public}s, id:%{public}d, type:%{public}u]", property_->GetWindowName().c_str(), GetPersistentId(), type); @@ -1232,7 +1232,7 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardViewMode mode) return Show(); } -void WindowSceneSessionImpl::NotifyPcModeResume() +void WindowSceneSessionImpl::NotifyFreeMultiWindowModeResume() { TLOGI(WmsLogTag::WMS_LIFE, "api version %{public}u, IsPcMode {public}d, isColdStart %{public}d", GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode(), isColdStart_); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 2aa47c7398..f10ec53b47 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -5142,7 +5142,7 @@ void WindowSessionImpl::SetTargetAPIVersion(uint32_t targetAPIVersion) targetAPIVersion_ = targetAPIVersion; } -uint32_t WindowSessionImpl::GetTargetAPIVersion() +uint32_t WindowSessionImpl::GetTargetAPIVersion() const { return targetAPIVersion_; } diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index c37ff7c4cf..826b38de5e 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -750,6 +750,33 @@ HWTEST_F(WindowSceneSessionImplTest5, NotifyAfterDidBackground, Function | Small EXPECT_CALL(*mockListener, AfterDidBackground()).Times(1); ASSERT_EQ(WMError::WM_OK, window->Hide(static_cast(WindowStateChangeReason::ABILITY_CALL), false, false)); } + +/** + * @tc.name: Resume + * @tc.desc: Resume + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, Resume, Function | SmallTest | Level2) +{ + sptr mockListener = sptr::MakeSptr(); + sptr listener = static_cast>(mockListener); + + sptr option = sptr::MakeSptr(); + option->SetWindowName("Test"); + option->SetDisplayId(0); + + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(1); + window->hostSession_ = session; + window->RegisterLifeCycleListener(listener); + window->SetTargetAPIVersion(16); + + EXPECT_CALL(*mockListener, AfterResumed()).Times(1); + window->Resume(); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 2c45d883749b5083cca190e98f06ffe2a9c1f9e1 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Wed, 26 Feb 2025 20:26:10 +0800 Subject: [PATCH 16/22] bugfix Signed-off-by: hust_5u --- window_scene/common/src/window_session_property.cpp | 2 ++ window_scene/session/host/include/scene_session.h | 2 +- wm/src/window_scene_session_impl.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 27199830db..b107d01854 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -1212,6 +1212,7 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const parcel.WriteUint8(backgroundAlpha_) && parcel.WriteUint32(static_cast(keyboardViewMode_)) && parcel.WriteFloat(cornerRadius_) && parcel.WriteBool(isExclusivelyHighlighted_) && parcel.WriteBool(isAtomicService_); + parcel.WriteUint32(apiVersion_); } WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) @@ -1299,6 +1300,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) property->SetWindowCornerRadius(parcel.ReadFloat()); property->SetExclusivelyHighlighted(parcel.ReadBool()); property->SetIsAtomicService(parcel.ReadBool()); + property->SetApiVersion(parcel.ReadUint32()); return property; } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index e7b5d262b0..970ff9d4f9 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -517,6 +517,7 @@ public: static uint32_t GetWindowDragHotAreaType(DisplayId displayId, uint32_t type, int32_t pointerX, int32_t pointerY); static void AddOrUpdateWindowDragHotArea(DisplayId displayId, uint32_t type, const WSRect& area); WSError UpdateRectChangeListenerRegistered(bool isRegister) override; + bool UpdateInteractiveInner(bool interactive); /* * Window Decor @@ -674,7 +675,6 @@ protected: * Window Pipeline */ bool UpdateVisibilityInner(bool visibility) REQUIRES(SCENE_GUARD); - bool UpdateInteractiveInner(bool interactive); virtual void NotifyClientToUpdateInteractive(bool interactive) {} bool PipelineNeedNotifyClientToUpdateRect() const; bool UpdateRectInner(const SessionUIParam& uiParam, SizeChangeReason reason); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 91c88562a6..c836fdd282 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1234,7 +1234,7 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardViewMode mode) void WindowSceneSessionImpl::NotifyFreeMultiWindowModeResume() { - TLOGI(WmsLogTag::WMS_LIFE, "api version %{public}u, IsPcMode {public}d, isColdStart %{public}d", + TLOGI(WmsLogTag::WMS_MAIN, "api version %{public}u, IsPcMode %{public}d, isColdStart %{public}d", GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode(), isColdStart_); if (GetTargetAPIVersion() >= API_VERSION_16 && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { isDidForeground_ = true; -- Gitee From 2cd7471f22c81e65a569ea33e2c40ba12eb4416d Mon Sep 17 00:00:00 2001 From: hust_5u Date: Thu, 27 Feb 2025 11:37:38 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=B0=E5=93=A5?= =?UTF-8?q?=E5=92=8C=E4=BA=AE=E5=93=A5=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- .../src/scene_session_manager.cpp | 6 +- wm/src/window_session_impl.cpp | 88 ++++++++++--------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3fb85bdcf8..b7d01da7d1 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2568,7 +2568,7 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { - TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); + TLOGI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } sceneSession->SetActive(false); @@ -2823,7 +2823,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrRemoveSnapshotFromCache(persistentId); }); if (sceneSession->GetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { - TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); + TLOGI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } sceneSession->DisconnectTask(false, isSaveSnapshot); @@ -4073,7 +4073,7 @@ WSError SceneSessionManager::StartOrMinimizeUIAbilityBySCB(const sptrGetWindowType(), sceneSession->GetSessionState()); bool isFromUser = false; if (sceneSession->GetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { - TLOGI(WmsLogTag::WMS_MAIN, "Notify scene session id:%{public}d pause", persistentId); + TLOGI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } int32_t errCode = AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB( diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index f10ec53b47..9e0bd942ff 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1174,15 +1174,19 @@ void WindowSessionImpl::NotifyForegroundInteractiveStatus(bool interactive) if (IsNotifyInteractiveDuplicative(interactive)) { return; } - if (state_ == WindowState::STATE_SHOWN) { - if (interactive) { - if (GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION && !isDidForeground_) { - return; - } - NotifyAfterResumed(); - } else { - NotifyAfterPaused(); + if (state_ != WindowState::STATE_SHOWN) { + TLOGI(WmsLogTag::WMS_LIFE, "window state %{public}, is not shown", state_); + return; + } + if (interactive) { + if (GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION && !isDidForeground_) { + TLOGI(WmsLogTag::WMS_LIFE, "api version %{public}u, isDidForeground %{public}d", GetTargetAPIVersion(), + isDidForeground_); + return; } + NotifyAfterResumed(); + } else { + NotifyAfterPaused(); } } @@ -3242,25 +3246,25 @@ void WindowSessionImpl::NotifyAfterForeground(bool needNotifyListeners, bool nee void WindowSessionImpl::NotifyAfterDidForeground(uint32_t reason) { TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d", reason); - if (reason == static_cast(WindowStateChangeReason::USER_SWITCH) || - reason == static_cast(WindowStateChangeReason::ABILITY_CALL)) { - if (handler_ == nullptr) { - TLOGE(WmsLogTag::WMS_LIFE, "handler is nullptr"); + if (reason != static_cast(WindowStateChangeReason::USER_SWITCH) && + reason != static_cast(WindowStateChangeReason::ABILITY_CALL)) { + return; + } + if (handler_ == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "handler is nullptr"); + return; + } + const char* const where = __func__; + handler_->PostTask([weak = wptr(this), where] { + auto window = weak.promote(); + if (window == nullptr) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); return; } - const char* const where = __func__; - handler_->PostTask([weak = wptr(this), where] { - auto window = weak.promote(); - if (window == nullptr) { - TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); - return; - } - TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); - auto lifecycleListeners = window->GetListeners(); - CALL_LIFECYCLE_LISTENER(AfterDidForeground, lifecycleListeners); - }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); - } - return; + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); + auto lifecycleListeners = window->GetListeners(); + CALL_LIFECYCLE_LISTENER(AfterDidForeground, lifecycleListeners); + }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } void WindowSessionImpl::NotifyAfterBackground(bool needNotifyListeners, bool needNotifyUiContent) @@ -3290,25 +3294,25 @@ void WindowSessionImpl::NotifyAfterBackground(bool needNotifyListeners, bool nee void WindowSessionImpl::NotifyAfterDidBackground(uint32_t reason) { TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d", reason); - if (reason == static_cast(WindowStateChangeReason::USER_SWITCH) || - reason == static_cast(WindowStateChangeReason::ABILITY_CALL)) { - if (handler_ == nullptr) { - TLOGE(WmsLogTag::WMS_LIFE, "handler is nullptr"); + if (reason != static_cast(WindowStateChangeReason::USER_SWITCH) && + reason != static_cast(WindowStateChangeReason::ABILITY_CALL)) { + return; + } + if (handler_ == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "handler is nullptr"); + return; + } + const char* const where = __func__; + handler_->PostTask([weak = wptr(this), where] { + auto window = weak.promote(); + if (window == nullptr) { + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); return; } - const char* const where = __func__; - handler_->PostTask([weak = wptr(this), where] { - auto window = weak.promote(); - if (window == nullptr) { - TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s window is nullptr", where); - return; - } - TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); - auto lifecycleListeners = window->GetListeners(); - CALL_LIFECYCLE_LISTENER(AfterDidBackground, lifecycleListeners); - }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); - } - return; + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s execute", where); + auto lifecycleListeners = window->GetListeners(); + CALL_LIFECYCLE_LISTENER(AfterDidBackground, lifecycleListeners); + }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } static void RequestInputMethodCloseKeyboard(bool isNeedKeyboard, bool keepKeyboardFlag) -- Gitee From 81fd73505ddea75a1ba1f0e8c65a1685124ad23b Mon Sep 17 00:00:00 2001 From: hust_5u Date: Thu, 27 Feb 2025 14:17:16 +0800 Subject: [PATCH 18/22] bugfix Signed-off-by: hust_5u --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 9e0bd942ff..dbdc90bbee 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1175,7 +1175,7 @@ void WindowSessionImpl::NotifyForegroundInteractiveStatus(bool interactive) return; } if (state_ != WindowState::STATE_SHOWN) { - TLOGI(WmsLogTag::WMS_LIFE, "window state %{public}, is not shown", state_); + TLOGI(WmsLogTag::WMS_LIFE, "window state %{public}d, is not shown", state_); return; } if (interactive) { -- Gitee From 14a8764c71fa719619fc83aeac2d320d3bf48110 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Thu, 27 Feb 2025 17:41:31 +0800 Subject: [PATCH 19/22] =?UTF-8?q?hide=E6=97=B6=E8=AE=BE=E7=BD=AEisDidForeg?= =?UTF-8?q?round=E4=B8=BAfalse=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- wm/src/window_scene_session_impl.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index b7d01da7d1..42bae64681 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2568,7 +2568,7 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { - TLOGI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); + TLOGNI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } sceneSession->SetActive(false); @@ -2823,7 +2823,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrRemoveSnapshotFromCache(persistentId); }); if (sceneSession->GetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { - TLOGI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); + TLOGNI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); sceneSession->UpdateInteractiveInner(false); } sceneSession->DisconnectTask(false, isSaveSnapshot); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index c836fdd282..9dfe2b89ef 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1311,6 +1311,7 @@ WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool i NotifyAfterDidBackground(reason); state_ = WindowState::STATE_HIDDEN; requestState_ = WindowState::STATE_HIDDEN; + isDidForeground_ = false; if (!interactive_) { hasFirstNotifyInteractive_ = false; } -- Gitee From 45c0ad023a6d85a908a0bec2ab1914e0c579ef86 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Thu, 27 Feb 2025 17:44:50 +0800 Subject: [PATCH 20/22] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- wm/src/window_session_impl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index dbdc90bbee..09f8feee2b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3248,6 +3248,7 @@ void WindowSessionImpl::NotifyAfterDidForeground(uint32_t reason) TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d", reason); if (reason != static_cast(WindowStateChangeReason::USER_SWITCH) && reason != static_cast(WindowStateChangeReason::ABILITY_CALL)) { + TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d no need notify did foreground", reason); return; } if (handler_ == nullptr) { @@ -3296,6 +3297,7 @@ void WindowSessionImpl::NotifyAfterDidBackground(uint32_t reason) TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d", reason); if (reason != static_cast(WindowStateChangeReason::USER_SWITCH) && reason != static_cast(WindowStateChangeReason::ABILITY_CALL)) { + TLOGI(WmsLogTag::WMS_LIFE, "reason: %{public}d no need notify did background", reason); return; } if (handler_ == nullptr) { -- Gitee From 2508a8ec23c6d24f68ac0b8142ba19400701d0a5 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Fri, 28 Feb 2025 16:16:47 +0800 Subject: [PATCH 21/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=9C=E6=80=BB?= =?UTF-8?q?=E5=92=8C=E6=98=86=E5=93=A5=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8Dipcbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- interfaces/innerkits/wm/window.h | 2 -- window_scene/common/src/window_session_property.cpp | 3 +-- window_scene/session/host/include/scene_session.h | 2 +- .../session_manager/src/scene_session_manager.cpp | 12 +++++++++--- wm/src/window_scene_session_impl.cpp | 5 +++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index f65dfb5aad..4922ce9d12 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1063,8 +1063,6 @@ public: /** * @brief resume window - * - * @return WMError */ virtual void Resume() {} diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index b107d01854..d81efc7151 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -1211,8 +1211,7 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const parcel.WriteUint32(avoidAreaOption_) && parcel.WriteBool(isWindowDelayRaiseEnabled_) && parcel.WriteUint8(backgroundAlpha_) && parcel.WriteUint32(static_cast(keyboardViewMode_)) && parcel.WriteFloat(cornerRadius_) && parcel.WriteBool(isExclusivelyHighlighted_) && - parcel.WriteBool(isAtomicService_); - parcel.WriteUint32(apiVersion_); + parcel.WriteBool(isAtomicService_) && parcel.WriteUint32(apiVersion_); } WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 970ff9d4f9..53112942c6 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -488,6 +488,7 @@ public: virtual void RegisterSessionLockStateChangeCallback(NotifySessionLockStateChangeCallback&& callback) {} virtual void NotifySessionLockStateChange(bool isLockedState) {} virtual void SetUpdateSessionLabelAndIconListener(NofitySessionLabelAndIconUpdatedFunc&& func) {} + bool UpdateInteractiveInner(bool interactive); void SendPointerEventToUI(std::shared_ptr pointerEvent); bool SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent = false); @@ -517,7 +518,6 @@ public: static uint32_t GetWindowDragHotAreaType(DisplayId displayId, uint32_t type, int32_t pointerX, int32_t pointerY); static void AddOrUpdateWindowDragHotArea(DisplayId displayId, uint32_t type, const WSRect& area); WSError UpdateRectChangeListenerRegistered(bool isRegister) override; - bool UpdateInteractiveInner(bool interactive); /* * Window Decor diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 42bae64681..ae9b8b62cd 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2569,7 +2569,9 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { TLOGNI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); - sceneSession->UpdateInteractiveInner(false); + if (!sceneSession->UpdateInteractiveInner(false)) { + TLOGNI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause is duplicative", persistentId); + } } sceneSession->SetActive(false); @@ -2824,7 +2826,9 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrGetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { TLOGNI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); - sceneSession->UpdateInteractiveInner(false); + if (!sceneSession->UpdateInteractiveInner(false)) { + TLOGNI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause is duplicative", persistentId); + } } sceneSession->DisconnectTask(false, isSaveSnapshot); if (!GetSceneSession(persistentId)) { @@ -4074,7 +4078,9 @@ WSError SceneSessionManager::StartOrMinimizeUIAbilityBySCB(const sptrGetSessionProperty()->GetApiVersion() >= LIFECYCLE_ISOLATE_VERSION) { TLOGI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause", persistentId); - sceneSession->UpdateInteractiveInner(false); + if (!sceneSession->UpdateInteractiveInner(false)) { + TLOGI(WmsLogTag::WMS_LIFE, "Notify scene session id:%{public}d pause is duplicative", persistentId); + } } int32_t errCode = AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB( abilitySessionInfo, isFromUser, static_cast(WindowStateChangeReason::USER_SWITCH)); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 9dfe2b89ef..556ba14267 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -128,6 +128,7 @@ constexpr float INVALID_DEFAULT_DENSITY = 1.0f; constexpr uint32_t FORCE_LIMIT_MIN_FLOATING_WIDTH = 40; constexpr uint32_t FORCE_LIMIT_MIN_FLOATING_HEIGHT = 40; constexpr int32_t API_VERSION_16 = 16; +constexpr uint32_t LIFECYCLE_ISOLATE_VERSION = 16; } uint32_t WindowSceneSessionImpl::maxFloatingWindowSize_ = 1920; std::mutex WindowSceneSessionImpl::keyboardPanelInfoChangeListenerMutex_; @@ -1236,7 +1237,7 @@ void WindowSceneSessionImpl::NotifyFreeMultiWindowModeResume() { TLOGI(WmsLogTag::WMS_MAIN, "api version %{public}u, IsPcMode %{public}d, isColdStart %{public}d", GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode(), isColdStart_); - if (GetTargetAPIVersion() >= API_VERSION_16 && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { + if (GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { isDidForeground_ = true; NotifyForegroundInteractiveStatus(true); } @@ -1244,7 +1245,7 @@ void WindowSceneSessionImpl::NotifyFreeMultiWindowModeResume() void WindowSceneSessionImpl::Resume() { - if (GetTargetAPIVersion() >= API_VERSION_16) { + if (GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION) { isDidForeground_ = true; isColdStart_ = false; TLOGI(WmsLogTag::WMS_LIFE, "in"); -- Gitee From 475ef96c9f265ffe8abcdb7e4453ad1fb3d422d1 Mon Sep 17 00:00:00 2001 From: hust_5u Date: Fri, 28 Feb 2025 16:30:33 +0800 Subject: [PATCH 22/22] =?UTF-8?q?=E6=96=B0=E5=A2=9EpcAPPinPad=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hust_5u --- wm/src/window_scene_session_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 556ba14267..f3c8988d4d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1236,8 +1236,8 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardViewMode mode) void WindowSceneSessionImpl::NotifyFreeMultiWindowModeResume() { TLOGI(WmsLogTag::WMS_MAIN, "api version %{public}u, IsPcMode %{public}d, isColdStart %{public}d", - GetTargetAPIVersion(), IsPcOrPadFreeMultiWindowMode(), isColdStart_); - if (GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION && IsPcOrPadFreeMultiWindowMode() && !isColdStart_) { + GetTargetAPIVersion(), IsPcOrPadCapabilityEnabled(), isColdStart_); + if (GetTargetAPIVersion() >= LIFECYCLE_ISOLATE_VERSION && IsPcOrPadCapabilityEnabled() && !isColdStart_) { isDidForeground_ = true; NotifyForegroundInteractiveStatus(true); } -- Gitee