From 07185fab1c35cbaa832099a080af1e61e8cc1c53 Mon Sep 17 00:00:00 2001 From: flybear Date: Fri, 23 Aug 2024 06:40:33 +0000 Subject: [PATCH 01/86] =?UTF-8?q?pc=20=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D=20=E6=96=B0=E5=A2=9E=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../kits/napi/scene_session_manager/js_scene_session_manager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h index 1a1b218bb2..604271ca12 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h @@ -103,6 +103,7 @@ public: static napi_value GetFreeMultiWindowConfig(napi_env env, napi_callback_info info); static napi_value GetIsLayoutFullScreen(napi_env env, napi_callback_info info); static napi_value IsScbCoreEnabled(napi_env env, napi_callback_info info); + static napi_value RefreshPcZOrder(napi_env env, napi_callback_info info); private: napi_value OnRegisterCallback(napi_env env, napi_callback_info info); @@ -159,6 +160,7 @@ private: napi_value OnInitScheduleUtils(napi_env env, napi_callback_info info); napi_value OnSetAppForceLandscapeConfig(napi_env env, napi_callback_info info); napi_value OnIsScbCoreEnabled(napi_env env, napi_callback_info info); + napi_value OnRefreshPcZOrder(napi_env env, napi_callback_info info); void OnStatusBarEnabledUpdate(bool enable, const std::string& bundleName); void OnGestureNavigationEnabledUpdate(bool enable, const std::string& bundleName); From 7b736959bffc3e8ea6a0b012b34ab1f90058a944 Mon Sep 17 00:00:00 2001 From: flybear Date: Fri, 23 Aug 2024 08:07:25 +0000 Subject: [PATCH 02/86] =?UTF-8?q?pc=20=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../js_scene_session_manager.cpp | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index d518e1bd62..f380bae682 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -184,6 +184,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::IsScbCoreEnabled); BindNativeFunction(env, exportObj, "updateAppHookDisplayInfo", moduleName, JsSceneSessionManager::UpdateAppHookDisplayInfo); + BindNativeFunction(env, exportObj, "refreshPcZOrder", moduleName, + JsSceneSessionManager::UpdateAppHookDisplayInfo); return NapiGetUndefined(env); } @@ -898,6 +900,13 @@ napi_value JsSceneSessionManager::IsScbCoreEnabled(napi_env env, napi_callback_i return (me != nullptr) ? me->OnIsScbCoreEnabled(env, info) : nullptr; } +napi_value JsSceneSessionManager::RefreshPcZOrder(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_PIPELINE, "[NAPI]"); + JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnRefreshPcZOrder(env, info) : nullptr; +} + bool JsSceneSessionManager::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSessionManager::IsCallbackRegistered[%s]", type.c_str()); @@ -2953,4 +2962,33 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback napi_get_boolean(env, Session::IsScbCoreEnabled(), &result); return result; } + +napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < ARGC_TWO) { + TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + uint32_t startZOrder; + if (!ConvertFromJsValue(env, argv[0], startZOrder)) { + TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert startZOrder to %{public}d", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + std::vector perisistendIds; + if (!ConvertInt32ArrayFromJs(env, argv[1], perisistendIds)){ + TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert perisistendIds to %{public}d", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, perisistendIds); + return NapiGetUndefined(env); +} } // namespace OHOS::Rosen From ca2138fbc8a6551f68e35776f42a362f09f3df76 Mon Sep 17 00:00:00 2001 From: flybear Date: Fri, 23 Aug 2024 08:36:52 +0000 Subject: [PATCH 03/86] =?UTF-8?q?pc=20=E6=89=A9=E5=B1=95=E5=B1=8F=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/include/scene_session.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index bbfced8de0..9439c3c374 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -392,6 +392,12 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; + bool GetPcScenePanel(){ + return isPcScenePanel_; + } + void SetPcScenePanel(bool isPcScenePanel){ + isPcScenePanel_ = isPcScenePanel; + } protected: void NotifySessionRectChange(const WSRect& rect, const SizeChangeReason& reason = SizeChangeReason::UNDEFINED); @@ -573,6 +579,9 @@ private: // Multi User bool isMinimizedByUserSwitch_ { false }; + + // pc scene panel is used to determine whether the freshPcZOrder method is used to process the layer + bool isPcScenePanel_ {false}; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H From 313606d35494c98671fdb177305b8750204d3fa0 Mon Sep 17 00:00:00 2001 From: flybear Date: Fri, 23 Aug 2024 08:45:42 +0000 Subject: [PATCH 04/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/src/scene_session.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index b7ad1056c1..7dfa465c24 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4304,9 +4304,11 @@ uint32_t SceneSession::UpdateUIParam(const SessionUIParam& uiParam) static_cast(SessionUIDirtyFlag::INTERACTIVE) : 0; dirtyFlags_ |= UpdateRectInner(uiParam, reason_) ? static_cast(SessionUIDirtyFlag::RECT) : 0; + if (!isPcScenePanel_) { + dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : 0; + } dirtyFlags_ |= UpdateScaleInner(uiParam.scaleX_, uiParam.scaleY_, uiParam.pivotX_, uiParam.pivotY_) ? static_cast(SessionUIDirtyFlag::SCALE) : 0; - dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : 0; if (!lastVisible && IsVisible() && !isFocused_ && !postProcessFocusState_.enabled_ && GetForegroundInteractiveStatus()) { postProcessFocusState_.enabled_ = true; From 4e1d96854033bd1f5ce3ffaa3bd00e8e31373cd4 Mon Sep 17 00:00:00 2001 From: flybear Date: Fri, 23 Aug 2024 08:52:18 +0000 Subject: [PATCH 05/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/include/scene_session_manager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index cc0caa5468..d1f8b201f5 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -377,6 +377,7 @@ public: WMError TerminateSessionByPersistentId(int32_t persistentId); WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, const std::vector& persistentIds, std::vector& surfaceNodeIds) override; + void RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds) protected: SceneSessionManager(); @@ -776,6 +777,7 @@ private: } }; std::unordered_map, SessionHasher> abilityInfoMap_; + std::map> idListMap_; }; } // namespace OHOS::Rosen From 24032a66aeb720039b264d00f978a7e50fc0c0e1 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 01:19:48 +0000 Subject: [PATCH 06/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../src/scene_session_manager.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 694e831657..c1e11cf603 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10198,4 +10198,36 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t return WMError::WM_OK; } + +void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds) +{ + idListMap_.erase(startZOrder); + idListMap_.insert({startZOrder, persistentId}); + std::ostringstream oss; + oss << "["; + for(size_t i = 0; i < persistentIds.size(); i++){ + int32_t persistentId = persistentId[i]; + oss << persistentId; + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_SCB, "sceneScene is nullptr persistentId = %{public}d", persistentId); + if(i < persistentIds.size() - 1){ + oss << ","; + } + continue; + } + if (!sceneSession->GetPcScenePanel()){ + sceneSession->SetPcScenePanel(true); + } + unint newZOrder = i + startZOrder; + if(SceneSession->GetZOrder()!=newZOrder){ + sceneSession->SetZOrder(newZOrder); + TLOGI(WmsLogTag::WMS_SCB, "SetZOrder persistentId:%{public}d", persistentId); + } + if(i < persistentIds.size() - 1){ + oss << ","; + } + } + TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}d", persistentId); +} } // namespace OHOS::Rosen From 410a558d3c4d8161dee6190ea5ac1b9fb945b3e6 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 03:04:01 +0000 Subject: [PATCH 07/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../unittest/scene_session_manager_test9.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 23d2af87aa..5d764a321a 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -594,6 +594,48 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function | property->SetPersistentId(0); ssm_->RecoverAndReconnectSceneSession(nullptr, nullptr, nullptr, session, property, nullptr); } + +HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest |Level3){ + vector persistentIds; + SessionInfo info1, info2, info3; + info1.abilityName_ = "RefreshPcZorder1"; + info1.bundleName_ = "RefreshPcZorder1"; + info2.abilityName_ = "RefreshPcZorder2"; + info2.bundleName_ = "RefreshPcZorder2"; + info3.abilityName_ = "RefreshPcZorder3"; + info3.bundleName_ = "RefreshPcZorder3"; + uint32_t startZOrder = 100; + sptr session1 = new (std::nothrow)SceneSession(info1); + EXPECT_NE(session1, nullptr); + persistentIds.push_back(session1->GetPersistentId()); + ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId, sceneSession1}); + sptr session2 = new (std::nothrow)SceneSession(info2); + EXPECT_NE(session2, nullptr); + persistentIds.push_back(session2->GetPersistentId()); + ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId, sceneSession2}); + sptr session3 = new (std::nothrow)SceneSession(info3); + EXPECT_NE(session3, nullptr); + persistentIds.push_back(999); + session3->SetZOrder(404); + ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId, sceneSession3}); + ssm_->RefreshPcZorder(startZOrder, persistentIds); + auto start = std::chrono::system_clock::now(); + while(true){ + bool isFinished = Session1->GetZOrder != 0 && Session2->GetZOrder != 0; + if(isFinished){ + break; + } + auto now = std::chrono::system_clock:now; + auto elapsed = std::chrono:duration_cast(now - start); + if (elapsed >= 3){ + break; + } + std::this_thread::sleep_for(std:chrono:milliseconds(100)); + } + ASSERT_EQ(session1->GetZOrder(),100); + ASSERT_EQ(session1->GetZOrder(),101); + ASSERT_EQ(session1->GetZOrder(),404); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file From f8c6d241d405316d161a9d3dc0e9489f396f165d Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 03:44:46 +0000 Subject: [PATCH 08/86] update window_scene/test/unittest/scene_session_manager_test9.cpp. Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 5d764a321a..b466760972 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -606,15 +606,15 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest |Level3 info3.bundleName_ = "RefreshPcZorder3"; uint32_t startZOrder = 100; sptr session1 = new (std::nothrow)SceneSession(info1); - EXPECT_NE(session1, nullptr); + ASSERT_NE(session1, nullptr); persistentIds.push_back(session1->GetPersistentId()); ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId, sceneSession1}); sptr session2 = new (std::nothrow)SceneSession(info2); - EXPECT_NE(session2, nullptr); + ASSERT_NE(session2, nullptr); persistentIds.push_back(session2->GetPersistentId()); ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId, sceneSession2}); sptr session3 = new (std::nothrow)SceneSession(info3); - EXPECT_NE(session3, nullptr); + ASSERT_NE(session3, nullptr); persistentIds.push_back(999); session3->SetZOrder(404); ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId, sceneSession3}); From c2e50443d2d1299cf91c0eb14dc5122bcd6c5ead Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 06:47:21 +0000 Subject: [PATCH 09/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index f380bae682..ac62a80345 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -185,7 +185,7 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) BindNativeFunction(env, exportObj, "updateAppHookDisplayInfo", moduleName, JsSceneSessionManager::UpdateAppHookDisplayInfo); BindNativeFunction(env, exportObj, "refreshPcZOrder", moduleName, - JsSceneSessionManager::UpdateAppHookDisplayInfo); + JsSceneSessionManager::RefreshPcZOrder); return NapiGetUndefined(env); } From ad162875d21c4276422221374b19e9aac3be6524 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 06:56:21 +0000 Subject: [PATCH 10/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index ac62a80345..6c9557a199 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -902,7 +902,7 @@ napi_value JsSceneSessionManager::IsScbCoreEnabled(napi_env env, napi_callback_i napi_value JsSceneSessionManager::RefreshPcZOrder(napi_env env, napi_callback_info info) { - TLOGD(WmsLogTag::WMS_PIPELINE, "[NAPI]"); + TLOGD(WmsLogTag::WMS_SCB, "[NAPI]"); JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnRefreshPcZOrder(env, info) : nullptr; } @@ -2966,7 +2966,7 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info) { size_t argc = 4; - napi_value argv[4] = {nullptr}; + napi_value argv[4]; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_TWO) { TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Argc is invalid: %{public}zu", argc); @@ -2991,4 +2991,4 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_ SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, perisistendIds); return NapiGetUndefined(env); } -} // namespace OHOS::Rosen +} // namespace OHOS::Rosen \ No newline at end of file From 6beebc213f53d4952756f6cc0e11ba19e63f67d7 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 07:10:20 +0000 Subject: [PATCH 11/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/src/scene_session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 7dfa465c24..db346600a8 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4304,11 +4304,11 @@ uint32_t SceneSession::UpdateUIParam(const SessionUIParam& uiParam) static_cast(SessionUIDirtyFlag::INTERACTIVE) : 0; dirtyFlags_ |= UpdateRectInner(uiParam, reason_) ? static_cast(SessionUIDirtyFlag::RECT) : 0; + dirtyFlags_ |= UpdateScaleInner(uiParam.scaleX_, uiParam.scaleY_, uiParam.pivotX_, uiParam.pivotY_) ? + static_cast(SessionUIDirtyFlag::SCALE) : 0; if (!isPcScenePanel_) { dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : 0; } - dirtyFlags_ |= UpdateScaleInner(uiParam.scaleX_, uiParam.scaleY_, uiParam.pivotX_, uiParam.pivotY_) ? - static_cast(SessionUIDirtyFlag::SCALE) : 0; if (!lastVisible && IsVisible() && !isFocused_ && !postProcessFocusState_.enabled_ && GetForegroundInteractiveStatus()) { postProcessFocusState_.enabled_ = true; From e9ecac35430d27552f05ea5e3c3cf975fe1cf3c8 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 07:12:21 +0000 Subject: [PATCH 12/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/src/scene_session.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index db346600a8..0007526928 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4307,7 +4307,8 @@ uint32_t SceneSession::UpdateUIParam(const SessionUIParam& uiParam) dirtyFlags_ |= UpdateScaleInner(uiParam.scaleX_, uiParam.scaleY_, uiParam.pivotX_, uiParam.pivotY_) ? static_cast(SessionUIDirtyFlag::SCALE) : 0; if (!isPcScenePanel_) { - dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : 0; + dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : + 0; } if (!lastVisible && IsVisible() && !isFocused_ && !postProcessFocusState_.enabled_ && GetForegroundInteractiveStatus()) { From f0352f3e9cbbcb709b79870a630fec7dc7861861 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 07:16:08 +0000 Subject: [PATCH 13/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/src/scene_session.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0007526928..5a70961310 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4307,8 +4307,7 @@ uint32_t SceneSession::UpdateUIParam(const SessionUIParam& uiParam) dirtyFlags_ |= UpdateScaleInner(uiParam.scaleX_, uiParam.scaleY_, uiParam.pivotX_, uiParam.pivotY_) ? static_cast(SessionUIDirtyFlag::SCALE) : 0; if (!isPcScenePanel_) { - dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : - 0; + dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : 0; } if (!lastVisible && IsVisible() && !isFocused_ && !postProcessFocusState_.enabled_ && GetForegroundInteractiveStatus()) { From 8b251450164e3cbbbf36fb352846addb46978015 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 07:36:44 +0000 Subject: [PATCH 14/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../test/unittest/scene_session_manager_test9.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index b466760972..a01c4956e9 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -605,23 +605,24 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest |Level3 info3.abilityName_ = "RefreshPcZorder3"; info3.bundleName_ = "RefreshPcZorder3"; uint32_t startZOrder = 100; - sptr session1 = new (std::nothrow)SceneSession(info1); + sptr session1 = new (std::nothrow)SceneSession(info1, nullptr); ASSERT_NE(session1, nullptr); persistentIds.push_back(session1->GetPersistentId()); ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId, sceneSession1}); - sptr session2 = new (std::nothrow)SceneSession(info2); + sptr session2 = new (std::nothrow)SceneSession(info2, nullptr); ASSERT_NE(session2, nullptr); persistentIds.push_back(session2->GetPersistentId()); ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId, sceneSession2}); - sptr session3 = new (std::nothrow)SceneSession(info3); + sptr session3 = new (std::nothrow)SceneSession(info3, nullptr); ASSERT_NE(session3, nullptr); persistentIds.push_back(999); session3->SetZOrder(404); - ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId, sceneSession3}); + ssm_->sceneSessionMap_.insert({session3->GetPersistentId, session3}); ssm_->RefreshPcZorder(startZOrder, persistentIds); auto start = std::chrono::system_clock::now(); + // Due to SetZOrder being asynchronous, spin lock is added. The spin lock itself is set with a timeout escape time of 3 seconds while(true){ - bool isFinished = Session1->GetZOrder != 0 && Session2->GetZOrder != 0; + bool isFinished = Session1->GetZOrder() != 0 && Session2->GetZOrder() != 0; if(isFinished){ break; } From 8d8a055c84aa945415159e65e84db1e8b6765379 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 07:38:59 +0000 Subject: [PATCH 15/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c1e11cf603..35df5a7cda 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10220,7 +10220,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v sceneSession->SetPcScenePanel(true); } unint newZOrder = i + startZOrder; - if(SceneSession->GetZOrder()!=newZOrder){ + if(sceneSession->GetZOrder()!=newZOrder){ sceneSession->SetZOrder(newZOrder); TLOGI(WmsLogTag::WMS_SCB, "SetZOrder persistentId:%{public}d", persistentId); } From 893d930ccf8c46674a2b848790df559bfee2b373 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 09:01:28 +0000 Subject: [PATCH 16/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E9=9C=80?= =?UTF-8?q?=E6=B1=82=20=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/include/scene_session_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index d1f8b201f5..9d0198c734 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -377,7 +377,7 @@ public: WMError TerminateSessionByPersistentId(int32_t persistentId); WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, const std::vector& persistentIds, std::vector& surfaceNodeIds) override; - void RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds) + void RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds); protected: SceneSessionManager(); From 561be8ca6f367c48d130e295879f0b9e8aadc37f Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 09:06:06 +0000 Subject: [PATCH 17/86] =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index a01c4956e9..a7b3994402 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -633,9 +633,9 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest |Level3 } std::this_thread::sleep_for(std:chrono:milliseconds(100)); } - ASSERT_EQ(session1->GetZOrder(),100); - ASSERT_EQ(session1->GetZOrder(),101); - ASSERT_EQ(session1->GetZOrder(),404); + ASSERT_EQ(session1->GetZOrder(), 100); + ASSERT_EQ(session1->GetZOrder(), 101); + ASSERT_EQ(session1->GetZOrder(), 404); } } } // namespace Rosen From 5ca0989c0a248a5bbc28fc981cf9495bb575e7f4 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 09:20:19 +0000 Subject: [PATCH 18/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/include/scene_session.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 9439c3c374..fb8dd8a198 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -392,10 +392,10 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; - bool GetPcScenePanel(){ + bool GetPcScenePanel() { return isPcScenePanel_; } - void SetPcScenePanel(bool isPcScenePanel){ + void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; } From d5020acdf9e98c7f1fc417c77e55a8e296e917f6 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 09:24:47 +0000 Subject: [PATCH 19/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 6c9557a199..b3a6ffaaf2 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2982,7 +2982,7 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_ return NapiGetUndefined(env); } std::vector perisistendIds; - if (!ConvertInt32ArrayFromJs(env, argv[1], perisistendIds)){ + if (!ConvertInt32ArrayFromJs(env, argv[1], perisistendIds)) { TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert perisistendIds to %{public}d", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); From 9b43d25d3ae069710e904f1d5cd7219a1a800a64 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 09:26:27 +0000 Subject: [PATCH 20/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index a7b3994402..34116f459c 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -595,7 +595,7 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function | ssm_->RecoverAndReconnectSceneSession(nullptr, nullptr, nullptr, session, property, nullptr); } -HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest |Level3){ +HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level3){ vector persistentIds; SessionInfo info1, info2, info3; info1.abilityName_ = "RefreshPcZorder1"; From 44a06d56314318ed2d01e0c757d7e22a08452991 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 09:26:40 +0000 Subject: [PATCH 21/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../session_manager/src/scene_session_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 35df5a7cda..87b7e57336 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10202,12 +10202,12 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds) { idListMap_.erase(startZOrder); - idListMap_.insert({startZOrder, persistentId}); + idListMap_.insert({startZOrder, persistentIds}); std::ostringstream oss; oss << "["; for(size_t i = 0; i < persistentIds.size(); i++){ int32_t persistentId = persistentId[i]; - oss << persistentId; + oss << persistentIds; auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { TLOGE(WmsLogTag::WMS_SCB, "sceneScene is nullptr persistentId = %{public}d", persistentId); @@ -10219,7 +10219,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v if (!sceneSession->GetPcScenePanel()){ sceneSession->SetPcScenePanel(true); } - unint newZOrder = i + startZOrder; + uint32_t newZOrder = i + startZOrder; if(sceneSession->GetZOrder()!=newZOrder){ sceneSession->SetZOrder(newZOrder); TLOGI(WmsLogTag::WMS_SCB, "SetZOrder persistentId:%{public}d", persistentId); @@ -10228,6 +10228,6 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v oss << ","; } } - TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}d", persistentId); + TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}d", oss.str().c_str()); } } // namespace OHOS::Rosen From 556c69a6411e9794d7843f63126706fc4a5e212f Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 09:34:40 +0000 Subject: [PATCH 22/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/src/scene_session.cpp | 2 +- .../test/unittest/scene_session_manager_test9.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 5a70961310..db346600a8 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4307,7 +4307,7 @@ uint32_t SceneSession::UpdateUIParam(const SessionUIParam& uiParam) dirtyFlags_ |= UpdateScaleInner(uiParam.scaleX_, uiParam.scaleY_, uiParam.pivotX_, uiParam.pivotY_) ? static_cast(SessionUIDirtyFlag::SCALE) : 0; if (!isPcScenePanel_) { - dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : 0; + dirtyFlags_ |= UpdateZOrderInner(uiParam.zOrder_) ? static_cast(SessionUIDirtyFlag::Z_ORDER) : 0; } if (!lastVisible && IsVisible() && !isFocused_ && !postProcessFocusState_.enabled_ && GetForegroundInteractiveStatus()) { diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 34116f459c..0949694415 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -620,15 +620,16 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level ssm_->sceneSessionMap_.insert({session3->GetPersistentId, session3}); ssm_->RefreshPcZorder(startZOrder, persistentIds); auto start = std::chrono::system_clock::now(); - // Due to SetZOrder being asynchronous, spin lock is added. The spin lock itself is set with a timeout escape time of 3 seconds - while(true){ + // Due to SetZOrder being asynchronous, spin lock is added. + // The spin lock itself is set with a timeout escape time of 3 seconds + while(true) { bool isFinished = Session1->GetZOrder() != 0 && Session2->GetZOrder() != 0; - if(isFinished){ + if(isFinished) { break; } auto now = std::chrono::system_clock:now; auto elapsed = std::chrono:duration_cast(now - start); - if (elapsed >= 3){ + if (elapsed >= 3) { break; } std::this_thread::sleep_for(std:chrono:milliseconds(100)); From 169d2b0f30dac9b1bf5aba3c5965ea13dd2da423 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 10:29:57 +0000 Subject: [PATCH 23/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../session/host/include/scene_session.h | 6 ++-- .../src/scene_session_manager.cpp | 1 + .../unittest/scene_session_manager_test9.cpp | 31 +++++++++++-------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index fb8dd8a198..a3ccfdb945 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -392,10 +392,12 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; - bool GetPcScenePanel() { + bool GetPcScenePanel() + { return isPcScenePanel_; } - void SetPcScenePanel(bool isPcScenePanel) { + void SetPcScenePanel(bool isPcScenePanel) + { isPcScenePanel_ = isPcScenePanel; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 87b7e57336..58927c1dbb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10228,6 +10228,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v oss << ","; } } + oss << "["; TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}d", oss.str().c_str()); } } // namespace OHOS::Rosen diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 0949694415..e03247a209 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -595,6 +595,11 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function | ssm_->RecoverAndReconnectSceneSession(nullptr, nullptr, nullptr, session, property, nullptr); } +/** + * @tc.name: RefreshPcZorder + * @tc.desc: RefreshPcZorder + * @tc.type: FUNC + */ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level3){ vector persistentIds; SessionInfo info1, info2, info3; @@ -608,35 +613,35 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level sptr session1 = new (std::nothrow)SceneSession(info1, nullptr); ASSERT_NE(session1, nullptr); persistentIds.push_back(session1->GetPersistentId()); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId, sceneSession1}); + ssm_->sceneSessionMap_.insert({session1->GetPersistentId(), session1}); sptr session2 = new (std::nothrow)SceneSession(info2, nullptr); ASSERT_NE(session2, nullptr); persistentIds.push_back(session2->GetPersistentId()); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId, sceneSession2}); + ssm_->sceneSessionMap_.insert({session2->GetPersistentId(), session2}); sptr session3 = new (std::nothrow)SceneSession(info3, nullptr); ASSERT_NE(session3, nullptr); persistentIds.push_back(999); session3->SetZOrder(404); - ssm_->sceneSessionMap_.insert({session3->GetPersistentId, session3}); - ssm_->RefreshPcZorder(startZOrder, persistentIds); + ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); + ssm_->RefreshPcZOrderList(startZOrder, persistentIds); auto start = std::chrono::system_clock::now(); - // Due to SetZOrder being asynchronous, spin lock is added. + // Due to SetZOrder being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds - while(true) { - bool isFinished = Session1->GetZOrder() != 0 && Session2->GetZOrder() != 0; - if(isFinished) { + while (true) { + bool isFinished = session1->GetZOrder() != 0 && session2->GetZOrder() != 0; + if (isFinished) { break; } - auto now = std::chrono::system_clock:now; - auto elapsed = std::chrono:duration_cast(now - start); + auto now = std::chrono::system_clock::now(); + auto elapsed = std::chrono::duration_cast(now - start).count(); if (elapsed >= 3) { break; } - std::this_thread::sleep_for(std:chrono:milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } ASSERT_EQ(session1->GetZOrder(), 100); - ASSERT_EQ(session1->GetZOrder(), 101); - ASSERT_EQ(session1->GetZOrder(), 404); + ASSERT_EQ(session2->GetZOrder(), 101); + ASSERT_EQ(session3->GetZOrder(), 404); } } } // namespace Rosen From bbd1494c8ec67cfe3bdcd5a3fa1dd573b027f3a2 Mon Sep 17 00:00:00 2001 From: flybear Date: Sat, 24 Aug 2024 10:45:11 +0000 Subject: [PATCH 24/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 58927c1dbb..69aef83a18 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10206,8 +10206,8 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v std::ostringstream oss; oss << "["; for(size_t i = 0; i < persistentIds.size(); i++){ - int32_t persistentId = persistentId[i]; - oss << persistentIds; + int32_t persistentId = persistentIds[i]; + oss << persistentId; auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { TLOGE(WmsLogTag::WMS_SCB, "sceneScene is nullptr persistentId = %{public}d", persistentId); @@ -10229,6 +10229,6 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v } } oss << "["; - TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}d", oss.str().c_str()); + TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}s", oss.str().c_str()); } } // namespace OHOS::Rosen From be67317b192cfe6cbe2b45a4f9607629a7512855 Mon Sep 17 00:00:00 2001 From: flybear Date: Mon, 26 Aug 2024 01:47:20 +0000 Subject: [PATCH 25/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index e03247a209..82bb8b0b28 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -600,7 +600,7 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function | * @tc.desc: RefreshPcZorder * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level3){ +HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level3) { vector persistentIds; SessionInfo info1, info2, info3; info1.abilityName_ = "RefreshPcZorder1"; From 4ab23d4aaaec2813974ff2352e29e89c48302206 Mon Sep 17 00:00:00 2001 From: flybear Date: Mon, 26 Aug 2024 02:05:00 +0000 Subject: [PATCH 26/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 69aef83a18..ef0660c94b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10228,7 +10228,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v oss << ","; } } - oss << "["; + oss << "]"; TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}s", oss.str().c_str()); } } // namespace OHOS::Rosen From 0981be2f54bd9a85ddf6f345473a3dd480b6f6f4 Mon Sep 17 00:00:00 2001 From: flybear Date: Mon, 26 Aug 2024 03:24:08 +0000 Subject: [PATCH 27/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../scene_session_manager/js_scene_session_manager.cpp | 8 ++++---- .../session_manager/src/scene_session_manager.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index b3a6ffaaf2..d60dcaba40 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -902,7 +902,7 @@ napi_value JsSceneSessionManager::IsScbCoreEnabled(napi_env env, napi_callback_i napi_value JsSceneSessionManager::RefreshPcZOrder(napi_env env, napi_callback_info info) { - TLOGD(WmsLogTag::WMS_SCB, "[NAPI]"); + TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]"); JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnRefreshPcZOrder(env, info) : nullptr; } @@ -2969,21 +2969,21 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_ napi_value argv[4]; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_TWO) { - TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } uint32_t startZOrder; if (!ConvertFromJsValue(env, argv[0], startZOrder)) { - TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert startZOrder to %{public}d", argc); + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert startZOrder to %{public}d", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } std::vector perisistendIds; if (!ConvertInt32ArrayFromJs(env, argv[1], perisistendIds)) { - TLOGE(WmsLogTag::WMS_SCB, "[NAPI]Failed to convert perisistendIds to %{public}d", argc); + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert perisistendIds to %{public}d", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index ef0660c94b..5b4a508b9d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10210,7 +10210,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v oss << persistentId; auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { - TLOGE(WmsLogTag::WMS_SCB, "sceneScene is nullptr persistentId = %{public}d", persistentId); + TLOGE(WmsLogTag::WMS_LAYOUT, "sceneScene is nullptr persistentId = %{public}d", persistentId); if(i < persistentIds.size() - 1){ oss << ","; } @@ -10222,13 +10222,13 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v uint32_t newZOrder = i + startZOrder; if(sceneSession->GetZOrder()!=newZOrder){ sceneSession->SetZOrder(newZOrder); - TLOGI(WmsLogTag::WMS_SCB, "SetZOrder persistentId:%{public}d", persistentId); + TLOGI(WmsLogTag::WMS_LAYOUT, "SetZOrder persistentId:%{public}d", persistentId); } if(i < persistentIds.size() - 1){ oss << ","; } } oss << "]"; - TLOGI(WmsLogTag::WMS_SCB, "RefreshPcZOrderList Complete:%{public}s", oss.str().c_str()); + TLOGI(WmsLogTag::WMS_LAYOUT, "RefreshPcZOrderList Complete:%{public}s", oss.str().c_str()); } } // namespace OHOS::Rosen From e86d6b80e449d2fc43bc8dbf8bfc2388b05d9f6b Mon Sep 17 00:00:00 2001 From: flybear Date: Mon, 26 Aug 2024 03:42:48 +0000 Subject: [PATCH 28/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 4 ++-- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index d60dcaba40..a85a50f475 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2965,8 +2965,8 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info) { - size_t argc = 4; - napi_value argv[4]; + size_t argc = 2; + napi_value argv[2]; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_TWO) { TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index a3ccfdb945..f5c26d8a84 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -583,7 +583,7 @@ private: bool isMinimizedByUserSwitch_ { false }; // pc scene panel is used to determine whether the freshPcZOrder method is used to process the layer - bool isPcScenePanel_ {false}; + bool isPcScenePanel_ { false }; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5b4a508b9d..583ba1919e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10220,7 +10220,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v sceneSession->SetPcScenePanel(true); } uint32_t newZOrder = i + startZOrder; - if(sceneSession->GetZOrder()!=newZOrder){ + if(sceneSession->GetZOrder() != newZOrder){ sceneSession->SetZOrder(newZOrder); TLOGI(WmsLogTag::WMS_LAYOUT, "SetZOrder persistentId:%{public}d", persistentId); } @@ -10229,6 +10229,6 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v } } oss << "]"; - TLOGI(WmsLogTag::WMS_LAYOUT, "RefreshPcZOrderList Complete:%{public}s", oss.str().c_str()); + TLOGI(WmsLogTag::WMS_LAYOUT, "Complete:%{public}s", oss.str().c_str()); } } // namespace OHOS::Rosen From 87ea4636d4b7aebbba5b22ea43e24285264b568d Mon Sep 17 00:00:00 2001 From: flybear Date: Mon, 26 Aug 2024 03:45:17 +0000 Subject: [PATCH 29/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 583ba1919e..41e452b7da 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10205,7 +10205,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v idListMap_.insert({startZOrder, persistentIds}); std::ostringstream oss; oss << "["; - for(size_t i = 0; i < persistentIds.size(); i++){ + for(size_t i = 0; i < persistentIds.size(); i++) { int32_t persistentId = persistentIds[i]; oss << persistentId; auto sceneSession = GetSceneSession(persistentId); @@ -10216,7 +10216,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v } continue; } - if (!sceneSession->GetPcScenePanel()){ + if (!sceneSession->GetPcScenePanel()) { sceneSession->SetPcScenePanel(true); } uint32_t newZOrder = i + startZOrder; @@ -10224,7 +10224,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v sceneSession->SetZOrder(newZOrder); TLOGI(WmsLogTag::WMS_LAYOUT, "SetZOrder persistentId:%{public}d", persistentId); } - if(i < persistentIds.size() - 1){ + if(i < persistentIds.size() - 1) { oss << ","; } } From fd885cbf104d32ffa12c72ae0cd7f9b53898f680 Mon Sep 17 00:00:00 2001 From: flybear Date: Mon, 26 Aug 2024 03:50:44 +0000 Subject: [PATCH 30/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../session_manager/src/scene_session_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 41e452b7da..41d4f9ed89 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10205,13 +10205,13 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v idListMap_.insert({startZOrder, persistentIds}); std::ostringstream oss; oss << "["; - for(size_t i = 0; i < persistentIds.size(); i++) { + for (size_t i = 0; i < persistentIds.size(); i++) { int32_t persistentId = persistentIds[i]; oss << persistentId; auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "sceneScene is nullptr persistentId = %{public}d", persistentId); - if(i < persistentIds.size() - 1){ + if(i < persistentIds.size() - 1) { oss << ","; } continue; @@ -10220,11 +10220,11 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v sceneSession->SetPcScenePanel(true); } uint32_t newZOrder = i + startZOrder; - if(sceneSession->GetZOrder() != newZOrder){ + if (sceneSession->GetZOrder() != newZOrder) { sceneSession->SetZOrder(newZOrder); TLOGI(WmsLogTag::WMS_LAYOUT, "SetZOrder persistentId:%{public}d", persistentId); } - if(i < persistentIds.size() - 1) { + if (i < persistentIds.size() - 1) { oss << ","; } } From 988c4e4e632f7e5e8108a1d345fbd6da8fb16c44 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 06:20:04 +0000 Subject: [PATCH 31/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/scene_session_test4.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 6a181092c8..d22f44dcf4 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -600,6 +600,10 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest property->SetSystemCalling(true); EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); + + sceneSession->property_ = property; + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); property->SetSystemCalling(false); EXPECT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, sceneSession->ProcessUpdatePropertyByAction(property, @@ -609,6 +613,10 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); + sceneSession->property_ = property; + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS)); @@ -637,7 +645,7 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest * @tc.name: HandleSpecificSystemBarProperty * @tc.desc: HandleSpecificSystemBarProperty * @tc.type: FUNC -*/ + */ HWTEST_F(SceneSessionTest4, HandleSpecificSystemBarProperty, Function | SmallTest | Level2) { SessionInfo info; @@ -655,7 +663,7 @@ HWTEST_F(SceneSessionTest4, HandleSpecificSystemBarProperty, Function | SmallTes * @tc.name: SetWindowFlags1 * @tc.desc: SetWindowFlags1 * @tc.type: FUNC -*/ + */ HWTEST_F(SceneSessionTest4, SetWindowFlags1, Function | SmallTest | Level2) { SessionInfo info; From b5546b22cc4cf34fb96b0172fcd2000eab97323b Mon Sep 17 00:00:00 2001 From: flybear Date: Tue, 27 Aug 2024 07:49:09 +0000 Subject: [PATCH 32/86] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 05f05660c1..c1cc5463c3 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -631,6 +631,7 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level ASSERT_EQ(session3->GetZOrder(), 404); } +/** * @tc.name: GetSessionRSVisible * @tc.desc: GetSessionRSVisible * @tc.type: FUNC From 500296f58907b57fd9f19651bf552294e3f522fc Mon Sep 17 00:00:00 2001 From: flybear Date: Tue, 27 Aug 2024 08:36:36 +0000 Subject: [PATCH 33/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../src/scene_session_manager.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 745ea0dbe4..bfd13dce4c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10184,25 +10184,21 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v for (size_t i = 0; i < persistentIds.size(); i++) { int32_t persistentId = persistentIds[i]; oss << persistentId; + if(i < persistentIds.size() - 1) { + oss << ","; + } auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "sceneScene is nullptr persistentId = %{public}d", persistentId); - if(i < persistentIds.size() - 1) { - oss << ","; - } continue; } - if (!sceneSession->GetPcScenePanel()) { - sceneSession->SetPcScenePanel(true); + sceneSession->SetPcScenePanel(true); + if (i > UINT32_MAX - startZOrder) { + TLOGE(WmsLogTag::WMS_LAYOUT, "newStartZOrder overflow,stop refresh"); + break; } uint32_t newZOrder = i + startZOrder; - if (sceneSession->GetZOrder() != newZOrder) { - sceneSession->SetZOrder(newZOrder); - TLOGI(WmsLogTag::WMS_LAYOUT, "SetZOrder persistentId:%{public}d", persistentId); - } - if (i < persistentIds.size() - 1) { - oss << ","; - } + sceneSession->SetZOrder(newZOrder); } oss << "]"; TLOGI(WmsLogTag::WMS_LAYOUT, "Complete:%{public}s", oss.str().c_str()); From 973866869098c1989192b0488228e002c2b7bec7 Mon Sep 17 00:00:00 2001 From: flybear Date: Tue, 27 Aug 2024 08:47:00 +0000 Subject: [PATCH 34/86] =?UTF-8?q?pc=E6=89=A9=E5=B1=95=E5=B1=8F=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index c1cc5463c3..f0cefdf46d 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -611,6 +611,7 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level session3->SetZOrder(404); ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); ssm_->RefreshPcZOrderList(startZOrder, persistentIds); + ssm_->RefreshPcZOrderList(UINT32_MAX, persistentIds); auto start = std::chrono::system_clock::now(); // Due to SetZOrder being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds From 33985cf25916a6e57afcee54999698624574b8a3 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:12:53 +0000 Subject: [PATCH 35/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index a4d1c4d324..d5c033d475 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -981,6 +981,60 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2) EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr)); } +/** + * @tc.name: RectCheckProcess01 + * @tc.desc: RectCheckProcess01 Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + session_->state_ = SessionState::STATE_INACTIVE; + session_->isVisible_ = false; + session_->property_ = nullptr; + session_->RectCheckProcess(); + + session_->state_ = SessionState::STATE_ACTIVE; + session_->isVisible_ = true; + session_->property_ = sptr::MakeSptr(); + session_->RectCheckProcess(); + + session_->property_->displayId_ = 0; + sptr screenSession = new ScreenSession(0, ScreenProperty(), 0); + ASSERT_NE(screenSession, nullptr); + ScreenProperty screenProperty = screenSession->GetScreenProperty(); + ASSERT_NE(&screenProperty, nullptr); + screenSession->screenId_ = 0; + screenSession->SetVirtualPixelRatio(0.0f); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); + session_->RectCheckProcess(); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); + screenSession->SetVirtualPixelRatio(1.0f); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); + session_->RectCheckProcess(); + + session_->winRect_.height_ = 0; + session_->RectCheckProcess(); + + session_->winRect_.height_ = 200; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 0.0f; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 0.5f; + session_->RectCheckProcess(); + + session_->winRect_.width_ = 200; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 1.0f; + session_->RectCheckProcess(); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); +} + /** * @tc.name: SetIsPcAppInPad * @tc.desc: SetIsPcAppInPad Test From 68accfc53c37f21c60d4f5344c79b57d138e2178 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:19:10 +0000 Subject: [PATCH 36/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index d5c033d475..cf4910655e 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1014,7 +1014,8 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); session_->RectCheckProcess(); - session_->winRect_.height_ = 0; + WsRect rect = {0, 0, 0, 0}; + session_->winRect_ = rect; session_->RectCheckProcess(); session_->winRect_.height_ = 200; From b0124b5aeed205790ff0ef466a213d78da39f0f4 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:24:00 +0000 Subject: [PATCH 37/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index cf4910655e..0d6cae3d82 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1001,9 +1001,9 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) session_->property_->displayId_ = 0; sptr screenSession = new ScreenSession(0, ScreenProperty(), 0); - ASSERT_NE(screenSession, nullptr); + ASSERT_NE(screenSession, nullptr); ScreenProperty screenProperty = screenSession->GetScreenProperty(); - ASSERT_NE(&screenProperty, nullptr); + ASSERT_NE(&screenProperty, nullptr); screenSession->screenId_ = 0; screenSession->SetVirtualPixelRatio(0.0f); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); From d4c72de6c39fd2c9a934f6711aa3e4bb4b878616 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:27:09 +0000 Subject: [PATCH 38/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 0d6cae3d82..ab8fd68edd 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -28,6 +28,8 @@ #include "session/host/include/session.h" #include "session_manager/include/scene_session_manager.h" #include "session_info.h" +#include "session/screen/include/screen_session.h" +#include "screen_session_manager/include/screen_session_manager_client" #include "wm_common.h" #include "window_manager_hilog.h" @@ -1014,7 +1016,7 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); session_->RectCheckProcess(); - WsRect rect = {0, 0, 0, 0}; + WSRect rect = {0, 0, 0, 0}; session_->winRect_ = rect; session_->RectCheckProcess(); From 9570db55ed3f82e85d37c42b79fded7b6114081d Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:32:30 +0000 Subject: [PATCH 39/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 55 -------------------- 1 file changed, 55 deletions(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index ab8fd68edd..63dd5d99ba 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -983,61 +983,6 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2) EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr)); } -/** - * @tc.name: RectCheckProcess01 - * @tc.desc: RectCheckProcess01 Test - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) -{ - ASSERT_NE(session_, nullptr); - session_->state_ = SessionState::STATE_INACTIVE; - session_->isVisible_ = false; - session_->property_ = nullptr; - session_->RectCheckProcess(); - - session_->state_ = SessionState::STATE_ACTIVE; - session_->isVisible_ = true; - session_->property_ = sptr::MakeSptr(); - session_->RectCheckProcess(); - - session_->property_->displayId_ = 0; - sptr screenSession = new ScreenSession(0, ScreenProperty(), 0); - ASSERT_NE(screenSession, nullptr); - ScreenProperty screenProperty = screenSession->GetScreenProperty(); - ASSERT_NE(&screenProperty, nullptr); - screenSession->screenId_ = 0; - screenSession->SetVirtualPixelRatio(0.0f); - ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); - session_->RectCheckProcess(); - - ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); - screenSession->SetVirtualPixelRatio(1.0f); - ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); - session_->RectCheckProcess(); - - WSRect rect = {0, 0, 0, 0}; - session_->winRect_ = rect; - session_->RectCheckProcess(); - - session_->winRect_.height_ = 200; - session_->RectCheckProcess(); - - session_->aspectRatio_ = 0.0f; - session_->RectCheckProcess(); - - session_->aspectRatio_ = 0.5f; - session_->RectCheckProcess(); - - session_->winRect_.width_ = 200; - session_->RectCheckProcess(); - - session_->aspectRatio_ = 1.0f; - session_->RectCheckProcess(); - - ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); -} - /** * @tc.name: SetIsPcAppInPad * @tc.desc: SetIsPcAppInPad Test From 523a356989ee7b8e8d474b12adb46030ebef6cf0 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:32:49 +0000 Subject: [PATCH 40/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 63dd5d99ba..e394d3b90a 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -983,6 +983,62 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2) EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr)); } + +/** + * @tc.name: RectCheckProcess01 + * @tc.desc: RectCheckProcess01 Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + session_->state_ = SessionState::STATE_INACTIVE; + session_->isVisible_ = false; + session_->property_ = nullptr; + session_->RectCheckProcess(); + + session_->state_ = SessionState::STATE_ACTIVE; + session_->isVisible_ = true; + session_->property_ = sptr::MakeSptr(); + session_->RectCheckProcess(); + + session_->property_->displayId_ = 0; + sptr screenSession = new ScreenSession(0, ScreenProperty(), 0); + ASSERT_NE(screenSession, nullptr); + ScreenProperty screenProperty = screenSession->GetScreenProperty(); + ASSERT_NE(&screenProperty, nullptr); + screenSession->screenId_ = 0; + screenSession->SetVirtualPixelRatio(0.0f); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); + session_->RectCheckProcess(); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); + screenSession->SetVirtualPixelRatio(1.0f); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); + session_->RectCheckProcess(); + + WSRect rect = {0, 0, 0, 0}; + session_->winRect_ = rect; + session_->RectCheckProcess(); + + session_->winRect_.height_ = 200; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 0.0f; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 0.5f; + session_->RectCheckProcess(); + + session_->winRect_.width_ = 200; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 1.0f; + session_->RectCheckProcess(); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); +} + /** * @tc.name: SetIsPcAppInPad * @tc.desc: SetIsPcAppInPad Test From 1c57e5f9f5e9d2e437c7dbc452b6972d040f02cb Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:33:13 +0000 Subject: [PATCH 41/86] add test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 56 -------------------- 1 file changed, 56 deletions(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index e394d3b90a..63dd5d99ba 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -983,62 +983,6 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2) EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr)); } - -/** - * @tc.name: RectCheckProcess01 - * @tc.desc: RectCheckProcess01 Test - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) -{ - ASSERT_NE(session_, nullptr); - session_->state_ = SessionState::STATE_INACTIVE; - session_->isVisible_ = false; - session_->property_ = nullptr; - session_->RectCheckProcess(); - - session_->state_ = SessionState::STATE_ACTIVE; - session_->isVisible_ = true; - session_->property_ = sptr::MakeSptr(); - session_->RectCheckProcess(); - - session_->property_->displayId_ = 0; - sptr screenSession = new ScreenSession(0, ScreenProperty(), 0); - ASSERT_NE(screenSession, nullptr); - ScreenProperty screenProperty = screenSession->GetScreenProperty(); - ASSERT_NE(&screenProperty, nullptr); - screenSession->screenId_ = 0; - screenSession->SetVirtualPixelRatio(0.0f); - ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); - session_->RectCheckProcess(); - - ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); - screenSession->SetVirtualPixelRatio(1.0f); - ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); - session_->RectCheckProcess(); - - WSRect rect = {0, 0, 0, 0}; - session_->winRect_ = rect; - session_->RectCheckProcess(); - - session_->winRect_.height_ = 200; - session_->RectCheckProcess(); - - session_->aspectRatio_ = 0.0f; - session_->RectCheckProcess(); - - session_->aspectRatio_ = 0.5f; - session_->RectCheckProcess(); - - session_->winRect_.width_ = 200; - session_->RectCheckProcess(); - - session_->aspectRatio_ = 1.0f; - session_->RectCheckProcess(); - - ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); -} - /** * @tc.name: SetIsPcAppInPad * @tc.desc: SetIsPcAppInPad Test From 388c038823e6c2b86f81ada223ce7d4e87644fb2 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:33:31 +0000 Subject: [PATCH 42/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 55 ++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 63dd5d99ba..ab8fd68edd 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -983,6 +983,61 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2) EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr)); } +/** + * @tc.name: RectCheckProcess01 + * @tc.desc: RectCheckProcess01 Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest3, RectCheckProcess01, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + session_->state_ = SessionState::STATE_INACTIVE; + session_->isVisible_ = false; + session_->property_ = nullptr; + session_->RectCheckProcess(); + + session_->state_ = SessionState::STATE_ACTIVE; + session_->isVisible_ = true; + session_->property_ = sptr::MakeSptr(); + session_->RectCheckProcess(); + + session_->property_->displayId_ = 0; + sptr screenSession = new ScreenSession(0, ScreenProperty(), 0); + ASSERT_NE(screenSession, nullptr); + ScreenProperty screenProperty = screenSession->GetScreenProperty(); + ASSERT_NE(&screenProperty, nullptr); + screenSession->screenId_ = 0; + screenSession->SetVirtualPixelRatio(0.0f); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); + session_->RectCheckProcess(); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); + screenSession->SetVirtualPixelRatio(1.0f); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); + session_->RectCheckProcess(); + + WSRect rect = {0, 0, 0, 0}; + session_->winRect_ = rect; + session_->RectCheckProcess(); + + session_->winRect_.height_ = 200; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 0.0f; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 0.5f; + session_->RectCheckProcess(); + + session_->winRect_.width_ = 200; + session_->RectCheckProcess(); + + session_->aspectRatio_ = 1.0f; + session_->RectCheckProcess(); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); +} + /** * @tc.name: SetIsPcAppInPad * @tc.desc: SetIsPcAppInPad Test From ad594220ff1dcb6bb135e1286ab6f483c37b9378 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 09:39:12 +0000 Subject: [PATCH 43/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_test3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index ab8fd68edd..0f1dabc963 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -29,7 +29,7 @@ #include "session_manager/include/scene_session_manager.h" #include "session_info.h" #include "session/screen/include/screen_session.h" -#include "screen_session_manager/include/screen_session_manager_client" +#include "screen_session_manager/include/screen_session_manager_client.h" #include "wm_common.h" #include "window_manager_hilog.h" From 216e1aaa420fafc7defbdbed23812d806dbb4d70 Mon Sep 17 00:00:00 2001 From: flybear Date: Tue, 27 Aug 2024 10:58:29 +0000 Subject: [PATCH 44/86] =?UTF-8?q?pc=20=E6=89=A9=E5=B1=95=E5=B1=8F=20?= =?UTF-8?q?=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 4 ++-- window_scene/test/unittest/scene_session_manager_test9.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index a85a50f475..8498f9b80e 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2976,14 +2976,14 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_ } uint32_t startZOrder; if (!ConvertFromJsValue(env, argv[0], startZOrder)) { - TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert startZOrder to %{public}d", argc); + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert startZOrder to %{public}d", startZOrder); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } std::vector perisistendIds; if (!ConvertInt32ArrayFromJs(env, argv[1], perisistendIds)) { - TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert perisistendIds to %{public}d", argc); + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert perisistendIds"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index f0cefdf46d..a2ac6908d8 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -616,7 +616,7 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level // Due to SetZOrder being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds while (true) { - bool isFinished = session1->GetZOrder() != 0 && session2->GetZOrder() != 0; + bool isFinished = session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100; if (isFinished) { break; } @@ -627,9 +627,9 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } - ASSERT_EQ(session1->GetZOrder(), 100); ASSERT_EQ(session2->GetZOrder(), 101); ASSERT_EQ(session3->GetZOrder(), 404); + ASSERT_EQ(session1->GetZOrder(), UINT32_MAX); } /** From c71a3320e0efb018a75b649cb36cdc2ffd9a35fc Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 11:41:25 +0000 Subject: [PATCH 45/86] add tdd test Signed-off-by: cuiyongzhe --- .../test/unittest/scene_session_test4.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index d22f44dcf4..6b934d2ac5 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -571,6 +571,11 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction2, Function | SmallTest WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); property->SetSystemCalling(true); + sceneSession->property_ = property; + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); + + sceneSession->property_ = nullptr; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); } @@ -589,7 +594,11 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest ASSERT_NE(nullptr, sceneSession); sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(nullptr, property); + sceneSession->property_ = property; + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); + sceneSession->property_ = nullptr; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); @@ -598,10 +607,11 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); property->SetSystemCalling(true); + sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); - sceneSession->property_ = property; + sceneSession->property_ = nullptr; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); @@ -610,13 +620,18 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); property->SetSystemCalling(true); - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); - sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); + sceneSession->property_ = nullptr; + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS)); + + sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS)); From 0e26ad1bd2e68c0cf456143e3d730a6b02eba489 Mon Sep 17 00:00:00 2001 From: flybear Date: Tue, 27 Aug 2024 11:49:53 +0000 Subject: [PATCH 46/86] =?UTF-8?q?pc=20=E6=89=A9=E5=B1=95=E5=B1=8F=20?= =?UTF-8?q?=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/include/scene_session.h | 4 ---- window_scene/test/unittest/scene_session_manager_test9.cpp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 88ce39a64d..db504ad3de 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -392,10 +392,6 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; - bool GetPcScenePanel() - { - return isPcScenePanel_; - } void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index a2ac6908d8..cbd31aa146 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -616,7 +616,7 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level // Due to SetZOrder being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds while (true) { - bool isFinished = session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100; + bool isFinished = session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100; if (isFinished) { break; } From c230b4d7ef00fba9ffeb8ea7860c83b3f3c59468 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 12:03:30 +0000 Subject: [PATCH 47/86] add tdd test Signed-off-by: cuiyongzhe --- .../test/unittest/scene_session_test4.cpp | 73 ++++++++++++++----- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 6b934d2ac5..6f027ecfba 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -571,11 +571,6 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction2, Function | SmallTest WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); property->SetSystemCalling(true); - sceneSession->property_ = property; - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); - - sceneSession->property_ = nullptr; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); } @@ -594,11 +589,6 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest ASSERT_NE(nullptr, sceneSession); sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(nullptr, property); - sceneSession->property_ = property; - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); - - sceneSession->property_ = nullptr; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); @@ -607,11 +597,10 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); property->SetSystemCalling(true); - sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); - sceneSession->property_ = nullptr; + sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); @@ -620,18 +609,13 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); property->SetSystemCalling(true); + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); + sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); - sceneSession->property_ = nullptr; - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); - - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS)); - - sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS)); @@ -656,6 +640,55 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest WSPropertyChangeAction::ACTION_UPDATE_RECT)); } +/** + * @tc.name: ProcessUpdatePropertyByAction4 + * @tc.desc: ProcessUpdatePropertyByAction4 function + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction4, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "ProcessUpdatePropertyByAction4"; + info.bundleName_ = "ProcessUpdatePropertyByAction4"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(nullptr, sceneSession); + sptr property = new (std::nothrow) WindowSessionProperty(); + ASSERT_NE(nullptr, property); + sceneSession->property_ = property; + property->SetSystemCalling(true); + sceneSession->property_ = property; + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS)); + + sceneSession->property_ = nullptr; + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE)); + + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS)); +} + /** * @tc.name: HandleSpecificSystemBarProperty * @tc.desc: HandleSpecificSystemBarProperty From bf24f53b242250ed21d2aa6990b8d2fb3fb6b064 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 12:05:06 +0000 Subject: [PATCH 48/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/scene_session_test4.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 6f027ecfba..6b1ca888e5 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -657,12 +657,6 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction4, Function | SmallTest sceneSession->property_ = property; property->SetSystemCalling(true); sceneSession->property_ = property; - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED)); - - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED)); - EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); From 600b70ea94cadfcb496f9b96044bba2b31f41f1a Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 12:05:39 +0000 Subject: [PATCH 49/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/scene_session_test4.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 6b1ca888e5..04d2567d23 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -589,6 +589,7 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, Function | SmallTest ASSERT_NE(nullptr, sceneSession); sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(nullptr, property); + EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS)); From 491f0ece7626f76484ad79a62e427a3b294feb81 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Tue, 27 Aug 2024 12:06:16 +0000 Subject: [PATCH 50/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/scene_session_test4.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 04d2567d23..1bac28aa1c 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -655,7 +655,6 @@ HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction4, Function | SmallTest ASSERT_NE(nullptr, sceneSession); sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(nullptr, property); - sceneSession->property_ = property; property->SetSystemCalling(true); sceneSession->property_ = property; EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property, From adea3eeaf4eeabe0c0be82e9b85ad298267859bc Mon Sep 17 00:00:00 2001 From: hxf233333 Date: Fri, 23 Aug 2024 11:34:43 +0800 Subject: [PATCH 51/86] fix: use libdmlite Signed-off-by: hxf233333 --- dm_lite/BUILD.gn | 1 + .../include/display_manager_adapter_lite.h | 27 ++ dm_lite/src/display_manager_adapter_lite.cpp | 89 +++++ dm_lite/src/display_manager_lite.cpp | 162 +++++++++ dm_lite/src/screen_manager_lite.cpp | 59 +++ dm_lite/test/unittest/BUILD.gn | 16 + .../unittest/display_lite_power_unit_test.cpp | 211 +++++++++++ .../display_manager_adapter_lite_test.cpp | 58 +++ .../unittest/display_manager_lite_test.cpp | 13 + .../innerkits/dm_lite/display_manager_lite.h | 81 +++++ .../innerkits/dm_lite/screen_manager_lite.h | 64 ++++ .../mock/mock_display_manager_adapter_lite.h | 20 ++ .../include/screen_session_manager_lite.h | 15 + .../screen_session_manager_lite_interface.h | 17 + .../zidl/screen_session_manager_lite_proxy.h | 15 + .../zidl/screen_session_manager_lite_stub.h | 16 + .../src/screen_session_manager_lite.cpp | 108 ++++++ .../screen_session_manager_lite_proxy.cpp | 338 ++++++++++++++++++ .../zidl/screen_session_manager_lite_stub.cpp | 179 +++++++++- ...screen_session_manager_lite_proxy_test.cpp | 96 +++++ 20 files changed, 1567 insertions(+), 18 deletions(-) create mode 100644 dm_lite/src/screen_manager_lite.cpp create mode 100644 dm_lite/test/unittest/display_lite_power_unit_test.cpp create mode 100644 interfaces/innerkits/dm_lite/screen_manager_lite.h diff --git a/dm_lite/BUILD.gn b/dm_lite/BUILD.gn index b2d8317df1..a5c162b640 100644 --- a/dm_lite/BUILD.gn +++ b/dm_lite/BUILD.gn @@ -47,6 +47,7 @@ ohos_shared_library("libdm_lite") { "src/display_lite.cpp", "src/display_manager_adapter_lite.cpp", "src/display_manager_lite.cpp", + "src/screen_manager_lite.cpp", ] configs = [ diff --git a/dm_lite/include/display_manager_adapter_lite.h b/dm_lite/include/display_manager_adapter_lite.h index 154e02dba6..4c0a6ad348 100644 --- a/dm_lite/include/display_manager_adapter_lite.h +++ b/dm_lite/include/display_manager_adapter_lite.h @@ -53,14 +53,41 @@ class DisplayManagerAdapterLite : public BaseAdapterLite { WM_DECLARE_SINGLE_INSTANCE(DisplayManagerAdapterLite); public: virtual sptr GetDefaultDisplayInfo(); + virtual std::vector GetAllDisplayIds(); virtual bool IsFoldable(); virtual FoldStatus GetFoldStatus(); virtual FoldDisplayMode GetFoldDisplayMode(); virtual void SetFoldDisplayMode(const FoldDisplayMode); virtual sptr GetDisplayInfo(DisplayId displayId); virtual sptr GetCutoutInfo(DisplayId displayId); + /* + * used by powermgr + */ + virtual bool WakeUpBegin(PowerStateChangeReason reason); + virtual bool WakeUpEnd(); + virtual bool SuspendBegin(PowerStateChangeReason reason); + virtual bool SuspendEnd(); + virtual bool SetDisplayState(DisplayState state); + virtual DisplayState GetDisplayState(DisplayId displayId); + virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level); + virtual uint32_t GetScreenBrightness(uint64_t screenId); private: static inline SingletonDelegator delegator; }; + +class ScreenManagerAdapterLite : public BaseAdapterLite { +WM_DECLARE_SINGLE_INSTANCE(ScreenManagerAdapterLite); +public: + /* + * used by powermgr + */ + virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason); + virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); + virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId); +private: + static inline SingletonDelegator delegator; +}; + + } // namespace OHOS::Rosen #endif // FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_LITE_H diff --git a/dm_lite/src/display_manager_adapter_lite.cpp b/dm_lite/src/display_manager_adapter_lite.cpp index 76b2916e7c..e443d8b9a2 100644 --- a/dm_lite/src/display_manager_adapter_lite.cpp +++ b/dm_lite/src/display_manager_adapter_lite.cpp @@ -29,6 +29,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerAdapterLite"}; } WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAdapterLite) +WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerAdapterLite) #define INIT_PROXY_CHECK_RETURN(ret) \ @@ -157,6 +158,94 @@ sptr DisplayManagerAdapterLite::GetCutoutInfo(DisplayId displayId) return displayManagerServiceProxy_->GetCutoutInfo(displayId); } +/* + * used by powermgr + */ +bool DisplayManagerAdapterLite::WakeUpBegin(PowerStateChangeReason reason) +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->WakeUpBegin(reason); +} + +bool DisplayManagerAdapterLite::WakeUpEnd() +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->WakeUpEnd(); +} + +bool DisplayManagerAdapterLite::SuspendBegin(PowerStateChangeReason reason) +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->SuspendBegin(reason); +} + +bool DisplayManagerAdapterLite::SuspendEnd() +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->SuspendEnd(); +} + +bool DisplayManagerAdapterLite::SetDisplayState(DisplayState state) +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->SetDisplayState(state); +} + +DisplayState DisplayManagerAdapterLite::GetDisplayState(DisplayId displayId) +{ + INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN); + + return displayManagerServiceProxy_->GetDisplayState(displayId); +} + +bool DisplayManagerAdapterLite::SetScreenBrightness(uint64_t screenId, uint32_t level) +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->SetScreenBrightness(screenId, level); +} + +uint32_t DisplayManagerAdapterLite::GetScreenBrightness(uint64_t screenId) +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->GetScreenBrightness(screenId); +} + +std::vector DisplayManagerAdapterLite::GetAllDisplayIds() +{ + WLOGFD("DisplayManagerAdapter::GetAllDisplayIds enter"); + INIT_PROXY_CHECK_RETURN(std::vector()); + + return displayManagerServiceProxy_->GetAllDisplayIds(); +} + +bool ScreenManagerAdapterLite::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, + PowerStateChangeReason reason) +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->SetSpecifiedScreenPower(screenId, state, reason); +} + +bool ScreenManagerAdapterLite::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) +{ + INIT_PROXY_CHECK_RETURN(false); + + return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason); +} + +ScreenPowerState ScreenManagerAdapterLite::GetScreenPower(ScreenId dmsScreenId) +{ + INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE); + + return displayManagerServiceProxy_->GetScreenPower(dmsScreenId); +} DMSDeathRecipientLite::DMSDeathRecipientLite(BaseAdapterLite& adapter) : adapter_(adapter) { diff --git a/dm_lite/src/display_manager_lite.cpp b/dm_lite/src/display_manager_lite.cpp index acd9640931..916b4c0345 100644 --- a/dm_lite/src/display_manager_lite.cpp +++ b/dm_lite/src/display_manager_lite.cpp @@ -49,6 +49,10 @@ public: DMError UnregisterDisplayModeListener(sptr listener); void OnRemoteDied(); sptr GetDisplayById(DisplayId displayId); + /* + * used by powermgr + */ + bool SetDisplayState(DisplayState state, DisplayStateCallback callback); private: void NotifyDisplayCreate(sptr info); void NotifyDisplayDestroy(DisplayId); @@ -56,9 +60,15 @@ private: bool UpdateDisplayInfoLocked(sptr); void NotifyFoldStatusChanged(FoldStatus foldStatus); void NotifyDisplayModeChanged(FoldDisplayMode displayMode); + /* + * used by powermgr + */ + void NotifyDisplayStateChanged(DisplayId id, DisplayState state); + void ClearDisplayStateCallback(); void Clear(); std::map> displayMap_; + DisplayStateCallback displayStateCallback_; std::recursive_mutex& mutex_; std::set> displayListeners_; std::set> foldStatusListeners_; @@ -69,6 +79,11 @@ private: sptr foldStatusListenerAgent_; class DisplayManagerDisplayModeAgent; sptr displayModeListenerAgent_; + /* + * used by powermgr + */ + class DisplayManagerAgent; + sptr displayStateAgent_; }; class DisplayManagerLite::Impl::DisplayManagerListener : public DisplayManagerAgentDefault { @@ -174,6 +189,24 @@ private: sptr pImpl_; }; +/* + * used by powermgr + */ +class DisplayManagerLite::Impl::DisplayManagerAgent : public DisplayManagerAgentDefault { +public: + explicit DisplayManagerAgent(sptr impl) : pImpl_(impl) + { + } + ~DisplayManagerAgent() = default; + + virtual void NotifyDisplayStateChanged(DisplayId id, DisplayState state) override + { + pImpl_->NotifyDisplayStateChanged(id, state); + } +private: + sptr pImpl_; +}; + void DisplayManagerLite::Impl::Clear() { std::lock_guard lock(mutex_); @@ -186,6 +219,7 @@ void DisplayManagerLite::Impl::Clear() if (res != DMError::DM_OK) { WLOGFW("UnregisterDisplayManagerAgent DISPLAY_EVENT_LISTENER failed"); } + ClearDisplayStateCallback(); } DisplayManagerLite::Impl::~Impl() @@ -531,4 +565,132 @@ sptr DisplayManagerLite::GetDisplayById(DisplayId displayId) std::lock_guard lock(mutex_); return pImpl_->GetDisplayById(displayId); } + +/* + * used by powermgr + */ +bool DisplayManagerLite::WakeUpBegin(PowerStateChangeReason reason) +{ + WLOGFD("[UL_POWER]WakeUpBegin start, reason:%{public}u", reason); + return SingletonContainer::Get().WakeUpBegin(reason); +} + +bool DisplayManagerLite::WakeUpEnd() +{ + WLOGFD("[UL_POWER]WakeUpEnd start"); + return SingletonContainer::Get().WakeUpEnd(); +} + +bool DisplayManagerLite::SuspendBegin(PowerStateChangeReason reason) +{ + // dms->wms notify other windows to hide + WLOGFD("[UL_POWER]SuspendBegin start, reason:%{public}u", reason); + return SingletonContainer::Get().SuspendBegin(reason); +} + +bool DisplayManagerLite::SuspendEnd() +{ + WLOGFD("[UL_POWER]SuspendEnd start"); + return SingletonContainer::Get().SuspendEnd(); +} + +bool DisplayManagerLite::SetDisplayState(DisplayState state, DisplayStateCallback callback) +{ + return pImpl_->SetDisplayState(state, callback); +} + +DisplayState DisplayManagerLite::GetDisplayState(DisplayId displayId) +{ + return SingletonContainer::Get().GetDisplayState(displayId); +} + +bool DisplayManagerLite::Impl::SetDisplayState(DisplayState state, DisplayStateCallback callback) +{ + WLOGFD("[UL_POWER]state:%{public}u", state); + bool ret = true; + { + std::lock_guard lock(mutex_); + if (displayStateCallback_ != nullptr || callback == nullptr) { + WLOGFI("[UL_POWER]previous callback not called or callback invalid"); + if (displayStateCallback_ != nullptr) { + WLOGFI("[UL_POWER]previous callback not called, the displayStateCallback_ is not null"); + } + if (callback == nullptr) { + WLOGFI("[UL_POWER]Invalid callback received"); + } + return false; + } + displayStateCallback_ = callback; + + if (displayStateAgent_ == nullptr) { + displayStateAgent_ = new DisplayManagerAgent(this); + ret = SingletonContainer::Get().RegisterDisplayManagerAgent( + displayStateAgent_, + DisplayManagerAgentType::DISPLAY_STATE_LISTENER) == DMError::DM_OK; + } + } + ret = ret && SingletonContainer::Get().SetDisplayState(state); + if (!ret) { + ClearDisplayStateCallback(); + } + return ret; +} + +void DisplayManagerLite::Impl::NotifyDisplayStateChanged(DisplayId id, DisplayState state) +{ + WLOGFD("state:%{public}u", state); + DisplayStateCallback displayStateCallback = nullptr; + { + std::lock_guard lock(mutex_); + displayStateCallback = displayStateCallback_; + } + if (displayStateCallback) { + displayStateCallback(state); + ClearDisplayStateCallback(); + return; + } + WLOGFW("callback_ target is not set!"); +} + +void DisplayManagerLite::Impl::ClearDisplayStateCallback() +{ + std::lock_guard lock(mutex_); + WLOGFD("[UL_POWER]Clear displaystatecallback enter"); + displayStateCallback_ = nullptr; + if (displayStateAgent_ != nullptr) { + WLOGFI("[UL_POWER]UnregisterDisplayManagerAgent enter and displayStateAgent_ is cleared"); + SingletonContainer::Get().UnregisterDisplayManagerAgent(displayStateAgent_, + DisplayManagerAgentType::DISPLAY_STATE_LISTENER); + displayStateAgent_ = nullptr; + } +} + +bool DisplayManagerLite::SetScreenBrightness(uint64_t screenId, uint32_t level) +{ + WLOGFI("[UL_POWER]SetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level); + SingletonContainer::Get().SetScreenBrightness(screenId, level); + return true; +} + +uint32_t DisplayManagerLite::GetScreenBrightness(uint64_t screenId) const +{ + uint32_t level = SingletonContainer::Get().GetScreenBrightness(screenId); + WLOGFI("GetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level); + return level; +} + +DisplayId DisplayManagerLite::GetDefaultDisplayId() +{ + auto info = SingletonContainer::Get().GetDefaultDisplayInfo(); + if (info == nullptr) { + return DISPLAY_ID_INVALID; + } + return info->GetDisplayId(); +} + +std::vector DisplayManagerLite::GetAllDisplayIds() +{ + return SingletonContainer::Get().GetAllDisplayIds(); +} + } // namespace OHOS::Rosen \ No newline at end of file diff --git a/dm_lite/src/screen_manager_lite.cpp b/dm_lite/src/screen_manager_lite.cpp new file mode 100644 index 0000000000..98f93bed51 --- /dev/null +++ b/dm_lite/src/screen_manager_lite.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "screen_manager_lite.h" + +#include "display_manager_adapter_lite.h" +#include "singleton_delegator.h" +#include "window_manager_hilog.h" + +namespace OHOS::Rosen { +namespace { + constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenManagerLite"}; +} + +WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerLite) + +ScreenManagerLite::ScreenManagerLite() +{ + WLOGFD("Create ScreenManagerLite instance"); +} + +ScreenManagerLite::~ScreenManagerLite() +{ + WLOGFD("Destroy ScreenManagerLite instance"); +} + +/* + * used by powermgr + */ +bool ScreenManagerLite::SetSpecifiedScreenPower(ScreenId screenId, + ScreenPowerState state, PowerStateChangeReason reason) +{ + WLOGFI("screenId:%{public}" PRIu64 ", state:%{public}u, reason:%{public}u", screenId, state, reason); + return SingletonContainer::Get().SetSpecifiedScreenPower(screenId, state, reason); +} + +bool ScreenManagerLite::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) +{ + WLOGFI("state:%{public}u, reason:%{public}u", state, reason); + return SingletonContainer::Get().SetScreenPowerForAll(state, reason); +} + +ScreenPowerState ScreenManagerLite::GetScreenPower(ScreenId dmsScreenId) +{ + return SingletonContainer::Get().GetScreenPower(dmsScreenId); +} + +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/dm_lite/test/unittest/BUILD.gn b/dm_lite/test/unittest/BUILD.gn index fba2bc646a..9c5eb9fc93 100644 --- a/dm_lite/test/unittest/BUILD.gn +++ b/dm_lite/test/unittest/BUILD.gn @@ -20,6 +20,7 @@ group("unittest") { testonly = true deps = [ + ":dm_display_lite_power_unit_test", ":dm_display_lite_test", ":dm_display_manager_adapter_lite_test", ":dm_display_manager_lite_test", @@ -72,6 +73,21 @@ ohos_unittest("dm_display_manager_lite_test") { ] } +ohos_unittest("dm_display_lite_power_unit_test") { + module_out_path = module_out_path + + include_dirs = [ "../../src" ] + + sources = [ "display_lite_power_unit_test.cpp" ] + + deps = [ ":dm_unittest_common_lite" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] +} + ## Build dm_unittest_common_lite.a {{{ config("dm_unittest_common_public_config") { include_dirs = [ diff --git a/dm_lite/test/unittest/display_lite_power_unit_test.cpp b/dm_lite/test/unittest/display_lite_power_unit_test.cpp new file mode 100644 index 0000000000..1679b79b93 --- /dev/null +++ b/dm_lite/test/unittest/display_lite_power_unit_test.cpp @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "display_manager_lite.h" +#include "screen_manager_lite.h" +#include "mock_display_manager_adapter_lite.h" +#include "singleton_mocker.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +using Mocker = SingletonMocker; + +class DisplayLitePowerUnitTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + static inline DisplayId defaultId_ = 0; + static inline uint32_t brightnessLevel_ = 80; + static inline ScreenPowerState initialPowerState_; + static inline DisplayState initialState_; +}; + +void DisplayLitePowerUnitTest::SetUpTestCase() +{ +} + +void DisplayLitePowerUnitTest::TearDownTestCase() +{ +} + +void DisplayLitePowerUnitTest::SetUp() +{ + initialPowerState_ = ScreenManagerLite::GetInstance().GetScreenPower(defaultId_); + initialState_ = DisplayManagerLite::GetInstance().GetDisplayState(defaultId_); +} + +void DisplayLitePowerUnitTest::TearDown() +{ + ScreenManagerLite::GetInstance().SetScreenPowerForAll(initialPowerState_, PowerStateChangeReason::POWER_BUTTON); + DisplayStateCallback callback; + DisplayManagerLite::GetInstance().SetDisplayState(initialState_, callback); +} + +namespace { +/** + * @tc.name: wake_up_begin_001 + * @tc.desc: call WakeUpBegin and check return value + * @tc.type: FUNC + */ +HWTEST_F(DisplayLitePowerUnitTest, wake_up_begin_001, Function | SmallTest | Level2) +{ + Mocker m; + EXPECT_CALL(m.Mock(), WakeUpBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(true));; + bool ret = DisplayManagerLite::GetInstance().WakeUpBegin(PowerStateChangeReason::POWER_BUTTON); + ASSERT_EQ(true, ret); + + EXPECT_CALL(m.Mock(), WakeUpBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(false));; + ret = DisplayManagerLite::GetInstance().WakeUpBegin(PowerStateChangeReason::POWER_BUTTON); + ASSERT_EQ(false, ret); +} + +/** + * @tc.name: wake_up_end_001 + * @tc.desc: call WakeUpEnd and check return value + * @tc.type: FUNC + */ +HWTEST_F(DisplayLitePowerUnitTest, wake_up_end_001, Function | SmallTest | Level2) +{ + Mocker m; + EXPECT_CALL(m.Mock(), WakeUpEnd()).Times(1).WillOnce(Return(true)); + bool ret = DisplayManagerLite::GetInstance().WakeUpEnd(); + ASSERT_EQ(true, ret); + + EXPECT_CALL(m.Mock(), WakeUpEnd()).Times(1).WillOnce(Return(false)); + ret = DisplayManagerLite::GetInstance().WakeUpEnd(); + ASSERT_EQ(false, ret); +} + +/** + * @tc.name: suspend_begin_001 + * @tc.desc: call SuspendBegin and check return value + * @tc.type: FUNC + */ +HWTEST_F(DisplayLitePowerUnitTest, suspend_begin_001, Function | SmallTest | Level2) +{ + Mocker m; + EXPECT_CALL(m.Mock(), SuspendBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(true));; + bool ret = DisplayManagerLite::GetInstance().SuspendBegin(PowerStateChangeReason::POWER_BUTTON); + ASSERT_EQ(true, ret); + + EXPECT_CALL(m.Mock(), SuspendBegin(PowerStateChangeReason::POWER_BUTTON)).Times(1).WillOnce(Return(false));; + ret = DisplayManagerLite::GetInstance().SuspendBegin(PowerStateChangeReason::POWER_BUTTON); + ASSERT_EQ(false, ret); +} + +/** +* @tc.name: suspend_end_001 +* @tc.desc: call SuspendEnd and check return value +* @tc.type: FUNC +*/ +HWTEST_F(DisplayLitePowerUnitTest, suspend_end_001, Function | SmallTest | Level2) +{ + Mocker m; + EXPECT_CALL(m.Mock(), SuspendEnd()).Times(1).WillOnce(Return(true)); + bool ret = DisplayManagerLite::GetInstance().SuspendEnd(); + ASSERT_EQ(true, ret); + + EXPECT_CALL(m.Mock(), SuspendEnd()).Times(1).WillOnce(Return(false)); + ret = DisplayManagerLite::GetInstance().SuspendEnd(); + ASSERT_EQ(false, ret); +} + +/** +* @tc.name: set_screen_brightness_001 +* @tc.desc: Call SetScreenBrightness with a valid value and check the GetScreenBrightness return value +* @tc.type: FUNC +*/ +HWTEST_F(DisplayLitePowerUnitTest, set_screen_brightness_001, Function | MediumTest | Level2) +{ + bool ret = DisplayManagerLite::GetInstance().SetScreenBrightness(defaultId_, brightnessLevel_); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: SetSpecifiedScreenPower + * @tc.desc: test SetSpecifiedScreenPower + * @tc.type: FUNC + */ +HWTEST_F(DisplayLitePowerUnitTest, set_specified_screen_power_001, Function | SmallTest | Level2) +{ + ScreenPowerState state = ScreenPowerState{0}; + PowerStateChangeReason reason = PowerStateChangeReason{0}; + bool ret = ScreenManagerLite::GetInstance().SetSpecifiedScreenPower(0, state, reason); + ASSERT_TRUE(ret); +} + +/** +* @tc.name: set_screen_power_for_all_001 +* @tc.desc: Call SetScreenPowerForAll with valid value and check the GetScreenPower return value +* @tc.type: FUNC +*/ +HWTEST_F(DisplayLitePowerUnitTest, set_screen_power_for_all_001, Function | MediumTest | Level2) +{ + SingletonMocker m; + EXPECT_CALL(m.Mock(), GetScreenPower(_)).Times(1).WillOnce(Return(ScreenPowerState::POWER_OFF)); + EXPECT_CALL(m.Mock(), SetScreenPowerForAll(_, PowerStateChangeReason::POWER_BUTTON)) + .Times(1).WillOnce(Return(true)); + + bool ret = ScreenManagerLite::GetInstance().SetScreenPowerForAll(ScreenPowerState::POWER_OFF, + PowerStateChangeReason::POWER_BUTTON); + ASSERT_EQ(true, ret); + + ScreenPowerState state = ScreenManagerLite::GetInstance().GetScreenPower(defaultId_); + ASSERT_EQ(state, ScreenPowerState::POWER_OFF); +} + +/** +* @tc.name: set_display_state_001 +* @tc.desc: Call SetDisplayState with valid value and check the GetDisplayState return value +* @tc.type: FUNC +*/ +HWTEST_F(DisplayLitePowerUnitTest, set_display_state_001, Function | MediumTest | Level2) +{ + DisplayState stateToSet = (initialState_ == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF); + Mocker m; + EXPECT_CALL(m.Mock(), RegisterDisplayManagerAgent(_, DisplayManagerAgentType::DISPLAY_STATE_LISTENER)) + .Times(1).WillOnce(Return(DMError::DM_OK)); + EXPECT_CALL(m.Mock(), SetDisplayState(stateToSet)).Times(1).WillOnce(Return(true)); + DisplayStateCallback callback = [](DisplayState state) {}; + bool ret = DisplayManagerLite::GetInstance().SetDisplayState(stateToSet, callback); + ASSERT_EQ(true, ret); + + EXPECT_CALL(m.Mock(), GetDisplayState(defaultId_)).Times(1).WillOnce(Return(stateToSet)); + DisplayState state = DisplayManagerLite::GetInstance().GetDisplayState(defaultId_); + ASSERT_EQ(state, stateToSet); +} + +/** +* @tc.name: set_display_state_002 +* @tc.desc: Call SetDisplayState with invalid callback and check the GetDisplayState return value +* @tc.type: FUNC +*/ +HWTEST_F(DisplayLitePowerUnitTest, set_display_state_002, Function | MediumTest | Level2) +{ + Mocker m; + EXPECT_CALL(m.Mock(), SetDisplayState(_)).Times(0); + DisplayState stateToSet = (initialState_ == DisplayState::OFF ? DisplayState::ON : DisplayState::OFF); + bool ret = DisplayManagerLite::GetInstance().SetDisplayState(stateToSet, nullptr); + ASSERT_EQ(false, ret); +} +} +} +} \ No newline at end of file diff --git a/dm_lite/test/unittest/display_manager_adapter_lite_test.cpp b/dm_lite/test/unittest/display_manager_adapter_lite_test.cpp index 74d7f7dc5d..d3812830c9 100644 --- a/dm_lite/test/unittest/display_manager_adapter_lite_test.cpp +++ b/dm_lite/test/unittest/display_manager_adapter_lite_test.cpp @@ -100,6 +100,64 @@ HWTEST_F(DisplayManagerAdapterLiteTest, Clear01, Function | SmallTest | Level2) SingletonContainer::Get().Clear(); ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); } + +/** + * @tc.name: WakeUpBegin + * @tc.desc: test WakeUpBegin + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterLiteTest, WakeUpBegin, Function | SmallTest | Level2) +{ + PowerStateChangeReason reason = PowerStateChangeReason{0}; + bool ret = SingletonContainer::Get().WakeUpBegin(reason); + ASSERT_TRUE(ret); +} + +/** + * @tc.name: WakeUpEnd + * @tc.desc: test WakeUpEnd + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterLiteTest, WakeUpEnd, Function | SmallTest | Level2) +{ + bool ret = SingletonContainer::Get().WakeUpEnd(); + ASSERT_TRUE(ret); +} + +/** + * @tc.name: SuspendBegin + * @tc.desc: test SuspendBegin + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterLiteTest, SuspendBegin, Function | SmallTest | Level2) +{ + PowerStateChangeReason reason = PowerStateChangeReason{0}; + bool ret = SingletonContainer::Get().SuspendBegin(reason); + ASSERT_TRUE(ret); +} + +/** + * @tc.name: SuspendEnd + * @tc.desc: test SuspendEnd + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterLiteTest, SuspendEnd, Function | SmallTest | Level2) +{ + bool ret = SingletonContainer::Get().SuspendEnd(); + ASSERT_TRUE(ret); +} + +/** + * @tc.name: SetDisplayState + * @tc.desc: test SetDisplayState + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterLiteTest, SetDisplayState, Function | SmallTest | Level2) +{ + DisplayState state = DisplayState{1}; + bool ret = SingletonContainer::Get().SetDisplayState(state); + ASSERT_FALSE(ret); +} } } } diff --git a/dm_lite/test/unittest/display_manager_lite_test.cpp b/dm_lite/test/unittest/display_manager_lite_test.cpp index b545868e5a..70e723a86f 100644 --- a/dm_lite/test/unittest/display_manager_lite_test.cpp +++ b/dm_lite/test/unittest/display_manager_lite_test.cpp @@ -636,6 +636,19 @@ HWTEST_F(DisplayManagerTest, GetFoldDisplayMode03, Function | SmallTest | Level1 ASSERT_EQ(ret, FoldDisplayMode::UNKNOWN); displayInfo.clear(); } + +/** + * @tc.name: GetScreenBrightness + * @tc.desc: GetScreenBrightness + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerTest, GetScreenBrightness, Function | SmallTest | Level1) +{ + uint64_t screenId = 2; + auto ret = DisplayManagerLite::GetInstance().GetScreenBrightness(screenId); + ASSERT_FALSE(ret == 1); +} + } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/interfaces/innerkits/dm_lite/display_manager_lite.h b/interfaces/innerkits/dm_lite/display_manager_lite.h index 54415d7b77..95a29588aa 100644 --- a/interfaces/innerkits/dm_lite/display_manager_lite.h +++ b/interfaces/innerkits/dm_lite/display_manager_lite.h @@ -157,6 +157,87 @@ public: * @return Default display object. */ sptr GetDisplayById(DisplayId displayId); + + /* + * used by powermgr + */ + /** + * @brief Begin to wake up screen. + * + * @param reason Reason for power state change. + * @return True means begin success, false means begin failed. + */ + bool WakeUpBegin(PowerStateChangeReason reason); + + /** + * @brief Wake up screen end. + * + * @return True means end success, false means end failed. + */ + bool WakeUpEnd(); + + /** + * @brief Begin to suspend the screen. + * + * @param reason Reason for power state change. + * @return True means begin success, false means begin failed. + */ + bool SuspendBegin(PowerStateChangeReason reason); + + /** + * @brief Suspend screen end. + * + * @return True means suspend screen end success. + * @return False means suspend screen end failed. + */ + bool SuspendEnd(); + + /** + * @brief Set the Display State object + * + * @param state State of display. + * @param callback Callback for display state. + * @return True means set success, false means set failed. + */ + bool SetDisplayState(DisplayState state, DisplayStateCallback callback); + + /** + * @brief Get the state of the target display. + * + * @param displayId Display id. + * @return State of display. + */ + DisplayState GetDisplayState(DisplayId displayId); + + /** + * @brief Set the brightness level of the target screen. + * + * @param screenId Target screen. + * @param level Brightness level. + */ + bool SetScreenBrightness(uint64_t screenId, uint32_t level); + + /** + * @brief Get the brightness level of the target screen. + * + * @param screenId Screen id. + * @return Brightness value of screen. + */ + uint32_t GetScreenBrightness(uint64_t screenId) const; + + /** + * @brief Obtain the id of the default display. + * + * @return Default display id. + */ + DisplayId GetDefaultDisplayId(); + + /** + * @brief Get IDs of all displays. + * + * @return All display IDs. + */ + std::vector GetAllDisplayIds(); private: DisplayManagerLite(); ~DisplayManagerLite(); diff --git a/interfaces/innerkits/dm_lite/screen_manager_lite.h b/interfaces/innerkits/dm_lite/screen_manager_lite.h new file mode 100644 index 0000000000..d5da4fa4ad --- /dev/null +++ b/interfaces/innerkits/dm_lite/screen_manager_lite.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_DM_SCREEN_MANAGER_H +#define FOUNDATION_DM_SCREEN_MANAGER_H + +#include +#include "dm_common.h" +#include "wm_single_instance.h" + +namespace OHOS::Rosen { +class ScreenManagerLite : public RefBase { +WM_DECLARE_SINGLE_INSTANCE_BASE(ScreenManagerLite); +friend class DMSDeathRecipient; +public: + /* + * used by powermgr + */ + /** + * @brief Set the screen power state on the specified screen. + * + * @param screenId Screen id. + * @param state Screen power state. + * @param reason Reason for power state change. + * @return True means set success, false means set failed. + */ + bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason); + + /** + * @brief Set the screen power states for all screens. + * + * @param state Screen power state. + * @param reason Reason for power state change. + * @return True means set success, false means set failed. + */ + bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); + + /** + * @brief Get screen power state. + * + * @param screenId Screen id. + * @return Power state of screen. + */ + ScreenPowerState GetScreenPower(ScreenId screenId); +private: + ScreenManagerLite(); + ~ScreenManagerLite(); + void OnRemoteDied(); +}; +} // namespace OHOS::Rosen + +#endif // FOUNDATION_DM_SCREEN_MANAGER_H \ No newline at end of file diff --git a/test/common/mock/mock_display_manager_adapter_lite.h b/test/common/mock/mock_display_manager_adapter_lite.h index 48dcb7ecb2..26cb219d76 100644 --- a/test/common/mock/mock_display_manager_adapter_lite.h +++ b/test/common/mock/mock_display_manager_adapter_lite.h @@ -30,6 +30,26 @@ public: DisplayManagerAgentType type)); MOCK_METHOD0(GetDefaultDisplayInfo, sptr()); MOCK_METHOD1(GetDisplayInfo, sptr(DisplayId displayId)); + + MOCK_METHOD1(WakeUpBegin, bool(PowerStateChangeReason reason)); + MOCK_METHOD0(WakeUpEnd, bool()); + MOCK_METHOD1(SuspendBegin, bool(PowerStateChangeReason reason)); + MOCK_METHOD0(SuspendEnd, bool()); + MOCK_METHOD1(SetDisplayState, bool(DisplayState state)); + MOCK_METHOD1(GetDisplayState, DisplayState(DisplayId displayId)); +}; + +class MockScreenManagerAdapterLite : public ScreenManagerAdapterLite { +public: + MOCK_METHOD0(Clear, void()); + MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr& displayManagerAgent, + DisplayManagerAgentType type)); + MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr& displayManagerAgent, + DisplayManagerAgentType type)); + MOCK_METHOD3(SetSpecifiedScreenPower, bool(ScreenId screenId, ScreenPowerState state, + PowerStateChangeReason reason)); + MOCK_METHOD2(SetScreenPowerForAll, bool(ScreenPowerState state, PowerStateChangeReason reason)); + MOCK_METHOD1(GetScreenPower, ScreenPowerState(ScreenId dmsScreenId)); }; } } // namespace OHOS diff --git a/window_scene/session_manager/include/screen_session_manager_lite.h b/window_scene/session_manager/include/screen_session_manager_lite.h index f26cb73ce2..af8cd10dfd 100644 --- a/window_scene/session_manager/include/screen_session_manager_lite.h +++ b/window_scene/session_manager/include/screen_session_manager_lite.h @@ -47,6 +47,21 @@ public: sptr GetDefaultDisplayInfo() override; virtual sptr GetDisplayInfoById(DisplayId displayId) override; sptr GetCutoutInfo(DisplayId displayId) override; + /* + * used by powermgr + */ + bool WakeUpBegin(PowerStateChangeReason reason) override; + bool WakeUpEnd() override; + bool SuspendBegin(PowerStateChangeReason reason) override; + bool SuspendEnd() override; + bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override; + bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override; + ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override; + bool SetDisplayState(DisplayState state) override; + DisplayState GetDisplayState(DisplayId displayId) override; + bool SetScreenBrightness(uint64_t screenId, uint32_t level) override; + uint32_t GetScreenBrightness(uint64_t screenId) override; + std::vector GetAllDisplayIds() override; protected: ScreenSessionManagerLite() = default; virtual ~ScreenSessionManagerLite(); diff --git a/window_scene/session_manager/include/zidl/screen_session_manager_lite_interface.h b/window_scene/session_manager/include/zidl/screen_session_manager_lite_interface.h index ef4ea6b1dd..9ae8476660 100644 --- a/window_scene/session_manager/include/zidl/screen_session_manager_lite_interface.h +++ b/window_scene/session_manager/include/zidl/screen_session_manager_lite_interface.h @@ -63,6 +63,8 @@ public: TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS, TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION, TRANS_ID_GET_CUTOUT_INFO, + TRANS_ID_SET_SCREEN_BRIGHTNESS, + TRANS_ID_GET_SCREEN_BRIGHTNESS, }; virtual DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, @@ -77,6 +79,21 @@ public: virtual sptr GetDefaultDisplayInfo() { return nullptr; } virtual sptr GetDisplayInfoById(DisplayId displayId) { return nullptr; } virtual sptr GetCutoutInfo(DisplayId displayId) { return nullptr; } + /* + * used by powermgr + */ + virtual bool WakeUpBegin(PowerStateChangeReason reason) { return false; } + virtual bool WakeUpEnd() { return false; } + virtual bool SuspendBegin(PowerStateChangeReason reason) { return false; } + virtual bool SuspendEnd() { return false; } + virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) { return false; } + virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { return false; } + virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) { return ScreenPowerState::INVALID_STATE; } + virtual bool SetDisplayState(DisplayState state) { return false; } + virtual DisplayState GetDisplayState(DisplayId displayId) { return DisplayState::UNKNOWN; } + virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; } + virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; } + virtual std::vector GetAllDisplayIds() { return std::vector{}; } }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session_manager/include/zidl/screen_session_manager_lite_proxy.h b/window_scene/session_manager/include/zidl/screen_session_manager_lite_proxy.h index 3d25a20a62..91a762c763 100644 --- a/window_scene/session_manager/include/zidl/screen_session_manager_lite_proxy.h +++ b/window_scene/session_manager/include/zidl/screen_session_manager_lite_proxy.h @@ -42,6 +42,21 @@ public: virtual sptr GetDefaultDisplayInfo() override; virtual sptr GetDisplayInfoById(DisplayId displayId) override; virtual sptr GetCutoutInfo(DisplayId displayId) override; + /* + * used by powermgr + */ + virtual bool WakeUpBegin(PowerStateChangeReason reason) override; + virtual bool WakeUpEnd() override; + virtual bool SuspendBegin(PowerStateChangeReason reason) override; + virtual bool SuspendEnd() override; + virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override; + virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override; + virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override; + virtual bool SetDisplayState(DisplayState state) override; + virtual DisplayState GetDisplayState(DisplayId displayId) override; + virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) override; + virtual uint32_t GetScreenBrightness(uint64_t screenId) override; + virtual std::vector GetAllDisplayIds() override; private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session_manager/include/zidl/screen_session_manager_lite_stub.h b/window_scene/session_manager/include/zidl/screen_session_manager_lite_stub.h index 2dd8d3df85..4f8eeb8252 100644 --- a/window_scene/session_manager/include/zidl/screen_session_manager_lite_stub.h +++ b/window_scene/session_manager/include/zidl/screen_session_manager_lite_stub.h @@ -31,6 +31,7 @@ public: virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; private: + int RemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option); int HandleRegisterDisplayManagerAgent(MessageParcel& data, MessageParcel& reply); int HandleUnRegisterDisplayManagerAgent(MessageParcel& data, MessageParcel& reply); int HandleGetFoldDisplayMode(MessageParcel& data, MessageParcel& reply); @@ -40,6 +41,21 @@ private: int HandleGetDefaultDisplayInfo(MessageParcel& data, MessageParcel& reply); int HandleGetDisplayById(MessageParcel& data, MessageParcel& reply); int HandleGetCutoutInfo(MessageParcel& data, MessageParcel& reply); + /* + * used by powermgr + */ + int HandleWakeUpBegin(MessageParcel& data, MessageParcel& reply); + int HandleWakeUpEnd(MessageParcel& data, MessageParcel& reply); + int HandleSuspendBegin(MessageParcel& data, MessageParcel& reply); + int HandleSuspendEnd(MessageParcel& data, MessageParcel& reply); + int HandleSetSpecifiedScreenPower(MessageParcel& data, MessageParcel& reply); + int HandleSetScreenPowerForAll(MessageParcel& data, MessageParcel& reply); + int HandleGetScreenPower(MessageParcel& data, MessageParcel& reply); + int HandleSetDisplayState(MessageParcel& data, MessageParcel& reply); + int HandleGetDisplayState(MessageParcel& data, MessageParcel& reply); + int HandleSetScreenBrightness(MessageParcel& data, MessageParcel& reply); + int HandleGetScreenBrightness(MessageParcel& data, MessageParcel& reply); + int HandleGetAllDisplayIds(MessageParcel& data, MessageParcel& reply); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session_manager/src/screen_session_manager_lite.cpp b/window_scene/session_manager/src/screen_session_manager_lite.cpp index adc7f1f766..118b42508f 100644 --- a/window_scene/session_manager/src/screen_session_manager_lite.cpp +++ b/window_scene/session_manager/src/screen_session_manager_lite.cpp @@ -16,6 +16,7 @@ #include "session_manager/include/screen_session_manager_lite.h" #include #include +#include #include "window_manager_hilog.h" namespace OHOS::Rosen { @@ -157,6 +158,113 @@ sptr ScreenSessionManagerLite::GetCutoutInfo(DisplayId displayId) return nullptr; } +/* + * used by powermgr + */ +bool ScreenSessionManagerLite::WakeUpBegin(PowerStateChangeReason reason) +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->WakeUpBegin(reason); + } + return false; +} + +bool ScreenSessionManagerLite::WakeUpEnd() +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->WakeUpEnd(); + } + return false; +} + +bool ScreenSessionManagerLite::SuspendBegin(PowerStateChangeReason reason) +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->SuspendBegin(reason); + } + return false; +} + +bool ScreenSessionManagerLite::SuspendEnd() +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->SuspendEnd(); + } + return false; +} + +bool ScreenSessionManagerLite::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, + PowerStateChangeReason reason) +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->SetSpecifiedScreenPower(screenId, state, reason); + } + return false; +} + +bool ScreenSessionManagerLite::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->SetScreenPowerForAll(state, reason); + } + return false; +} + +ScreenPowerState ScreenSessionManagerLite::GetScreenPower(ScreenId dmsScreenId) +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->GetScreenPower(dmsScreenId); + } + return ScreenPowerState::INVALID_STATE; +} + +bool ScreenSessionManagerLite::SetDisplayState(DisplayState state) +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->SetDisplayState(state); + } + return false; +} + +DisplayState ScreenSessionManagerLite::GetDisplayState(DisplayId displayId) +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->GetDisplayState(displayId); + } + return DisplayState::UNKNOWN; +} + +bool ScreenSessionManagerLite::SetScreenBrightness(uint64_t screenId, uint32_t level) +{ + ConnectToServer(); + RSInterfaces::GetInstance().SetScreenBacklight(screenId, level); + return true; +} + +uint32_t ScreenSessionManagerLite::GetScreenBrightness(uint64_t screenId) +{ + ConnectToServer(); + return static_cast(RSInterfaces::GetInstance().GetScreenBacklight(screenId)); +} + +std::vector ScreenSessionManagerLite::GetAllDisplayIds() +{ + ConnectToServer(); + if (screenSessionManager_) { + return screenSessionManager_->GetAllDisplayIds(); + } + return std::vector{}; +} + void ScreenSessionManagerLite::Clear() { std::lock_guard lock(mutex_); diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp index 36be7d9446..3cdc2433c9 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp @@ -289,4 +289,342 @@ sptr ScreenSessionManagerLiteProxy::GetCutoutInfo(DisplayId displayI sptr info = reply.ReadParcelable(); return info; } +/* + * used by powermgr + */ +bool ScreenSessionManagerLiteProxy::WakeUpBegin(PowerStateChangeReason reason) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]WakeUpBegin remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("[UL_POWER]WakeUpBegin: WriteInterfaceToken failed"); + return false; + } + if (!data.WriteUint32(static_cast(reason))) { + WLOGFE("[UL_POWER]WakeUpBegin: Write PowerStateChangeReason failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_BEGIN), + data, reply, option) != ERR_NONE) { + WLOGFW("[UL_POWER]WakeUpBegin: SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +bool ScreenSessionManagerLiteProxy::WakeUpEnd() +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]WakeUpEnd remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("[UL_POWER]WakeUpEnd: WriteInterfaceToken failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_END), + data, reply, option) != ERR_NONE) { + WLOGFW("[UL_POWER]WakeUpEnd: SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +bool ScreenSessionManagerLiteProxy::SuspendBegin(PowerStateChangeReason reason) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]SuspendBegin remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("[UL_POWER]SuspendBegin: WriteInterfaceToken failed"); + return false; + } + if (!data.WriteUint32(static_cast(reason))) { + WLOGFE("[UL_POWER]SuspendBegin: Write PowerStateChangeReason failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_SUSPEND_BEGIN), + data, reply, option) != ERR_NONE) { + WLOGFW("[UL_POWER]SuspendBegin: SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +bool ScreenSessionManagerLiteProxy::SuspendEnd() +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]SuspendEnd remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("[UL_POWER]SuspendEnd: WriteInterfaceToken failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_SUSPEND_END), + data, reply, option) != ERR_NONE) { + WLOGFW("[UL_POWER]SuspendEnd: SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +bool ScreenSessionManagerLiteProxy::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, + PowerStateChangeReason reason) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]SetSpecifiedScreenPower remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("[UL_POWER]WriteInterfaceToken failed"); + return false; + } + if (!data.WriteUint32(static_cast(screenId))) { + WLOGFE("[UL_POWER]Write ScreenId failed"); + return false; + } + if (!data.WriteUint32(static_cast(state))) { + WLOGFE("[UL_POWER]Write ScreenPowerState failed"); + return false; + } + if (!data.WriteUint32(static_cast(reason))) { + WLOGFE("[UL_POWER]Write PowerStateChangeReason failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER), + data, reply, option) != ERR_NONE) { + WLOGFW("[UL_POWER]SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +bool ScreenSessionManagerLiteProxy::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]SetScreenPowerForAll remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("[UL_POWER]WriteInterfaceToken failed"); + return false; + } + if (!data.WriteUint32(static_cast(state))) { + WLOGFE("[UL_POWER]Write ScreenPowerState failed"); + return false; + } + if (!data.WriteUint32(static_cast(reason))) { + WLOGFE("[UL_POWER]Write PowerStateChangeReason failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL), + data, reply, option) != ERR_NONE) { + WLOGFW("[UL_POWER]SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +ScreenPowerState ScreenSessionManagerLiteProxy::GetScreenPower(ScreenId dmsScreenId) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("GetScreenPower remote is nullptr"); + return ScreenPowerState::INVALID_STATE; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return ScreenPowerState::INVALID_STATE; + } + if (!data.WriteUint64(static_cast(dmsScreenId))) { + WLOGFE("Write dmsScreenId failed"); + return ScreenPowerState::INVALID_STATE; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_POWER), + data, reply, option) != ERR_NONE) { + WLOGFW("SendRequest failed"); + return ScreenPowerState::INVALID_STATE; + } + return static_cast(reply.ReadUint32()); +} + +bool ScreenSessionManagerLiteProxy::SetDisplayState(DisplayState state) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]SetDisplayState remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("[UL_POWER]WriteInterfaceToken failed"); + return false; + } + if (!data.WriteUint32(static_cast(state))) { + WLOGFE("[UL_POWER]Write DisplayState failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_SET_DISPLAY_STATE), + data, reply, option) != ERR_NONE) { + WLOGFW("[UL_POWER]SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +DisplayState ScreenSessionManagerLiteProxy::GetDisplayState(DisplayId displayId) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("GetDisplayState remote is nullptr"); + return DisplayState::UNKNOWN; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return DisplayState::UNKNOWN; + } + if (!data.WriteUint64(displayId)) { + WLOGFE("Write displayId failed"); + return DisplayState::UNKNOWN; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_STATE), + data, reply, option) != ERR_NONE) { + WLOGFW("SendRequest failed"); + return DisplayState::UNKNOWN; + } + return static_cast(reply.ReadUint32()); +} + +bool ScreenSessionManagerLiteProxy::SetScreenBrightness(uint64_t screenId, uint32_t level) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("SetScreenBrightness remote is nullptr"); + return false; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return false; + } + if (!data.WriteUint64(screenId)) { + WLOGFE("Write screenId failed"); + return false; + } + if (!data.WriteUint64(level)) { + WLOGFE("Write level failed"); + return false; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS), + data, reply, option) != ERR_NONE) { + WLOGFW("SendRequest failed"); + return false; + } + return reply.ReadBool(); +} + +uint32_t ScreenSessionManagerLiteProxy::GetScreenBrightness(uint64_t screenId) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("GetScreenBrightness remote is nullptr"); + return 0; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return 0; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFE("Write screenId failed"); + return 0; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS), + data, reply, option) != ERR_NONE) { + WLOGFW("SendRequest failed"); + return 0; + } + return reply.ReadUint32(); +} + +std::vector ScreenSessionManagerLiteProxy::GetAllDisplayIds() +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("[UL_POWER]GetAllDisplayIds remote is nullptr"); + return {}; + } + + std::vector allDisplayIds; + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return allDisplayIds; + } + if (remote->SendRequest(static_cast(ScreenManagerLiteMessage::TRANS_ID_GET_ALL_DISPLAYIDS), + data, reply, option) != ERR_NONE) { + WLOGFW("SendRequest failed"); + return allDisplayIds; + } + reply.ReadUInt64Vector(&allDisplayIds); + return allDisplayIds; +} + } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp index 992c081958..a6bb17189c 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp @@ -35,42 +35,80 @@ int32_t ScreenSessionManagerLiteStub::OnRemoteRequest(uint32_t code, MessageParc } ScreenManagerLiteMessage msgId = static_cast(code); switch (msgId) { - case ScreenManagerLiteMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT: { + case ScreenManagerLiteMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT: HandleRegisterDisplayManagerAgent(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: { + case ScreenManagerLiteMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: HandleUnRegisterDisplayManagerAgent(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE: { + case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE: HandleGetFoldDisplayMode(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE: { + case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE: HandleSetFoldDisplayMode(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE: { + case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE: HandleIsFoldable(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS: { + case ScreenManagerLiteMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS: HandleGetFoldStatus(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO: { + case ScreenManagerLiteMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO: HandleGetDefaultDisplayInfo(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_BY_ID: { + case ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_BY_ID: HandleGetDisplayById(data, reply); break; - } - case ScreenManagerLiteMessage::TRANS_ID_GET_CUTOUT_INFO: { + case ScreenManagerLiteMessage::TRANS_ID_GET_CUTOUT_INFO: HandleGetCutoutInfo(data, reply); break; - } + default: + return RemoteRequest(code, data, reply, option); + } + return 0; +} + +int ScreenSessionManagerLiteStub::RemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, + MessageOption& option) +{ + ScreenManagerLiteMessage msgId = static_cast(code); + switch (msgId) { + case ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_BEGIN: + HandleWakeUpBegin(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_WAKE_UP_END: + HandleWakeUpEnd(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_SUSPEND_BEGIN: + HandleSuspendBegin(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_SUSPEND_END: + HandleSuspendEnd(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER: + HandleSetSpecifiedScreenPower(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL: + HandleSetScreenPowerForAll(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_POWER: + HandleGetScreenPower(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_SET_DISPLAY_STATE: + HandleSetDisplayState(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_GET_DISPLAY_STATE: + HandleGetDisplayState(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_GET_ALL_DISPLAYIDS: + HandleGetAllDisplayIds(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS: + HandleSetScreenBrightness(data, reply); + break; + case ScreenManagerLiteMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS: + HandleGetScreenBrightness(data, reply); + break; default: WLOGFW("unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -159,4 +197,109 @@ int ScreenSessionManagerLiteStub::HandleGetCutoutInfo(MessageParcel &data, Messa reply.WriteParcelable(cutoutInfo); return ERR_NONE; } +/* + * used by powermgr + */ +int ScreenSessionManagerLiteStub::HandleWakeUpBegin(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleWakeUpBegin!"); + PowerStateChangeReason reason = static_cast(data.ReadUint32()); + reply.WriteBool(WakeUpBegin(reason)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleWakeUpEnd(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleWakeUpEnd!"); + reply.WriteBool(WakeUpEnd()); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleSuspendBegin(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleSuspendBegin!"); + PowerStateChangeReason reason = static_cast(data.ReadUint32()); + reply.WriteBool(SuspendBegin(reason)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleSuspendEnd(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleSuspendEnd!"); + reply.WriteBool(SuspendEnd()); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleSetSpecifiedScreenPower(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleSetSpecifiedScreenPower!"); + ScreenId screenId = static_cast(data.ReadUint32()); + ScreenPowerState state = static_cast(data.ReadUint32()); + PowerStateChangeReason reason = static_cast(data.ReadUint32()); + reply.WriteBool(SetSpecifiedScreenPower(screenId, state, reason)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleSetScreenPowerForAll(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleSetScreenPowerForAll!"); + ScreenPowerState state = static_cast(data.ReadUint32()); + PowerStateChangeReason reason = static_cast(data.ReadUint32()); + reply.WriteBool(SetScreenPowerForAll(state, reason)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleGetScreenPower(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleGetScreenPower!"); + ScreenId dmsScreenId; + if (!data.ReadUint64(dmsScreenId)) { + WLOGFE("fail to read dmsScreenId."); + return ERR_INVALID_DATA; + } + reply.WriteUint32(static_cast(GetScreenPower(dmsScreenId))); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleSetDisplayState(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleSetDisplayState!"); + DisplayState state = static_cast(data.ReadUint32()); + reply.WriteBool(SetDisplayState(state)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleGetDisplayState(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleGetDisplayState!"); + DisplayState state = GetDisplayState(data.ReadUint64()); + reply.WriteUint32(static_cast(state)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleSetScreenBrightness(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleSetScreenBrightness!"); + uint64_t screenId = data.ReadUint64(); + uint32_t level = data.ReadUint64(); + reply.WriteBool(SetScreenBrightness(screenId, level)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleGetScreenBrightness(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleGetScreenBrightness!"); + uint64_t screenId = data.ReadUint64(); + reply.WriteUint32(GetScreenBrightness(screenId)); + return ERR_NONE; +} + +int ScreenSessionManagerLiteStub::HandleGetAllDisplayIds(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("run HandleGetAllDisplayIds!"); + std::vector allDisplayIds = GetAllDisplayIds(); + reply.WriteUInt64Vector(allDisplayIds); + return ERR_NONE; +} + } // namespace OHOS::Rosen diff --git a/window_scene/test/dms_unittest/screen_session_manager_lite_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_lite_proxy_test.cpp index ea5b356829..7acd77cfdf 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_lite_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_lite_proxy_test.cpp @@ -160,6 +160,102 @@ HWTEST_F(ScreenSessionManagerLiteProxyTest, GetCutoutInfo, Function | SmallTest auto res = screenSessionManagerLiteProxy_->GetCutoutInfo(displayId); ASSERT_EQ(nullptr, res); } + +/** + * @tc.name: WakeUpBegin + * @tc.desc: WakeUpBegin + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, WakeUpBegin, Function | SmallTest | Level1) +{ + PowerStateChangeReason reason {0}; + bool expectation = true; + EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->WakeUpBegin(reason)); +} + +/** + * @tc.name: WakeUpEnd + * @tc.desc: WakeUpEnd + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, WakeUpEnd, Function | SmallTest | Level1) +{ + bool expectation = true; + EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->WakeUpEnd()); +} + +/** + * @tc.name: SuspendEnd + * @tc.desc: SuspendEnd + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, SuspendEnd, Function | SmallTest | Level1) +{ + bool expectation = true; + EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->SuspendEnd()); +} + +/** + * @tc.name: SetDisplayState + * @tc.desc: SetDisplayState + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, SetDisplayState, Function | SmallTest | Level1) +{ + DisplayState state {1}; + screenSessionManagerLiteProxy_->SetDisplayState(state); + int resultValue = 0; + ASSERT_EQ(resultValue, 0); +} + +/** + * @tc.name: SetSpecifiedScreenPower + * @tc.desc: SetSpecifiedScreenPower + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, SetSpecifiedScreenPower, Function | SmallTest | Level1) +{ + ScreenPowerState state {0}; + ScreenId id = 1001; + PowerStateChangeReason reason {1}; + bool expectation = true; + EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->SetSpecifiedScreenPower(id, state, reason)); +} + +/** + * @tc.name: SetScreenPowerForAll + * @tc.desc: SetScreenPowerForAll + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, SetScreenPowerForAll, Function | SmallTest | Level1) +{ + ScreenPowerState state {0}; + PowerStateChangeReason reason {1}; + bool expectation = true; + EXPECT_EQ(expectation, screenSessionManagerLiteProxy_->SetScreenPowerForAll(state, reason)); +} + +/** + * @tc.name: GetDisplayState + * @tc.desc: GetDisplayState + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, GetDisplayState, Function | SmallTest | Level1) +{ + DisplayId displayId {0}; + EXPECT_NE(DisplayState::UNKNOWN, screenSessionManagerLiteProxy_->GetDisplayState(displayId)); +} + +/** + * @tc.name: GetScreenPower + * @tc.desc: GetScreenPower + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerLiteProxyTest, GetScreenPower, Function | SmallTest | Level1) +{ + ScreenId dmsScreenId = 1001; + EXPECT_NE(ScreenPowerState::INVALID_STATE, screenSessionManagerLiteProxy_->GetScreenPower(dmsScreenId)); +} } } } \ No newline at end of file From 4f33fd059b21c46bf1d17e5343627bf8448a002b Mon Sep 17 00:00:00 2001 From: flybear Date: Wed, 28 Aug 2024 06:38:14 +0000 Subject: [PATCH 52/86] =?UTF-8?q?pc=20=E6=89=A9=E5=B1=95=E5=B1=8F=E9=9C=80?= =?UTF-8?q?=E6=B1=82=20=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../js_scene_session_manager.cpp | 14 +++--- .../session/host/include/scene_session.h | 9 ++-- .../include/scene_session_manager.h | 1 - .../src/scene_session_manager.cpp | 48 +++++++++---------- .../unittest/scene_session_manager_test9.cpp | 2 +- 5 files changed, 36 insertions(+), 38 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 8498f9b80e..360414a7ed 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2965,8 +2965,8 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info) { - size_t argc = 2; - napi_value argv[2]; + size_t argc = ARGC_TWO; + napi_value argv[ARGC_TWO]; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_TWO) { TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); @@ -2976,19 +2976,19 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_ } uint32_t startZOrder; if (!ConvertFromJsValue(env, argv[0], startZOrder)) { - TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert startZOrder to %{public}d", startZOrder); + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert start Z order to %{public}d", startZOrder); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - std::vector perisistendIds; - if (!ConvertInt32ArrayFromJs(env, argv[1], perisistendIds)) { - TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert perisistendIds"); + std::vector persistentIds; + if (!ConvertInt32ArrayFromJs(env, argv[1], persistentIds)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert persistentIds"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, perisistendIds); + SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, persistentIds); return NapiGetUndefined(env); } } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index db504ad3de..674b05e893 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -392,10 +392,7 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; - void SetPcScenePanel(bool isPcScenePanel) - { - isPcScenePanel_ = isPcScenePanel; - } + void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel }; protected: void NotifySessionRectChange(const WSRect& rect, const SizeChangeReason& reason = SizeChangeReason::UNDEFINED); @@ -579,7 +576,9 @@ private: // Multi User bool isMinimizedByUserSwitch_ { false }; - // pc scene panel is used to determine whether the freshPcZOrder method is used to process the layer + /* + * Window ZOrder: PC + */ bool isPcScenePanel_ { false }; }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 84ee480eae..16e1374507 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -781,7 +781,6 @@ private: } }; std::unordered_map, SessionHasher> abilityInfoMap_; - std::map> idListMap_; }; } // 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 bfd13dce4c..229d2c7578 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10177,30 +10177,30 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds) { - idListMap_.erase(startZOrder); - idListMap_.insert({startZOrder, persistentIds}); - std::ostringstream oss; - oss << "["; - for (size_t i = 0; i < persistentIds.size(); i++) { - int32_t persistentId = persistentIds[i]; - oss << persistentId; - if(i < persistentIds.size() - 1) { - oss << ","; + auto task = [weakThis = wptr(this)] { + std::ostringstream oss; + oss << "["; + for (size_t i = 0; i < persistentIds.size(); i++) { + int32_t persistentId = persistentIds[i]; + oss << persistentId; + if (i < persistentIds.size() - 1) { + oss << ","; + } + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "sceneSession is nullptr persistentId = %{public}d", persistentId); + continue; + } + sceneSession->SetPcScenePanel(true); + if (i > UINT32_MAX - startZOrder) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Z order overflow,stop refresh"); + break; + } + sceneSession->SetZOrder(i + startZOrder); } - auto sceneSession = GetSceneSession(persistentId); - if (sceneSession == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "sceneScene is nullptr persistentId = %{public}d", persistentId); - continue; - } - sceneSession->SetPcScenePanel(true); - if (i > UINT32_MAX - startZOrder) { - TLOGE(WmsLogTag::WMS_LAYOUT, "newStartZOrder overflow,stop refresh"); - break; - } - uint32_t newZOrder = i + startZOrder; - sceneSession->SetZOrder(newZOrder); - } - oss << "]"; - TLOGI(WmsLogTag::WMS_LAYOUT, "Complete:%{public}s", oss.str().c_str()); + oss << "]"; + TLOGI(WmsLogTag::WMS_LAYOUT, "Complete:%{public}s", oss.str().c_str()); + }; + PostTask(task, "RefreshPcZOrderList"); } } // namespace OHOS::Rosen diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index cbd31aa146..d39df461d7 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -613,7 +613,7 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level ssm_->RefreshPcZOrderList(startZOrder, persistentIds); ssm_->RefreshPcZOrderList(UINT32_MAX, persistentIds); auto start = std::chrono::system_clock::now(); - // Due to SetZOrder being asynchronous, spin lock is added. + // Due to RefreshPcZOrderList being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds while (true) { bool isFinished = session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100; From 97d415c5416beff25ad4d00496662724defa1792 Mon Sep 17 00:00:00 2001 From: flybear Date: Wed, 28 Aug 2024 08:07:10 +0000 Subject: [PATCH 53/86] =?UTF-8?q?pc=20=E5=A4=9A=E5=B1=8F=E9=80=82=E9=85=8D?= =?UTF-8?q?=20=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 674b05e893..f2e50d7afb 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -392,7 +392,7 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; - void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel }; + void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; }; protected: void NotifySessionRectChange(const WSRect& rect, const SizeChangeReason& reason = SizeChangeReason::UNDEFINED); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 229d2c7578..df09af909a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10177,7 +10177,7 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds) { - auto task = [weakThis = wptr(this)] { + auto task = [this, startZOrder, persistentIds]() { std::ostringstream oss; oss << "["; for (size_t i = 0; i < persistentIds.size(); i++) { @@ -10200,7 +10200,8 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v } oss << "]"; TLOGI(WmsLogTag::WMS_LAYOUT, "Complete:%{public}s", oss.str().c_str()); + return WSError::WS_OK; }; - PostTask(task, "RefreshPcZOrderList"); + taskScheduler_->PostSyncTask(task, "RefreshPcZOrderList"); } } // namespace OHOS::Rosen From 6a1d5c22639e4788c82aa21fe7408563eb32eb73 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Wed, 28 Aug 2024 08:17:55 +0000 Subject: [PATCH 54/86] add tdd test Signed-off-by: cuiyongzhe --- .../test/unittest/session_proxy_mock_test.cpp | 39 +++++++++ .../test/unittest/session_stub_test.cpp | 32 +++++++ .../unittest/window_session_property_test.cpp | 86 ++++++++++++++----- 3 files changed, 135 insertions(+), 22 deletions(-) diff --git a/window_scene/test/unittest/session_proxy_mock_test.cpp b/window_scene/test/unittest/session_proxy_mock_test.cpp index 7694a225d0..5f55333997 100644 --- a/window_scene/test/unittest/session_proxy_mock_test.cpp +++ b/window_scene/test/unittest/session_proxy_mock_test.cpp @@ -94,6 +94,45 @@ HWTEST_F(SessionProxyMockTest, TransferAccessibilityEvent03, Function | SmallTes MockMessageParcel::ClearAllErrorFlag(); WLOGI("TransferAccessibilityEvent03 end"); } + +/** + * @tc.name: UpdateSessionPropertyByAction + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, Function | SmallTest | Level2) +{ + WLOGI("UpdateSessionPropertyByAction begin"); + MockMessageParcel::ClearAllErrorFlag(); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + SessionProxy* sessionProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + WSError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + MockMessageParcel::ClearAllErrorFlag(); + + MockMessageParcel::setWriteUint32ErrorFlag(true); + WSError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + MockMessageParcel::ClearAllErrorFlag(); + + sptr property = new WindowSessionProperty(); + ASSERT_NE(property, nullptr); + MockMessageParcel::setWriteBoolErrorFlag(true); + WSError res = sessionProxy->UpdateSessionPropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + MockMessageParcel::ClearAllErrorFlag(); + + MockMessageParcel::setWriteBoolErrorFlag(true); + WSError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + MockMessageParcel::ClearAllErrorFlag(); + WLOGI("UpdateSessionPropertyByAction end"); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 8cd174bb48..9374ef88a2 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -581,6 +581,38 @@ HWTEST_F(SessionStubTest, HandleSetDialogSessionBackGestureEnabled01, Function | auto res = session_->HandleSetDialogSessionBackGestureEnabled(data, reply); ASSERT_EQ(0, res); } + +/** + * @tc.name: HandleUpdatePropertyByAction01 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleUpdatePropertyByAction01, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + ASSERT_NE(session_, nullptr); + auto res = session_->HandleUpdatePropertyByAction(data, reply); + ASSERT_EQ(0, res); +} + +/** + * @tc.name: HandleUpdatePropertyByAction02 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleUpdatePropertyByAction02, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(false); + ASSERT_NE(session_, nullptr); + auto res = session_->HandleUpdatePropertyByAction(data, reply); + ASSERT_EQ(0, res); +} } } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 78c6929e92..4ec152e9c5 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -651,13 +651,38 @@ HWTEST_F(WindowSessionPropertyTest, SetIsLayoutFullScreen, Function | SmallTest */ HWTEST_F(WindowSessionPropertyTest, Read, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); - if (property != nullptr) { - Parcel parcel = Parcel(); - property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE); - ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID); - delete property; - } + sptr property = new WindowSessionProperty(); + ASSERT_NE(property, nullptr); + Parcel parcel = Parcel(); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_RECT); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_FLAGS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST); + property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); + ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID); } /** @@ -667,21 +692,38 @@ HWTEST_F(WindowSessionPropertyTest, Read, Function | SmallTest | Level2) */ HWTEST_F(WindowSessionPropertyTest, Write, Function | SmallTest | Level2) { - WindowSessionProperty *oldProperty = new (std::nothrow) WindowSessionProperty(); - WindowSessionProperty *newProperty = new (std::nothrow) WindowSessionProperty(); - if ((oldProperty != nullptr) && (newProperty != nullptr)) { - int32_t persistentId = 2; - oldProperty->SetPersistentId(persistentId); - oldProperty->SetFocusable(true); - Parcel parcel = Parcel(); - oldProperty->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE); - - newProperty->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE); - ASSERT_EQ(newProperty->GetPersistentId(), persistentId); - ASSERT_EQ(newProperty->GetFocusable(), true); - delete oldProperty; - delete newProperty; - } + sptr property = new WindowSessionProperty(); + ASSERT_NE(property, nullptr); + Parcel parcel = Parcel(); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_RECT); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_FLAGS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST); + property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); + ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID); } /** From 8858a3f86177aaceb30552f273071e59f38a4198 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Wed, 28 Aug 2024 08:34:15 +0000 Subject: [PATCH 55/86] add tdd test Signed-off-by: cuiyongzhe --- .../test/unittest/session_proxy_mock_test.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/window_scene/test/unittest/session_proxy_mock_test.cpp b/window_scene/test/unittest/session_proxy_mock_test.cpp index 5f55333997..7cb9b97e3e 100644 --- a/window_scene/test/unittest/session_proxy_mock_test.cpp +++ b/window_scene/test/unittest/session_proxy_mock_test.cpp @@ -106,28 +106,29 @@ HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, Function | SmallTe MockMessageParcel::ClearAllErrorFlag(); sptr iRemoteObjectMocker = new IRemoteObjectMocker(); SessionProxy* sessionProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); + ASSERT_NE(sessionProxy, nullptr); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); - WSError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, + WMError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); - MockMessageParcel::setWriteUint32ErrorFlag(true); - WSError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, + MockMessageParcel::SetWriteUint32ErrorFlag(true); + WMError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); - sptr property = new WindowSessionProperty(); + sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(property, nullptr); - MockMessageParcel::setWriteBoolErrorFlag(true); - WSError res = sessionProxy->UpdateSessionPropertyByAction(property, + MockMessageParcel::SetWriteBoolErrorFlag(true); + WMError res = sessionProxy->UpdateSessionPropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); - MockMessageParcel::setWriteBoolErrorFlag(true); - WSError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, + MockMessageParcel::SetWriteBoolErrorFlag(true); + WMError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); From ad1b99e14b30029f1fa8f35b639fb160a8c68abf Mon Sep 17 00:00:00 2001 From: flybear Date: Wed, 28 Aug 2024 08:37:09 +0000 Subject: [PATCH 56/86] =?UTF-8?q?pc=E6=B7=B7=E6=8E=92=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session/host/include/scene_session.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index f2e50d7afb..a53cd2e150 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -577,8 +577,8 @@ private: bool isMinimizedByUserSwitch_ { false }; /* - * Window ZOrder: PC - */ + * Window ZOrder: PC + */ bool isPcScenePanel_ { false }; }; } // namespace OHOS::Rosen From 53f98daa26862bdacb90a940d133e0dc86ca3143 Mon Sep 17 00:00:00 2001 From: cxy20001123 Date: Wed, 28 Aug 2024 08:31:46 +0000 Subject: [PATCH 57/86] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=96=E5=B1=8F?= =?UTF-8?q?=E6=88=AA=E5=9B=BE=E6=96=B9=E5=90=91=E5=80=92=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cxy20001123 --- .../include/screen_rotation_property.h | 1 - .../src/screen_rotation_property.cpp | 21 ------------------- .../src/screen_session_manager.cpp | 11 ++++++++-- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/window_scene/session_manager/include/screen_rotation_property.h b/window_scene/session_manager/include/screen_rotation_property.h index 72d0257ba0..3fd595e025 100644 --- a/window_scene/session_manager/include/screen_rotation_property.h +++ b/window_scene/session_manager/include/screen_rotation_property.h @@ -43,7 +43,6 @@ public: static void HandleSensorEventInput(DeviceRotation deviceRotation); private: static float ConvertDeviceToFloat(DeviceRotation deviceRotation); - static DeviceRotation ConvertSinglePocketOuterRotation(DeviceRotation deviceRotation); }; } // Rosen } // OHOS diff --git a/window_scene/session_manager/src/screen_rotation_property.cpp b/window_scene/session_manager/src/screen_rotation_property.cpp index 0140d7357b..fb25b60ac7 100644 --- a/window_scene/session_manager/src/screen_rotation_property.cpp +++ b/window_scene/session_manager/src/screen_rotation_property.cpp @@ -15,17 +15,12 @@ #include "screen_rotation_property.h" #include "screen_session_manager.h" -#include "fold_screen_state_internel.h" namespace OHOS { namespace Rosen { void ScreenRotationProperty::HandleSensorEventInput(DeviceRotation deviceRotation) { static DeviceRotation lastSensorRotationConverted_ = DeviceRotation::INVALID; - if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() && - ScreenSessionManager::GetInstance().GetFoldStatus() == FoldStatus::FOLDED) { - deviceRotation = ConvertSinglePocketOuterRotation(deviceRotation); - } TLOGI(WmsLogTag::DMS, "DeviceRotation: %{public}d, " "lastSensorRotationConverted: %{public}d", deviceRotation, lastSensorRotationConverted_); @@ -40,22 +35,6 @@ void ScreenRotationProperty::HandleSensorEventInput(DeviceRotation deviceRotatio screenSession->HandleSensorRotation(ConvertDeviceToFloat(deviceRotation)); } -DeviceRotation ScreenRotationProperty::ConvertSinglePocketOuterRotation(DeviceRotation deviceRotation) -{ - DeviceRotation sensorRotation = deviceRotation; - switch (deviceRotation) { - case DeviceRotation::ROTATION_LANDSCAPE: - sensorRotation = DeviceRotation::ROTATION_LANDSCAPE_INVERTED; - break; - case DeviceRotation::ROTATION_LANDSCAPE_INVERTED: - sensorRotation = DeviceRotation::ROTATION_LANDSCAPE; - break; - default: - TLOGW(WmsLogTag::DMS, "no need to covert, rotation: %{public}d", deviceRotation); - } - return sensorRotation; -} - float ScreenRotationProperty::ConvertDeviceToFloat(DeviceRotation deviceRotation) { float sensorRotation = -1.0f; // -1 mean keep before degree diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 9e361bd9aa..09f4ae4fd7 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -155,9 +155,16 @@ void ScreenSessionManager::HandleFoldScreenPowerInit() return; } foldScreenController_->SetOnBootAnimation(true); - auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_FULL, static_cast(g_screenRotationOffSet)); std::ostringstream oss; - oss << "SetScreenCorrection g_screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret; + if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) { + auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_MAIN, + static_cast(g_screenRotationOffSet)); + oss << "SetScreenCorrection g_screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret; + } else { + auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_FULL, + static_cast(g_screenRotationOffSet)); + oss << "SetScreenCorrection g_screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret; + } TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str()); screenEventTracker_.RecordEvent(oss.str()); FoldScreenPowerInit(); From 81e492e09d95b5cd39494b4f086010814bd8de08 Mon Sep 17 00:00:00 2001 From: flybear Date: Wed, 28 Aug 2024 08:53:19 +0000 Subject: [PATCH 58/86] =?UTF-8?q?pc=E5=A4=9A=E5=B1=8F=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index df09af909a..5f16353612 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10193,7 +10193,7 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v } sceneSession->SetPcScenePanel(true); if (i > UINT32_MAX - startZOrder) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Z order overflow,stop refresh"); + TLOGE(WmsLogTag::WMS_LAYOUT, "Z order overflow, stop refresh"); break; } sceneSession->SetZOrder(i + startZOrder); From fadb4406862d60f6a034833a2b60646e8ae68647 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Wed, 28 Aug 2024 09:06:18 +0000 Subject: [PATCH 59/86] add tdd test Signed-off-by: cuiyongzhe --- .../test/unittest/session_proxy_mock_test.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/window_scene/test/unittest/session_proxy_mock_test.cpp b/window_scene/test/unittest/session_proxy_mock_test.cpp index 7cb9b97e3e..56804656bb 100644 --- a/window_scene/test/unittest/session_proxy_mock_test.cpp +++ b/window_scene/test/unittest/session_proxy_mock_test.cpp @@ -108,29 +108,25 @@ HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, Function | SmallTe SessionProxy* sessionProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); ASSERT_NE(sessionProxy, nullptr); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); - WMError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); - ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteUint32ErrorFlag(true); - WMError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); - ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(property, nullptr); MockMessageParcel::SetWriteBoolErrorFlag(true); - WMError res = sessionProxy->UpdateSessionPropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); - ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(true); - WMError res = sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); - ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); + ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); WLOGI("UpdateSessionPropertyByAction end"); } From 8b8e09129e16e0bab0a03e0abf331e54af40c464 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Wed, 28 Aug 2024 09:38:50 +0000 Subject: [PATCH 60/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_proxy_mock_test.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/window_scene/test/unittest/session_proxy_mock_test.cpp b/window_scene/test/unittest/session_proxy_mock_test.cpp index 56804656bb..708cc771cb 100644 --- a/window_scene/test/unittest/session_proxy_mock_test.cpp +++ b/window_scene/test/unittest/session_proxy_mock_test.cpp @@ -124,10 +124,20 @@ HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, Function | SmallTe WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteBoolErrorFlag(false); + ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteBoolErrorFlag(true); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); + + MockMessageParcel::SetWriteBoolErrorFlag(false); + ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + MockMessageParcel::ClearAllErrorFlag(); WLOGI("UpdateSessionPropertyByAction end"); } } // namespace From 35e08969d84288a495e511aa81c0304019adba57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9C=89=E5=BA=B7?= Date: Wed, 28 Aug 2024 20:11:59 +0800 Subject: [PATCH 61/86] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddms=5Fdisplay=5Fmanager?= =?UTF-8?q?=5Ftest=E5=A4=B1=E8=B4=A5=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张有康 --- test/systemtest/dms/display_manager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/systemtest/dms/display_manager_test.cpp b/test/systemtest/dms/display_manager_test.cpp index b801dc8393..4f57592c87 100644 --- a/test/systemtest/dms/display_manager_test.cpp +++ b/test/systemtest/dms/display_manager_test.cpp @@ -384,7 +384,7 @@ HWTEST_F(DisplayManagerTest, SetVirtualScreenSecurityExemption, Function | Small uint32_t pid = 0; std::vector windowList; auto ret = DisplayManager::GetInstance().SetVirtualScreenSecurityExemption(id, pid, windowList); - ASSERT_EQ(DMError::DM_OK, ret); + ASSERT_NE(DMError::DM_OK, ret); // not virtual screen for id 0 sleep(2); } From 58e887bd82cb5d4bd6dbc646fb51eac54d234367 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Thu, 29 Aug 2024 01:13:57 +0000 Subject: [PATCH 62/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/session_proxy_mock_test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/window_scene/test/unittest/session_proxy_mock_test.cpp b/window_scene/test/unittest/session_proxy_mock_test.cpp index 708cc771cb..eeccd94987 100644 --- a/window_scene/test/unittest/session_proxy_mock_test.cpp +++ b/window_scene/test/unittest/session_proxy_mock_test.cpp @@ -102,7 +102,6 @@ HWTEST_F(SessionProxyMockTest, TransferAccessibilityEvent03, Function | SmallTes */ HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, Function | SmallTest | Level2) { - WLOGI("UpdateSessionPropertyByAction begin"); MockMessageParcel::ClearAllErrorFlag(); sptr iRemoteObjectMocker = new IRemoteObjectMocker(); SessionProxy* sessionProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); @@ -138,7 +137,6 @@ HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, Function | SmallTe ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); - WLOGI("UpdateSessionPropertyByAction end"); } } // namespace } // namespace Rosen From 8b86251c43a36fc7783468c2c266185d915bb3f5 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Thu, 29 Aug 2024 01:54:02 +0000 Subject: [PATCH 63/86] add tdd test Signed-off-by: cuiyongzhe --- .../test/unittest/scene_session_test4.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 1bac28aa1c..eddadd3ad4 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -699,6 +699,25 @@ HWTEST_F(SceneSessionTest4, HandleSpecificSystemBarProperty, Function | SmallTes ASSERT_NE(nullptr, property); WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR; sceneSession->HandleSpecificSystemBarProperty(type, property); + + sceneSession->isDisplayStatusBarTemporarily_.store(true); + sceneSession->HandleSpecificSystemBarProperty(type, property); + + sceneSession->specificCallback_ = nullptr; + sceneSession->HandleSpecificSystemBarProperty(type, property); + + sptr specificCallback = + new (std::nothrow) SceneSession::SpecificSessionCallback(); + ASSERT_NE(nullptr, specificCallback); + sceneSession->specificCallback_ = specificCallback; + sceneSession->HandleSpecificSystemBarProperty(type, property); + + sceneSession->specificCallback_->onUpdateAvoidArea_ = nullptr; + sceneSession->HandleSpecificSystemBarProperty(type, property); + + UpdateAvoidAreaCallback onUpdateAvoidArea; + sceneSession->specificCallback_->onUpdateAvoidArea_ = onUpdateAvoidArea; + sceneSession->HandleSpecificSystemBarProperty(type, property); } /** From 56c2e9879728c8df53a543e25ae26bbe2d029d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B1=89=E5=85=83?= Date: Thu, 29 Aug 2024 10:19:48 +0800 Subject: [PATCH 64/86] =?UTF-8?q?Signed-off-by:=20=E6=9D=8E=E6=B1=89?= =?UTF-8?q?=E5=85=83=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: window_scene/common/src/window_session_property.cpp --- window_scene/common/src/window_session_property.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 01c8251bff..8ff589de8c 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -360,7 +360,6 @@ void WindowSessionProperty::SetWindowFlags(uint32_t flags) flags_ = flags; } -/** @note @window.hierarchy */ void WindowSessionProperty::SetTopmost(bool topmost) { topmost_ = topmost; From 3e7421623cec701725c666961d89a4f1ec182d3c Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 02:36:00 +0000 Subject: [PATCH 65/86] =?UTF-8?q?PC=E6=89=A9=E5=B1=95=E5=B1=8F=20=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../js_scene_session_manager.cpp | 6 ++-- .../session/host/include/scene_session.h | 2 +- .../include/scene_session_manager.h | 2 +- .../src/scene_session_manager.cpp | 8 ++--- .../unittest/scene_session_manager_test9.cpp | 29 +++++++++---------- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 360414a7ed..05a50bbfd8 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2965,8 +2965,8 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info) { - size_t argc = ARGC_TWO; - napi_value argv[ARGC_TWO]; + size_t argc = 4; + napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_TWO) { TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); @@ -2988,7 +2988,7 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_ "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, persistentIds); + SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, std::move[persistentIds]); return NapiGetUndefined(env); } } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index a53cd2e150..b4f55a662a 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -392,7 +392,7 @@ public: void SetMinimizedFlagByUserSwitch(bool isMinimized); bool IsMinimizedByUserSwitch() const; void UnregisterSessionChangeListeners() override; - void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; }; + void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; } protected: void NotifySessionRectChange(const WSRect& rect, const SizeChangeReason& reason = SizeChangeReason::UNDEFINED); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 16e1374507..d4cf11e0b2 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -378,7 +378,7 @@ public: WMError TerminateSessionByPersistentId(int32_t persistentId); WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, const std::vector& persistentIds, std::vector& surfaceNodeIds) override; - void RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds); + void RefreshPcZOrderList(uint32_t startZOrder, const std::vector&& persistentIds); protected: SceneSessionManager(); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5f16353612..189681aff9 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10175,9 +10175,9 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t return WMError::WM_OK; } -void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector& persistentIds) +void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector&& persistentIds) { - auto task = [this, startZOrder, persistentIds]() { + auto task = [this, startZOrder, persistentIds = std::move[persistentIds]] { std::ostringstream oss; oss << "["; for (size_t i = 0; i < persistentIds.size(); i++) { @@ -10199,9 +10199,9 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v sceneSession->SetZOrder(i + startZOrder); } oss << "]"; - TLOGI(WmsLogTag::WMS_LAYOUT, "Complete:%{public}s", oss.str().c_str()); + TLOGI(WmsLogTag::WMS_LAYOUT, "RefreshPcZOrderList:%{public}s", oss.str().c_str()); return WSError::WS_OK; }; - taskScheduler_->PostSyncTask(task, "RefreshPcZOrderList"); + taskScheduler_->PostTask(task, "RefreshPcZOrderList"); } } // namespace OHOS::Rosen diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index d39df461d7..85cbf04059 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -589,40 +589,37 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function | */ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level3) { vector persistentIds; - SessionInfo info1, info2, info3; + SessionInfo info1; info1.abilityName_ = "RefreshPcZorder1"; info1.bundleName_ = "RefreshPcZorder1"; - info2.abilityName_ = "RefreshPcZorder2"; - info2.bundleName_ = "RefreshPcZorder2"; - info3.abilityName_ = "RefreshPcZorder3"; - info3.bundleName_ = "RefreshPcZorder3"; - uint32_t startZOrder = 100; - sptr session1 = new (std::nothrow)SceneSession(info1, nullptr); + sptr session1 = (std::nothrow)SceneSession(info1, nullptr); ASSERT_NE(session1, nullptr); persistentIds.push_back(session1->GetPersistentId()); ssm_->sceneSessionMap_.insert({session1->GetPersistentId(), session1}); - sptr session2 = new (std::nothrow)SceneSession(info2, nullptr); + SessionInfo info2; + info2.abilityName_ = "RefreshPcZorder2"; + info2.bundleName_ = "RefreshPcZorder2"; + sptr session2 = (std::nothrow)SceneSession(info2, nullptr); ASSERT_NE(session2, nullptr); persistentIds.push_back(session2->GetPersistentId()); ssm_->sceneSessionMap_.insert({session2->GetPersistentId(), session2}); - sptr session3 = new (std::nothrow)SceneSession(info3, nullptr); + SessionInfo info3; + info3.abilityName_ = "RefreshPcZorder3"; + info3.bundleName_ = "RefreshPcZorder3"; + sptr session3 = (std::nothrow)SceneSession(info3, nullptr); ASSERT_NE(session3, nullptr); persistentIds.push_back(999); session3->SetZOrder(404); ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); + uint32_t startZOrder = 100; ssm_->RefreshPcZOrderList(startZOrder, persistentIds); ssm_->RefreshPcZOrderList(UINT32_MAX, persistentIds); auto start = std::chrono::system_clock::now(); // Due to RefreshPcZOrderList being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds while (true) { - bool isFinished = session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100; - if (isFinished) { - break; - } - auto now = std::chrono::system_clock::now(); - auto elapsed = std::chrono::duration_cast(now - start).count(); - if (elapsed >= 3) { + if (session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100 + && std::chrono::duration_cast(std::chrono::system_clock::now() - start).count() >= 3) { break; } std::this_thread::sleep_for(std::chrono::milliseconds(100)); From 035e4c7f419d416c4e3d581d3a9cb071a57ad22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9C=89=E5=BA=B7?= Date: Thu, 29 Aug 2024 10:18:08 +0800 Subject: [PATCH 66/86] =?UTF-8?q?screen=5Fsession=5Fmanager=5Ftest?= =?UTF-8?q?=E8=A7=84=E9=81=BFcfi=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张有康 --- .../screen_session_manager_test.cpp | 58 ++++++------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/window_scene/test/dms_unittest/screen_session_manager_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_test.cpp index 120dab8549..321d161725 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -829,7 +829,7 @@ HWTEST_F(ScreenSessionManagerTest, NotifyScreenChanged, Function | SmallTest | L */ HWTEST_F(ScreenSessionManagerTest, NotifyDisplayEvent, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); DisplayEvent event = DisplayEvent::KEYGUARD_DRAWN; @@ -2086,14 +2086,13 @@ HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenBlackList01, Function | Small */ HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenBlackList02, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1010; ScreenId rsScreenId = SCREEN_ID_INVALID; ASSERT_FALSE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId)); std::vector windowId = {10, 20, 30}; ssm->SetVirtualScreenBlackList(screenId, windowId); - ssm = nullptr; } /** @@ -2166,7 +2165,7 @@ HWTEST_F(ScreenSessionManagerTest, ScreenCastConnection, Function | SmallTest | */ HWTEST_F(ScreenSessionManagerTest, ReportFoldStatusToScb, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ssm->clientProxy_ = nullptr; FoldStatus currentStatus = FoldStatus::FOLDED; @@ -2176,7 +2175,6 @@ HWTEST_F(ScreenSessionManagerTest, ReportFoldStatusToScb, Function | SmallTest | std::vector screenFoldInfo {std::to_string(static_cast(currentStatus)), std::to_string(static_cast(nextStatus)), std::to_string(duration), std::to_string(postureAngle)}; ssm->ReportFoldStatusToScb(screenFoldInfo); - ssm = nullptr; } /** @@ -2186,7 +2184,7 @@ HWTEST_F(ScreenSessionManagerTest, ReportFoldStatusToScb, Function | SmallTest | */ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl01, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; ScreenId rsScreenId = SCREEN_ID_INVALID; @@ -2194,7 +2192,6 @@ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl01, Function | Sm ssm->screenIdManager_.sms2RsScreenIdMap_[screenId] = rsScreenId1; ASSERT_TRUE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId)); ssm->DisablePowerOffRenderControl(screenId); - ssm = nullptr; } /** @@ -2204,13 +2201,12 @@ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl01, Function | Sm */ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl02, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1010; ScreenId rsScreenId = SCREEN_ID_INVALID; ASSERT_FALSE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId)); ssm->DisablePowerOffRenderControl(screenId); - ssm = nullptr; } /** @@ -2220,12 +2216,11 @@ HWTEST_F(ScreenSessionManagerTest, DisablePowerOffRenderControl02, Function | Sm */ HWTEST_F(ScreenSessionManagerTest, CheckAndSendHiSysEvent, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); std::string eventName = "GET_DISPLAY_SNAPSHOT"; std::string bundleName = "hmos.screenshot"; ssm->CheckAndSendHiSysEvent(eventName, bundleName); - ssm = nullptr; } /** @@ -2235,14 +2230,13 @@ HWTEST_F(ScreenSessionManagerTest, CheckAndSendHiSysEvent, Function | SmallTest */ HWTEST_F(ScreenSessionManagerTest, NotifyFoldToExpandCompletion, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); bool foldToExpand = false; ssm->NotifyFoldToExpandCompletion(foldToExpand); foldToExpand = true; ssm->NotifyFoldToExpandCompletion(foldToExpand); - ssm = nullptr; } /** @@ -2252,12 +2246,11 @@ HWTEST_F(ScreenSessionManagerTest, NotifyFoldToExpandCompletion, Function | Smal */ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea01, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; DMRect area = DMRect{}; ssm->UpdateAvailableArea(screenId, area); - ssm = nullptr; } /** @@ -2267,7 +2260,7 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea01, Function | SmallTest | */ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea02, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; DMRect area{0, 0, 600, 900}; @@ -2278,7 +2271,6 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea02, Function | SmallTest | ASSERT_EQ(screenSession1, screenSession); ASSERT_TRUE(screenSession->UpdateAvailableArea(area)); ssm->UpdateAvailableArea(screenId, area); - ssm = nullptr; } /** @@ -2288,7 +2280,7 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea02, Function | SmallTest | */ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea03, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; sptr screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); @@ -2297,7 +2289,6 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea03, Function | SmallTest | ssm->screenSessionMap_[screenId] = screenSession; ASSERT_FALSE(screenSession->UpdateAvailableArea(area)); ssm->UpdateAvailableArea(screenId, area); - ssm = nullptr; } /** @@ -2307,11 +2298,10 @@ HWTEST_F(ScreenSessionManagerTest, UpdateAvailableArea03, Function | SmallTest | */ HWTEST_F(ScreenSessionManagerTest, NotifyAvailableAreaChanged01, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); DMRect area = DMRect{}; ssm->NotifyAvailableAreaChanged(area); - ssm = nullptr; } /** @@ -2321,7 +2311,7 @@ HWTEST_F(ScreenSessionManagerTest, NotifyAvailableAreaChanged01, Function | Smal */ HWTEST_F(ScreenSessionManagerTest, NotifyFoldStatusChanged02, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); std::string statusParam; auto ret = ssm->NotifyFoldStatusChanged(statusParam); @@ -2345,8 +2335,6 @@ HWTEST_F(ScreenSessionManagerTest, NotifyFoldStatusChanged02, Function | SmallTe ssm->HandleFoldScreenPowerInit(); ret = ssm->NotifyFoldStatusChanged(statusParam); ASSERT_EQ(ret, 0); - - ssm = nullptr; } /** @@ -2356,13 +2344,12 @@ HWTEST_F(ScreenSessionManagerTest, NotifyFoldStatusChanged02, Function | SmallTe */ HWTEST_F(ScreenSessionManagerTest, Dump, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); int fd = 2; std::vector args; int ret = ssm->Dump(fd, args); ASSERT_EQ(ret, 0); - ssm = nullptr; } /** @@ -2372,12 +2359,11 @@ HWTEST_F(ScreenSessionManagerTest, Dump, Function | SmallTest | Level3) */ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode01, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; auto ret = ssm->GetDisplayNode(screenId); ASSERT_EQ(ret, nullptr); - ssm = nullptr; } /** @@ -2387,7 +2373,7 @@ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode01, Function | SmallTest | Leve */ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode02, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; sptr screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); @@ -2395,7 +2381,6 @@ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode02, Function | SmallTest | Leve ssm->screenSessionMap_[screenId] = screenSession; auto ret = ssm->GetDisplayNode(screenId); ASSERT_NE(ret, nullptr); - ssm = nullptr; } /** @@ -2405,11 +2390,10 @@ HWTEST_F(ScreenSessionManagerTest, GetDisplayNode02, Function | SmallTest | Leve */ HWTEST_F(ScreenSessionManagerTest, GetScreenProperty01, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; auto ret = ssm->GetScreenProperty(screenId); - ssm = nullptr; } /** @@ -2419,14 +2403,13 @@ HWTEST_F(ScreenSessionManagerTest, GetScreenProperty01, Function | SmallTest | L */ HWTEST_F(ScreenSessionManagerTest, GetScreenProperty02, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; sptr screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); ASSERT_NE(screenSession, nullptr); ssm->screenSessionMap_[screenId] = screenSession; auto ret = ssm->GetScreenProperty(screenId); - ssm = nullptr; } /** @@ -2436,7 +2419,7 @@ HWTEST_F(ScreenSessionManagerTest, GetScreenProperty02, Function | SmallTest | L */ HWTEST_F(ScreenSessionManagerTest, GetCurrentScreenPhyBounds01, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); float phyWidth = 0.0f; float phyHeight = 0.0f; @@ -2450,8 +2433,6 @@ HWTEST_F(ScreenSessionManagerTest, GetCurrentScreenPhyBounds01, Function | Small ASSERT_NE(ssm->foldScreenController_, nullptr); ssm->GetCurrentScreenPhyBounds(phyWidth, phyHeight, isReset, screenId); ASSERT_FALSE(isReset); - - ssm = nullptr; } /** @@ -2461,7 +2442,7 @@ HWTEST_F(ScreenSessionManagerTest, GetCurrentScreenPhyBounds01, Function | Small */ HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenStatus, Function | SmallTest | Level3) { - sptr ssm = new ScreenSessionManager(); + ScreenSessionManager* ssm = new ScreenSessionManager(); ASSERT_NE(ssm, nullptr); ScreenId screenId = 1050; auto ret = ssm->SetVirtualScreenStatus(screenId, VirtualScreenStatus::VIRTUAL_SCREEN_PAUSE); @@ -2471,7 +2452,6 @@ HWTEST_F(ScreenSessionManagerTest, SetVirtualScreenStatus, Function | SmallTest ssm->screenIdManager_.sms2RsScreenIdMap_[screenId] = rsScreenId1; ASSERT_TRUE(ssm->ConvertScreenIdToRsScreenId(screenId, rsScreenId)); ssm->SetVirtualScreenStatus(screenId, VirtualScreenStatus::VIRTUAL_SCREEN_PAUSE); - ssm = nullptr; } /** From 0671e303842df95093201f4e3214a711014c8dc5 Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 02:46:01 +0000 Subject: [PATCH 67/86] =?UTF-8?q?pc=E6=B7=B7=E6=8E=92=20=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 85cbf04059..727f145d93 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -612,8 +612,8 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level session3->SetZOrder(404); ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); uint32_t startZOrder = 100; - ssm_->RefreshPcZOrderList(startZOrder, persistentIds); - ssm_->RefreshPcZOrderList(UINT32_MAX, persistentIds); + ssm_->RefreshPcZOrderList(startZOrder, std::move[persistentIds]); + ssm_->RefreshPcZOrderList(UINT32_MAX, std::move[persistentIds]); auto start = std::chrono::system_clock::now(); // Due to RefreshPcZOrderList being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds From de9eb12382019a3f8bd1178f95a6c1d148f1a36e Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 03:06:04 +0000 Subject: [PATCH 68/86] =?UTF-8?q?pc=20=E6=89=A9=E5=B1=95=E5=B1=8F=E6=B7=B7?= =?UTF-8?q?=E6=8E=92=20=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- .../scene_session_manager/js_scene_session_manager.cpp | 2 +- .../session_manager/src/scene_session_manager.cpp | 2 +- .../test/unittest/scene_session_manager_test9.cpp | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 05a50bbfd8..9dcf60163c 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2988,7 +2988,7 @@ napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_ "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, std::move[persistentIds]); + SceneSessionManager::GetInstance().RefreshPcZOrderList(startZOrder, std::move(persistentIds)); return NapiGetUndefined(env); } } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 189681aff9..f97c4c8dfd 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10177,7 +10177,7 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector&& persistentIds) { - auto task = [this, startZOrder, persistentIds = std::move[persistentIds]] { + auto task = [this, startZOrder, persistentIds = std::move(persistentIds)] { std::ostringstream oss; oss << "["; for (size_t i = 0; i < persistentIds.size(); i++) { diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 727f145d93..dfa3d3f487 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -592,28 +592,28 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level SessionInfo info1; info1.abilityName_ = "RefreshPcZorder1"; info1.bundleName_ = "RefreshPcZorder1"; - sptr session1 = (std::nothrow)SceneSession(info1, nullptr); + sptr session1 = sptr::MakeSptr(info1, nullptr); ASSERT_NE(session1, nullptr); persistentIds.push_back(session1->GetPersistentId()); ssm_->sceneSessionMap_.insert({session1->GetPersistentId(), session1}); SessionInfo info2; info2.abilityName_ = "RefreshPcZorder2"; info2.bundleName_ = "RefreshPcZorder2"; - sptr session2 = (std::nothrow)SceneSession(info2, nullptr); + sptr session2 = sptr::MakeSptr(info2, nullptr); ASSERT_NE(session2, nullptr); persistentIds.push_back(session2->GetPersistentId()); ssm_->sceneSessionMap_.insert({session2->GetPersistentId(), session2}); SessionInfo info3; info3.abilityName_ = "RefreshPcZorder3"; info3.bundleName_ = "RefreshPcZorder3"; - sptr session3 = (std::nothrow)SceneSession(info3, nullptr); + sptr session3 = sptr::MakeSptr(info3, nullptr) ASSERT_NE(session3, nullptr); persistentIds.push_back(999); session3->SetZOrder(404); ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); uint32_t startZOrder = 100; - ssm_->RefreshPcZOrderList(startZOrder, std::move[persistentIds]); - ssm_->RefreshPcZOrderList(UINT32_MAX, std::move[persistentIds]); + ssm_->RefreshPcZOrderList(startZOrder, std::move(persistentIds)); + ssm_->RefreshPcZOrderList(UINT32_MAX, std::move(persistentIds)); auto start = std::chrono::system_clock::now(); // Due to RefreshPcZOrderList being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds From 70a46b781d9581fbb072d10693f8562aa116fb7c Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 03:16:54 +0000 Subject: [PATCH 69/86] =?UTF-8?q?pc=E6=B7=B7=E6=8E=92=20=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index dfa3d3f487..d4001c9b10 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -606,7 +606,7 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level SessionInfo info3; info3.abilityName_ = "RefreshPcZorder3"; info3.bundleName_ = "RefreshPcZorder3"; - sptr session3 = sptr::MakeSptr(info3, nullptr) + sptr session3 = sptr::MakeSptr(info3, nullptr); ASSERT_NE(session3, nullptr); persistentIds.push_back(999); session3->SetZOrder(404); From ad22eacdace8df20f64a1cf587b0a878f6fa6ef6 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Thu, 29 Aug 2024 03:20:06 +0000 Subject: [PATCH 70/86] add tdd test Signed-off-by: cuiyongzhe --- .../unittest/scene_session_manager_test5.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index ec7eaff75b..ac0a90daf9 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -403,6 +403,17 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, Function | SmallTest | L FocusChangeReason reason = FocusChangeReason::DEFAULT; ssm_->RequestSessionFocus(0, true, reason); ssm_->RequestSessionFocus(100, true, reason); + + sceneSession->property_ = property; + ASSERT_NE(sceneSession->property_, nullptr); + sceneSession->persistentId_ = 1; + sceneSession->isVisible_ = true; + sceneSession->state_ = SessionState::STATE_ACTIVE; + sceneSession->focusedOnShow_ = true; + sceneSession->property_->focusable_ = true; + sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + ssm_->focusedSessionId_ = 2; + ssm_->RequestSessionFocus(0, true, reason); } /** @@ -476,6 +487,18 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, Function | SmallTest | ASSERT_NE(sceneSession, nullptr); FocusChangeReason reason = FocusChangeReason::MOVE_UP; ssm_->RequestSessionUnfocus(0, reason); + + sptr focusedSession = new (std::nothrow) SceneSession(info, nullptr); + ASSERT_NE(focusedSession, nullptr); + sceneSession->property_ = property; + ASSERT_NE(sceneSession->property_, nullptr); + sceneSession->persistentId_ = 1; + focusedSession->persistentId_ = 2; + focusedSession->property_->parentPersistentId_ = 1; + ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession}); + ssm_->RequestSessionUnfocus(0, reason); + ssm_->sceneSessionMap_.clear(); } /** From 860f9c27a9bdf1927ea9aeea3fc5d241a5989bf2 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Thu, 29 Aug 2024 03:27:58 +0000 Subject: [PATCH 71/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/scene_session_manager_test5.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index ac0a90daf9..a8370b05ad 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -413,7 +413,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, Function | SmallTest | L sceneSession->property_->focusable_ = true; sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ssm_->focusedSessionId_ = 2; - ssm_->RequestSessionFocus(0, true, reason); + ssm_->RequestSessionFocus(1, true, reason); } /** @@ -495,9 +495,10 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, Function | SmallTest | sceneSession->persistentId_ = 1; focusedSession->persistentId_ = 2; focusedSession->property_->parentPersistentId_ = 1; + ssm_->focusedSessionId_ = 2 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession}); - ssm_->RequestSessionUnfocus(0, reason); + ssm_->RequestSessionUnfocus(1, reason); ssm_->sceneSessionMap_.clear(); } From c6f8d4a9985ab42d99961d7dc2971b5f029238e2 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Thu, 29 Aug 2024 03:31:23 +0000 Subject: [PATCH 72/86] add tdd test Signed-off-by: cuiyongzhe --- .../test/unittest/scene_session_manager_test5.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index a8370b05ad..88096d010e 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -413,7 +413,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, Function | SmallTest | L sceneSession->property_->focusable_ = true; sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ssm_->focusedSessionId_ = 2; - ssm_->RequestSessionFocus(1, true, reason); + ssm_->RequestSessionFocus(1, true, reason); } /** @@ -490,12 +490,12 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, Function | SmallTest | sptr focusedSession = new (std::nothrow) SceneSession(info, nullptr); ASSERT_NE(focusedSession, nullptr); - sceneSession->property_ = property; - ASSERT_NE(sceneSession->property_, nullptr); + focusedSession->property_ = property; + ASSERT_NE(focusedSession->property_, nullptr); sceneSession->persistentId_ = 1; focusedSession->persistentId_ = 2; focusedSession->property_->parentPersistentId_ = 1; - ssm_->focusedSessionId_ = 2 + ssm_->focusedSessionId_ = 2; ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession}); ssm_->RequestSessionUnfocus(1, reason); From f18b6eb0b60c50a6552dbe61c7dbb2f958e80efa Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Thu, 29 Aug 2024 06:47:34 +0000 Subject: [PATCH 73/86] add tdd test Signed-off-by: cuiyongzhe --- window_scene/test/unittest/scene_session_manager_test5.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 88096d010e..a012df3a19 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -412,7 +412,6 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, Function | SmallTest | L sceneSession->focusedOnShow_ = true; sceneSession->property_->focusable_ = true; sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - ssm_->focusedSessionId_ = 2; ssm_->RequestSessionFocus(1, true, reason); } @@ -495,7 +494,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, Function | SmallTest | sceneSession->persistentId_ = 1; focusedSession->persistentId_ = 2; focusedSession->property_->parentPersistentId_ = 1; - ssm_->focusedSessionId_ = 2; + ssm_->focusedSessionId_ = 1; ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession}); ssm_->RequestSessionUnfocus(1, reason); From 41536814152a9ce1c6a2b6aa02446ddee66d4a34 Mon Sep 17 00:00:00 2001 From: zhouyangkai Date: Thu, 29 Aug 2024 14:50:31 +0800 Subject: [PATCH 74/86] remove unused code in IntentionEventManager Signed-off-by: zhouyangkai --- .../include/intention_event_manager.h | 2 - .../src/intention_event_manager.cpp | 57 --------------- .../unittest/intention_event_manager_test.cpp | 72 ------------------- 3 files changed, 131 deletions(-) diff --git a/window_scene/intention_event/include/intention_event_manager.h b/window_scene/intention_event/include/intention_event_manager.h index cfbcd4879d..17a7b672f0 100644 --- a/window_scene/intention_event/include/intention_event_manager.h +++ b/window_scene/intention_event/include/intention_event_manager.h @@ -44,14 +44,12 @@ public: void OnInputEvent(std::shared_ptr pointerEvent) const override; void OnInputEvent(std::shared_ptr keyEvent) const override; void OnInputEvent(std::shared_ptr axisEvent) const override; - void RegisterWindowChanged(); private: void DispatchKeyEventCallback( int32_t focusedSessionId, std::shared_ptr keyEvent, bool consumed) const; void UpdateLastMouseEvent(std::shared_ptr pointerEvent) const; bool CheckPointerEvent(const std::shared_ptr pointerEvent) const; - void ProcessEnterLeaveEventAsync(); bool IsKeyboardEvent(const std::shared_ptr& keyEvent) const; Ace::UIContent* uiContent_ = nullptr; std::weak_ptr weakEventConsumer_; diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index e4de381ccd..c47ef2ef78 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -105,63 +105,6 @@ bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent, return true; } -void IntentionEventManager::InputEventListener::RegisterWindowChanged() -{} - -void IntentionEventManager::InputEventListener::ProcessEnterLeaveEventAsync() -{ - auto task = [this]() { - std::lock_guard guard(mouseEventMutex_); - if ((g_lastMouseEvent == nullptr) || - (g_lastMouseEvent->GetButtonId() != MMI::PointerEvent::BUTTON_NONE && - g_lastMouseEvent->GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_BUTTON_UP)) { - return; - } - auto enterSession = SceneSession::GetEnterWindow().promote(); - if (enterSession == nullptr) { - WLOGFE("Enter session is null, do not reissuing enter leave events"); - return; - } - if (g_lastLeaveWindowId == enterSession->GetPersistentId()) { - WLOGFI("g_lastLeaveWindowId:%{public}d equal enterSession id", g_lastLeaveWindowId); - return; - } - - WLOGFD("Reissue enter leave, persistentId:%{public}d", enterSession->GetPersistentId()); - auto leavePointerEvent = std::make_shared(*g_lastMouseEvent); - if (leavePointerEvent != nullptr) { - leavePointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW); - } - WSError ret = enterSession->TransferPointerEvent(leavePointerEvent); - if (ret != WSError::WS_OK && leavePointerEvent != nullptr) { - leavePointerEvent->MarkProcessed(); - } - g_lastLeaveWindowId = enterSession->GetPersistentId(); - - auto enterPointerEvent = std::make_shared(*g_lastMouseEvent); - if (enterPointerEvent == nullptr) { - WLOGFE("The enter pointer event is nullptr"); - return; - } - enterPointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW); - if (uiContent_ == nullptr) { - WLOGFE("ProcessEnterLeaveEventAsync uiContent_ is null"); - return; - } - if (!(uiContent_->ProcessPointerEvent(enterPointerEvent))) { - WLOGFE("The UI content consumes pointer event failed"); - enterPointerEvent->MarkProcessed(); - } - }; - auto eventHandler = weakEventConsumer_.lock(); - if (eventHandler == nullptr) { - WLOGFE("ProcessEnterLeaveEventAsync eventHandler is null"); - return; - } - eventHandler->PostTask(std::move(task), "wms:ProcessEventLeaveEventAsync", - DELAY_TIME, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - void IntentionEventManager::InputEventListener::UpdateLastMouseEvent( std::shared_ptr pointerEvent) const { diff --git a/window_scene/test/unittest/intention_event_manager_test.cpp b/window_scene/test/unittest/intention_event_manager_test.cpp index 42e601225d..084774b862 100644 --- a/window_scene/test/unittest/intention_event_manager_test.cpp +++ b/window_scene/test/unittest/intention_event_manager_test.cpp @@ -355,78 +355,6 @@ HWTEST_F(IntentionEventManagerTest, UpdateLastMouseEvent, Function | MediumTest inputEventListener_->UpdateLastMouseEvent(pointerEvent); } -/** - * @tc.name: ProcessEnterLeaveEventAsync0 - * @tc.desc: ProcessEnterLeaveEventAsync0 Test - * @tc.type: FUNC - */ -HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync0, Function | MediumTest | Level2) -{ - std::shared_ptr inputEventListener1 = - std::make_shared(nullptr, nullptr); - EXPECT_NE(nullptr, inputEventListener1); - inputEventListener1->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); -} - -/** - * @tc.name: ProcessEnterLeaveEventAsync1 - * @tc.desc: ProcessEnterLeaveEventAsync1 Test - * @tc.type: FUNC - */ -HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync1, Function | MediumTest | Level2) -{ - inputEventListener_->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - EXPECT_NE(nullptr, pointerEvent); - pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_MOUSE); - pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP); - inputEventListener_->UpdateLastMouseEvent(pointerEvent); - - SceneSession::ClearEnterWindow(); - EXPECT_EQ(nullptr, SceneSession::GetEnterWindow().promote()); - inputEventListener_->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); - - SessionInfo info; - info.bundleName_ = "IntentionEventManager"; - info.moduleName_ = "InputEventListener"; - info.isSystem_ = false; - info.persistentId_ = -1; - sptr callback = - new SceneSession::SpecificSessionCallback(); - EXPECT_NE(nullptr, callback); - sptr sceneSession = new SceneSession(info, callback); - EXPECT_NE(nullptr, sceneSession); - EXPECT_EQ(-1, sceneSession->GetPersistentId()); - - pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW); - sceneSession->TransferPointerEvent(pointerEvent, true); - EXPECT_NE(nullptr, SceneSession::GetEnterWindow().promote()); - inputEventListener_->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); - - sceneSession->sessionInfo_.isSystem_ = false; - inputEventListener_->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); - - sceneSession->sessionInfo_.isSystem_ = true; - auto tempUiContent = inputEventListener_->uiContent_; - inputEventListener_->uiContent_ = nullptr; - inputEventListener_->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); - inputEventListener_->uiContent_ = tempUiContent; - - sceneSession->sessionInfo_.persistentId_ = 2024; - inputEventListener_->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); - std::shared_ptr inputEventListener2 = - std::make_shared(nullptr, eventHandler_); - inputEventListener2->ProcessEnterLeaveEventAsync(); - usleep(WAIT_SYNC_IN_NS); -} - /** * @tc.name: OnInputEventPointer1 * @tc.desc: OnInputEventPointer1 Test From 85b30f19281c246b4795056b99ecbf0897757202 Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 07:01:48 +0000 Subject: [PATCH 75/86] =?UTF-8?q?pc=20=E6=B7=B7=E6=8E=92=E9=80=82=E9=85=8D?= =?UTF-8?q?=20=E5=B1=82=E7=BA=A7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/session_manager/include/scene_session_manager.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- window_scene/test/unittest/scene_session_manager_test9.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index d4cf11e0b2..ddbfa63b59 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -378,7 +378,7 @@ public: WMError TerminateSessionByPersistentId(int32_t persistentId); WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, const std::vector& persistentIds, std::vector& surfaceNodeIds) override; - void RefreshPcZOrderList(uint32_t startZOrder, const std::vector&& persistentIds); + void RefreshPcZOrderList(uint32_t startZOrder, std::vector&& persistentIds); protected: SceneSessionManager(); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index f97c4c8dfd..bd5fa38239 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10175,7 +10175,7 @@ WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t return WMError::WM_OK; } -void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::vector&& persistentIds) +void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, std::vector&& persistentIds) { auto task = [this, startZOrder, persistentIds = std::move(persistentIds)] { std::ostringstream oss; @@ -10191,11 +10191,11 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, const std::v TLOGE(WmsLogTag::WMS_LAYOUT, "sceneSession is nullptr persistentId = %{public}d", persistentId); continue; } - sceneSession->SetPcScenePanel(true); if (i > UINT32_MAX - startZOrder) { TLOGE(WmsLogTag::WMS_LAYOUT, "Z order overflow, stop refresh"); break; } + sceneSession->SetPcScenePanel(true); sceneSession->SetZOrder(i + startZOrder); } oss << "]"; diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index d4001c9b10..580294b256 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -608,9 +608,9 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level info3.bundleName_ = "RefreshPcZorder3"; sptr session3 = sptr::MakeSptr(info3, nullptr); ASSERT_NE(session3, nullptr); - persistentIds.push_back(999); session3->SetZOrder(404); ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); + persistentIds.push_back(999); uint32_t startZOrder = 100; ssm_->RefreshPcZOrderList(startZOrder, std::move(persistentIds)); ssm_->RefreshPcZOrderList(UINT32_MAX, std::move(persistentIds)); From ef3386aee8f30000c487fefbd9c7152ef36ed8d6 Mon Sep 17 00:00:00 2001 From: tanchenghao Date: Tue, 27 Aug 2024 14:43:16 +0800 Subject: [PATCH 76/86] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=92=8C=E5=B9=B3?= =?UTF-8?q?=E6=9D=BF=E9=9D=9E=E8=87=AA=E7=94=B1=E7=AA=97=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E7=A6=81=E7=94=A8=E6=9C=80=E5=A4=A7=E5=8C=96=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanchenghao --- wm/src/window_scene_session_impl.cpp | 6 ++++++ wm/test/unittest/window_scene_session_impl_test2.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 8135a1f0c6..398825b642 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2023,6 +2023,12 @@ WMError WindowSceneSessionImpl::Maximize(MaximizePresentation presentation) if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { return WMError::WM_ERROR_INVALID_WINDOW; } + // The device is not supported + auto isPC = windowSystemConfig_.uiType_ == UI_TYPE_PC; + if (!isPC && !IsFreeMultiWindowMode()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "The device is not supported"); + return WMError::WM_ERROR_INVALID_WINDOW; + } if (property_->GetCompatibleModeInPc()) { TLOGE(WmsLogTag::WMS_IMMS, "isCompatibleModeInPc, can not Maximize"); return WMError::WM_ERROR_INVALID_WINDOW; diff --git a/wm/test/unittest/window_scene_session_impl_test2.cpp b/wm/test/unittest/window_scene_session_impl_test2.cpp index ed896fd8c8..7241ed7a18 100644 --- a/wm/test/unittest/window_scene_session_impl_test2.cpp +++ b/wm/test/unittest/window_scene_session_impl_test2.cpp @@ -1464,7 +1464,11 @@ HWTEST_F(WindowSceneSessionImplTest2, Maximize03, Function | SmallTest | Level2) ASSERT_NE(nullptr, window); // case1: only set maximize() MaximizePresentation presentation = MaximizePresentation::ENTER_IMMERSIVE; + window->windowSystemConfig_.uiType_ = "phone"; auto ret = window->Maximize(presentation); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret); + window->windowSystemConfig_.uiType_ = "pc"; + ret = window->Maximize(presentation); ASSERT_EQ(WMError::WM_OK, ret); ASSERT_EQ(window->GetImmersiveModeEnabledState(), true); From 1b3f1c9de5b230af06ee4c878d89c9eee456f27c Mon Sep 17 00:00:00 2001 From: thks Date: Thu, 29 Aug 2024 15:51:24 +0800 Subject: [PATCH 77/86] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=A8=B3=E5=AE=9A?= =?UTF-8?q?=E6=80=A7=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: thks --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 34f3b116dc..a929db5cb5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3876,7 +3876,7 @@ bool SceneSessionManager::IsSessionVisible(const sptr& session) } const auto& state = session->GetSessionState(); if (WindowHelper::IsSubWindow(session->GetWindowType())) { - const auto& parentSceneSession = GetSceneSession(session->GetParentPersistentId()); + const auto& parentSceneSession = session->GetParentSession(); if (parentSceneSession == nullptr) { WLOGFW("Can not find parent for this sub window, id: %{public}d", session->GetPersistentId()); return false; From bc3cf8fe078b5157e4f534e0240bcaa425439020 Mon Sep 17 00:00:00 2001 From: cuiyongzhe Date: Thu, 29 Aug 2024 08:31:32 +0000 Subject: [PATCH 78/86] =?UTF-8?q?RaiseToAppTop=E4=BF=AE=E6=94=B9=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cuiyongzhe --- wm/src/window_adapter.cpp | 4 ++-- wmserver/src/zidl/window_manager_proxy.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index d17788adbb..cf58375adf 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -571,10 +571,10 @@ void WindowAdapter::OffWindowZoom() /** @note @window.hierarchy */ WMError WindowAdapter::RaiseToAppTop(uint32_t windowId) { - INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING); + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); auto wmsProxy = GetWindowManagerServiceProxy(); - CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING); + CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); return wmsProxy->RaiseToAppTop(windowId); } diff --git a/wmserver/src/zidl/window_manager_proxy.cpp b/wmserver/src/zidl/window_manager_proxy.cpp index 7904d12a66..64b4f5d0ef 100644 --- a/wmserver/src/zidl/window_manager_proxy.cpp +++ b/wmserver/src/zidl/window_manager_proxy.cpp @@ -1031,23 +1031,23 @@ WMError WindowManagerProxy::RaiseToAppTop(uint32_t windowId) MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { WLOGFE("WriteInterfaceToken failed"); - return WMError::WM_DO_NOTHING; + return WMError::WM_ERROR_IPC_FAILED; } if (!data.WriteUint32(windowId)) { WLOGFE("Write anchor delatX failed"); - return WMError::WM_DO_NOTHING; + return WMError::WM_ERROR_IPC_FAILED; } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); - return WMError::WM_DO_NOTHING; + return WMError::WM_ERROR_IPC_FAILED; } if (remote->SendRequest(static_cast(WindowManagerMessage::TRANS_ID_RAISE_WINDOW_Z_ORDER), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); - return WMError::WM_DO_NOTHING; + return WMError::WM_ERROR_IPC_FAILED; } return WMError::WM_OK; } From 303b82233d4b9f442c708ca27a9a6e1410c2f6da Mon Sep 17 00:00:00 2001 From: MirMort Date: Thu, 29 Aug 2024 17:09:25 +0800 Subject: [PATCH 79/86] =?UTF-8?q?cast=E6=8A=95=E5=B1=8F=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E4=BF=AE=E6=94=B9=20Signed-off-by:=20MirMort?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session_manager/src/screen_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index e49d6a9960..dd951209a8 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -5393,7 +5393,7 @@ bool ScreenSessionManager::SetVirtualScreenStatus(ScreenId screenId, VirtualScre return false; } - return rsInterface_.SetVirtualScreenStatus(screenId, screenStatus); + return rsInterface_.SetVirtualScreenStatus(rsScreenId, screenStatus); } DMError ScreenSessionManager::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, From 18bf0e38ab33a30f0fcc06bbb300aab34e51bf73 Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 09:09:46 +0000 Subject: [PATCH 80/86] =?UTF-8?q?pc=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E6=9D=A1=E4=BB=B6=E6=BB=A1=E8=B6=B3=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=B0=B1=E8=A1=8C=20=E4=B8=8D=E9=9C=80=E4=B8=A4?= =?UTF-8?q?=E8=80=85=E5=9D=87=E6=BB=A1=E8=B6=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 580294b256..2f1ec7e2b7 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -618,8 +618,8 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level // Due to RefreshPcZOrderList being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds while (true) { - if (session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100 - && std::chrono::duration_cast(std::chrono::system_clock::now() - start).count() >= 3) { + if ((session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100) + || std::chrono::duration_cast(std::chrono::system_clock::now() - start).count() >= 3) { break; } std::this_thread::sleep_for(std::chrono::milliseconds(100)); From 066b6e0bf932e36c9463bd7895934ca75dda125f Mon Sep 17 00:00:00 2001 From: yu Date: Thu, 29 Aug 2024 01:56:31 +0000 Subject: [PATCH 81/86] bugfix destroy surface node Signed-off-by: yu Change-Id: Ic759b341db5a804173981292af3264d5435f0be0 --- wm/src/window_scene_session_impl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index d6195f505b..2319544c72 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1362,6 +1362,8 @@ WMError WindowSceneSessionImpl::Destroy(bool needNotifyServer, bool needClearLis if (WindowHelper::IsMainWindow(GetType())) { SetUIContentComplete(); } + + surfaceNode_ = nullptr; TLOGI(WmsLogTag::WMS_LIFE, "Destroy success, id: %{public}d", property_->GetPersistentId()); return WMError::WM_OK; } From 69eecc04443b9a28c917e627feaae626d5ad343f Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 09:15:58 +0000 Subject: [PATCH 82/86] =?UTF-8?q?pc=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E4=B8=BA=E9=98=B2=E6=AD=A2move=E6=8E=89=E6=95=B0=E6=8D=AE=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA=E4=B8=B4=E6=97=B6=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 2f1ec7e2b7..b1d0aaadff 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -612,8 +612,9 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); persistentIds.push_back(999); uint32_t startZOrder = 100; + std::vector newPersistentIds = persistentIds; ssm_->RefreshPcZOrderList(startZOrder, std::move(persistentIds)); - ssm_->RefreshPcZOrderList(UINT32_MAX, std::move(persistentIds)); + ssm_->RefreshPcZOrderList(UINT32_MAX, std::move(newPersistentIds)); auto start = std::chrono::system_clock::now(); // Due to RefreshPcZOrderList being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds From f6f3c741d414ee47a13d3cb0638168a44d8acbf7 Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 09:20:01 +0000 Subject: [PATCH 83/86] =?UTF-8?q?pc=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index b1d0aaadff..d75dcf8a75 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -588,7 +588,7 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function | * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level3) { - vector persistentIds; + std::vector persistentIds; SessionInfo info1; info1.abilityName_ = "RefreshPcZorder1"; info1.bundleName_ = "RefreshPcZorder1"; From 096a23169db74c68fc7fdc71e90906df588bf5c1 Mon Sep 17 00:00:00 2001 From: flybear Date: Thu, 29 Aug 2024 09:31:55 +0000 Subject: [PATCH 84/86] =?UTF-8?q?pc=E5=B1=82=E7=BA=A7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: flybear --- window_scene/test/unittest/scene_session_manager_test9.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index d75dcf8a75..5317131648 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -619,8 +619,8 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, Function | SmallTest | Level // Due to RefreshPcZOrderList being asynchronous, spin lock is added. // The spin lock itself is set with a timeout escape time of 3 seconds while (true) { - if ((session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100) - || std::chrono::duration_cast(std::chrono::system_clock::now() - start).count() >= 3) { + if ((session1->GetZOrder() != 0 && session2->GetZOrder() != 0 && session1->GetZOrder() != 100) || + std::chrono::duration_cast(std::chrono::system_clock::now() - start).count() >= 3) { break; } std::this_thread::sleep_for(std::chrono::milliseconds(100)); From a00666ae5a53f503da20a11da8a76df27ce116bb Mon Sep 17 00:00:00 2001 From: whqwe Date: Thu, 29 Aug 2024 19:36:32 +0800 Subject: [PATCH 85/86] fix vsync trace print format Signed-off-by: whqwe --- wm/src/vsync_station.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/vsync_station.cpp b/wm/src/vsync_station.cpp index 12464f23c0..9c5748167b 100644 --- a/wm/src/vsync_station.cpp +++ b/wm/src/vsync_station.cpp @@ -165,7 +165,7 @@ void VsyncStation::RemoveCallback() void VsyncStation::VsyncCallbackInner(int64_t timestamp, int64_t frameCount) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, - "OnVsyncCallback %{public}" PRId64 ":%{public}" PRId64, timestamp, frameCount); + "OnVsyncCallback %" PRId64 ":%" PRId64, timestamp, frameCount); Callbacks vsyncCallbacks; { std::lock_guard lock(mutex_); From 57e463e6ee3f2a4bc20bedc1f70fd0f954884d20 Mon Sep 17 00:00:00 2001 From: z00514981 Date: Thu, 29 Aug 2024 17:19:55 +0800 Subject: [PATCH 86/86] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E9=80=9A=E8=AE=AF=E6=AC=A1=E6=95=B0=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z00514981 Change-Id: I21d735d1fc8cd8ea7e74a1377d242d69d40bfbc7 --- wm/include/window_scene_session_impl.h | 5 +-- wm/include/window_session_impl.h | 4 ++- wm/src/window_scene_session_impl.cpp | 42 ++++++++++++++++---------- wm/src/window_session_impl.cpp | 17 +++++++---- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 9788cf1ac5..d0e2137368 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -216,7 +216,8 @@ private: void CalculateNewLimitsByLimits( WindowLimits& newLimits, WindowLimits& customizedLimits, float& virtualPixelRatio); void CalculateNewLimitsByRatio(WindowLimits& newLimits, WindowLimits& customizedLimits); - void NotifyDisplayInfoChange(); + void NotifyDisplayInfoChange(const sptr& info = nullptr); + void UpdateDensityInner(const sptr& info = nullptr); /** * Window Immersive @@ -230,7 +231,7 @@ private: std::atomic isDefaultDensityEnabled_ = false; std::atomic getAvoidAreaCnt_ = 0; bool enableImmersiveMode_ = false; - void PreLayoutOnShow(WindowType type); + void PreLayoutOnShow(WindowType type, const sptr& info = nullptr); void InitSystemSessionDragEnable(); WMError RegisterKeyboardPanelInfoChangeListener(const sptr& listener) override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 2622ba50dc..b07df85921 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -28,6 +28,7 @@ #include "singleton_container.h" #include "common/include/window_session_property.h" +#include "display_info.h" #include "interfaces/include/ws_common.h" #include "interfaces/include/ws_common_inner.h" #include "session/container/include/zidl/session_stage_stub.h" @@ -276,7 +277,8 @@ protected: virtual WMError SetLayoutFullScreenByApiVersion(bool status); virtual float GetVirtualPixelRatio(sptr displayInfo); void UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason, - const std::shared_ptr& rsTransaction = nullptr); + const std::shared_ptr& rsTransaction = nullptr, + const sptr& info = nullptr); void NotifySizeChange(Rect rect, WindowSizeChangeReason reason); void NotifySubWindowClose(bool& terminateCloseProcess); void NotifySwitchFreeMultiWindow(bool enable); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index d6195f505b..56a92fc192 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -25,7 +25,6 @@ #include "anr_handler.h" #include "color_parser.h" #include "common/include/future_callback.h" -#include "display_info.h" #include "singleton_container.h" #include "display_manager.h" #include "display_manager_adapter.h" @@ -950,7 +949,7 @@ void WindowSceneSessionImpl::UpdateSubWindowStateAndNotify(int32_t parentPersist } } -void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type) +void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type, const sptr& info) { std::shared_ptr uiContent = GetUIContentSharedPtr(); if (uiContent == nullptr) { @@ -961,7 +960,7 @@ void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type) TLOGI(WmsLogTag::WMS_LIFE, "name: %{public}s, id: %{public}d, type: %{public}u, requestRect:%{public}s", property_->GetWindowName().c_str(), GetPersistentId(), type, requestRect.ToString().c_str()); if (requestRect.width_ != 0 && requestRect.height_ != 0) { - UpdateViewportConfig(GetRequestRect(), WindowSizeChangeReason::RESIZE); + UpdateViewportConfig(GetRequestRect(), WindowSizeChangeReason::RESIZE, nullptr, info); } state_ = WindowState::STATE_SHOWN; requestState_ = WindowState::STATE_SHOWN; @@ -1017,7 +1016,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) float density = GetVirtualPixelRatio(displayInfo); if (!MathHelper::NearZero(virtualPixelRatio_ - density) || !MathHelper::NearZero(property_->GetLastLimitsVpr() - density)) { - UpdateDensity(); + UpdateDensityInner(displayInfo); } WMError ret = UpdateAnimationFlagProperty(withAnimation); @@ -1030,7 +1029,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) if (WindowHelper::IsMainWindow(type)) { ret = static_cast(hostSession->Foreground(property_, true)); } else if (WindowHelper::IsSubWindow(type) || WindowHelper::IsSystemWindow(type)) { - PreLayoutOnShow(type); + PreLayoutOnShow(type, displayInfo); // Add maintenance logs before the IPC process. TLOGI(WmsLogTag::WMS_LIFE, "Show session [name: %{public}s, id: %{public}d]", property_->GetWindowName().c_str(), GetPersistentId()); @@ -1055,7 +1054,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) static_cast(ret), property_->GetWindowName().c_str(), GetPersistentId()); } NotifyWindowStatusChange(GetMode()); - NotifyDisplayInfoChange(); + NotifyDisplayInfoChange(displayInfo); return ret; } @@ -3582,6 +3581,11 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vector& info) { if (!userLimitsSet_) { UpdateWindowSizeLimits(); @@ -3593,10 +3597,10 @@ void WindowSceneSessionImpl::UpdateDensity() } } - NotifyDisplayInfoChange(); + NotifyDisplayInfoChange(info); auto preRect = GetRect(); - UpdateViewportConfig(preRect, WindowSizeChangeReason::UNDEFINED); + UpdateViewportConfig(preRect, WindowSizeChangeReason::UNDEFINED, nullptr, info); WLOGFI("[%{public}d, %{public}d, %{public}u, %{public}u]", preRect.posX_, preRect.posY_, preRect.width_, preRect.height_); } @@ -3655,17 +3659,23 @@ WSError WindowSceneSessionImpl::UpdateOrientation() return WSError::WS_OK; } -void WindowSceneSessionImpl::NotifyDisplayInfoChange() +void WindowSceneSessionImpl::NotifyDisplayInfoChange(const sptr& info) { TLOGD(WmsLogTag::DMS, "id: %{public}d", GetPersistentId()); - auto displayId = property_->GetDisplayId(); - auto display = SingletonContainer::IsDestroyed() ? nullptr : - SingletonContainer::Get().GetDisplayById(displayId); - if (display == nullptr) { - TLOGE(WmsLogTag::DMS, "get display by displayId %{public}" PRIu64 " failed.", displayId); - return; + sptr displayInfo = nullptr; + DisplayId displayId = 0; + if (info == nullptr) { + displayId = property_->GetDisplayId(); + auto display = SingletonContainer::IsDestroyed() ? nullptr : + SingletonContainer::Get().GetDisplayById(displayId); + if (display == nullptr) { + TLOGE(WmsLogTag::DMS, "get display by displayId %{public}" PRIu64 " failed.", displayId); + return; + } + displayInfo = display->GetDisplayInfo(); + } else { + displayInfo = info; } - auto displayInfo = display->GetDisplayInfo(); if (displayInfo == nullptr) { TLOGE(WmsLogTag::DMS, "get display info %{public}" PRIu64 " failed.", displayId); return; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 32506d705a..c13d8cdb63 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -889,14 +889,19 @@ float WindowSessionImpl::GetVirtualPixelRatio(sptr displayInfo) } void WindowSessionImpl::UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason, - const std::shared_ptr& rsTransaction) + const std::shared_ptr& rsTransaction, const sptr& info) { - auto display = SingletonContainer::Get().GetDisplayById(property_->GetDisplayId()); - if (display == nullptr) { - WLOGFE("display is null!"); - return; + sptr displayInfo; + if (info == nullptr) { + auto display = SingletonContainer::Get().GetDisplayById(property_->GetDisplayId()); + if (display == nullptr) { + WLOGFE("display is null!"); + return; + } + displayInfo = display->GetDisplayInfo(); + } else { + displayInfo = info; } - auto displayInfo = display->GetDisplayInfo(); if (displayInfo == nullptr) { WLOGFE("displayInfo is null!"); return;