From ab9221d889e7fba6354e2bb626fc5ca962363b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B1=89=E5=85=83?= Date: Mon, 28 Oct 2024 11:42:39 +0800 Subject: [PATCH 001/171] =?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: wm/src/window_session_impl.cpp --- wm/src/window_session_impl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 1b67e5f20f..74eda70be5 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1593,6 +1593,21 @@ WMError WindowSessionImpl::SetResizeByDragEnabled(bool dragEnabled) WMError WindowSessionImpl::SetRaiseByClickEnabled(bool raiseEnabled) { WLOGFD("%{public}d", raiseEnabled); + auto parentId = GetParentId(); + if (parentId == INVALID_SESSION_ID) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "Only the children of the main window can be raised!"); + return WMError::WM_ERROR_INVALID_PARENT; + } + + if (!WindowHelper::IsSubWindow(GetType())) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "Must be app sub window window!"); + return WMError::WM_ERROR_INVALID_CALLING; + } + + if (state_ != WindowState::STATE_SHOWN) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "The sub window must be shown!"); + return WMError::WM_DO_NOTHING; + } if (IsWindowSessionInvalid()) { return WMError::WM_ERROR_INVALID_WINDOW; } From b321bd328b145aa5ea5096829059379398249da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B1=89=E5=85=83?= Date: Tue, 29 Oct 2024 18:25:05 +0800 Subject: [PATCH 002/171] =?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: wm/test/unittest/window_session_impl_test.cpp modified: wm/test/unittest/window_session_impl_test.cpp modified: wm/test/unittest/window_session_impl_test.cpp --- wm/test/unittest/window_session_impl_test.cpp | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 8d5e7a49e7..29ac48f721 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1920,18 +1920,32 @@ HWTEST_F(WindowSessionImplTest, SetRaiseByClickEnabled01, Function | SmallTest | { sptr option = new WindowOption(); option->SetWindowName("SetRaiseByClickEnabled01"); + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr window = new(std::nothrow) WindowSessionImpl(option); ASSERT_NE(nullptr, window); WMError retCode = window->SetRaiseByClickEnabled(true); + ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_PARENT); + option->SetWindowName("SetRaiseByClickForFloatWindow"); + option->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + sptr floatWindow = new(std::nothrow) WindowSessionImpl(option); + floatWindow->property_->SetParentPersistentId(1); + ASSERT_NE(nullptr, floatWindow); + retCode = floatWindow->SetRaiseByClickEnabled(true); + ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_CALLING); + option->SetWindowName("SetRaiseByClickForSubWindow"); + option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + sptr subWindow = new(std::nothrow) WindowSessionImpl(option); + ASSERT_NE(nullptr, subWindow); + subWindow->property_->SetParentPersistentId(1); + subWindow->Hide(); + retCode = subWindow->SetRaiseByClickEnabled(true); + ASSERT_EQ(retCode, WMError::WM_DO_NOTHING); + subWindow->state_ = WindowState::STATE_SHOWN; + retCode = subWindow->SetRaiseByClickEnabled(true); ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW); - window->property_->SetPersistentId(1); - SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; - sptr session = new(std::nothrow) SessionMocker(sessionInfo); - ASSERT_NE(nullptr, session); - window->hostSession_ = session; - window->state_ = WindowState::STATE_CREATED; - window->SetRaiseByClickEnabled(true); - ASSERT_NE(nullptr, session); + subWindow->property_->SetParentPersistentId(2); + subWindow->SetRaiseByClickEnabled(true); + ASSERT_EQ(subWindow->property_->GetRaiseEnabled(), true); } /** From 42e9ca5c735d373c213fd3b8a0a79c47885e250b Mon Sep 17 00:00:00 2001 From: meikun4 Date: Wed, 6 Nov 2024 14:49:40 +0800 Subject: [PATCH 003/171] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtdd=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun4 --- wm/src/window_scene_session_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 1ae2b3ae4c..d3187f14e0 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2158,7 +2158,7 @@ WMError WindowSceneSessionImpl::SetFullScreen(bool status) } if (WindowHelper::IsMainWindow(GetType()) && - (IsFreeMultiWindowMode() || windowSystemConfig_.IsPcWindow())) { + (IsFreeMultiWindowMode() || (!windowSystemConfig_.IsPhoneWindow() && !windowSystemConfig_.IsPadWindow()))) { if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported"); return WMError::WM_ERROR_INVALID_WINDOW; @@ -3570,6 +3570,7 @@ WSError WindowSceneSessionImpl::SwitchFreeMultiWindow(bool enable) } NotifySwitchFreeMultiWindow(enable); // Switch process finish, update system config + windowSystemConfig_.freeMultiWindowEnable_ = enable; std::unique_lock lock(windowSessionMutex_); for (const auto& winPair : windowSessionMap_) { auto window = winPair.second.second; From b38d5166cab6c997d105d1c7895bd9d8d5e335dd Mon Sep 17 00:00:00 2001 From: meikun4 Date: Thu, 7 Nov 2024 20:31:09 +0800 Subject: [PATCH 004/171] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtdd=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun4 --- wm/src/window_scene_session_impl.cpp | 1 - wm/test/unittest/window_scene_session_impl_test3.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index d3187f14e0..fd251ba010 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3570,7 +3570,6 @@ WSError WindowSceneSessionImpl::SwitchFreeMultiWindow(bool enable) } NotifySwitchFreeMultiWindow(enable); // Switch process finish, update system config - windowSystemConfig_.freeMultiWindowEnable_ = enable; std::unique_lock lock(windowSessionMutex_); for (const auto& winPair : windowSessionMap_) { auto window = winPair.second.second; diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index 8b91320475..dee1f26b63 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -174,6 +174,8 @@ HWTEST_F(WindowSceneSessionImplTest3, UpdateTitleInTargetPos, Function | SmallTe ASSERT_NE(nullptr, session); windowSceneSessionImpl->hostSession_ = session; windowSceneSessionImpl->state_ = WindowState::STATE_SHOWN; + windowSceneSessionImpl->windowSessionMap_.insert(std::make_pair(windowSceneSessionImpl->GetWindowName(), + std::make_pair(windowSceneSessionImpl->GetWindowId(), windowSceneSessionImpl))); ret = windowSceneSessionImpl->SwitchFreeMultiWindow(true); EXPECT_EQ(WSError::WS_OK, ret); ret = windowSceneSessionImpl->SwitchFreeMultiWindow(false); @@ -191,6 +193,7 @@ HWTEST_F(WindowSceneSessionImplTest3, UpdateTitleInTargetPos, Function | SmallTe EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); ret = windowSceneSessionImpl->UpdateTitleInTargetPos(false, 0); EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); + windowSceneSessionImpl->windowSessionMap_.clear(); } /** From dafc6e95f9845d3b5cf6689851876ddebda47eb0 Mon Sep 17 00:00:00 2001 From: wangziyao Date: Thu, 7 Nov 2024 22:24:15 +0800 Subject: [PATCH 005/171] Quick opening and close of DMS Signed-off-by: wangziyao --- .../src/fold_screen_controller/single_display_fold_policy.cpp | 1 + .../fold_screen_controller/single_display_pocket_fold_policy.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp index 4bb06fd13b..40d1af37f2 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp @@ -107,6 +107,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod SetdisplayModeChangeStatus(true); ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); + RSInterfaces::GetInstance().isScreenSwitching(); switch (displayMode) { case FoldDisplayMode::MAIN: { ChangeScreenDisplayModeToMain(screenSession); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp index 32dbed54e7..c19ec9118f 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp @@ -108,6 +108,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp } ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); + RSInterfaces::GetInstance().isScreenSwitching(); ChangeScreenDisplayModeProc(screenSession, displayMode); { std::lock_guard lock_mode(displayModeMutex_); From c58a3dc8e8abff5f763e11aa6f615ea62d8fcde2 Mon Sep 17 00:00:00 2001 From: wangziyao Date: Fri, 8 Nov 2024 09:56:43 +0800 Subject: [PATCH 006/171] Quick opening and close of DMS Signed-off-by: wangziyao --- .../src/fold_screen_controller/single_display_fold_policy.cpp | 2 +- .../single_display_pocket_fold_policy.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp index 40d1af37f2..13f82386ba 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp @@ -107,7 +107,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod SetdisplayModeChangeStatus(true); ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); - RSInterfaces::GetInstance().isScreenSwitching(); + RSInterfaces::GetInstance().isScreenSwitching(true); switch (displayMode) { case FoldDisplayMode::MAIN: { ChangeScreenDisplayModeToMain(screenSession); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp index c19ec9118f..c3e2b25ba4 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp @@ -108,7 +108,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp } ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); - RSInterfaces::GetInstance().isScreenSwitching(); + RSInterfaces::GetInstance().isScreenSwitching(true); ChangeScreenDisplayModeProc(screenSession, displayMode); { std::lock_guard lock_mode(displayModeMutex_); From af51374c742c0e2e58c305f7429593d604002431 Mon Sep 17 00:00:00 2001 From: rsyys Date: Sat, 9 Nov 2024 14:47:57 +0800 Subject: [PATCH 007/171] GetVisibilityWindowInfo Signed-off-by: rsyys --- .../napi/window_runtime/window_napi/js_window_utils.cpp | 1 + utils/include/window_visibility_info.h | 9 ++++++--- utils/src/window_visibility_info.cpp | 3 ++- .../session_manager/src/scene_session_manager.cpp | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 68771a5fb1..50e5cfb834 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -563,6 +563,7 @@ napi_value CreateJsWindowInfoObject(napi_env env, const sptrGetWindowId())); napi_set_named_property(env, objValue, "windowStatusType", CreateJsValue(env, static_cast(info->GetWindowStatus()))); + napi_set_named_property(env, objValue, "isFocused", CreateJsValue(env, info->IsFocused())); return objValue; } diff --git a/utils/include/window_visibility_info.h b/utils/include/window_visibility_info.h index 72f4a6b3a9..937ba3565e 100644 --- a/utils/include/window_visibility_info.h +++ b/utils/include/window_visibility_info.h @@ -71,9 +71,9 @@ public: WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState, WindowType winType, WindowStatus windowStatus, const Rect& rect, const std::string& bundleName, - const std::string& abilityName) : windowId_(winId), pid_(pid), uid_(uid), visibilityState_(visibilityState), - windowType_(winType), windowStatus_(windowStatus), rect_(rect), bundleName_(bundleName), - abilityName_(abilityName) {} + const std::string& abilityName, const bool isFocused) : windowId_(winId), pid_(pid), uid_(uid), + visibilityState_(visibilityState), windowType_(winType), windowStatus_(windowStatus), rect_(rect), + bundleName_(bundleName), abilityName_(abilityName), isFocused_(isFocused) {} /** * @brief Deconstruct of WindowVisibilityInfo. @@ -109,6 +109,8 @@ public: WindowVisibilityState GetWindowVisibilityState() const { return visibilityState_; } + bool IsFocused() const { return isFocused_; } + uint32_t windowId_ { INVALID_WINDOW_ID }; int32_t pid_ { 0 }; int32_t uid_ { 0 }; @@ -118,6 +120,7 @@ public: Rect rect_ = {0, 0, 0, 0}; std::string bundleName_; std::string abilityName_; + bool isFocused_ = false; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H \ No newline at end of file diff --git a/utils/src/window_visibility_info.cpp b/utils/src/window_visibility_info.cpp index 6fd09537c3..1461f7d1b3 100644 --- a/utils/src/window_visibility_info.cpp +++ b/utils/src/window_visibility_info.cpp @@ -28,7 +28,7 @@ bool WindowVisibilityInfo::Marshalling(Parcel& parcel) const parcel.WriteUint32(static_cast(windowType_)) && parcel.WriteUint32(static_cast(windowStatus_)) && parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) && parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) && - parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_); + parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_) && parcel.WriteBool(isFocused_); } WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel) @@ -52,6 +52,7 @@ WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel) windowVisibilityInfo->rect_ = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() }; windowVisibilityInfo->bundleName_ = parcel.ReadString(); windowVisibilityInfo->abilityName_ = parcel.ReadString(); + windowVisibilityInfo->isFocused_ = parcel.ReadBool(); return windowVisibilityInfo; } } // 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 6b8c94c11c..e98d83154d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9793,7 +9793,8 @@ WMError SceneSessionManager::GetVisibilityWindowInfo(std::vectorGetSessionProperty()); infos.emplace_back(sptr::MakeSptr(session->GetWindowId(), session->GetCallingPid(), session->GetCallingUid(), session->GetVisibilityState(), session->GetWindowType(), windowStatus, rect, - session->GetSessionInfo().bundleName_, session->GetSessionInfo().abilityName_)); + session->GetSessionInfo().bundleName_, session->GetSessionInfo().abilityName_, + session->IsFocused())); } return WMError::WM_OK; }; From 15e5832c57833d6c855171cf38f09b856316997b Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Sat, 9 Nov 2024 10:52:53 +0000 Subject: [PATCH 008/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 74eda70be5..4f65117cdc 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1600,7 +1600,7 @@ WMError WindowSessionImpl::SetRaiseByClickEnabled(bool raiseEnabled) } if (!WindowHelper::IsSubWindow(GetType())) { - TLOGE(WmsLogTag::WMS_HIERARCHY, "Must be app sub window window!"); + TLOGE(WmsLogTag::WMS_HIERARCHY, "Must be app sub window!"); return WMError::WM_ERROR_INVALID_CALLING; } From 3d1a9c97fe38057967b32c9c9a6e826105ba0dfb Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Sat, 9 Nov 2024 11:06:47 +0000 Subject: [PATCH 009/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=86=97=E4=BD=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 4f65117cdc..a20a4ef950 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1595,7 +1595,7 @@ WMError WindowSessionImpl::SetRaiseByClickEnabled(bool raiseEnabled) WLOGFD("%{public}d", raiseEnabled); auto parentId = GetParentId(); if (parentId == INVALID_SESSION_ID) { - TLOGE(WmsLogTag::WMS_HIERARCHY, "Only the children of the main window can be raised!"); + TLOGE(WmsLogTag::WMS_HIERARCHY, "Parent id is invalid!"); return WMError::WM_ERROR_INVALID_PARENT; } From 37f672eadf1921a59000096914c72a61f07dbf04 Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Sat, 9 Nov 2024 11:28:23 +0000 Subject: [PATCH 010/171] =?UTF-8?q?setRaiseByClickEnabled=20tdd=20?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E5=88=86?= =?UTF-8?q?=E8=A1=8C=E5=A2=9E=E5=8A=A0=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- wm/test/unittest/window_session_impl_test.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 29ac48f721..2267569416 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1923,26 +1923,33 @@ HWTEST_F(WindowSessionImplTest, SetRaiseByClickEnabled01, Function | SmallTest | option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr window = new(std::nothrow) WindowSessionImpl(option); ASSERT_NE(nullptr, window); + WMError retCode = window->SetRaiseByClickEnabled(true); ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_PARENT); + option->SetWindowName("SetRaiseByClickForFloatWindow"); option->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); sptr floatWindow = new(std::nothrow) WindowSessionImpl(option); floatWindow->property_->SetParentPersistentId(1); ASSERT_NE(nullptr, floatWindow); + retCode = floatWindow->SetRaiseByClickEnabled(true); ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_CALLING); + option->SetWindowName("SetRaiseByClickForSubWindow"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); sptr subWindow = new(std::nothrow) WindowSessionImpl(option); ASSERT_NE(nullptr, subWindow); + subWindow->property_->SetParentPersistentId(1); subWindow->Hide(); retCode = subWindow->SetRaiseByClickEnabled(true); ASSERT_EQ(retCode, WMError::WM_DO_NOTHING); + subWindow->state_ = WindowState::STATE_SHOWN; retCode = subWindow->SetRaiseByClickEnabled(true); ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW); + subWindow->property_->SetParentPersistentId(2); subWindow->SetRaiseByClickEnabled(true); ASSERT_EQ(subWindow->property_->GetRaiseEnabled(), true); From f67fd7b124a9147dee5e74f158539132b8378f11 Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Sat, 9 Nov 2024 12:05:46 +0000 Subject: [PATCH 011/171] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=90=E7=AA=97id?= =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- wm/src/window_session_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a20a4ef950..8811614591 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1595,7 +1595,8 @@ WMError WindowSessionImpl::SetRaiseByClickEnabled(bool raiseEnabled) WLOGFD("%{public}d", raiseEnabled); auto parentId = GetParentId(); if (parentId == INVALID_SESSION_ID) { - TLOGE(WmsLogTag::WMS_HIERARCHY, "Parent id is invalid!"); + TLOGE(WmsLogTag::WMS_HIERARCHY, "Window id: %{public}d Parent id is invalid!", + GetPersistentId()); return WMError::WM_ERROR_INVALID_PARENT; } From 3044e14003496441f1889d0eaa3d68d7d9274516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sun, 10 Nov 2024 12:51:00 +0000 Subject: [PATCH 012/171] =?UTF-8?q?=E7=A8=B3=E5=AE=9A=E6=80=A7=EF=BC=9APC?= =?UTF-8?q?=E7=AA=97=E5=8F=A3OnSetTitleAndDockHoverShown=E3=80=81OnMinimiz?= =?UTF-8?q?e=E3=80=81OnSetSubWindowModal=E3=80=81OnSetWindowMask=E5=88=9B?= =?UTF-8?q?=E5=BB=BAtask=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- .../window_runtime/window_napi/js_window.cpp | 221 +++++++++--------- 1 file changed, 111 insertions(+), 110 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index d44784d06e..4e726a3937 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2644,33 +2644,37 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf if (argc > 1 && !ConvertFromJsValue(env, argv[INDEX_ONE], isDockHoverShown)) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert isDockHoverShown parameter"); } - const char* const funcName = __func__; - NapiAsyncTask::CompleteCallback complete = - [weakToken = wptr(windowToken_), isTitleHoverShown, isDockHoverShown, funcName](napi_env env, - NapiAsyncTask& task, int32_t status) { - auto window = weakToken.promote(); - if (window == nullptr) { - TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", funcName); - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); - return; - } - WMError errCode = window->SetTitleAndDockHoverShown(isTitleHoverShown, isDockHoverShown); - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); - if (ret != WmErrorCode::WM_OK) { - TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", funcName); - task.Reject(env, JsErrUtils::CreateJsError(env, - ret, "Window OnSetTitleAndDockHoverShown failed.")); - } else { - task.Resolve(env, NapiGetUndefined(env)); - } - TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]", - funcName, window->GetWindowId(), window->GetWindowName().c_str(), - isTitleHoverShown, isDockHoverShown); - }; - napi_value lastParam = (argc <= 2) ? nullptr : (GetType(env, argv[2]) == napi_function ? argv[2] : nullptr); + // 2: params num; 2: index of callback + napi_value lastParam = (argc <= 2) ? nullptr : + (GetType(env, argv[INDEX_TWO]) == napi_function ? argv[INDEX_TWO] : nullptr); napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::OnSetTitleAndDockHoverShown", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); + const char* const funcName = __func__; + NapiAsyncTask::CompleteCallback complete = [windowToken = wptr(windowToken_), isTitleHoverShown, + isDockHoverShown, env, task = napiAsyncTask, funcName] { + auto window = windowToken.promote(); + if (window == nullptr) { + TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", funcName); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + return; + } + WMError errCode = window->SetTitleAndDockHoverShown(isTitleHoverShown, isDockHoverShown); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); + if (ret != WmErrorCode::WM_OK) { + TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", funcName); + task.Reject(env, JsErrUtils::CreateJsError(env, + ret, "Window OnSetTitleAndDockHoverShown failed.")); + } else { + task.Resolve(env, NapiGetUndefined(env)); + } + TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]", + funcName, window->GetWindowId(), window->GetWindowName().c_str(), + isTitleHoverShown, isDockHoverShown); + }; + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { + napiAsyncTask->Reject(env, CreateJsError(env, + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } return result; } @@ -5896,52 +5900,49 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) { - WmErrorCode errCode = WmErrorCode::WM_OK; - errCode = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; - size_t argc = 4; - napi_value argv[4] = {nullptr}; + size_t argc = FOUR_PARAMS_SIZE; + napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > 1) { - WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } - if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } - if (errCode == WmErrorCode::WM_OK && WindowHelper::IsSubWindow(windowToken_->GetType())) { - WLOGFE("subWindow hide"); + if (WindowHelper::IsSubWindow(windowToken_->GetType())) { + TLOGE(WmsLogTag::WMS_LAYOUT, "subWindow hide"); return HideWindowFunction(env, info, WmErrorCode::WM_OK); } - wptr weakToken(windowToken_); - NapiAsyncTask::CompleteCallback complete = - [weakToken, errCode](napi_env env, NapiAsyncTask& task, int32_t status) mutable { - auto weakWindow = weakToken.promote(); - errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode; - if (errCode != WmErrorCode::WM_OK) { - task.Reject(env, - JsErrUtils::CreateJsError(env, errCode, "OnMinimize failed.")); - WLOGFE("window is nullptr"); - return; - } - WMError ret = weakWindow->Minimize(); - if (ret == WMError::WM_OK) { - task.Resolve(env, NapiGetUndefined(env)); - } else { - WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed.")); - } - WLOGI("[NAPI]Window [%{public}u, %{public}s] minimize end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); - }; - napi_value lastParam = (argc == 0) ? nullptr : - (GetType(env, argv[0]) == napi_function ? argv[0] : nullptr); + (GetType(env, argv[INDEX_ZERO]) == napi_function ? argv[INDEX_ZERO] : nullptr); napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::OnMinimize", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); - return result; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); + const char* const where = __func__; + auto asyncTask = [windowToken = wptr(windowToken_), env, task = napiAsyncTask, where] { + auto window = windowToken.promote(); + if (window == nullptr) { + task->Reject(env, + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr")); + return; + } + WMError ret = window->Minimize(); + if (ret == WMError::WM_OK) { + task->Resolve(env, NapiGetUndefined(env)); + } else { + WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed.")); + } + TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s [NAPI]Window [%{public}u, %{public}s] minimize end, ret = %{public}d", + where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); + }; + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { + napiAsyncTask->Reject(env, CreateJsError(env, + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } } napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) @@ -6314,8 +6315,8 @@ napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_inf napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) { - size_t argc = 4; - napi_value argv[4] = { nullptr }; + size_t argc = FOUR_PARAMS_SIZE; + napi_value argv[FOUR_PARAMS_SIZE] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argc > 2) { // 1: the minimum param num 2: the maximum param num TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc); @@ -6343,40 +6344,39 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } } - + napi_value result = nullptr; + std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); const char* const where = __func__; - NapiAsyncTask::CompleteCallback complete = - [where, window = windowToken_, isModal, modalityType](napi_env env, NapiAsyncTask& task, int32_t status) { + auto asyncTask = [where, window = wptr(windowToken_), isModal, modalityType, env, task = napiAsyncTask] { if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr.")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr.")); return; } if (!WindowHelper::IsSubWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s invalid call, type:%{public}d", where, window->GetType()); - task.Reject(env, JsErrUtils::CreateJsError(env, + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, "invalid window type.")); return; } WMError ret = window->SetSubWindowModal(isModal, modalityType); if (ret == WMError::WM_OK) { - task.Resolve(env, NapiGetUndefined(env)); + task->Resolve(env, NapiGetUndefined(env)); } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); TLOGNE(WmsLogTag::WMS_SUB, "%{public}s set failed, ret is %{public}d", where, wmErrorCode); - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed")); } TLOGNI(WmsLogTag::WMS_SUB, "%{public}s id:%{public}u, name:%{public}s, isModal:%{public}d, modalityType:%{public}hhu", where, window->GetWindowId(), window->GetWindowName().c_str(), isModal, modalityType); }; - napi_value lastParam = nullptr; - napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::SetSubWindowModal", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); - return result; + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { + napiAsyncTask->(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } } napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info info) @@ -6584,51 +6584,52 @@ napi_value JsWindow::OnSetWindowTitleButtonVisible(napi_env env, napi_callback_i napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) { - size_t argc = 4; - napi_value argv[4] = {nullptr}; + size_t argc = FOUR_PARAMS_SIZE; + napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("Argc is invalid: %{public}zu", argc); + TLOGI(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - if (!CheckWindowMaskParams(env, argv[0])) { + if (!CheckWindowMaskParams(env, argv[INDEX_ZERO])) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } std::vector> windowMask; - if (!GetWindowMaskFromJsValue(env, argv[0], windowMask)) { - WLOGFE("GetWindowMaskFromJsValue failed"); + if (!GetWindowMaskFromJsValue(env, argv[INDEX_ZERO], windowMask)) { + TLOGI(WmsLogTag::DEFAULT, "GetWindowMaskFromJsValue failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - wptr weakToken(windowToken_); - NapiAsyncTask::CompleteCallback complete = - [weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { - auto weakWindow = weakToken.promote(); - if (weakWindow == nullptr) { - WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate params")); - return; - } - if (!WindowHelper::IsSubWindow(weakWindow->GetType()) && - !WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) { - WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate window type")); - return; - } - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, JsErrUtils::CreateJsError(env, ret)); - WLOGFE("Window [%{public}u, %{public}s] set window mask failed", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); - return; - } - task.Resolve(env, NapiGetUndefined(env)); - WLOGI("Window [%{public}u, %{public}s] set window mask succeed", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); - }; - napi_value lastParam = nullptr; napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::OnSetWindowMask", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); + const char* const where = __func__; + auto asyncTask = [windowToken = wptr(windowToken_), windowMask, env, task = napiAsyncTask, where] { + auto window = windowToken.promote(); + if (window == nullptr) { + WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr")); + return; + } + if (!WindowHelper::IsSubWindow(window->GetType()) && + !WindowHelper::IsAppFloatingWindow(window->GetType())) { + WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate window type")); + return; + } + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMask(windowMask)); + if (ret != WmErrorCode::WM_OK) { + task->Reject(env, JsErrUtils::CreateJsError(env, ret)); + TLOGNE((WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask failed", + where, window->GetWindowId(), window->GetWindowName().c_str()); + return; + } + task->Resolve(env, NapiGetUndefined(env)); + TLOGNI((WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask succeed", + where, window->GetWindowId(), window->GetWindowName().c_str()); + }; + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { + napiAsyncTask->Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } return result; } From 7f233652b04a97142a43fe52eccfad72f3c72af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Mon, 11 Nov 2024 02:08:53 +0000 Subject: [PATCH 013/171] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- .../napi/window_runtime/window_napi/js_window.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 4e726a3937..35f8f26951 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2655,18 +2655,18 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", funcName); - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); return; } WMError errCode = window->SetTitleAndDockHoverShown(isTitleHoverShown, isDockHoverShown); WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); if (ret != WmErrorCode::WM_OK) { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", funcName); - task.Reject(env, JsErrUtils::CreateJsError(env, + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window OnSetTitleAndDockHoverShown failed.")); - } else { - task.Resolve(env, NapiGetUndefined(env)); + return; } + task->Resolve(env, NapiGetUndefined(env)); TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]", funcName, window->GetWindowId(), window->GetWindowName().c_str(), isTitleHoverShown, isDockHoverShown); @@ -6368,13 +6368,14 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); TLOGNE(WmsLogTag::WMS_SUB, "%{public}s set failed, ret is %{public}d", where, wmErrorCode); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed")); + return; } TLOGNI(WmsLogTag::WMS_SUB, "%{public}s id:%{public}u, name:%{public}s, isModal:%{public}d, modalityType:%{public}hhu", where, window->GetWindowId(), window->GetWindowName().c_str(), isModal, modalityType); }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { - napiAsyncTask->(env, + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); } } From 9f46810aefa34f57b42ef90983090e2377e8c419 Mon Sep 17 00:00:00 2001 From: wangziyao Date: Mon, 11 Nov 2024 10:14:01 +0800 Subject: [PATCH 014/171] Quick opening and close of DMS Signed-off-by: wangziyao --- .../src/fold_screen_controller/single_display_fold_policy.cpp | 2 +- .../single_display_pocket_fold_policy.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp index 13f82386ba..13c5061ff2 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp @@ -107,7 +107,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod SetdisplayModeChangeStatus(true); ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); - RSInterfaces::GetInstance().isScreenSwitching(true); + RSInterfaces::GetInstance().SetScreenSwitching(true); switch (displayMode) { case FoldDisplayMode::MAIN: { ChangeScreenDisplayModeToMain(screenSession); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp index c3e2b25ba4..0eb1278cb9 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp @@ -108,7 +108,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp } ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); - RSInterfaces::GetInstance().isScreenSwitching(true); + RSInterfaces::GetInstance().SetScreenSwitching(true); ChangeScreenDisplayModeProc(screenSession, displayMode); { std::lock_guard lock_mode(displayModeMutex_); From 07a03ab73b59dad9a112c4650b4631f6ca0073dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Mon, 11 Nov 2024 04:18:00 +0000 Subject: [PATCH 015/171] =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- .../napi/window_runtime/window_napi/js_window.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 35f8f26951..eb86c09a0f 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2650,7 +2650,7 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); const char* const funcName = __func__; - NapiAsyncTask::CompleteCallback complete = [windowToken = wptr(windowToken_), isTitleHoverShown, + auto asyncTask = [windowToken = wptr(windowToken_), isTitleHoverShown, isDockHoverShown, env, task = napiAsyncTask, funcName] { auto window = windowToken.promote(); if (window == nullptr) { @@ -5905,7 +5905,7 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); - errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } if (windowToken_ == nullptr) { @@ -5937,12 +5937,13 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed.")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s [NAPI]Window [%{public}u, %{public}s] minimize end, ret = %{public}d", - where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); + where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); } + return result; } napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) @@ -6345,7 +6346,7 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) } } napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); const char* const where = __func__; auto asyncTask = [where, window = wptr(windowToken_), isModal, modalityType, env, task = napiAsyncTask] { if (window == nullptr) { @@ -6378,6 +6379,7 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); } + return result; } napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info info) @@ -6601,7 +6603,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); const char* const where = __func__; auto asyncTask = [windowToken = wptr(windowToken_), windowMask, env, task = napiAsyncTask, where] { auto window = windowToken.promote(); @@ -6624,7 +6626,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) return; } task->Resolve(env, NapiGetUndefined(env)); - TLOGNI((WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask succeed", + TLOGNI(WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask succeed", where, window->GetWindowId(), window->GetWindowName().c_str()); }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { From f2e3c79e0b856474177bbac8d8fb93b4fba8d956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Mon, 11 Nov 2024 06:04:35 +0000 Subject: [PATCH 016/171] =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index eb86c09a0f..014849199c 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2644,8 +2644,8 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf if (argc > 1 && !ConvertFromJsValue(env, argv[INDEX_ONE], isDockHoverShown)) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert isDockHoverShown parameter"); } - // 2: params num; 2: index of callback - napi_value lastParam = (argc <= 2) ? nullptr : + // 2: params num; 2: index of callback= + napi_value lastParam = (argc <= 2) ? nullptr : (GetType(env, argv[INDEX_TWO]) == napi_function ? argv[INDEX_TWO] : nullptr); napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); @@ -6621,7 +6621,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMask(windowMask)); if (ret != WmErrorCode::WM_OK) { task->Reject(env, JsErrUtils::CreateJsError(env, ret)); - TLOGNE((WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask failed", + TLOGNE(WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask failed", where, window->GetWindowId(), window->GetWindowName().c_str()); return; } From 97b67bca613210f05bf40964ca4bb7e9dfa83ac0 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 11 Nov 2024 16:51:26 +0800 Subject: [PATCH 017/171] add code Signed-off-by: ZihaoWU --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index f567f324a5..633dd874b3 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -3631,7 +3631,7 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info } else { task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set brightness failed")); } - TLOGI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, state: %{public}d", + TLOGI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, result: %{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index fe5dc99503..52801642cb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3924,7 +3924,7 @@ void SceneSessionManager::PostBrightnessTask(float brightness) SetDisplayBrightness(brightness); } if (!postTaskRet) { - TLOGI(WmsLogTag::DEFAULT, "Report post listener callback task failed. the task name is SetBrightness"); + TLOGE(WmsLogTag::DEFAULT, "Report post listener callback task failed. the task name is SetBrightness"); } } From 1ad6df20f855b8de4833200628eb8e28641e70ed Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 11 Nov 2024 20:20:35 +0800 Subject: [PATCH 018/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 5 +- .../src/scene_session_manager.cpp | 53 ++++++++++++++++--- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index f3ca2a86c3..6d7ff60c65 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -383,7 +383,7 @@ public: WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, const std::vector>& currVisibleData); - void DealwithDrawingContentChange(const std::vector>& drawingChangeInfos); + void DealwithDrawingContentChange(const std::vector>& drawingContentChangeInfo); void NotifyUpdateRectAfterLayout(); void FlushUIParams(ScreenId screenId, std::unordered_map&& uiParams); WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener) override; @@ -670,6 +670,7 @@ private: std::vector>& currVisibleData); std::vector> GetWindowDrawingContentChangeInfo( std::vector> currDrawingContentData); + void GetDrawingDataElement(uint64_t surfaceId, int32_t& pid, int32_t& uid); void GetWindowLayerChangeInfo(std::shared_ptr occlusionData, std::vector>& currVisibleData, std::vector>& currDrawingContentData); @@ -831,6 +832,7 @@ private: std::shared_ptr eventHandler_; bool isReportTaskStart_ = false; std::vector > lastVisibleData_; + std::vector > lastDrawingData_; RSInterfaces& rsInterface_; void ClearUnrecoveredSessions(const std::vector& recoveredPersistentIds); SessionInfo RecoverSessionInfo(const sptr& property); @@ -911,6 +913,7 @@ private: sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); void CreateKeyboardPanelSession(sptr keyboardSession); bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); + void RemoveDuplicateDrawingData(uint64_t windowId); bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); WSError DestroyAndDisconnectSpecificSessionInner(const int32_t persistentId); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 52801642cb..9907beb5ea 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7770,18 +7770,26 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { - continue; + GetDrawingDataElement(surfaceId, pid, uid); + } else { + winId = session->GetWindowId(); + pid = session->GetCallingPid(); + uid = session->GetCallingUid(); + type = session->GetWindowType(); } - windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(session->GetWindowId(), - session->GetCallingPid(), session->GetCallingUid(), drawingState, session->GetWindowType())); + windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(winId, pid, uid, drawingState, type)); if (openDebugTrace_) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "Drawing status changed pid:(%d ) surfaceId:(%" PRIu64 ")" - "drawingState:(%d )", session->GetCallingPid(), surfaceId, drawingState); + "drawingState:(%d )", pid, surfaceId, drawingState); } WLOGFD("drawing status changed pid:%{public}d, " - "surfaceId:%{public}" PRIu64 ", drawingState:%{public}d", session->GetCallingPid(), surfaceId, drawingState); + "surfaceId:%{public}" PRIu64 ", drawingState:%{public}d", pid, surfaceId, drawingState); } if (windowDrawingContenInfos.size() != 0) { WLOGFD("Notify WindowDrawingContenInfo changed start"); @@ -7789,6 +7797,19 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector(elem) == windowId) { + pid = std::get<1>(elem); + uid = std::get<2>(elem); + lastDrawingData_.erase(elemIter); + break; + } + } +} + std::vector> SceneSessionManager::GetWindowDrawingContentChangeInfo( std::vector> currDrawingContentData) { @@ -7798,12 +7819,16 @@ std::vector> SceneSessionManager::GetWindowDrawingCont bool currentDrawingContentState = data.second; int32_t pid = 0; bool isChange = false; - if (GetPreWindowDrawingState(windowId, pid, currentDrawingContentState) == currentDrawingContentState) { + sptr session = SelectSesssionFromMap(windowId); + if (session == nullptr) { + isChange = false; + } + if (!isChange && GetPreWindowDrawingState(windowId, pid, currentDrawingContentState) == currentDrawingContentState) { continue; - } else { + } + if (!isChange) { isChange = GetProcessDrawingState(windowId, pid, currentDrawingContentState); } - if (isChange) { processDrawingContentChangeInfo.emplace_back(windowId, currentDrawingContentState); } @@ -7821,9 +7846,21 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, int32_t& p pid = session->GetCallingPid(); preWindowDrawingState = session->GetDrawingContentState(); session->SetDrawingContentState(currentDrawingContentState); + RemoveDuplicateDrawingData(windowId); + lastDrawingData_.emplace_back(windowId, pid, session->GetCallingUid()); return preWindowDrawingState; } +void SceneSessionManager::RemoveDuplicateDrawingData(uint64_t windowId) { + for (auto elemIter = lastDrawingData_.begin(); elemIter != lastDrawingData_.end();) { + auto elem = *elemIter; + if(std::get<0>(elem) == surfaceId) { + lastDrawingData_.erase(elemIter); + } else { + ++elemIter; + } + } +} bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState) { bool isChange = true; From c56494f2cf3743cff447dd7d565fd43ced56b365 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 11 Nov 2024 20:28:39 +0800 Subject: [PATCH 019/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 9907beb5ea..7cb99ec206 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7861,6 +7861,7 @@ void SceneSessionManager::RemoveDuplicateDrawingData(uint64_t windowId) { } } } + bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState) { bool isChange = true; From 9d4f5d661681ec6e5ebbb269931c873fe7ff6bbf Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 11 Nov 2024 20:39:57 +0800 Subject: [PATCH 020/171] add code Signed-off-by: ZihaoWU --- 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 6d7ff60c65..795bff9309 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -832,7 +832,7 @@ private: std::shared_ptr eventHandler_; bool isReportTaskStart_ = false; std::vector > lastVisibleData_; - std::vector > lastDrawingData_; + std::vector> lastDrawingData_; RSInterfaces& rsInterface_; void ClearUnrecoveredSessions(const std::vector& recoveredPersistentIds); SessionInfo RecoverSessionInfo(const sptr& property); From 5c9e7acae591338c1a2e1741d3cfaade1e36410c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 11 Nov 2024 20:50:45 +0800 Subject: [PATCH 021/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 795bff9309..2484342f6e 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -670,7 +670,7 @@ private: std::vector>& currVisibleData); std::vector> GetWindowDrawingContentChangeInfo( std::vector> currDrawingContentData); - void GetDrawingDataElement(uint64_t surfaceId, int32_t& pid, int32_t& uid); + void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); void GetWindowLayerChangeInfo(std::shared_ptr occlusionData, std::vector>& currVisibleData, std::vector>& currDrawingContentData); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7cb99ec206..6cc65684cb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7854,7 +7854,7 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, int32_t& p void SceneSessionManager::RemoveDuplicateDrawingData(uint64_t windowId) { for (auto elemIter = lastDrawingData_.begin(); elemIter != lastDrawingData_.end();) { auto elem = *elemIter; - if(std::get<0>(elem) == surfaceId) { + if(std::get<0>(elem) == windowId) { lastDrawingData_.erase(elemIter); } else { ++elemIter; From 0c7720252682e1d4e061f69e158fca2a418ca296 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 11 Nov 2024 21:00:14 +0800 Subject: [PATCH 022/171] add code Signed-off-by: ZihaoWU --- 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 6cc65684cb..ce51aaec31 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7821,7 +7821,7 @@ std::vector> SceneSessionManager::GetWindowDrawingCont bool isChange = false; sptr session = SelectSesssionFromMap(windowId); if (session == nullptr) { - isChange = false; + isChange = true; } if (!isChange && GetPreWindowDrawingState(windowId, pid, currentDrawingContentState) == currentDrawingContentState) { continue; From ccedad7a86a2162f90558581dfc5296aadf766eb Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 09:55:18 +0800 Subject: [PATCH 023/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 1 - 1 file changed, 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 ce51aaec31..69202d443c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7798,7 +7798,6 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector(elem) == windowId) { From f51126e9cf4bdba88434f8d5e8488fbd3185f557 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 10:24:58 +0800 Subject: [PATCH 024/171] add code Signed-off-by: ZihaoWU --- 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 69202d443c..03ffb66abb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7776,7 +7776,7 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { - GetDrawingDataElement(surfaceId, pid, uid); + GetDrawingDataElement(surfaceId, pid, uid); } else { winId = session->GetWindowId(); pid = session->GetCallingPid(); From 5957fea5eca5f73734212bb33b98f853f6437c34 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 15:40:54 +0800 Subject: [PATCH 025/171] add code Signed-off-by: ZihaoWU --- 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 2484342f6e..8bb5dd05a1 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -670,6 +670,7 @@ private: std::vector>& currVisibleData); std::vector> GetWindowDrawingContentChangeInfo( std::vector> currDrawingContentData); + void RemoveDuplicateDrawingData(uint64_t windowId); void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); void GetWindowLayerChangeInfo(std::shared_ptr occlusionData, std::vector>& currVisibleData, @@ -913,7 +914,6 @@ private: sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); void CreateKeyboardPanelSession(sptr keyboardSession); bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); - void RemoveDuplicateDrawingData(uint64_t windowId); bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); WSError DestroyAndDisconnectSpecificSessionInner(const int32_t persistentId); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); From b91340bf28406d9acc4a7f76304ec2314ceb9fca Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 16:05:45 +0800 Subject: [PATCH 026/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8bb5dd05a1..ccd378a6a0 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -668,10 +668,6 @@ private: const sptr& sceneSession); std::vector> GetWindowVisibilityChangeInfo( std::vector>& currVisibleData); - std::vector> GetWindowDrawingContentChangeInfo( - std::vector> currDrawingContentData); - void RemoveDuplicateDrawingData(uint64_t windowId); - void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); void GetWindowLayerChangeInfo(std::shared_ptr occlusionData, std::vector>& currVisibleData, std::vector>& currDrawingContentData); @@ -682,6 +678,16 @@ private: void RegisterSessionSnapshotFunc(const sptr& sceneSession); void ResetWantInfo(const sptr& sceneSession); + /* + * Window DrawingContent + */ + std::vector> GetWindowDrawingContentChangeInfo( + std::vector> currDrawingContentData); + bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); + bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); + void RemoveDuplicateDrawingData(uint64_t windowId); + void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); + /* * Window Rotate Animation */ @@ -913,8 +919,6 @@ private: sptr property, const WindowType& type); sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); void CreateKeyboardPanelSession(sptr keyboardSession); - bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); - bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); WSError DestroyAndDisconnectSpecificSessionInner(const int32_t persistentId); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); void CalculateCombinedExtWindowFlags(); From 01de25d0b76f90effb33dabc5e1acdd4e3ea1f8f Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 16:20:25 +0800 Subject: [PATCH 027/171] add code Signed-off-by: ZihaoWU --- 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 1a3b07eb0e..6cca1d8c5a 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -685,7 +685,7 @@ private: void ResetWantInfo(const sptr& sceneSession); /* - * Window DrawingContent + * Window Property */ std::vector> GetWindowDrawingContentChangeInfo( std::vector> currDrawingContentData); From ba504d388dd87212593005f22dcba1b02110f310 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 16:26:37 +0800 Subject: [PATCH 028/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 6cca1d8c5a..aa708db102 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -388,7 +388,6 @@ public: WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, const std::vector>& currVisibleData); - void DealwithDrawingContentChange(const std::vector>& drawingContentChangeInfo); void NotifyUpdateRectAfterLayout(); void FlushUIParams(ScreenId screenId, std::unordered_map&& uiParams); WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener) override; @@ -430,6 +429,12 @@ public: int32_t GetCustomDecorHeight(int32_t persistentId); + /* + * Window Property + */ + WMError ReleaseForegroundSessionScreenLock() override; + void DealwithDrawingContentChange(const std::vector>& drawingContentChangeInfo); + /* * Free Multi Window */ @@ -491,11 +496,6 @@ public: std::string GetLastInstanceKey(const std::string& bundleName); void RefreshAppInfo(const std::string& bundleName); - /* - * Window Property - */ - WMError ReleaseForegroundSessionScreenLock() override; - /* * PiP Window */ @@ -1048,6 +1048,11 @@ private: }; std::unordered_map, SessionHasher> abilityInfoMap_; + /* + * Window Property + */ + std::vector> lastDrawingData_; + /** * PC Window */ From 1115effddf45ad298715e5a0ccf6517727182478 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 16:27:33 +0800 Subject: [PATCH 029/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 1 - 1 file changed, 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 aa708db102..231dc4579c 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -850,7 +850,6 @@ private: std::shared_ptr eventHandler_; bool isReportTaskStart_ = false; std::vector > lastVisibleData_; - std::vector> lastDrawingData_; RSInterfaces& rsInterface_; void ClearUnrecoveredSessions(const std::vector& recoveredPersistentIds); SessionInfo RecoverSessionInfo(const sptr& property); From 2abb6b1f832db05c4b2b4e83a8114bb12c3e58fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Tue, 12 Nov 2024 11:45:21 +0000 Subject: [PATCH 030/171] =?UTF-8?q?=E6=84=8F=E8=A7=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- .../window_runtime/window_napi/js_window.cpp | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 014849199c..2e7b1c8131 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2649,26 +2649,26 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf (GetType(env, argv[INDEX_TWO]) == napi_function ? argv[INDEX_TWO] : nullptr); napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - const char* const funcName = __func__; - auto asyncTask = [windowToken = wptr(windowToken_), isTitleHoverShown, - isDockHoverShown, env, task = napiAsyncTask, funcName] { - auto window = windowToken.promote(); + const char* const where = __func__; + auto asyncTask = [weakToken = wptr(windowToken_), isTitleHoverShown, + isDockHoverShown, env, task = napiAsyncTask, where] { + auto window = weakToken.promote(); if (window == nullptr) { - TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", funcName); + TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); return; } WMError errCode = window->SetTitleAndDockHoverShown(isTitleHoverShown, isDockHoverShown); WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); if (ret != WmErrorCode::WM_OK) { - TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", funcName); + TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", where); task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window OnSetTitleAndDockHoverShown failed.")); return; } task->Resolve(env, NapiGetUndefined(env)); TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]", - funcName, window->GetWindowId(), window->GetWindowName().c_str(), + where, window->GetWindowId(), window->GetWindowName().c_str(), isTitleHoverShown, isDockHoverShown); }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { @@ -5913,7 +5913,7 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } if (WindowHelper::IsSubWindow(windowToken_->GetType())) { - TLOGE(WmsLogTag::WMS_LAYOUT, "subWindow hide"); + TLOGI(WmsLogTag::WMS_LAYOUT, "subWindow use hide"); return HideWindowFunction(env, info, WmErrorCode::WM_OK); } @@ -5922,9 +5922,10 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); const char* const where = __func__; - auto asyncTask = [windowToken = wptr(windowToken_), env, task = napiAsyncTask, where] { - auto window = windowToken.promote(); + auto asyncTask = [weakToken = wptr(windowToken_), env, task = napiAsyncTask, where] { + auto window = weakToken.promote(); if (window == nullptr) { + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr")); return; @@ -5936,7 +5937,7 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed.")); } - TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s [NAPI]Window [%{public}u, %{public}s] minimize end, ret = %{public}d", + TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s Window [%{public}u, %{public}s] minimize end, ret = %{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { @@ -6317,7 +6318,7 @@ napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_inf napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) { size_t argc = FOUR_PARAMS_SIZE; - napi_value argv[FOUR_PARAMS_SIZE] = {nullptr}; + napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argc > 2) { // 1: the minimum param num 2: the maximum param num TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc); @@ -6348,7 +6349,8 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); const char* const where = __func__; - auto asyncTask = [where, window = wptr(windowToken_), isModal, modalityType, env, task = napiAsyncTask] { + auto asyncTask = [where, weakToken = wptr(windowToken_), isModal, modalityType, env, task = napiAsyncTask] { + auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); @@ -6591,7 +6593,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - TLOGI(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } if (!CheckWindowMaskParams(env, argv[INDEX_ZERO])) { @@ -6599,15 +6601,17 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) } std::vector> windowMask; if (!GetWindowMaskFromJsValue(env, argv[INDEX_ZERO], windowMask)) { - TLOGI(WmsLogTag::DEFAULT, "GetWindowMaskFromJsValue failed"); + TLOGE(WmsLogTag::DEFAULT, "GetWindowMaskFromJsValue failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); const char* const where = __func__; - auto asyncTask = [windowToken = wptr(windowToken_), windowMask, env, task = napiAsyncTask, where] { - auto window = windowToken.promote(); + auto asyncTask = [weakToken = wptr(windowToken_), windowMask = std::move(windowMask), env, + task = napiAsyncTask, where] { + auto window = weakToken.promote(); if (window == nullptr) { + TLOGNE(WmsLogTag::DEFAULT, "%{public}s window is nullptr", where); WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr")); return; From 8f59d5f2614c3ff4e65e69c8e1bd8a9a511444ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Tue, 12 Nov 2024 20:58:35 +0800 Subject: [PATCH 031/171] =?UTF-8?q?uiextension=E6=94=AF=E6=8C=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96statusbar=20height?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- .../session/host/include/extension_session.h | 3 +++ .../session/host/src/extension_session.cpp | 9 +++++++ .../test/unittest/extension_session_test.cpp | 25 +++++++++++++++++++ wm/include/window_scene_session_impl.h | 1 - wm/include/window_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 10 -------- wm/src/window_session_impl.cpp | 10 ++++++++ .../window_scene_session_impl_test.cpp | 14 ----------- wm/test/unittest/window_session_impl_test.cpp | 14 +++++++++++ 9 files changed, 62 insertions(+), 25 deletions(-) diff --git a/window_scene/session/host/include/extension_session.h b/window_scene/session/host/include/extension_session.h index 565a099e07..a930779f2e 100644 --- a/window_scene/session/host/include/extension_session.h +++ b/window_scene/session/host/include/extension_session.h @@ -59,6 +59,7 @@ using NotifyAsyncOnFunc = std::function; using NotifyGetAvoidAreaByTypeFunc = std::function; using NotifyBindModalFunc = std::function; using NotifyExtensionEventFunc = std::function; +using GetStatusBarHeightFunc = std::function; class ExtensionSession : public Session { public: @@ -71,6 +72,7 @@ public: NotifyGetAvoidAreaByTypeFunc notifyGetAvoidAreaByTypeFunc_; NotifyBindModalFunc notifyBindModalFunc_; NotifyExtensionEventFunc notifyExtensionEventFunc_; + GetStatusBarHeightFunc getStatusBarHeightFunc_; }; explicit ExtensionSession(const SessionInfo& info); @@ -113,6 +115,7 @@ public: WSError Background(bool isFromClient = false, const std::string& identityToken = "") override; void NotifyExtensionEventAsync(uint32_t notifyEvent) override; WSError NotifyDumpInfo(const std::vector& params, std::vector& info); + int32_t GetStatusBarHeight() override; private: sptr extSessionEventCallback_ = nullptr; diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 63add20261..eecf497f69 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -477,4 +477,13 @@ WSError ExtensionSession::NotifyDumpInfo(const std::vector& params, } return sessionStage_->NotifyDumpInfo(params, info); } + +int32_t ExtensionSession::GetStatusBarHeight() +{ + TLOGI(WmsLogTag::WMS_UIEXT, "called, persistenId=%{public}d", GetPersistentId()); + if (extSessionEventCallback_ != nullptr && extSessionEventCallback_->getStatusBarHeightFunc_ != nullptr) { + return extSessionEventCallback_->getStatusBarHeightFunc_(); + } + return 0; +} } // namespace OHOS::Rosen diff --git a/window_scene/test/unittest/extension_session_test.cpp b/window_scene/test/unittest/extension_session_test.cpp index 71893b2d84..be1099a577 100644 --- a/window_scene/test/unittest/extension_session_test.cpp +++ b/window_scene/test/unittest/extension_session_test.cpp @@ -901,6 +901,31 @@ HWTEST_F(ExtensionSessionTest, NotifyDumpInfo, Function | SmallTest | Level1) res = extensionSession_->NotifyDumpInfo(params, info); ASSERT_EQ(WSError::WS_ERROR_NULLPTR, res); } + +/** + * @tc.name: GetStatusBarHeight + * @tc.desc: test function : GetStatusBarHeight + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, GetStatusBarHeight, Function | SmallTest | Level1) +{ + ASSERT_NE(nullptr, extSessionEventCallback_); + MockFunction mockGetStatusBarHeightFunc_; + extSessionEventCallback_->getStatusBarHeightFunc_ = mockGetStatusBarHeightFunc_.AsStdFunction(); + extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); + EXPECT_CALL(mockGetStatusBarHeightFunc_, Call()).Times(1); + extensionSession_->GetStatusBarHeight(); + + extSessionEventCallback_->getStatusBarHeightFunc_ = nullptr; + extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); + EXPECT_CALL(mockGetStatusBarHeightFunc_, Call()).Times(0); + extensionSession_->GetStatusBarHeight(); + + extSessionEventCallback_ = nullptr; + extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); + EXPECT_CALL(mockGetStatusBarHeightFunc_, Call()).Times(0); + extensionSession_->GetStatusBarHeight(); +} } } } \ No newline at end of file diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index fa2c24feb8..7547f7a977 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -164,7 +164,6 @@ public: void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) override; virtual WMError SetImmersiveModeEnabledState(bool enable) override; virtual bool GetImmersiveModeEnabledState() const override; - uint32_t GetStatusBarHeight() override; void NotifySessionFullScreen(bool fullScreen) override; WMError GetWindowStatus(WindowStatus& windowStatus) override; bool GetIsUIExtFirstSubWindow() const override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 7d41a1d4b6..a35e8f2ecb 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -346,6 +346,7 @@ protected: void RefreshNoInteractionTimeoutMonitor(); WindowStatus GetWindowStatusInner(WindowMode mode); + uint32_t GetStatusBarHeight() override; /** * Sub Window diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 4501e32672..81783e5686 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -4074,16 +4074,6 @@ bool WindowSceneSessionImpl::GetImmersiveModeEnabledState() const return enableImmersiveMode_; } -uint32_t WindowSceneSessionImpl::GetStatusBarHeight() -{ - uint32_t height = 0; - auto hostSession = GetHostSession(); - CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, height); - height = static_cast(hostSession->GetStatusBarHeight()); - TLOGI(WmsLogTag::WMS_IMMS, "%{public}d", height); - return height; -} - template static V GetValueByKey(const std::unordered_map& map, K key) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index f56956b9cd..49097af057 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3914,6 +3914,16 @@ WindowStatus WindowSessionImpl::GetWindowStatusInner(WindowMode mode) return windowStatus; } +uint32_t WindowSceneSessionImpl::GetStatusBarHeight() +{ + uint32_t height = 0; + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, height); + height = static_cast(hostSession->GetStatusBarHeight()); + TLOGI(WmsLogTag::WMS_IMMS, "%{public}d", height); + return height; +} + /** @note @window.layout */ void WindowSessionImpl::NotifyWindowStatusChange(WindowMode mode) { diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 1d62876934..8a35291f5f 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1716,20 +1716,6 @@ HWTEST_F(WindowSceneSessionImplTest, SetShadowOffsetY, Function | SmallTest | Le ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetShadowOffsetY(1.0)); } -/* - * @tc.name: GetStatusBarHeight - * @tc.desc: GetStatusBarHeight test - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest, GetStatusBarHeight, Function | SmallTest | Level3) -{ - sptr option = new (std::nothrow) WindowOption(); - option->SetWindowName("GetStatusBarHeight"); - sptr window = new (std::nothrow) WindowSceneSessionImpl(option); - ASSERT_NE(window, nullptr); - ASSERT_EQ(0, window->GetStatusBarHeight()); -} - /* * @tc.name: SetGestureBackEnabled * @tc.desc: SetGestureBackEnabled test diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 6c26ae695a..8247d4262d 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -2205,6 +2205,20 @@ HWTEST_F(WindowSessionImplTest, NotifySetUIContentComplete, Function | SmallTest window->NotifySetUIContentComplete(); EXPECT_EQ(window->setUIContentCompleted_.load(), false); } + +/* + * @tc.name: GetStatusBarHeight + * @tc.desc: GetStatusBarHeight test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, GetStatusBarHeight, Function | SmallTest | Level3) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("GetStatusBarHeight"); + sptr window = new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + ASSERT_EQ(0, window->GetStatusBarHeight()); +} } } // namespace Rosen } // namespace OHOS From ded1d79d9ff85ba2ed1f1323c137986f160f5478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Tue, 12 Nov 2024 21:02:47 +0800 Subject: [PATCH 032/171] =?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: 赵聪 --- .../window_scene_session_impl_test.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 5a0e3f70d6..830a37eac7 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1776,25 +1776,7 @@ HWTEST_F(WindowSceneSessionImplTest, SetShadowOffsetY, Function | SmallTest | Le ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetShadowOffsetY(1.0)); } -<<<<<<< HEAD -/* -======= /** - * @tc.name: GetStatusBarHeight - * @tc.desc: GetStatusBarHeight test - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest, GetStatusBarHeight, Function | SmallTest | Level3) -{ - sptr option = new (std::nothrow) WindowOption(); - option->SetWindowName("GetStatusBarHeight"); - sptr window = new (std::nothrow) WindowSceneSessionImpl(option); - ASSERT_NE(window, nullptr); - ASSERT_EQ(0, window->GetStatusBarHeight()); -} - -/** ->>>>>>> upgrade/master * @tc.name: SetGestureBackEnabled * @tc.desc: SetGestureBackEnabled test * @tc.type: FUNC From 4e8f8b7c1cc2da6dda6a3fb634ab58d2508c5b58 Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Tue, 12 Nov 2024 21:10:32 +0800 Subject: [PATCH 033/171] =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BC=98=E5=85=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- .../js_scene_session.cpp | 43 +++++++++++++++++++ .../scene_session_manager/js_scene_session.h | 2 + .../session/host/include/scene_session.h | 1 + .../session/host/src/move_drag_controller.cpp | 4 +- .../session/host/src/scene_session.cpp | 19 ++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index c14c9a9a2b..930f5b9b2f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -322,6 +322,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c moduleName, JsSceneSession::SetSystemSceneOcclusionAlpha); BindNativeFunction(env, objValue, "setSystemSceneForceUIFirst", moduleName, JsSceneSession::SetSystemSceneForceUIFirst); + BindNativeFunction(env, objValue, "markSystemSceneUIFirst", + moduleName, JsSceneSession::MarkSystemSceneUIFirst); BindNativeFunction(env, objValue, "setFloatingScale", moduleName, JsSceneSession::SetFloatingScale); BindNativeFunction(env, objValue, "setIsMidScene", moduleName, JsSceneSession::SetIsMidScene); BindNativeFunction(env, objValue, "setScale", moduleName, JsSceneSession::SetScale); @@ -1811,6 +1813,13 @@ napi_value JsSceneSession::SetSystemSceneForceUIFirst(napi_env env, napi_callbac return (me != nullptr) ? me->OnSetSystemSceneForceUIFirst(env, info) : nullptr; } +napi_value JsSceneSession::MarkSystemSceneUIFirst(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::DEFAULT, "[NAPI]"); + JsSceneSession* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnMarkSystemSceneUIFirst(env, info) : nullptr; +} + napi_value JsSceneSession::SetFocusable(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_FOCUS, "[NAPI]"); @@ -2483,6 +2492,40 @@ napi_value JsSceneSession::OnSetSystemSceneForceUIFirst(napi_env env, napi_callb return NapiGetUndefined(env); } +napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info) { + size_t argc = ARG_COUNT_4; + napi_value argv[ARG_COUNT_4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < ARGC_TWO) { // 1: params num + TLOGE(WmsLogTag::DEFAULT, "[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); + } + bool isUIFirst = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isUIFirst)) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUIFirst"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + bool isForceFlag = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForceFlag)) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForceFlag"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]session is nullptr, id:%{public}d", persistentId_); + return NapiGetUndefined(env); + } + session->MarkSystemSceneUIFirst(isUIFirst, isForceFlag); + TLOGD(WmsLogTag::DEFAULT, "[NAPI] end"); + return NapiGetUndefined(env); +} + napi_value JsSceneSession::OnSetFocusable(napi_env env, napi_callback_info info) { size_t argc = 4; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index 8e3722449b..e95da2bfb0 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -105,6 +105,7 @@ private: static napi_value SetIsMidScene(napi_env env, napi_callback_info info); static napi_value SetSystemSceneOcclusionAlpha(napi_env env, napi_callback_info info); static napi_value SetSystemSceneForceUIFirst(napi_env env, napi_callback_info info); + static napi_value MarkSystemSceneUIFirst(napi_env env, napi_callback_info info); static napi_value SetFocusable(napi_env env, napi_callback_info info); static napi_value SetFocusableOnShow(napi_env env, napi_callback_info info); static napi_value SetSystemFocusable(napi_env env, napi_callback_info info); @@ -169,6 +170,7 @@ private: napi_value OnSetIsMidScene(napi_env env, napi_callback_info info); napi_value OnSetSystemSceneOcclusionAlpha(napi_env env, napi_callback_info info); napi_value OnSetSystemSceneForceUIFirst(napi_env env, napi_callback_info info); + napi_value OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info); napi_value OnSetFocusable(napi_env env, napi_callback_info info); napi_value OnSetFocusableOnShow(napi_env env, napi_callback_info info); napi_value OnSetSystemFocusable(napi_env env, napi_callback_info info); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 55cccf95e1..916f0f173c 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -261,6 +261,7 @@ public: void SetSnapshotSkip(bool isSkip); void SetSystemSceneOcclusionAlpha(double alpha); void SetSystemSceneForceUIFirst(bool forceUIFirst); + void MarkSystemSceneUIFirst(bool isUIFirst, bool isForceFlag); void SetRequestedOrientation(Orientation orientation); WSError SetDefaultRequestedOrientation(Orientation orientation); void SetWindowAnimationFlag(bool needDefaultAnimationFlag); diff --git a/window_scene/session/host/src/move_drag_controller.cpp b/window_scene/session/host/src/move_drag_controller.cpp index d849b91fad..8b558596f2 100644 --- a/window_scene/session/host/src/move_drag_controller.cpp +++ b/window_scene/session/host/src/move_drag_controller.cpp @@ -379,7 +379,7 @@ void MoveDragController::UpdateGravityWhenDrag(const std::shared_ptrGetPointerAction() == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN) { bool isNeedFlush = false; if (isStartDrag_ && isPcWindow_) { - surfaceNode->MarkUifirstNode(false); + surfaceNode->MarkUifirstNode(false, true); isNeedFlush = true; } Gravity dragGravity = GRAVITY_MAP.at(type_); @@ -396,7 +396,7 @@ void MoveDragController::UpdateGravityWhenDrag(const std::shared_ptrGetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP || pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_CANCEL) { if (!isStartDrag_ && isPcWindow_) { - surfaceNode->MarkUifirstNode(true); + surfaceNode->MarkUifirstNode(true, false); } surfaceNode->SetFrameGravity(Gravity::TOP_LEFT); RSTransaction::FlushImplicitTransaction(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ebb7da1a5b..74d6bf6e7f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3145,6 +3145,25 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) } } +void SceneSession::MarkSystemSceneUIFirst(bool isUIFirst, bool isForceFlag) +{ + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::MarkSystemSceneUIFirst"); + auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); + if (leashWinSurfaceNode == nullptr && surfaceNode_ == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "leashWindow and surfaceNode are nullptr"); + return; + } + if (leashWinSurfaceNode != nullptr) { + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isUIFirst=%{public}d. isForceFlag=%{public}d", + leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isUIFirst, isForceFlag); + leashWinSurfaceNode->MarkSystemSceneUIFirst(isUIFirst, isForceFlag); + } else { + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isUIFirst=%{public}d. isForceFlag=%{public}d", + surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isUIFirst, isForceFlag); + surfaceNode_->MarkSystemSceneUIFirst(isUIFirst, isForceFlag); + } +} + WSError SceneSession::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) { auto task = [weakThis = wptr(this), needDefaultAnimationFlag]() { From 51a54b43fe8cc61f09745b4c764e3a889d47540b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Tue, 12 Nov 2024 21:14:15 +0800 Subject: [PATCH 034/171] =?UTF-8?q?tdd=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- window_scene/test/unittest/extension_session_test.cpp | 10 +++++----- wm/test/unittest/window_session_impl_test.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/test/unittest/extension_session_test.cpp b/window_scene/test/unittest/extension_session_test.cpp index be1099a577..373dfffa32 100644 --- a/window_scene/test/unittest/extension_session_test.cpp +++ b/window_scene/test/unittest/extension_session_test.cpp @@ -910,20 +910,20 @@ HWTEST_F(ExtensionSessionTest, NotifyDumpInfo, Function | SmallTest | Level1) HWTEST_F(ExtensionSessionTest, GetStatusBarHeight, Function | SmallTest | Level1) { ASSERT_NE(nullptr, extSessionEventCallback_); - MockFunction mockGetStatusBarHeightFunc_; - extSessionEventCallback_->getStatusBarHeightFunc_ = mockGetStatusBarHeightFunc_.AsStdFunction(); + MockFunction mockGetStatusBarHeightFunc; + extSessionEventCallback_->getStatusBarHeightFunc_ = mockGetStatusBarHeightFunc.AsStdFunction(); extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); - EXPECT_CALL(mockGetStatusBarHeightFunc_, Call()).Times(1); + EXPECT_CALL(mockGetStatusBarHeightFunc, Call()).Times(1); extensionSession_->GetStatusBarHeight(); extSessionEventCallback_->getStatusBarHeightFunc_ = nullptr; extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); - EXPECT_CALL(mockGetStatusBarHeightFunc_, Call()).Times(0); + EXPECT_CALL(mockGetStatusBarHeightFunc, Call()).Times(0); extensionSession_->GetStatusBarHeight(); extSessionEventCallback_ = nullptr; extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); - EXPECT_CALL(mockGetStatusBarHeightFunc_, Call()).Times(0); + EXPECT_CALL(mockGetStatusBarHeightFunc, Call()).Times(0); extensionSession_->GetStatusBarHeight(); } } diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index e376ad958f..b0c81f0c3a 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -2137,7 +2137,7 @@ HWTEST_F(WindowSessionImplTest, NotifySetUIContentComplete, Function | SmallTest EXPECT_EQ(window->setUIContentCompleted_.load(), false); } -/* +/** * @tc.name: GetStatusBarHeight * @tc.desc: GetStatusBarHeight test * @tc.type: FUNC From ef7a8a00316c1d6ff607c2a7a73f2b10b05166dc Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 21:19:45 +0800 Subject: [PATCH 035/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 11 ++-- .../src/scene_session_manager.cpp | 52 ++++++++++--------- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 231dc4579c..8486f229f2 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -688,8 +688,8 @@ private: * Window Property */ std::vector> GetWindowDrawingContentChangeInfo( - std::vector> currDrawingContentData); - bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); + const std::vector>& currDrawingContentData); + bool GetPreWindowDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t& pid) bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); void RemoveDuplicateDrawingData(uint64_t windowId); void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); @@ -1050,7 +1050,12 @@ private: /* * Window Property */ - std::vector> lastDrawingData_; + std::vector lastDrawingData_; + struct SessionRelatedID { + uint64_t windowId_; + int32_t pid_; + int32_t uid_; + }; /** * PC Window diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e770bced38..76276d0698 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3936,7 +3936,7 @@ void SceneSessionManager::PostBrightnessTask(float brightness) SetDisplayBrightness(brightness); } if (!postTaskRet) { - TLOGE(WmsLogTag::DEFAULT, "Report post listener callback task failed. the task name is SetBrightness"); + TLOGE(WmsLogTag::DEFAULT, "post task failed. task is SetBrightness"); } } @@ -7884,44 +7884,45 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector(elem) == windowId) { - pid = std::get<1>(elem); - uid = std::get<2>(elem); - lastDrawingData_.erase(elemIter); + for (auto it = lastDrawingData_.begin(); it != lastDrawingData_.end(); ++it) { + auto& elem = *it; + if (elem.windowId_ == windowId) { + pid = elem.pid_; + uid = elem.uid_; + lastDrawingData_.erase(it); break; } } } std::vector> SceneSessionManager::GetWindowDrawingContentChangeInfo( - std::vector> currDrawingContentData) + const std::vector>& currDrawingContentData) { std::vector> processDrawingContentChangeInfo; for (const auto& data : currDrawingContentData) { uint64_t windowId = data.first; - bool currentDrawingContentState = data.second; + bool currentDrawingContentChange = data.second; int32_t pid = 0; - bool isChange = false; + bool DrawingContentChange = false; sptr session = SelectSesssionFromMap(windowId); - if (session == nullptr) { - isChange = true; + if + (session == nullptr) { + WindowDrawingContentChange = true; } - if (!isChange && GetPreWindowDrawingState(windowId, pid, currentDrawingContentState) == currentDrawingContentState) { + if (!WindowDrawingContentChange && GetPreWindowDrawingState(windowId, currentDrawingContentChange, pid) == currentDrawingContentChange) { continue; } - if (!isChange) { - isChange = GetProcessDrawingState(windowId, pid, currentDrawingContentState); + if (!WindowDrawingContentChange) { + WindowDrawingContentChange = GetProcessDrawingState(windowId, pid, currentDrawingContentChange); } - if (isChange) { - processDrawingContentChangeInfo.emplace_back(windowId, currentDrawingContentState); + if (WindowDrawingContentChange) { + processDrawingContentChangeInfo.emplace_back(windowId, currentDrawingContentChange); } } return processDrawingContentChangeInfo; } -bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState) +bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t& pid) { bool preWindowDrawingState = true; sptr session = SelectSesssionFromMap(windowId); @@ -7930,19 +7931,20 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, int32_t& p } pid = session->GetCallingPid(); preWindowDrawingState = session->GetDrawingContentState(); - session->SetDrawingContentState(currentDrawingContentState); + session->SetDrawingContentState(currentDrawingContentChange); RemoveDuplicateDrawingData(windowId); - lastDrawingData_.emplace_back(windowId, pid, session->GetCallingUid()); + SessionRelatedID Ids = { windowId, pid, session->GetCallingUid() }; + lastDrawingData_.emplace_back(Ids); return preWindowDrawingState; } void SceneSessionManager::RemoveDuplicateDrawingData(uint64_t windowId) { - for (auto elemIter = lastDrawingData_.begin(); elemIter != lastDrawingData_.end();) { - auto elem = *elemIter; - if(std::get<0>(elem) == windowId) { - lastDrawingData_.erase(elemIter); + for (auto it = lastDrawingData_.begin(); it != lastDrawingData_.end();) { + auto& elem = *it; + if (elem.windowId_ == windowId) { + lastDrawingData_.erase(it); } else { - ++elemIter; + ++it; } } } From 84c4b553354e2682a97c4e09bbe69e5f7344a6a9 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 21:20:40 +0800 Subject: [PATCH 036/171] add code Signed-off-by: ZihaoWU --- 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 8486f229f2..a346563fe4 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -690,7 +690,7 @@ private: std::vector> GetWindowDrawingContentChangeInfo( const std::vector>& currDrawingContentData); bool GetPreWindowDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t& pid) - bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); + bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentChange); void RemoveDuplicateDrawingData(uint64_t windowId); void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); From be302d62e7064610b4f4355caa2f7c4d30001fe8 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 21:24:45 +0800 Subject: [PATCH 037/171] add code Signed-off-by: ZihaoWU --- .../session_manager/include/scene_session_manager.h | 1 + .../session_manager/src/scene_session_manager.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index a346563fe4..411018ee70 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1051,6 +1051,7 @@ private: * Window Property */ std::vector lastDrawingData_; + struct SessionRelatedID { uint64_t windowId_; int32_t pid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 76276d0698..80ade31598 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7896,8 +7896,7 @@ void SceneSessionManager::GetDrawingDataElement(uint64_t windowId, int32_t& pid, } std::vector> SceneSessionManager::GetWindowDrawingContentChangeInfo( - const std::vector>& currDrawingContentData) -{ + const std::vector>& currDrawingContentData) { std::vector> processDrawingContentChangeInfo; for (const auto& data : currDrawingContentData) { uint64_t windowId = data.first; @@ -7905,11 +7904,11 @@ std::vector> SceneSessionManager::GetWindowDrawingCont int32_t pid = 0; bool DrawingContentChange = false; sptr session = SelectSesssionFromMap(windowId); - if - (session == nullptr) { + if (session == nullptr) { WindowDrawingContentChange = true; } - if (!WindowDrawingContentChange && GetPreWindowDrawingState(windowId, currentDrawingContentChange, pid) == currentDrawingContentChange) { + if (!WindowDrawingContentChange && + GetPreWindowDrawingState(windowId, currentDrawingContentChange, pid) == currentDrawingContentChange) { continue; } if (!WindowDrawingContentChange) { From f940345528a19c5a12074b2e546f9aa45eef63eb Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 21:26:25 +0800 Subject: [PATCH 038/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 4 ++-- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 411018ee70..9f66f482bb 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -690,7 +690,7 @@ private: std::vector> GetWindowDrawingContentChangeInfo( const std::vector>& currDrawingContentData); bool GetPreWindowDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t& pid) - bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentChange); + bool GetProcessDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t pid); void RemoveDuplicateDrawingData(uint64_t windowId); void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); @@ -1051,7 +1051,7 @@ private: * Window Property */ std::vector lastDrawingData_; - + struct SessionRelatedID { uint64_t windowId_; int32_t pid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 80ade31598..33f9fb2388 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7948,7 +7948,7 @@ void SceneSessionManager::RemoveDuplicateDrawingData(uint64_t windowId) { } } -bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState) +bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t pid) { bool isChange = true; std::shared_lock lock(sceneSessionMapMutex_); From 37e566b29bdaf82464b4425ba04010934e8a23b0 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Tue, 12 Nov 2024 21:29:37 +0800 Subject: [PATCH 039/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 4 ++-- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 9f66f482bb..7551f6f140 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1050,9 +1050,9 @@ private: /* * Window Property */ - std::vector lastDrawingData_; + std::vector lastDrawingData_; - struct SessionRelatedID { + struct SessionRelatedId { uint64_t windowId_; int32_t pid_; int32_t uid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 33f9fb2388..06e3df434d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7932,7 +7932,7 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre preWindowDrawingState = session->GetDrawingContentState(); session->SetDrawingContentState(currentDrawingContentChange); RemoveDuplicateDrawingData(windowId); - SessionRelatedID Ids = { windowId, pid, session->GetCallingUid() }; + SessionRelatedId Ids = { windowId, pid, session->GetCallingUid() }; lastDrawingData_.emplace_back(Ids); return preWindowDrawingState; } From 85f21a87f2bf1f272d4a57cce2ee518524c6eb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Tue, 12 Nov 2024 16:10:17 +0800 Subject: [PATCH 040/171] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=90=E7=AA=97?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- .../src/scene_session_manager.cpp | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 96cec56c57..3406bd9cae 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2370,7 +2370,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW && property->GetIsUIExtFirstSubWindow()) { + if (property->GetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { WSError err = CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage); if (err != WSError::WS_OK) { return err; @@ -2438,25 +2438,48 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co { sptr extensionParentSession = GetSceneSession(property->GetParentPersistentId()); if (extensionParentSession == nullptr) { - WLOGFE("extensionParentSession is invalid with %{public}d", property->GetParentPersistentId()); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionParentSession is invalid with %{public}d", + property->GetParentPersistentId()); return WSError::WS_ERROR_NULLPTR; } + sptr parentProperty = extensionParentSession->GetSessionProperty(); + if (sessionStage && parentProperty && property->GetIsUIExtFirstSubWindow()) { + sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); + property->SetDisplayId(parentProperty->GetDisplayId()); + } + auto pid = IPCSkeleton::GetCallingRealPid(); + auto parentPid = extensionParentSession->GetCallingPid(); + if (pid == parentPid) { + TLOGI(WmsLogTag::WMS_UIEXT, "pid == parentPid(pid:%{public}d)", pid); + return WSError::WS_OK; + } + AAFwk::UIExtensionSessionInfo info; + AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info); + if (info.persistentId != INVALID_SESSION_ID && info.hostWindowId != INVALID_SESSION_ID) { + int32_t parentId = static_cast(info.hostWindowId); + if (parentId == property->GetParentPersistentId()) { + TLOGI(WmsLogTag::WMS_UIEXT, "parentId == property->GetParentPersistentId(parentId:%{public}d)", parentId); + return WSError::WS_OK; + } + } + if (SessionPermission::IsSystemCalling()) { + TLOGI(WmsLogTag::WMS_UIEXT, "is system app"); + return WSError::WS_OK; + } if (property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); AAFwk::UIExtensionHostInfo hostInfo; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); if (sessionInfo.bundleName_ != hostInfo.elementName_.GetBundleName()) { - WLOGE("The hostWindow is not this parentwindow ! parentwindow bundleName: %{public}s, " - "hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), + TLOGE(WmsLogTag::WMS_UIEXT, "The hostWindow is not this parentwindow ! parentwindow bundleName: %{public}s," + " hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), hostInfo.elementName_.GetBundleName().c_str()); return WSError::WS_ERROR_INVALID_WINDOW; } + return WSError::WS_OK; } - sptr parentProperty = extensionParentSession->GetSessionProperty(); - if (sessionStage && parentProperty) { - sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); - property->SetDisplayId(parentProperty->GetDisplayId()); - } + TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: not system app; pid: %{public}d; persistentId %{public}d", + pid, property->GetPersistentId()); return WSError::WS_OK; } From 38818f8281b6d6560425f15eec62e4d071589949 Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Wed, 13 Nov 2024 09:38:39 +0800 Subject: [PATCH 041/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 930f5b9b2f..e7bfaafb57 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -2492,7 +2492,8 @@ napi_value JsSceneSession::OnSetSystemSceneForceUIFirst(napi_env env, napi_callb return NapiGetUndefined(env); } -napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info) { +napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info) +{ size_t argc = ARG_COUNT_4; napi_value argv[ARG_COUNT_4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); From dfc3f75ecd9cb3548bac67a471f0ad2d1d6f6fc4 Mon Sep 17 00:00:00 2001 From: liangxinghui Date: Wed, 13 Nov 2024 02:05:32 +0000 Subject: [PATCH 042/171] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=A7=84=E8=8C=83=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liangxinghui Change-Id: Ia4369fe21269d291301881e0627913ae37de8b80 --- .../src/zidl/scene_session_manager_lite_stub.cpp | 4 ++-- .../session_manager/src/zidl/scene_session_manager_stub.cpp | 4 ++-- wmserver/src/zidl/window_manager_stub.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index c233ee9ff4..ea72d7a74f 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -537,7 +537,7 @@ int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel& return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleRegisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); @@ -555,7 +555,7 @@ int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParce return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleUnregisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index 693a5e0d39..2295036dcc 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -372,7 +372,7 @@ int SceneSessionManagerStub::HandleRegisterWindowManagerAgent(MessageParcel& dat return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleRegisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); @@ -390,7 +390,7 @@ int SceneSessionManagerStub::HandleUnregisterWindowManagerAgent(MessageParcel& d return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleUnregisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index 9673900624..3b318faffc 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -370,7 +370,7 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& data, M case WindowManagerMessage::TRANS_ID_BIND_DIALOG_TARGET: { uint32_t windowId = 0; if (!data.ReadUint32(windowId)) { - TLOGE(WmsLogTag::DEFAULT, "Failed to readInt32 windowId"); + TLOGE(WmsLogTag::DEFAULT, "Failed to read windowId"); return ERR_INVALID_DATA; } sptr targetToken = data.ReadRemoteObject(); From a2cdc65f0633bb7384c4e7837e7e189d2a27c989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Wed, 13 Nov 2024 10:15:13 +0800 Subject: [PATCH 043/171] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- 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 3406bd9cae..f318e1e6e8 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2480,7 +2480,7 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co } TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: not system app; pid: %{public}d; persistentId %{public}d", pid, property->GetPersistentId()); - return WSError::WS_OK; + return WSError::WS_ERROR_INVALID_WINDOW; } void SceneSessionManager::ClosePipWindowIfExist(WindowType type) From d6e09111a7869520bb3f2d260305d2ad0ec0f997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Wed, 13 Nov 2024 10:45:32 +0800 Subject: [PATCH 044/171] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- wm/src/window_session_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0421064156..68b74b7451 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3940,13 +3940,13 @@ WindowStatus WindowSessionImpl::GetWindowStatusInner(WindowMode mode) return windowStatus; } -uint32_t WindowSceneSessionImpl::GetStatusBarHeight() +uint32_t WindowSessionImpl::GetStatusBarHeight() { uint32_t height = 0; auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, height); height = static_cast(hostSession->GetStatusBarHeight()); - TLOGI(WmsLogTag::WMS_IMMS, "%{public}d", height); + TLOGI(WmsLogTag::WMS_IMMS, "StatusBarVectorHeight is %{public}d", height); return height; } From 0f8a067f2aa66620a4899014edb70eeed7d35a1e Mon Sep 17 00:00:00 2001 From: liuhonghao123 Date: Wed, 13 Nov 2024 10:39:54 +0800 Subject: [PATCH 045/171] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhonghao123 --- window_scene/session/host/include/scene_session.h | 6 ++++-- window_scene/session/host/src/scene_session.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 8a0c9b77bf..40c204d21c 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -211,6 +211,8 @@ public: WSError TransferPointerEvent(const std::shared_ptr& pointerEvent, bool needNotifyClient = true) override; + WSError TransferPointerEventInner(const std::shared_ptr& pointerEvent, + bool needNotifyClient = true); WSError RequestSessionBack(bool needMoveToBackground) override; WSError SetAspectRatio(float ratio) override; WSError SetGlobalMaximizeMode(MaximizeMode mode) override; @@ -574,7 +576,7 @@ protected: sptr specificCallback_ = nullptr; sptr sessionChangeCallback_ = nullptr; - + /* * Dialog window */ @@ -615,7 +617,7 @@ protected: NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_; NotifyRestoreMainWindowFunc onRestoreMainWindowFunc_; NotifySetWindowRectAutoSaveFunc onSetWindowRectAutoSaveFunc_; - + /* * Window Layout */ diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 2b4518a61d..9bd408d523 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2128,6 +2128,20 @@ void SceneSession::NotifyOutsideDownEvent(const std::shared_ptr& pointerEvent, bool needNotifyClient) +{ + auto task = [weakThis = wptr(this), pointerEvent, needNotifyClient]() { + auto session = weakThis.promote(); + if (!session) { + TLOGE(WmsLogTag::DEFAULT, "session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + return session->TransferPointerEventInner(pointerEvent, needNotifyClient); + }; + return PostSyncTask(task, __func__); +} + +WSError SceneSession::TransferPointerEventInner(const std::shared_ptr& pointerEvent, + bool needNotifyClient) { WLOGFD("[WMSCom] TransferPointEvent, id: %{public}d, type: %{public}d, needNotifyClient: %{public}d", GetPersistentId(), GetWindowType(), needNotifyClient); From 78c88fb8eced7f13a6095884a85240a0f1c460fb Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Wed, 13 Nov 2024 11:03:44 +0800 Subject: [PATCH 046/171] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index e7bfaafb57..8b1f34cae5 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -2492,7 +2492,7 @@ napi_value JsSceneSession::OnSetSystemSceneForceUIFirst(napi_env env, napi_callb return NapiGetUndefined(env); } -napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info) +napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info) { size_t argc = ARG_COUNT_4; napi_value argv[ARG_COUNT_4] = {nullptr}; From b445a55c314c91088f0f67f13720fb5cd5fc61eb Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 11:09:15 +0800 Subject: [PATCH 047/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 8 ++--- .../src/scene_session_manager.cpp | 33 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 7551f6f140..744c0e6cc9 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -689,8 +689,8 @@ private: */ std::vector> GetWindowDrawingContentChangeInfo( const std::vector>& currDrawingContentData); - bool GetPreWindowDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t& pid) - bool GetProcessDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t pid); + bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid) + bool GetProcessDrawingState(uint64_t windowId, int32_t pid); void RemoveDuplicateDrawingData(uint64_t windowId); void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); @@ -1050,9 +1050,9 @@ private: /* * Window Property */ - std::vector lastDrawingData_; + std::vector lastDrawingData_; - struct SessionRelatedId { + struct DrawingSessionId { uint64_t windowId_; int32_t pid_; int32_t uid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 06e3df434d..581ff093d0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7849,9 +7849,8 @@ void SceneSessionManager::DealwithVisibilityChange(const std::vector>& - drawingContentChangeInfo) -{ +void SceneSessionManager::DealwithDrawingContentChange( + const std::vector>& drawingContentChangeInfo) { std::vector> windowDrawingContenInfos; for (const auto& elem : drawingContentChangeInfo) { uint64_t surfaceId = elem.first; @@ -7892,7 +7891,7 @@ void SceneSessionManager::GetDrawingDataElement(uint64_t windowId, int32_t& pid, lastDrawingData_.erase(it); break; } - } + } } std::vector> SceneSessionManager::GetWindowDrawingContentChangeInfo( @@ -7900,28 +7899,28 @@ std::vector> SceneSessionManager::GetWindowDrawingCont std::vector> processDrawingContentChangeInfo; for (const auto& data : currDrawingContentData) { uint64_t windowId = data.first; - bool currentDrawingContentChange = data.second; + bool currentWindowDrawingState = data.second; int32_t pid = 0; bool DrawingContentChange = false; sptr session = SelectSesssionFromMap(windowId); if (session == nullptr) { - WindowDrawingContentChange = true; + DrawingContentChange = true; } - if (!WindowDrawingContentChange && - GetPreWindowDrawingState(windowId, currentDrawingContentChange, pid) == currentDrawingContentChange) { + if (!DrawingContentChange && + GetPreWindowDrawingState(windowId, currentWindowDrawingState, pid) == currentWindowDrawingState) { continue; } - if (!WindowDrawingContentChange) { - WindowDrawingContentChange = GetProcessDrawingState(windowId, pid, currentDrawingContentChange); + if (!DrawingContentChange) { + WindowDrawingContentChange = GetProcessDrawingState(windowId, pid); } - if (WindowDrawingContentChange) { - processDrawingContentChangeInfo.emplace_back(windowId, currentDrawingContentChange); + if (DrawingContentChange) { + processDrawingContentChangeInfo.emplace_back(windowId, currentWindowDrawingState); } } return processDrawingContentChangeInfo; } -bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t& pid) +bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid) { bool preWindowDrawingState = true; sptr session = SelectSesssionFromMap(windowId); @@ -7930,9 +7929,9 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre } pid = session->GetCallingPid(); preWindowDrawingState = session->GetDrawingContentState(); - session->SetDrawingContentState(currentDrawingContentChange); + session->SetDrawingContentState(currentDrawingContentState); RemoveDuplicateDrawingData(windowId); - SessionRelatedId Ids = { windowId, pid, session->GetCallingUid() }; + DrawingSessionId Ids = { windowId, pid, session->GetCallingUid() }; lastDrawingData_.emplace_back(Ids); return preWindowDrawingState; } @@ -7945,10 +7944,10 @@ void SceneSessionManager::RemoveDuplicateDrawingData(uint64_t windowId) { } else { ++it; } - } + } } -bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, bool currentDrawingContentChange, int32_t pid) +bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid) { bool isChange = true; std::shared_lock lock(sceneSessionMapMutex_); From 9243ed4e63c1fb1d340b7abd5904fd96d7665f28 Mon Sep 17 00:00:00 2001 From: liuhonghao123 Date: Wed, 13 Nov 2024 11:24:18 +0800 Subject: [PATCH 048/171] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuhonghao123 --- window_scene/session/host/src/scene_session.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 9bd408d523..5e8970dce6 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2129,15 +2129,15 @@ void SceneSession::NotifyOutsideDownEvent(const std::shared_ptr& pointerEvent, bool needNotifyClient) { - auto task = [weakThis = wptr(this), pointerEvent, needNotifyClient]() { + auto task = [weakThis = wptr(this), pointerEvent, needNotifyClient] { auto session = weakThis.promote(); if (!session) { - TLOGE(WmsLogTag::DEFAULT, "session is null"); + TLOGNE(WmsLogTag::DEFAULT, "session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } return session->TransferPointerEventInner(pointerEvent, needNotifyClient); }; - return PostSyncTask(task, __func__); + return PostSyncTask(std::move(task), __func__); } WSError SceneSession::TransferPointerEventInner(const std::shared_ptr& pointerEvent, From b4ea470de4919d5cae2f57c33990197be50c4f0f Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 11:27:19 +0800 Subject: [PATCH 049/171] add code Signed-off-by: ZihaoWU --- 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 581ff093d0..6568e19058 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3862,7 +3862,7 @@ void SceneSessionManager::HandleKeepScreenOn(const sptr& sceneSess return; } bool shouldLock = requireLock && IsSessionVisibleForeground(sceneSession); - TLOGNI(WmsLogTag::DEFAULT, "keep screen on: [%{public}s, %{public}d, %{public}d], %{public}d], %{public}d]", + TLOGNI(WmsLogTag::DEFAULT, "keep screen on: [%{public}s, %{public}d, %{public}d, %{public}d, %{public}d]", sceneSession->GetWindowName().c_str(), sceneSession->GetSessionState(), sceneSession->IsVisible(), requireLock, shouldLock); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:HandleKeepScreenOn"); From e352386b5e73fd8e18fed2d0ed6c64eaf90ab99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Wed, 13 Nov 2024 12:02:54 +0800 Subject: [PATCH 050/171] =?UTF-8?q?tdd=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- wm/test/unittest/window_session_impl_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index b0c81f0c3a..d7e0611644 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -2144,9 +2144,9 @@ HWTEST_F(WindowSessionImplTest, NotifySetUIContentComplete, Function | SmallTest */ HWTEST_F(WindowSessionImplTest, GetStatusBarHeight, Function | SmallTest | Level3) { - sptr option = new (std::nothrow) WindowOption(); + sptr option = sptr::MakeSptr(); option->SetWindowName("GetStatusBarHeight"); - sptr window = new (std::nothrow) WindowSessionImpl(option); + sptr window = sptr::MakeSptr(option); ASSERT_NE(window, nullptr); ASSERT_EQ(0, window->GetStatusBarHeight()); } From b01ef5f2bf77079501ccb5234041511700f8c21c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 12:47:38 +0800 Subject: [PATCH 051/171] add code Signed-off-by: ZihaoWU --- 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 744c0e6cc9..878ed2bda2 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -689,7 +689,7 @@ private: */ std::vector> GetWindowDrawingContentChangeInfo( const std::vector>& currDrawingContentData); - bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid) + bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid); bool GetProcessDrawingState(uint64_t windowId, int32_t pid); void RemoveDuplicateDrawingData(uint64_t windowId); void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); From e2322b46242d852641824f25e49ab2f955a055a2 Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Sat, 9 Nov 2024 12:16:10 +0000 Subject: [PATCH 052/171] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AD=90=E7=AA=97id?= =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- wm/src/window_session_impl.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 8811614591..f9b00bf6cf 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1596,17 +1596,19 @@ WMError WindowSessionImpl::SetRaiseByClickEnabled(bool raiseEnabled) auto parentId = GetParentId(); if (parentId == INVALID_SESSION_ID) { TLOGE(WmsLogTag::WMS_HIERARCHY, "Window id: %{public}d Parent id is invalid!", - GetPersistentId()); + GetPersistentId()); return WMError::WM_ERROR_INVALID_PARENT; } if (!WindowHelper::IsSubWindow(GetType())) { - TLOGE(WmsLogTag::WMS_HIERARCHY, "Must be app sub window!"); + TLOGE(WmsLogTag::WMS_HIERARCHY, "Window id: %{public}d Must be app sub window!", + GetPersistentId()); return WMError::WM_ERROR_INVALID_CALLING; } if (state_ != WindowState::STATE_SHOWN) { - TLOGE(WmsLogTag::WMS_HIERARCHY, "The sub window must be shown!"); + TLOGE(WmsLogTag::WMS_HIERARCHY, "Window id: %{public}d The sub window must be shown!", + GetPersistentId()); return WMError::WM_DO_NOTHING; } if (IsWindowSessionInvalid()) { From 849e5cc7e0b1f807caf64fc715056f4bc1212a9a Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Wed, 13 Nov 2024 16:14:26 +0800 Subject: [PATCH 053/171] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- .../scene_session_manager/js_scene_session.cpp | 10 +++++----- window_scene/session/host/include/scene_session.h | 2 +- .../session/host/src/move_drag_controller.cpp | 4 ++-- window_scene/session/host/src/scene_session.cpp | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 8b1f34cae5..d63ea8a5cd 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -2503,15 +2503,15 @@ napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_ "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - bool isUIFirst = false; - if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isUIFirst)) { + bool isForceFlag = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForceFlag)) { TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUIFirst"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - bool isForceFlag = false; - if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForceFlag)) { + bool isUifirstEnable = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isUifirstEnable)) { TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForceFlag"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); @@ -2522,7 +2522,7 @@ napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_ TLOGE(WmsLogTag::DEFAULT, "[NAPI]session is nullptr, id:%{public}d", persistentId_); return NapiGetUndefined(env); } - session->MarkSystemSceneUIFirst(isUIFirst, isForceFlag); + session->MarkSystemSceneUIFirst(isForceFlag, isUifirstEnable); TLOGD(WmsLogTag::DEFAULT, "[NAPI] end"); return NapiGetUndefined(env); } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 916f0f173c..37784e3bd6 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -261,7 +261,7 @@ public: void SetSnapshotSkip(bool isSkip); void SetSystemSceneOcclusionAlpha(double alpha); void SetSystemSceneForceUIFirst(bool forceUIFirst); - void MarkSystemSceneUIFirst(bool isUIFirst, bool isForceFlag); + void MarkSystemSceneUIFirst(bool isForceFlag, bool isUifirstEnable); void SetRequestedOrientation(Orientation orientation); WSError SetDefaultRequestedOrientation(Orientation orientation); void SetWindowAnimationFlag(bool needDefaultAnimationFlag); diff --git a/window_scene/session/host/src/move_drag_controller.cpp b/window_scene/session/host/src/move_drag_controller.cpp index 8b558596f2..d849b91fad 100644 --- a/window_scene/session/host/src/move_drag_controller.cpp +++ b/window_scene/session/host/src/move_drag_controller.cpp @@ -379,7 +379,7 @@ void MoveDragController::UpdateGravityWhenDrag(const std::shared_ptrGetPointerAction() == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN) { bool isNeedFlush = false; if (isStartDrag_ && isPcWindow_) { - surfaceNode->MarkUifirstNode(false, true); + surfaceNode->MarkUifirstNode(false); isNeedFlush = true; } Gravity dragGravity = GRAVITY_MAP.at(type_); @@ -396,7 +396,7 @@ void MoveDragController::UpdateGravityWhenDrag(const std::shared_ptrGetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP || pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_CANCEL) { if (!isStartDrag_ && isPcWindow_) { - surfaceNode->MarkUifirstNode(true, false); + surfaceNode->MarkUifirstNode(true); } surfaceNode->SetFrameGravity(Gravity::TOP_LEFT); RSTransaction::FlushImplicitTransaction(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 74d6bf6e7f..a1cb148dcf 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3145,7 +3145,7 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) } } -void SceneSession::MarkSystemSceneUIFirst(bool isUIFirst, bool isForceFlag) +void SceneSession::MarkSystemSceneUIFirst(bool isForceFlag, bool isUifirstEnable) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::MarkSystemSceneUIFirst"); auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); @@ -3154,13 +3154,13 @@ void SceneSession::MarkSystemSceneUIFirst(bool isUIFirst, bool isForceFlag) return; } if (leashWinSurfaceNode != nullptr) { - TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isUIFirst=%{public}d. isForceFlag=%{public}d", - leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isUIFirst, isForceFlag); - leashWinSurfaceNode->MarkSystemSceneUIFirst(isUIFirst, isForceFlag); + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForceFlag=%{public}d. isUifirstEnable=%{public}d", + leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isForceFlag, isUifirstEnable); + leashWinSurfaceNode->MarkSystemSceneUIFirst(isForceFlag, isUifirstEnable); } else { - TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isUIFirst=%{public}d. isForceFlag=%{public}d", - surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isUIFirst, isForceFlag); - surfaceNode_->MarkSystemSceneUIFirst(isUIFirst, isForceFlag); + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForceFlag=%{public}d. isUifirstEnable=%{public}d", + surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isForceFlag, isUifirstEnable); + surfaceNode_->MarkSystemSceneUIFirst(isForceFlag, isUifirstEnable); } } From 4f4b0f8944b1017f47b2bb66afbbd8e7fecbbdaf Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 16:55:38 +0800 Subject: [PATCH 054/171] add code Signed-off-by: ZihaoWU --- .../window_runtime/window_napi/js_window.cpp | 2 +- .../include/scene_session_manager.h | 15 +++-- .../src/scene_session_manager.cpp | 65 +++++++++---------- 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 66a602a9bb..a701152afc 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -3630,7 +3630,7 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info } else { task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set brightness failed")); } - TLOGI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, result: %{public}d", + TLOGNI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, result: %{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 878ed2bda2..00ca951a66 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -691,8 +691,9 @@ private: const std::vector>& currDrawingContentData); bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid); bool GetProcessDrawingState(uint64_t windowId, int32_t pid); - void RemoveDuplicateDrawingData(uint64_t windowId); - void GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid); + void UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid); + int GetDrawingDataIndex(uint64_t windowId); + void EraseDrawingDataElement(int index); /* * Window Rotate Animation @@ -1050,12 +1051,12 @@ private: /* * Window Property */ - std::vector lastDrawingData_; + std::vector lastDrawingData_; - struct DrawingSessionId { - uint64_t windowId_; - int32_t pid_; - int32_t uid_; + struct DrawingSessionIdInfo { + uint64_t windowId_ = 0; + int32_t pid_ = 0; + int32_t uid_ = 0; }; /** diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 6568e19058..7b034b69a3 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7861,7 +7861,13 @@ void SceneSessionManager::DealwithDrawingContentChange( WindowType type = WindowType::APP_WINDOW_BASE; sptr session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { - GetDrawingDataElement(surfaceId, pid, uid); + auto index = GetDrawingDataIndex(surfaceId); + if (index < 0) { + continue; + } + pid = lastDrawingData_[index].pid_; + uid = lastDrawingData_[index].uid_; + EraseDrawingDataElement(index); } else { winId = session->GetWindowId(); pid = session->GetCallingPid(); @@ -7882,16 +7888,20 @@ void SceneSessionManager::DealwithDrawingContentChange( } } -void SceneSessionManager::GetDrawingDataElement(uint64_t windowId, int32_t& pid, int32_t& uid) { - for (auto it = lastDrawingData_.begin(); it != lastDrawingData_.end(); ++it) { - auto& elem = *it; - if (elem.windowId_ == windowId) { - pid = elem.pid_; - uid = elem.uid_; - lastDrawingData_.erase(it); - break; +int SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) { + int num = static_cast(lastDrawingData_.size()); + for (int index = 0; index < lastDrawingData_.size(); ++index) { + if (lastDrawingData_[index].windowId_ == windowId) { + return index; } } + return -1; +} + +void SceneSessionManager::EraseDrawingDataElement(int index) { + if (index >= 0 && static_cast(index) < lastDrawingData_.size()) { + lastDrawingData_.erase(lastDrawingData_.begin() + index); + } } std::vector> SceneSessionManager::GetWindowDrawingContentChangeInfo( @@ -7899,21 +7909,14 @@ std::vector> SceneSessionManager::GetWindowDrawingCont std::vector> processDrawingContentChangeInfo; for (const auto& data : currDrawingContentData) { uint64_t windowId = data.first; - bool currentWindowDrawingState = data.second; + bool isWindowDrawing = data.second; int32_t pid = 0; - bool DrawingContentChange = false; + bool isDrawingStateChange = false; sptr session = SelectSesssionFromMap(windowId); - if (session == nullptr) { - DrawingContentChange = true; - } - if (!DrawingContentChange && - GetPreWindowDrawingState(windowId, currentWindowDrawingState, pid) == currentWindowDrawingState) { - continue; - } - if (!DrawingContentChange) { - WindowDrawingContentChange = GetProcessDrawingState(windowId, pid); - } - if (DrawingContentChange) { + isDrawingStateChange = (session == nullptr) || + (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) == isWindowDrawing) || + GetProcessDrawingState(windowId, pid); + if (isDrawingStateChange) { processDrawingContentChangeInfo.emplace_back(windowId, currentWindowDrawingState); } } @@ -7930,21 +7933,16 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre pid = session->GetCallingPid(); preWindowDrawingState = session->GetDrawingContentState(); session->SetDrawingContentState(currentDrawingContentState); - RemoveDuplicateDrawingData(windowId); - DrawingSessionId Ids = { windowId, pid, session->GetCallingUid() }; - lastDrawingData_.emplace_back(Ids); + UpdateWindowDrawingData(windowId, pid, session->GetCallingUid()); return preWindowDrawingState; } -void SceneSessionManager::RemoveDuplicateDrawingData(uint64_t windowId) { - for (auto it = lastDrawingData_.begin(); it != lastDrawingData_.end();) { - auto& elem = *it; - if (elem.windowId_ == windowId) { - lastDrawingData_.erase(it); - } else { - ++it; - } +void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) { + auto index = GetDrawingDataIndex(windowId); + if (index < 0) { + EraseDrawingDataElement(index); } + lastDrawingData_.emplace_back({ windowId, pid, uid }); } bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid) @@ -7966,7 +7964,6 @@ bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid) return isChange; } - void SceneSessionManager::InitWithRenderServiceAdded() { auto windowVisibilityChangeCb = [this](std::shared_ptr occlusiontionData) { From 7bd447c193bc30515f799c1e7074b98e91ac9f8c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:08:06 +0800 Subject: [PATCH 055/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 00ca951a66..6208f146bb 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1051,6 +1051,7 @@ private: /* * Window Property */ + std::mutex lastDrawingDataMutex_; std::vector lastDrawingData_; struct DrawingSessionIdInfo { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7b034b69a3..5ad2033f12 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7888,24 +7888,32 @@ void SceneSessionManager::DealwithDrawingContentChange( } } -int SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) { +int SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) +{ + int index = -1; int num = static_cast(lastDrawingData_.size()); - for (int index = 0; index < lastDrawingData_.size(); ++index) { - if (lastDrawingData_[index].windowId_ == windowId) { - return index; + { + std::unique_lock lock(lastDrawingDataMutex_); + for (int i = 0; i < num; ++i) { + if (lastDrawingData_[index].windowId_ == windowId) { + index = i; + } } } - return -1; + return index; } -void SceneSessionManager::EraseDrawingDataElement(int index) { +void SceneSessionManager::EraseDrawingDataElement(int index) +{ + std::unique_lock lock(lastDrawingDataMutex_); if (index >= 0 && static_cast(index) < lastDrawingData_.size()) { lastDrawingData_.erase(lastDrawingData_.begin() + index); } } std::vector> SceneSessionManager::GetWindowDrawingContentChangeInfo( - const std::vector>& currDrawingContentData) { + const std::vector>& currDrawingContentData) +{ std::vector> processDrawingContentChangeInfo; for (const auto& data : currDrawingContentData) { uint64_t windowId = data.first; @@ -7937,11 +7945,13 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre return preWindowDrawingState; } -void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) { +void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) +{ auto index = GetDrawingDataIndex(windowId); if (index < 0) { EraseDrawingDataElement(index); } + std::unique_lock lock(lastDrawingDataMutex_); lastDrawingData_.emplace_back({ windowId, pid, uid }); } From 5ae5345325cb99228b8fea5fb8775976e011cbd1 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:23:16 +0800 Subject: [PATCH 056/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 4 ++-- .../session_manager/src/scene_session_manager.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 6208f146bb..b0d3c75560 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -692,8 +692,8 @@ private: bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid); bool GetProcessDrawingState(uint64_t windowId, int32_t pid); void UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid); - int GetDrawingDataIndex(uint64_t windowId); - void EraseDrawingDataElement(int index); + size_t GetDrawingDataIndex(uint64_t windowId); + void EraseDrawingDataElement(size_t index); /* * Window Rotate Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5ad2033f12..d7daf6df8b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7888,14 +7888,14 @@ void SceneSessionManager::DealwithDrawingContentChange( } } -int SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) +size_t SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) { - int index = -1; - int num = static_cast(lastDrawingData_.size()); + size_t index = -1; { std::unique_lock lock(lastDrawingDataMutex_); - for (int i = 0; i < num; ++i) { - if (lastDrawingData_[index].windowId_ == windowId) { + for (int i = 0; i < lastDrawingData_.size(); ++i) { + if ( + [index].windowId_ == windowId) { index = i; } } @@ -7903,10 +7903,10 @@ int SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) return index; } -void SceneSessionManager::EraseDrawingDataElement(int index) +void SceneSessionManager::EraseDrawingDataElement(size_t index) { std::unique_lock lock(lastDrawingDataMutex_); - if (index >= 0 && static_cast(index) < lastDrawingData_.size()) { + if (index >= 0 && index < lastDrawingData_.size()) { lastDrawingData_.erase(lastDrawingData_.begin() + index); } } From c5070c10bc71b9ebc5bd2d904a3d5aead1e88ea7 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:24:33 +0800 Subject: [PATCH 057/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 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 d7daf6df8b..7511f791e8 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7850,7 +7850,8 @@ void SceneSessionManager::DealwithVisibilityChange(const std::vector>& drawingContentChangeInfo) { + const std::vector>& drawingContentChangeInfo) +{ std::vector> windowDrawingContenInfos; for (const auto& elem : drawingContentChangeInfo) { uint64_t surfaceId = elem.first; From ce246d28f1f88af258e4f9003aa3249b7d6cc422 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:25:44 +0800 Subject: [PATCH 058/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7511f791e8..b2ae0af6e9 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7849,8 +7849,8 @@ void SceneSessionManager::DealwithVisibilityChange(const std::vector>& drawingContentChangeInfo) +void SceneSessionManager::DealwithDrawingContentChange(const std::vector>& + drawingContentChangeInfo) { std::vector> windowDrawingContenInfos; for (const auto& elem : drawingContentChangeInfo) { From 40a759a5fadb57fea8779c74b9ff4e2d980e32e5 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:26:39 +0800 Subject: [PATCH 059/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index b2ae0af6e9..8f258f6c21 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7895,8 +7895,7 @@ size_t SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) { std::unique_lock lock(lastDrawingDataMutex_); for (int i = 0; i < lastDrawingData_.size(); ++i) { - if ( - [index].windowId_ == windowId) { + if (lastDrawingData_[index].windowId_ == windowId) { index = i; } } From 0243b689936bef05d6ade764bdce5ece5a656f94 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:30:44 +0800 Subject: [PATCH 060/171] add code Signed-off-by: ZihaoWU --- .../session_manager/include/scene_session_manager.h | 2 +- .../session_manager/src/scene_session_manager.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index b0d3c75560..0d9532e0df 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -689,7 +689,7 @@ private: */ std::vector> GetWindowDrawingContentChangeInfo( const std::vector>& currDrawingContentData); - bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid); + bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawing, int32_t& pid); bool GetProcessDrawingState(uint64_t windowId, int32_t pid); void UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid); size_t GetDrawingDataIndex(uint64_t windowId); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 8f258f6c21..b4796ba083 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7931,18 +7931,18 @@ std::vector> SceneSessionManager::GetWindowDrawingCont return processDrawingContentChangeInfo; } -bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawingState, int32_t& pid) +bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawing, int32_t& pid) { - bool preWindowDrawingState = true; + bool preWindowDrawing = true; sptr session = SelectSesssionFromMap(windowId); if (session == nullptr) { return false; } pid = session->GetCallingPid(); - preWindowDrawingState = session->GetDrawingContentState(); - session->SetDrawingContentState(currentDrawingContentState); + preWindowDrawing = session->GetDrawingContentState(); + session->SetDrawingContentState(currentWindowDrawing); UpdateWindowDrawingData(windowId, pid, session->GetCallingUid()); - return preWindowDrawingState; + return preWindowDrawing; } void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) From 1e6850b032dc8f909613cb5b9cd9812ad3ad957c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:31:40 +0800 Subject: [PATCH 061/171] add code Signed-off-by: ZihaoWU --- 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 b4796ba083..9e2da5d1f2 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7925,7 +7925,7 @@ std::vector> SceneSessionManager::GetWindowDrawingCont (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) == isWindowDrawing) || GetProcessDrawingState(windowId, pid); if (isDrawingStateChange) { - processDrawingContentChangeInfo.emplace_back(windowId, currentWindowDrawingState); + processDrawingContentChangeInfo.emplace_back(windowId, isWindowDrawing); } } return processDrawingContentChangeInfo; From 5812d0f476fbdd4ded4bc07990eeb89a28a2c305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Wed, 13 Nov 2024 17:32:15 +0800 Subject: [PATCH 062/171] change1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wm/test/unittest/window_stub_test.cpp | 2 +- .../unittest/window_manager_stub_test.cpp | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/wm/test/unittest/window_stub_test.cpp b/wm/test/unittest/window_stub_test.cpp index 401cbe85c5..46c23fbb76 100644 --- a/wm/test/unittest/window_stub_test.cpp +++ b/wm/test/unittest/window_stub_test.cpp @@ -460,7 +460,7 @@ HWTEST_F(WindowStubTest, OnRemoteRequest18, Function | SmallTest | Level2) uint32_t code = static_cast(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE); int res = windowStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, static_cast(ERR_NONE)); + EXPECT_EQ(res, static_cast(ERR_INVALID_DATA)); } /** diff --git a/wmserver/test/unittest/window_manager_stub_test.cpp b/wmserver/test/unittest/window_manager_stub_test.cpp index f62e4835a7..c1ad6699a1 100644 --- a/wmserver/test/unittest/window_manager_stub_test.cpp +++ b/wmserver/test/unittest/window_manager_stub_test.cpp @@ -315,7 +315,7 @@ HWTEST_F(WindowManagerStubTest, OnRemoteRequest13, Function | SmallTest | Level2 uint32_t code = static_cast(IWindowManager::WindowManagerMessage::TRANS_ID_UPDATE_PROPERTY); int res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, static_cast(ERR_INVALID_DATA)); + EXPECT_EQ(res, static_cast(ERR_NONE)); } /** @@ -552,6 +552,26 @@ HWTEST_F(WindowManagerStubTest, OnRemoteRequest23, Function | SmallTest | Level2 int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest24 + * @tc.desc: test TRANS_ID_GET_SNAPSHOT success + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerStubTest, OnRemoteRequest24, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(WindowManagerStub::GetDescriptor()); + uint32_t writeValue = 0; + data.WriteInt32(writeValue); + uint32_t code = static_cast( + IWindowManager::WindowManagerMessage::TRANS_ID_GET_SNAPSHOT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, static_cast(ERR_NONE)); +} } } } From 02d7660ef9af5d38fd289c9035072b3075d8ca06 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:32:52 +0800 Subject: [PATCH 063/171] add code Signed-off-by: ZihaoWU --- 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 9e2da5d1f2..e1ab30faee 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7948,7 +7948,7 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) { auto index = GetDrawingDataIndex(windowId); - if (index < 0) { + if (index >= 0) { EraseDrawingDataElement(index); } std::unique_lock lock(lastDrawingDataMutex_); From 3eeafe38cf49cfe3bf219ba8766fef6012b82c0f Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Wed, 13 Nov 2024 17:33:44 +0800 Subject: [PATCH 064/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e1ab30faee..e4016c8e7d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7897,6 +7897,7 @@ size_t SceneSessionManager::GetDrawingDataIndex(uint64_t windowId) for (int i = 0; i < lastDrawingData_.size(); ++i) { if (lastDrawingData_[index].windowId_ == windowId) { index = i; + break; } } } From 17f42868b11d2312b49cfb38992d1ef4b38e353c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Wed, 13 Nov 2024 09:58:18 +0000 Subject: [PATCH 065/171] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 2e7b1c8131..123b459ee9 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2644,7 +2644,7 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf if (argc > 1 && !ConvertFromJsValue(env, argv[INDEX_ONE], isDockHoverShown)) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert isDockHoverShown parameter"); } - // 2: params num; 2: index of callback= + // 2: params num; 2: index of callback napi_value lastParam = (argc <= 2) ? nullptr : (GetType(env, argv[INDEX_TWO]) == napi_function ? argv[INDEX_TWO] : nullptr); napi_value result = nullptr; From 92bed68eef482f9d2de1e3caf00422bdcca8aa0d Mon Sep 17 00:00:00 2001 From: Angus Liu Date: Wed, 13 Nov 2024 20:59:18 +0800 Subject: [PATCH 066/171] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=AD=90=E7=AA=97=E5=88=9B=E5=BB=BA=E4=B8=94=E8=A2=AB=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E6=97=B6=E5=87=BA=E7=8E=B0=E7=9A=84=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=20resize=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Angus Liu --- interfaces/innerkits/wm/wm_common.h | 5 +++++ previewer/include/wm_common.h | 5 +++++ .../session_manager/include/scene_session_manager.h | 2 +- wm/src/window_scene_session_impl.cpp | 6 +++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index e9d8f5d1b9..51f9725f8b 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -713,6 +713,11 @@ struct Rect { return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0); } + bool IsUninitializedSize() const + { + return width_ == 0 && height_ == 0; + } + bool IsInsideOf(const Rect& a) const { return (posX_ >= a.posX_ && posY_ >= a.posY_ && diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 4f16c615eb..99b88a4cbe 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -511,6 +511,11 @@ struct Rect { { return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0); } + + bool IsUninitializedSize() const + { + return width_ == 0 && height_ == 0; + } }; /** diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 1806d07dd6..3e8ce53740 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -979,7 +979,7 @@ private: std::unordered_set snapshotSkipPidSet_ GUARDED_BY(SCENE_GUARD); // ONLY Accessed on OS_sceneSession thread std::unordered_set snapshotSkipBundleNameSet_ GUARDED_BY(SCENE_GUARD); - int32_t sessionMapDirty_ { 0 }; + uint32_t sessionMapDirty_ { 0 }; std::condition_variable nextFlushCompletedCV_; std::mutex nextFlushCompletedMutex_; RootSceneProcessBackEventFunc rootSceneProcessBackEventFunc_ = nullptr; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 33dbd386fd..c96c4e9412 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3748,10 +3748,10 @@ void WindowSceneSessionImpl::UpdateNewSize() } bool needResize = false; Rect windowRect = GetRequestRect(); - if (windowRect.IsUninitializedRect()) { + if (windowRect.IsUninitializedSize()) { windowRect = GetRect(); - if (windowRect.IsUninitializedRect()) { - TLOGW(WmsLogTag::WMS_LAYOUT, "The requestRect and rect are uninitialized. winId: %{public}u", + if (windowRect.IsUninitializedSize()) { + TLOGW(WmsLogTag::WMS_LAYOUT, "The sizes of requestRect and rect are uninitialized. winId: %{public}u", GetWindowId()); return; } From cf2af8d013fda2c8e55b4b06af585ca63a914b33 Mon Sep 17 00:00:00 2001 From: lpf Date: Mon, 11 Nov 2024 20:32:02 +0800 Subject: [PATCH 067/171] fix Signed-off-by: lpf --- window_scene/session/host/include/session.h | 9 +++++++++ window_scene/session/host/src/scene_session.cpp | 9 ++++++++- window_scene/session/host/src/session.cpp | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 0e2fbeba45..5265b8faf8 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -663,6 +663,15 @@ protected: float snapshotScale_ = 0.5; sptr scenePersistence_ = nullptr; + /** + * Window Layout + */ + float clientScaleX_ = 1.0f; + float clientScaleY_ = 1.0f; + float clientPivotX_ = 0.0f; + float clientPivotY_ = 0.0f; + void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY); + /** * Window ZOrder */ diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 4f38765606..a5dba936f6 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5386,10 +5386,16 @@ void SceneSession::NotifyClientToUpdateAvoidArea() bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY) { if (NearEqual(scaleX_, scaleX) && NearEqual(scaleY_, scaleY) && - NearEqual(pivotX_, pivotX) && NearEqual(pivotY_, pivotY)) { + NearEqual(pivotX_, pivotX) && NearEqual(pivotY_, pivotY) && + NearEqual(clientScaleX_, scaleX) && NearEqual(clientScaleY_, scaleY) && + NearEqual(clientPivotX_, pivotX) && NearEqual(clientPivotY_, pivotY)) { return false; } Session::SetScale(scaleX, scaleY, pivotX, pivotY); + if (!IsSessionForeground()) { + TLOGD(WmsLogTag::WMS_LAYOUT, "id:%{public}d, session is not foreground!", GetPersistentId()); + return false; + } if (sessionStage_ != nullptr) { Transform transform; transform.scaleX_ = scaleX; @@ -5397,6 +5403,7 @@ bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, fl transform.pivotX_ = pivotX; transform.pivotY_ = pivotY; sessionStage_->NotifyTransformChange(transform); + Session::SetClientScale(scaleX, scaleY, pivotX, pivotY); } else { WLOGFE("sessionStage is nullptr"); } diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 51f7e97dd4..e6413ba4ec 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3250,6 +3250,15 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY) pivotY_ = pivotY; } +void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) +{ + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, in", GetPersistentId()); + clientScaleX_ = scaleX; + clientScaleY_ = scaleY; + clientpivotX_ = pivotX; + clientpivotY_ = pivotY; +} + float Session::GetScaleX() const { return scaleX_; From 017f2c389c319b2194142475ff8341210b2a343c Mon Sep 17 00:00:00 2001 From: lpf Date: Tue, 12 Nov 2024 11:52:44 +0800 Subject: [PATCH 068/171] fix Signed-off-by: lpf --- window_scene/test/unittest/scene_session_test3.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index fe0fd445e3..e085c64b31 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -457,19 +457,27 @@ HWTEST_F(SceneSessionTest3, UpdateScaleInner, Function | SmallTest | Level2) EXPECT_NE(nullptr, sceneSession); sceneSession->sessionStage_ = nullptr; + sceneSession->state_ = SessionState::STATE_FOREGROUND; bool res = sceneSession->UpdateScaleInner(10.0f, 10.0f, 10.0f, 10.0f); EXPECT_EQ(true, res); + res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 10.0f, 10.0f); res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 10.0f); res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 9.0f); EXPECT_EQ(true, res); + + sceneSession->state_ = SessionState::STATE_BACKGROUND; res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 9.0f); EXPECT_EQ(false, res); + + sceneSession->state_ = SessionState::STATE_FOREGROUND; sptr mockSessionStage = sptr::MakeSptr(); ASSERT_NE(mockSessionStage, nullptr); sceneSession->sessionStage_ = mockSessionStage; res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f); EXPECT_EQ(true, res); + res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f); + EXPECT_EQ(false, res); } /** From 4707800f829588970b63bfe03eff6c47382f4156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Wed, 13 Nov 2024 21:44:25 +0800 Subject: [PATCH 069/171] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- .../src/scene_session_manager.cpp | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index f318e1e6e8..604f92a10e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2442,31 +2442,27 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co property->GetParentPersistentId()); return WSError::WS_ERROR_NULLPTR; } - sptr parentProperty = extensionParentSession->GetSessionProperty(); - if (sessionStage && parentProperty && property->GetIsUIExtFirstSubWindow()) { - sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); - property->SetDisplayId(parentProperty->GetDisplayId()); - } auto pid = IPCSkeleton::GetCallingRealPid(); auto parentPid = extensionParentSession->GetCallingPid(); + bool checkIsPassed = false; if (pid == parentPid) { - TLOGI(WmsLogTag::WMS_UIEXT, "pid == parentPid(pid:%{public}d)", pid); - return WSError::WS_OK; + TLOGI(WmsLogTag::WMS_UIEXT, "pid == parentPid"); + checkIsPassed = true } AAFwk::UIExtensionSessionInfo info; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info); - if (info.persistentId != INVALID_SESSION_ID && info.hostWindowId != INVALID_SESSION_ID) { + if (!checkIsPassed && info.persistentId != INVALID_SESSION_ID && info.hostWindowId != INVALID_SESSION_ID) { int32_t parentId = static_cast(info.hostWindowId); if (parentId == property->GetParentPersistentId()) { TLOGI(WmsLogTag::WMS_UIEXT, "parentId == property->GetParentPersistentId(parentId:%{public}d)", parentId); - return WSError::WS_OK; + checkIsPassed = true } } - if (SessionPermission::IsSystemCalling()) { + if (!checkIsPassed && SessionPermission::IsSystemCalling()) { TLOGI(WmsLogTag::WMS_UIEXT, "is system app"); - return WSError::WS_OK; + checkIsPassed = true } - if (property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { + if (!checkIsPassed && property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); AAFwk::UIExtensionHostInfo hostInfo; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); @@ -2476,10 +2472,17 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co hostInfo.elementName_.GetBundleName().c_str()); return WSError::WS_ERROR_INVALID_WINDOW; } - return WSError::WS_OK; + checkIsPassed = true } - TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: not system app; pid: %{public}d; persistentId %{public}d", - pid, property->GetPersistentId()); + if (checkIsPassed) { + sptr parentProperty = extensionParentSession->GetSessionProperty(); + if (sessionStage && parentProperty && property->GetIsUIExtFirstSubWindow()) { + sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); + property->SetDisplayId(parentProperty->GetDisplayId()); + } + return SError::WS_OK; + } + TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: persistentId %{public}d", property->GetPersistentId()); return WSError::WS_ERROR_INVALID_WINDOW; } From eeb5bfda34091f004774d836c31879267b7e4b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Wed, 13 Nov 2024 22:46:09 +0800 Subject: [PATCH 070/171] =?UTF-8?q?=E7=9B=91=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- 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 604f92a10e..bb65e713f1 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2480,7 +2480,7 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); property->SetDisplayId(parentProperty->GetDisplayId()); } - return SError::WS_OK; + return WSError::WS_OK; } TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: persistentId %{public}d", property->GetPersistentId()); return WSError::WS_ERROR_INVALID_WINDOW; From 8a93081f6c23c9b42209b1eccb617caa2b2c543c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Wed, 13 Nov 2024 22:59:58 +0800 Subject: [PATCH 071/171] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- 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 bb65e713f1..fd05cf17a6 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2451,18 +2451,18 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co } AAFwk::UIExtensionSessionInfo info; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info); - if (!checkIsPassed && info.persistentId != INVALID_SESSION_ID && info.hostWindowId != INVALID_SESSION_ID) { + if (info.persistentId != INVALID_SESSION_ID && info.hostWindowId != INVALID_SESSION_ID) { int32_t parentId = static_cast(info.hostWindowId); if (parentId == property->GetParentPersistentId()) { TLOGI(WmsLogTag::WMS_UIEXT, "parentId == property->GetParentPersistentId(parentId:%{public}d)", parentId); checkIsPassed = true } } - if (!checkIsPassed && SessionPermission::IsSystemCalling()) { + if (SessionPermission::IsSystemCalling()) { TLOGI(WmsLogTag::WMS_UIEXT, "is system app"); checkIsPassed = true } - if (!checkIsPassed && property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { + if (property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); AAFwk::UIExtensionHostInfo hostInfo; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); From a1748271f7e05c346d364b4632b718f9f8348253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Wed, 13 Nov 2024 23:17:25 +0800 Subject: [PATCH 072/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- .../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 fd05cf17a6..105974427f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2447,7 +2447,7 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co bool checkIsPassed = false; if (pid == parentPid) { TLOGI(WmsLogTag::WMS_UIEXT, "pid == parentPid"); - checkIsPassed = true + checkIsPassed = true; } AAFwk::UIExtensionSessionInfo info; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info); @@ -2455,12 +2455,12 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co int32_t parentId = static_cast(info.hostWindowId); if (parentId == property->GetParentPersistentId()) { TLOGI(WmsLogTag::WMS_UIEXT, "parentId == property->GetParentPersistentId(parentId:%{public}d)", parentId); - checkIsPassed = true + checkIsPassed = true; } } if (SessionPermission::IsSystemCalling()) { TLOGI(WmsLogTag::WMS_UIEXT, "is system app"); - checkIsPassed = true + checkIsPassed = true; } if (property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); @@ -2472,7 +2472,7 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co hostInfo.elementName_.GetBundleName().c_str()); return WSError::WS_ERROR_INVALID_WINDOW; } - checkIsPassed = true + checkIsPassed = true; } if (checkIsPassed) { sptr parentProperty = extensionParentSession->GetSessionProperty(); From b799d6e79d93cc5e1c8f1b3f2a8ba0c1c4cfce2c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 07:59:11 +0800 Subject: [PATCH 073/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 4 ++-- .../src/scene_session_manager.cpp | 23 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 0d9532e0df..9c88ca7c01 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -692,8 +692,8 @@ private: bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawing, int32_t& pid); bool GetProcessDrawingState(uint64_t windowId, int32_t pid); void UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid); - size_t GetDrawingDataIndex(uint64_t windowId); - void EraseDrawingDataElement(size_t index); + int GetSpecifiedDrawingData(uint64_t windowId); + void RemoveSpecifiedDrawingData(int index); /* * Window Rotate Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e4016c8e7d..3455d8d810 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7862,13 +7862,13 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { - auto index = GetDrawingDataIndex(surfaceId); + auto index = GetSpecifiedDrawingData(surfaceId); if (index < 0) { continue; } pid = lastDrawingData_[index].pid_; uid = lastDrawingData_[index].uid_; - EraseDrawingDataElement(index); + RemoveSpecifiedDrawingData(index); } else { winId = session->GetWindowId(); pid = session->GetCallingPid(); @@ -7889,22 +7889,21 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector lock(lastDrawingDataMutex_); - for (int i = 0; i < lastDrawingData_.size(); ++i) { - if (lastDrawingData_[index].windowId_ == windowId) { - index = i; - break; - } + auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), + [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); + if (it != lastDrawingData_.end()) { + index = it - lastDrawingData_.end(); } } return index; } -void SceneSessionManager::EraseDrawingDataElement(size_t index) +void SceneSessionManager::RemoveSpecifiedDrawingData(int index) { std::unique_lock lock(lastDrawingDataMutex_); if (index >= 0 && index < lastDrawingData_.size()) { @@ -7948,9 +7947,9 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) { - auto index = GetDrawingDataIndex(windowId); + auto index = GetSpecifiedDrawingData(windowId); if (index >= 0) { - EraseDrawingDataElement(index); + RemoveSpecifiedDrawingData(index); } std::unique_lock lock(lastDrawingDataMutex_); lastDrawingData_.emplace_back({ windowId, pid, uid }); From 469df1cb0d4b44ee1d087e8afe3c318dd9a9af37 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 08:31:14 +0800 Subject: [PATCH 074/171] add code Signed-off-by: ZihaoWU --- .../session_manager/include/scene_session_manager.h | 7 ++++--- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 2 files changed, 5 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 9c88ca7c01..2f2932acc9 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1051,14 +1051,15 @@ private: /* * Window Property */ - std::mutex lastDrawingDataMutex_; - std::vector lastDrawingData_; - struct DrawingSessionIdInfo { uint64_t windowId_ = 0; int32_t pid_ = 0; int32_t uid_ = 0; }; + + + std::mutex lastDrawingDataMutex_; + std::vector lastDrawingData_; /** * PC Window diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3455d8d810..9c0d8c7b0f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7952,7 +7952,7 @@ void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid RemoveSpecifiedDrawingData(index); } std::unique_lock lock(lastDrawingDataMutex_); - lastDrawingData_.emplace_back({ windowId, pid, uid }); + lastDrawingData_.push_back({ windowId, pid, uid }); } bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid) From 33da8964386546f2ad9eab6d9c659a604324d80f Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 08:36:04 +0800 Subject: [PATCH 075/171] add code Signed-off-by: ZihaoWU --- 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 9c0d8c7b0f..0ce94a848e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7897,7 +7897,7 @@ int SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId) auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); if (it != lastDrawingData_.end()) { - index = it - lastDrawingData_.end(); + index = it - lastDrawingData_.begin(); } } return index; From b43dd27d562a905a80f92ac36b756b73eb9e2d8d Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 08:56:43 +0800 Subject: [PATCH 076/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 7 ++++--- 1 file changed, 4 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 0ce94a848e..8f19b13dd5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7903,6 +7903,7 @@ int SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId) return index; } + void SceneSessionManager::RemoveSpecifiedDrawingData(int index) { std::unique_lock lock(lastDrawingDataMutex_); @@ -7921,9 +7922,9 @@ std::vector> SceneSessionManager::GetWindowDrawingCont int32_t pid = 0; bool isDrawingStateChange = false; sptr session = SelectSesssionFromMap(windowId); - isDrawingStateChange = (session == nullptr) || - (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) == isWindowDrawing) || - GetProcessDrawingState(windowId, pid); + isDrawingStateChange = + (session == nullptr) || (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) == isWindowDrawing && + GetProcessDrawingState(windowId, pid)); if (isDrawingStateChange) { processDrawingContentChangeInfo.emplace_back(windowId, isWindowDrawing); } From 40f2af229fd71df11e1604b187b208a76a2f5f19 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 09:02:14 +0800 Subject: [PATCH 077/171] add code Signed-off-by: ZihaoWU --- 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 8f19b13dd5..88a321dba0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7923,7 +7923,7 @@ std::vector> SceneSessionManager::GetWindowDrawingCont bool isDrawingStateChange = false; sptr session = SelectSesssionFromMap(windowId); isDrawingStateChange = - (session == nullptr) || (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) == isWindowDrawing && + (session == nullptr) || (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) != isWindowDrawing && GetProcessDrawingState(windowId, pid)); if (isDrawingStateChange) { processDrawingContentChangeInfo.emplace_back(windowId, isWindowDrawing); From c8d5ed0e344333e0b675bea8dd6487f9774080f4 Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 09:40:23 +0800 Subject: [PATCH 078/171] fix format Signed-off-by: lpf --- window_scene/test/unittest/scene_session_test3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index e085c64b31..86a0180e1c 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -477,7 +477,7 @@ HWTEST_F(SceneSessionTest3, UpdateScaleInner, Function | SmallTest | Level2) res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f); EXPECT_EQ(true, res); res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f); - EXPECT_EQ(false, res); + EXPECT_EQ(false, res); } /** From 7cf01c17a3485873fa76ec6e997f5380f47a053c Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 09:52:18 +0800 Subject: [PATCH 079/171] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- window_scene/session/host/src/session.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index e6413ba4ec..cd8fad25b3 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3253,6 +3253,12 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY) void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) { TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, in", GetPersistentId()); + TLOGD(WmsLogTag::WMS_LAYOUT, "clientScaleX_:%{public}d, clientScaleY_:%{public}d, " + "clientpivotX_:%{public}d, clientpivotY_:%{public}d, ", + clientScaleX_, clientScaleY_, clientpivotX_, clientpivotY_); + TLOGD(WmsLogTag::WMS_LAYOUT, "scaleX:%{public}d, scaleY:%{public}d, " + "pivotX:%{public}d, pivotY:%{public}d, ", + scaleX, scaleY, pivotX, pivotY); clientScaleX_ = scaleX; clientScaleY_ = scaleY; clientpivotX_ = pivotX; From 75a0904418b59c0a7a4fc9e5f1b3452953963cd3 Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 09:58:47 +0800 Subject: [PATCH 080/171] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- window_scene/session/host/src/session.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index cd8fad25b3..61c2a0f469 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3253,12 +3253,8 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY) void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) { TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, in", GetPersistentId()); - TLOGD(WmsLogTag::WMS_LAYOUT, "clientScaleX_:%{public}d, clientScaleY_:%{public}d, " - "clientpivotX_:%{public}d, clientpivotY_:%{public}d, ", - clientScaleX_, clientScaleY_, clientpivotX_, clientpivotY_); - TLOGD(WmsLogTag::WMS_LAYOUT, "scaleX:%{public}d, scaleY:%{public}d, " - "pivotX:%{public}d, pivotY:%{public}d, ", - scaleX, scaleY, pivotX, pivotY); + TLOGD(WmsLogTag::WMS_LAYOUT, "clientScaleX_:%{public}f, clientScaleY_:%{public}f", clientScaleX_, clientScaleY_); + TLOGD(WmsLogTag::WMS_LAYOUT, "scaleX:%{public}f, scaleY:%{public}f", scaleX, scaleY); clientScaleX_ = scaleX; clientScaleY_ = scaleY; clientpivotX_ = pivotX; From 44ca4f2a4ce332702dab10c8f11dc5fca9c5badc Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 10:03:10 +0800 Subject: [PATCH 081/171] add code Signed-off-by: ZihaoWU --- 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 88a321dba0..33b653a1da 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7895,7 +7895,7 @@ int SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId) { std::unique_lock lock(lastDrawingDataMutex_); auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), - [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); + [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); if (it != lastDrawingData_.end()) { index = it - lastDrawingData_.begin(); } From bbae55c1c8ccea5366a51645d8b14a3977ce8ab9 Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 10:13:59 +0800 Subject: [PATCH 082/171] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- window_scene/session/host/src/session.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 61c2a0f469..a798bde11d 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3252,9 +3252,8 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY) void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) { - TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, in", GetPersistentId()); - TLOGD(WmsLogTag::WMS_LAYOUT, "clientScaleX_:%{public}f, clientScaleY_:%{public}f", clientScaleX_, clientScaleY_); - TLOGD(WmsLogTag::WMS_LAYOUT, "scaleX:%{public}f, scaleY:%{public}f", scaleX, scaleY); + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, clientScaleX:%{public}f, clientScaleY:%{public}f, " + "scaleX:%{public}f, scaleY:%{public}f", GetPersistentId(), clientScaleX_, clientScaleY_, scaleX, scaleY); clientScaleX_ = scaleX; clientScaleY_ = scaleY; clientpivotX_ = pivotX; From 9a41f23cf10e1bc7e9e1a617cc5eea368ec056e6 Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 10:25:51 +0800 Subject: [PATCH 083/171] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- window_scene/session/host/src/session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index a798bde11d..2ec3cca9b1 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3252,8 +3252,8 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY) void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) { - TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, clientScaleX:%{public}f, clientScaleY:%{public}f, " - "scaleX:%{public}f, scaleY:%{public}f", GetPersistentId(), clientScaleX_, clientScaleY_, scaleX, scaleY); + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, preScaleX:%{public}f, preScaleY:%{public}f, " + "newScaleX:%{public}f, newScaleY:%{public}f", GetPersistentId(), clientScaleX_, clientScaleY_, scaleX, scaleY); clientScaleX_ = scaleX; clientScaleY_ = scaleY; clientpivotX_ = pivotX; From ac7203291287f4be63650fc9e30eee5b747cb699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Thu, 14 Nov 2024 10:37:43 +0800 Subject: [PATCH 084/171] =?UTF-8?q?Description:=E6=96=B0=E5=A2=9E=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=88=AA=E5=B1=8F=E5=BA=94=E7=94=A8=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20IssueNo:https:https://gitee.com/openharmony/window=5Fwindow?= =?UTF-8?q?=5Fmanager/issues/IB48FY=20Binary=20Source:No=20Signed-off-by:?= =?UTF-8?q?=20songjiawei9=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/include/event_tracker.h | 29 +++++++++++-- window_scene/screen_session_manager/BUILD.gn | 3 ++ .../include/screen_session_manager.h | 2 + .../src/screen_session_manager.cpp | 41 +++++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/utils/include/event_tracker.h b/utils/include/event_tracker.h index 07b9692cf0..747e906d1e 100644 --- a/utils/include/event_tracker.h +++ b/utils/include/event_tracker.h @@ -17,16 +17,18 @@ #define OHOS_ROSEN_SCREEN_EVENT_TRACKER_H #include -#include +#include #include #include #include +#include #include "window_manager_hilog.h" namespace OHOS { namespace Rosen { const int32_t OUTPUT_FREQ = 1; // 1Hz +const int32_t MAX_CAPACITY = 6; struct TrackInfo { std::string info; @@ -41,10 +43,20 @@ public: recordInfos_.push_back({info, std::chrono::system_clock::now()}); } + void RecordBoundsEvent(std::string info = "") + { + std::lock_guard lock(mutex_); + if (recordBoundsInfos_.size() >= MAX_CAPACITY) { + recordBoundsInfos_.pop_front(); + } + recordBoundsInfos_.push_back({info, std::chrono::system_clock::now()}); + } + void ClearAllRecordedEvents() { std::lock_guard lock(mutex_); recordInfos_.clear(); + recordBoundsInfos_.clear(); } void LogWarningAllInfos() const @@ -60,6 +72,11 @@ public: TLOGW(WmsLogTag::DMS, "[%{public}s]: %{public}s", formatTimestamp(info.timestamp).c_str(), info.info.c_str()); } + + for (const auto& info : recordBoundsInfos_) { + TLOGW(WmsLogTag::DMS, "[%{public}s]: %{public}s", + formatTimestamp(info.timestamp).c_str(), info.info.c_str()); + } } std::string formatTimestamp(const std::chrono::system_clock::time_point& timePoint) const @@ -85,16 +102,22 @@ public: return oss.str(); } - const std::vector& GetRecordInfos() const + const std::vector& GetRecordInfos() { std::lock_guard lock(mutex_); - return recordInfos_; + allRecordInfos_ = recordInfos_; + for (auto info : recordBoundsInfos_) { + allRecordInfos_.emplace_back(info); + } + return allRecordInfos_; } private: mutable std::mutex mutex_; mutable std::chrono::system_clock::time_point lastOutputTime_; std::vector recordInfos_; + std::list recordBoundsInfos_; + std::vector allRecordInfos_; }; diff --git a/window_scene/screen_session_manager/BUILD.gn b/window_scene/screen_session_manager/BUILD.gn index 5645bc9c02..06b176af98 100644 --- a/window_scene/screen_session_manager/BUILD.gn +++ b/window_scene/screen_session_manager/BUILD.gn @@ -141,6 +141,9 @@ ohos_shared_library("screen_session_manager") { "libxml2:libxml2", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "access_token:libaccesstoken_sdk", + "access_token:libprivacy_sdk", + "access_token:libtokenid_sdk", ] defines = [] diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index 8023bc974c..27cda60ca1 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -370,6 +370,7 @@ private: bool OnMakeExpand(std::vector screenId, std::vector startPoint); bool OnRemoteDied(const sptr& agent); std::string TransferTypeToString(ScreenType type) const; + std::string TransferPropertyChangeTypeToString(ScreenPropertyChangeType type) const; void CheckAndSendHiSysEvent(const std::string& eventName, const std::string& bundleName) const; void HandlerSensor(ScreenPowerStatus status, PowerStateChangeReason reason); bool GetPowerStatus(ScreenPowerState state, PowerStateChangeReason reason, ScreenPowerStatus& status); @@ -380,6 +381,7 @@ private: DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector& windowIdList) override; void GetInternalAndExternalSession(sptr& internalSession, sptr& externalSession); + void AddPermissionUsedRecord(const std::string& permission, int32_t successCount, int32_t failCount); #ifdef DEVICE_STATUS_ENABLE void SetDragWindowScreenId(ScreenId screenId, ScreenId displayNodeScreenId); #endif // DEVICE_STATUS_ENABLE diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 976f0c4f66..01ba16f533 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -2549,6 +2550,11 @@ void ScreenSessionManager::NotifyAndPublishEvent(sptr displayInfo, void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) { + std::ostringstream oss; + std::string changeType = TransferPropertyChangeTypeToString(screenPropertyChangeType); + oss << "screenId: " << screenId << " rotation: " << rotation << " width: " << bounds.rect_.width_ \ + << " height: " << bounds.rect_.height_ << " type: " << changeType; + screenEventTracker_.RecordBoundsEvent(oss.str()); if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::DMS, "permission denied!"); return; @@ -4689,6 +4695,26 @@ std::string ScreenSessionManager::TransferTypeToString(ScreenType type) const return screenType; } +std::string ScreenSessionManager::TransferPropertyChangeTypeToString(ScreenPropertyChangeType type) const +{ + std::string screenType; + switch (type) { + case ScreenPropertyChangeType::UNSPECIFIED: + screenType = "UNSPECIFIED"; + break; + case ScreenPropertyChangeType::ROTATION_BEGIN: + screenType = "ROTATION_BEGIN"; + break; + case ScreenPropertyChangeType::ROTATION_END: + screenType = "ROTATION_END"; + break; + default: + screenType = "ROTATION_UPDATE_PROPERTY_ONLY"; + break; + } + return screenType; +} + void ScreenSessionManager::DumpAllScreensInfo(std::string& dumpInfo) { if (!(SessionPermission::IsSACalling() || SessionPermission::IsStartByHdcd())) { @@ -6137,6 +6163,17 @@ void ScreenSessionManager::OnScreenCaptureNotify(ScreenId mainScreenId, int32_t clientProxy_->ScreenCaptureNotify(mainScreenId, uid, clientName); } +void ScreenSessionManager::AddPermissionUsedRecord(const std::string& permission, int32_t successCount, + int32_t failCount) +{ + int32_t ret = Security::AccessToken::PrivacyKit::AddPermissionUsedRecord(IPCSkeleton::GetCallingTokenID(), + permission, successCount, failCount); + if (ret != 0) { + TLOGW(WmsLogTag::DMS, "AddPermissionUsedRecord failed, permission:%{public}s, \ + successCount %{public}d, failedCount %{public}d", permission.c_str(), successCount, failCount); + } +} + std::shared_ptr ScreenSessionManager::GetScreenCapture(const CaptureOption& captureOption, DmErrorCode* errorCode) { @@ -6171,8 +6208,12 @@ std::shared_ptr ScreenSessionManager::GetScreenCapture(const Ca if (res == nullptr) { TLOGE(WmsLogTag::DMS, "get capture null."); *errorCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL; + AddPermissionUsedRecord(CUSTOM_SCREEN_CAPTURE_PERMISSION, + static_cast(res != nullptr), static_cast(res == nullptr)); return nullptr; } + AddPermissionUsedRecord(CUSTOM_SCREEN_CAPTURE_PERMISSION, + static_cast(res != nullptr), static_cast(res == nullptr)); NotifyScreenshot(captureOption.displayId_); if (SessionPermission::IsBetaVersion()) { CheckAndSendHiSysEvent("GET_DISPLAY_SNAPSHOT", "hmos.screenshot"); From 08ae96500bf4c9203e837043a50a778e1314a7c9 Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Thu, 14 Nov 2024 10:50:13 +0800 Subject: [PATCH 085/171] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- 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 a1cb148dcf..07a9b4f9da 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3156,11 +3156,11 @@ void SceneSession::MarkSystemSceneUIFirst(bool isForceFlag, bool isUifirstEnable if (leashWinSurfaceNode != nullptr) { TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForceFlag=%{public}d. isUifirstEnable=%{public}d", leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isForceFlag, isUifirstEnable); - leashWinSurfaceNode->MarkSystemSceneUIFirst(isForceFlag, isUifirstEnable); + leashWinSurfaceNode->MarkUifirstNode(isForceFlag, isUifirstEnable); } else { TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForceFlag=%{public}d. isUifirstEnable=%{public}d", surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isForceFlag, isUifirstEnable); - surfaceNode_->MarkSystemSceneUIFirst(isForceFlag, isUifirstEnable); + surfaceNode_->MarkUifirstNode(isForceFlag, isUifirstEnable); } } From 63902608fa0b7c152745755efc61862eed2bae81 Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 10:56:26 +0800 Subject: [PATCH 086/171] =?UTF-8?q?=E5=A2=9E=E5=8A=A0IsTransformNeedChange?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- window_scene/session/host/include/scene_session.h | 1 + window_scene/session/host/src/scene_session.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 57dd9c8a04..6f8adc353f 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -555,6 +555,7 @@ protected: bool PipelineNeedNotifyClientToUpdateRect() const; bool UpdateRectInner(const SessionUIParam& uiParam, SizeChangeReason reason); bool NotifyServerToUpdateRect(const SessionUIParam& uiParam, SizeChangeReason reason); + bool IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY); bool UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY); bool UpdateZOrderInner(uint32_t zOrder); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index a5dba936f6..cd17f77864 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5383,12 +5383,18 @@ void SceneSession::NotifyClientToUpdateAvoidArea() } } -bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY) +bool SceneSession::IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY) { - if (NearEqual(scaleX_, scaleX) && NearEqual(scaleY_, scaleY) && + bool nearEqual = NearEqual(scaleX_, scaleX) && NearEqual(scaleY_, scaleY) && NearEqual(pivotX_, pivotX) && NearEqual(pivotY_, pivotY) && NearEqual(clientScaleX_, scaleX) && NearEqual(clientScaleY_, scaleY) && - NearEqual(clientPivotX_, pivotX) && NearEqual(clientPivotY_, pivotY)) { + NearEqual(clientPivotX_, pivotX) && NearEqual(clientPivotY_, pivotY); + return !nearEqual; +} + +bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY) +{ + if (!IsTransformNeedChange()) { return false; } Session::SetScale(scaleX, scaleY, pivotX, pivotY); From 1f327866aaef94564972afe339c7b3a806db8f6c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 10:56:57 +0800 Subject: [PATCH 087/171] add code Signed-off-by: ZihaoWU --- .../session_manager/include/scene_session_manager.h | 4 ++-- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 2f2932acc9..caf17e061f 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1056,9 +1056,9 @@ private: int32_t pid_ = 0; int32_t uid_ = 0; }; - - std::mutex lastDrawingDataMutex_; + + std::shared_mutex lastDrawingDataMutex_; std::vector lastDrawingData_; /** diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 33b653a1da..66419f52cd 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7893,7 +7893,7 @@ int SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId) { int index = -1; { - std::unique_lock lock(lastDrawingDataMutex_); + std::shared_lock lock(lastDrawingDataMutex_); auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); if (it != lastDrawingData_.end()) { @@ -7906,7 +7906,7 @@ int SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId) void SceneSessionManager::RemoveSpecifiedDrawingData(int index) { - std::unique_lock lock(lastDrawingDataMutex_); + std::unique_lock lock(lastDrawingDataMutex_); if (index >= 0 && index < lastDrawingData_.size()) { lastDrawingData_.erase(lastDrawingData_.begin() + index); } @@ -7952,7 +7952,7 @@ void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid if (index >= 0) { RemoveSpecifiedDrawingData(index); } - std::unique_lock lock(lastDrawingDataMutex_); + std::unique_lock lock(lastDrawingDataMutex_); lastDrawingData_.push_back({ windowId, pid, uid }); } From ce243e2b86434fe5703ad00da1b32d088b2576ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E7=80=9A=E6=9E=970424?= Date: Thu, 14 Nov 2024 11:10:07 +0800 Subject: [PATCH 088/171] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=96=AD=E8=A8=80?= =?UTF-8?q?=E5=88=B0=E9=BB=84=E5=8C=BA=E5=B9=B6=E5=88=A0=E9=99=A4=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E8=B0=83=E7=94=A8session=5Flistener=5Fcontroller=5Fte?= =?UTF-8?q?st.cpp=20NotifySessionIconChanged?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 闫瀚林0424 Change-Id: I26b54d921f42144a22a70aea00075b53929542e6 --- .../test/unittest/session_listener_controller_test.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/window_scene/test/unittest/session_listener_controller_test.cpp b/window_scene/test/unittest/session_listener_controller_test.cpp index f165f1636b..59145e3ad1 100644 --- a/window_scene/test/unittest/session_listener_controller_test.cpp +++ b/window_scene/test/unittest/session_listener_controller_test.cpp @@ -384,9 +384,6 @@ HWTEST_F(SessionListenerControllerTest, NotifySessionIconChanged, Function | Sma persistentId = 1; slController->NotifySessionIconChanged(persistentId, icon); ASSERT_EQ(persistentId, 1); - - slController->NotifySessionIconChanged(persistentId, icon); - EXPECT_EQ(1, persistentId); } /** From af07358ebd987a04c3aafcd3b79ca4e308cc3ec2 Mon Sep 17 00:00:00 2001 From: hsdhebbd Date: Thu, 14 Nov 2024 11:17:46 +0800 Subject: [PATCH 089/171] =?UTF-8?q?=E6=94=AF=E6=8C=81windowManager?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E7=8B=AC=E7=AB=8B=E7=BC=96=E8=AF=91=20Signed?= =?UTF-8?q?-off-by:=20hsdhebbd=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bundle.json | 3 +-- interfaces/kits/ndk/wm/oh_window_event_filter.h | 2 +- window_scene/screen_session_manager_client/BUILD.gn | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundle.json b/bundle.json index c0b519adb7..bc484ca32d 100755 --- a/bundle.json +++ b/bundle.json @@ -72,8 +72,7 @@ "libjpeg-turbo", "libxml2", "bounds_checking_function", - "device_status", - "ets_frontend" + "device_status" ], "third_party": [ ] diff --git a/interfaces/kits/ndk/wm/oh_window_event_filter.h b/interfaces/kits/ndk/wm/oh_window_event_filter.h index 7b3f53a67d..b191f3bed7 100644 --- a/interfaces/kits/ndk/wm/oh_window_event_filter.h +++ b/interfaces/kits/ndk/wm/oh_window_event_filter.h @@ -15,7 +15,7 @@ #ifndef OH_WINDOW_EVENT_FILTER_H #define OH_WINDOW_EVENT_FILTER_H -#include "foundation/multimodalinput/input/interfaces/kits/c/input/oh_input_manager.h" +#include "oh_input_manager.h" #include "key_event.h" #include "oh_window_comm.h" #include "stdint.h" diff --git a/window_scene/screen_session_manager_client/BUILD.gn b/window_scene/screen_session_manager_client/BUILD.gn index d8fdd143a7..ac96e0e445 100644 --- a/window_scene/screen_session_manager_client/BUILD.gn +++ b/window_scene/screen_session_manager_client/BUILD.gn @@ -52,6 +52,7 @@ ohos_shared_library("screen_session_manager_client") { external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", From 181da657b7794d0150a6c531c9373a5d71698a36 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 11:31:22 +0800 Subject: [PATCH 090/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 4 +- .../src/scene_session_manager.cpp | 46 ++++++++----------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index caf17e061f..ea5b34dde0 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -692,8 +692,8 @@ private: bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawing, int32_t& pid); bool GetProcessDrawingState(uint64_t windowId, int32_t pid); void UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid); - int GetSpecifiedDrawingData(uint64_t windowId); - void RemoveSpecifiedDrawingData(int index); + bool GetSpecifiedDrawingData(uint64_t windowId, int32_t& pid, int32_t& uid); + void RemoveSpecifiedDrawingData(int windowId); /* * Window Rotate Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 66419f52cd..ca8005be20 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7862,13 +7862,10 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { - auto index = GetSpecifiedDrawingData(surfaceId); - if (index < 0) { + if (!GetSpecifiedDrawingData(surfaceId, pid, uid)) { continue; - } - pid = lastDrawingData_[index].pid_; - uid = lastDrawingData_[index].uid_; - RemoveSpecifiedDrawingData(index); + } + RemoveSpecifiedDrawingData(surfaceId); } else { winId = session->GetWindowId(); pid = session->GetCallingPid(); @@ -7889,26 +7886,26 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector lock(lastDrawingDataMutex_); - auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), - [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); - if (it != lastDrawingData_.end()) { - index = it - lastDrawingData_.begin(); - } + std::shared_lock lock(lastDrawingDataMutex_); + auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), + [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); + if (it != lastDrawingData_.end()) { + pid = it->pid_; + uid = it->uid_; + return true; } - return index; + return false; } - -void SceneSessionManager::RemoveSpecifiedDrawingData(int index) +void SceneSessionManager::RemoveSpecifiedDrawingData(int windowId) { std::unique_lock lock(lastDrawingDataMutex_); - if (index >= 0 && index < lastDrawingData_.size()) { - lastDrawingData_.erase(lastDrawingData_.begin() + index); + auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), + [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); + if (it != lastDrawingData_.end()) { + lastDrawingData_.erase(it); } } @@ -7923,8 +7920,8 @@ std::vector> SceneSessionManager::GetWindowDrawingCont bool isDrawingStateChange = false; sptr session = SelectSesssionFromMap(windowId); isDrawingStateChange = - (session == nullptr) || (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) != isWindowDrawing && - GetProcessDrawingState(windowId, pid)); + session == nullptr || (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) != isWindowDrawing && + GetProcessDrawingState(windowId, pid)); if (isDrawingStateChange) { processDrawingContentChangeInfo.emplace_back(windowId, isWindowDrawing); } @@ -7948,10 +7945,7 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) { - auto index = GetSpecifiedDrawingData(windowId); - if (index >= 0) { - RemoveSpecifiedDrawingData(index); - } + RemoveSpecifiedDrawingData(windowId); std::unique_lock lock(lastDrawingDataMutex_); lastDrawingData_.push_back({ windowId, pid, uid }); } From f05f17d203261a27549981f838d5e7daae1424fe Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 11:56:59 +0800 Subject: [PATCH 091/171] fix Signed-off-by: lpf --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index cd17f77864..687b2b19f7 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5394,7 +5394,7 @@ bool SceneSession::IsTransformNeedChange(float scaleX, float scaleY, float pivot bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY) { - if (!IsTransformNeedChange()) { + if (!IsTransformNeedChange(scaleX, scaleY, pivotX, pivotY)) { return false; } Session::SetScale(scaleX, scaleY, pivotX, pivotY); From 354890cf6a636ae326a79bfd01a6eebe00cf7015 Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 11:59:14 +0800 Subject: [PATCH 092/171] fix Signed-off-by: lpf --- window_scene/session/host/src/session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 2ec3cca9b1..438610d429 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3250,7 +3250,7 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY) pivotY_ = pivotY; } -void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) +void Session::SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) { TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, preScaleX:%{public}f, preScaleY:%{public}f, " "newScaleX:%{public}f, newScaleY:%{public}f", GetPersistentId(), clientScaleX_, clientScaleY_, scaleX, scaleY); From 06e00cdbc47b72ccd3e6eb9cdb7f1b7ede0c3f5e Mon Sep 17 00:00:00 2001 From: lpf Date: Thu, 14 Nov 2024 12:01:23 +0800 Subject: [PATCH 093/171] fix Signed-off-by: lpf --- window_scene/session/host/src/session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 438610d429..df8a87585e 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3256,8 +3256,8 @@ void Session::SetClientScale(float scaleX, float scaleY, float pivotX, float piv "newScaleX:%{public}f, newScaleY:%{public}f", GetPersistentId(), clientScaleX_, clientScaleY_, scaleX, scaleY); clientScaleX_ = scaleX; clientScaleY_ = scaleY; - clientpivotX_ = pivotX; - clientpivotY_ = pivotY; + clientPivotX_ = pivotX; + clientPivotY_ = pivotY; } float Session::GetScaleX() const From 109dfa132b8e1208c5563e73945a53dc870fef23 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 13:21:36 +0800 Subject: [PATCH 094/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index ea5b34dde0..5580e0917b 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -930,8 +930,6 @@ private: sptr property, const WindowType& type); sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); void CreateKeyboardPanelSession(sptr keyboardSession); - bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); - bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); void ClearSpecificSessionRemoteObjectMap(int32_t persistentId); WSError DestroyAndDisconnectSpecificSessionInner(const int32_t persistentId); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); From 12221ea939be76cf420af119b8023d7b0557f0b8 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 13:23:11 +0800 Subject: [PATCH 095/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 1 - 1 file changed, 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 5580e0917b..15490a6212 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1055,7 +1055,6 @@ private: int32_t uid_ = 0; }; - std::shared_mutex lastDrawingDataMutex_; std::vector lastDrawingData_; From cd3bb866c572b646352d8def798864433514144f Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Thu, 14 Nov 2024 14:30:25 +0800 Subject: [PATCH 096/171] =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index d63ea8a5cd..406241d306 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -2505,14 +2505,14 @@ napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_ } bool isForceFlag = false; if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForceFlag)) { - TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUIFirst"); + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForceFlag"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } bool isUifirstEnable = false; if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isUifirstEnable)) { - TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForceFlag"); + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUifirstEnable"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); From 19aee0826a0fda2dcda4bec1dbf9cf4c7053a5be Mon Sep 17 00:00:00 2001 From: nzy Date: Thu, 14 Nov 2024 14:36:54 +0800 Subject: [PATCH 097/171] =?UTF-8?q?session=E6=8A=9B=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nzy --- .../js_root_scene_session.cpp | 5 +- .../js_scene_session.cpp | 155 +++++++++--------- window_scene/session/host/include/session.h | 20 +-- .../session/host/src/scene_session.cpp | 6 +- window_scene/session/host/src/session.cpp | 119 +++++++++++--- .../src/scene_session_manager.cpp | 22 ++- .../unittest/scene_session_lifecycle_test.cpp | 4 +- .../unittest/scene_session_manager_test.cpp | 18 +- .../test/unittest/scene_session_test2.cpp | 4 +- .../test/unittest/scene_session_test4.cpp | 5 +- .../test/unittest/session_lifecycle_test.cpp | 11 +- window_scene/test/unittest/session_test.cpp | 9 +- window_scene/test/unittest/session_test2.cpp | 33 ++-- 13 files changed, 230 insertions(+), 181 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp index 8dc19a7011..59e7b76f5d 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp @@ -118,10 +118,9 @@ napi_value JsRootSceneSession::OnRegisterCallback(napi_env env, napi_callback_in return NapiGetUndefined(env); } - NotifyPendingSessionActivationFunc func = [this](SessionInfo& info) { + rootSceneSession_->SetPendingSessionActivationEventListener([this](SessionInfo& info) { this->PendingSessionActivation(info); - }; - rootSceneSession_->SetPendingSessionActivationEventListener(func); + }); std::shared_ptr callbackRef; napi_ref result = nullptr; napi_create_reference(env, value, 1, &result); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 855dc54a92..874c53afdd 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -452,20 +452,20 @@ JsSceneSession::~JsSceneSession() void JsSceneSession::ProcessPendingSceneSessionActivationRegister() { - NotifyPendingSessionActivationFunc func = [weakThis = wptr(this)](SessionInfo& info) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessPendingSceneSessionActivationRegister jsSceneSession is null"); - return; - } - jsSceneSession->PendingSessionActivation(info); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetPendingSessionActivationEventListener(func); + const char* const where = __func__; + session->SetPendingSessionActivationEventListener([weakThis = wptr(this), where](SessionInfo& info) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->PendingSessionActivation(info); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } @@ -1190,125 +1190,124 @@ void JsSceneSession::ProcessSessionEventRegister() void JsSceneSession::ProcessTerminateSessionRegister() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyTerminateSessionFunc func = [weakThis = wptr(this)](const SessionInfo& info) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegister jsSceneSession is null"); - return; - } - jsSceneSession->TerminateSession(info); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetTerminateSessionListener(func); + const char* const where = __func__; + session->SetTerminateSessionListener([weakThis = wptr(this), where](const SessionInfo& info) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->TerminateSession(info); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessTerminateSessionRegisterNew() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyTerminateSessionFuncNew func = [weakThis = wptr(this)]( - const SessionInfo& info, bool needStartCaller, bool isFromBroker) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegisterNew jsSceneSession is null"); - return; - } - jsSceneSession->TerminateSessionNew(info, needStartCaller, isFromBroker); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetTerminateSessionListenerNew(func); + const char* const where = __func__; + session->SetTerminateSessionListenerNew([weakThis = wptr(this), where]( + const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->TerminateSessionNew(info, needStartCaller, isFromBroker); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessTerminateSessionRegisterTotal() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyTerminateSessionFuncTotal func = [weakThis = wptr(this)]( - const SessionInfo& info, TerminateType terminateType) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegisterTotal jsSceneSession is null"); - return; - } - jsSceneSession->TerminateSessionTotal(info, terminateType); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetTerminateSessionListenerTotal(func); + const char* const where = __func__; + session->SetTerminateSessionListenerTotal([weakThis = wptr(this), where]( + const SessionInfo& info, TerminateType terminateType) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->TerminateSessionTotal(info, terminateType); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessPendingSessionToForegroundRegister() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyPendingSessionToForegroundFunc func = [weakThis = wptr(this)](const SessionInfo& info) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessPendingSessionToForegroundRegister jsSceneSession is null"); - return; - } - jsSceneSession->PendingSessionToForeground(info); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetPendingSessionToForegroundListener(func); + const char* const where = __func__; + session->SetPendingSessionToForegroundListener([weakThis = wptr(this), where](const SessionInfo& info) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->PendingSessionToForeground(info); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyPendingSessionToBackgroundForDelegatorFunc func = [weakThis = wptr(this)](const SessionInfo& info, - bool shouldBackToCaller) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession is null"); - return; - } - jsSceneSession->PendingSessionToBackgroundForDelegator(info, shouldBackToCaller); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetPendingSessionToBackgroundForDelegatorListener(func); + const char* const where = __func__; + session->SetPendingSessionToBackgroundForDelegatorListener([weakThis = wptr(this), where]( + const SessionInfo& info, bool shouldBackToCaller) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->PendingSessionToBackgroundForDelegator(info, shouldBackToCaller); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessSessionExceptionRegister() { - WLOGFD("in"); - NotifySessionExceptionFunc func = [weakThis = wptr(this)]( - const SessionInfo& info, bool needRemoveSession, bool startFail) { + TLOGD(WmsLogTag::WMS_LIFE, "in"); + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); + return; + } + const char* const where = __func__; + session->SetSessionExceptionListener([weakThis = wptr(this), where](const SessionInfo& info, + bool needRemoveSession, bool startFail) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessSessionExceptionRegister jsSceneSession is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); return; } jsSceneSession->OnSessionException(info, needRemoveSession, startFail); - }; - auto session = weakSession_.promote(); - if (session == nullptr) { - WLOGFE("session is nullptr, id:%{public}d", persistentId_); - return; - } - session->SetSessionExceptionListener(func, true); - WLOGFD("success"); + }, true); } /** @note @window.hierarchy */ @@ -1497,20 +1496,20 @@ void JsSceneSession::OnSessionEvent(uint32_t eventId, const SessionEventParam& p void JsSceneSession::ProcessBackPressedRegister() { - NotifyBackPressedFunc func = [weakThis = wptr(this)](bool needMoveToBackground) { + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); + return; + } + const char* const where = __func__; + session->SetBackPressedListenser([weakThis = wptr(this), where](bool needMoveToBackground) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessBackPressedRegister jsSceneSession is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); return; } jsSceneSession->OnBackPressed(needMoveToBackground); - }; - auto session = weakSession_.promote(); - if (session == nullptr) { - WLOGFE("session is nullptr, id:%{public}d", persistentId_); - return; - } - session->SetBackPressedListenser(func); + }); } void JsSceneSession::ProcessSystemBarPropertyChangeRegister() diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 0e2fbeba45..eda4a86843 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -255,16 +255,16 @@ public: virtual bool IsExitSplitOnBackground() const; virtual bool NeedStartingWindowExitAnimation() const { return true; } - void SetPendingSessionActivationEventListener(const NotifyPendingSessionActivationFunc& func); + void SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func); void SetChangeSessionVisibilityWithStatusBarEventListener( const NotifyChangeSessionVisibilityWithStatusBarFunc& func); - void SetTerminateSessionListener(const NotifyTerminateSessionFunc& func); + void SetTerminateSessionListener(NotifyTerminateSessionFunc&& func); WSError TerminateSessionNew(const sptr info, bool needStartCaller, bool isFromBroker); - void SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func); - void SetSessionExceptionListener(const NotifySessionExceptionFunc& func, bool fromJsScene); + void SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func); + void SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene); void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func); WSError TerminateSessionTotal(const sptr info, TerminateType terminateType); - void SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func); + void SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func); WSError Clear(bool needStartCaller = false); WSError SetSessionLabel(const std::string& label); void SetUpdateSessionLabelListener(const NofitySessionLabelUpdatedFunc& func); @@ -283,7 +283,7 @@ public: void SetSystemConfig(const SystemSessionConfig& systemConfig); void SetSnapshotScale(const float snapshotScale); - void SetBackPressedListenser(const NotifyBackPressedFunc& func); + void SetBackPressedListenser(NotifyBackPressedFunc&& func); virtual WSError ProcessBackEvent(); // send back event to session_stage sptr GetScenePersistence() const; @@ -297,9 +297,9 @@ public: WSError NotifyDestroy(); WSError NotifyCloseExistPipWindow(); - void SetPendingSessionToForegroundListener(const NotifyPendingSessionToForegroundFunc& func); + void SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func); WSError PendingSessionToForeground(); - void SetPendingSessionToBackgroundForDelegatorListener(const NotifyPendingSessionToBackgroundForDelegatorFunc& + void SetPendingSessionToBackgroundForDelegatorListener(NotifyPendingSessionToBackgroundForDelegatorFunc&& func); WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); @@ -638,8 +638,8 @@ protected: NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; NofitySessionLabelUpdatedFunc updateSessionLabelFunc_; NofitySessionIconUpdatedFunc updateSessionIconFunc_; - std::shared_ptr sessionExceptionFunc_; - std::shared_ptr jsSceneSessionExceptionFunc_; + NotifySessionExceptionFunc sessionExceptionFunc_; + NotifySessionExceptionFunc jsSceneSessionExceptionFunc_; NotifySessionSnapshotFunc notifySessionSnapshotFunc_; NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 4f38765606..d76c71ee36 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4335,12 +4335,10 @@ WSError SceneSession::NotifySessionExceptionInner(const sptr session->sessionInfo_.errorReason = abilitySessionInfo->errorReason; } if (session->sessionExceptionFunc_) { - auto exceptionFunc = *(session->sessionExceptionFunc_); - exceptionFunc(info, needRemoveSession, false); + session->sessionExceptionFunc_(info, needRemoveSession, false); } if (session->jsSceneSessionExceptionFunc_) { - auto exceptionFunc = *(session->jsSceneSessionExceptionFunc_); - exceptionFunc(info, needRemoveSession, startFail); + session->jsSceneSessionExceptionFunc_(info, needRemoveSession, startFail); } return WSError::WS_OK; }; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 51f7e97dd4..8180cd5411 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1469,19 +1469,46 @@ void Session::SetChangeSessionVisibilityWithStatusBarEventListener( changeSessionVisibilityWithStatusBarFunc_ = func; } -void Session::SetPendingSessionActivationEventListener(const NotifyPendingSessionActivationFunc& func) +void Session::SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func) { - pendingSessionActivationFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->pendingSessionActivationFunc_ = func; + }; + PostTask(task, where); } -void Session::SetBackPressedListenser(const NotifyBackPressedFunc& func) +void Session::SetBackPressedListenser(NotifyBackPressedFunc&& func) { - backPressedFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->backPressedFunc_ = func; + }; + PostTask(task, where); } -void Session::SetTerminateSessionListener(const NotifyTerminateSessionFunc& func) +void Session::SetTerminateSessionListener(NotifyTerminateSessionFunc&& func) { - terminateSessionFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->terminateSessionFunc_ = func; + }; + PostTask(task, where); } void Session::RemoveLifeCycleTask(const LifeCycleTaskType& taskType) @@ -1585,9 +1612,18 @@ WSError Session::TerminateSessionNew( return WSError::WS_OK; } -void Session::SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func) +void Session::SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func) { - terminateSessionFuncNew_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->terminateSessionFuncNew_ = func; + }; + PostTask(task, where); } WSError Session::TerminateSessionTotal(const sptr abilitySessionInfo, TerminateType terminateType) @@ -1617,9 +1653,18 @@ WSError Session::TerminateSessionTotal(const sptr abilitySes return WSError::WS_OK; } -void Session::SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func) +void Session::SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func) { - terminateSessionFuncTotal_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->terminateSessionFuncTotal_ = func; + }; + PostTask(task, where); } WSError Session::SetSessionLabel(const std::string& label) @@ -1675,18 +1720,22 @@ WSError Session::Clear(bool needStartCaller) return WSError::WS_OK; } -void Session::SetSessionExceptionListener(const NotifySessionExceptionFunc& func, bool fromJsScene) +void Session::SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene) { - if (func == nullptr) { - WLOGFE("func is nullptr"); - return; - } - std::shared_ptr funcSptr = std::make_shared(func); - if (fromJsScene) { - jsSceneSessionExceptionFunc_ = funcSptr; - } else { - sessionExceptionFunc_ = funcSptr; - } + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where, fromJsScene] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + if (fromJsScene) { + session->jsSceneSessionExceptionFunc_ = func; + } else { + session->sessionExceptionFunc_ = func; + } + }; + PostTask(task, where); } void Session::SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func) @@ -1698,9 +1747,18 @@ void Session::SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func) notifySessionSnapshotFunc_ = func; } -void Session::SetPendingSessionToForegroundListener(const NotifyPendingSessionToForegroundFunc& func) +void Session::SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func) { - pendingSessionToForegroundFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->pendingSessionToForegroundFunc_ = func; + }; + PostTask(task, where); } WSError Session::PendingSessionToForeground() @@ -1709,14 +1767,23 @@ WSError Session::PendingSessionToForeground() SessionInfo info = GetSessionInfo(); if (pendingSessionActivationFunc_) { pendingSessionActivationFunc_(info); - } + }; return WSError::WS_OK; } void Session::SetPendingSessionToBackgroundForDelegatorListener( - const NotifyPendingSessionToBackgroundForDelegatorFunc& func) + NotifyPendingSessionToBackgroundForDelegatorFunc&& func) { - pendingSessionToBackgroundForDelegatorFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->pendingSessionToBackgroundForDelegatorFunc_ = func; + }; + PostTask(task, where); } WSError Session::PendingSessionToBackgroundForDelegator(bool shouldBackToCaller) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 560655b29e..07aa481146 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4079,35 +4079,33 @@ static bool IsValidDigitString(const std::string& windowIdStr) void SceneSessionManager::RegisterSessionExceptionFunc(const sptr& sceneSession) { if (sceneSession == nullptr) { - WLOGFE("session is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } - NotifySessionExceptionFunc sessionExceptionFunc = [this]( + const char* const where = __func__; + sceneSession->SetSessionExceptionListener([this, where]( const SessionInfo& info, bool needRemoveSession, bool startFail) { - auto task = [this, info] { + auto task = [this, info, where] { auto session = GetSceneSession(info.persistentId_); if (session == nullptr) { - WLOGW("NotifySessionExceptionFunc, Not found session, id: %{public}d", - info.persistentId_); + TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s Not found session, id:%{public}d", where, info.persistentId_); return; } if (session->GetSessionInfo().isSystem_) { - WLOGW("NotifySessionExceptionFunc, id: %{public}d is system", - session->GetPersistentId()); + TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s id: %{public}d is system", where, session->GetPersistentId()); return; } - WLOGI("NotifySessionExceptionFunc, errorCode: %{public}d, id: %{public}d", - info.errorCode, info.persistentId_); + TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s errorCode: %{public}d, id: %{public}d", + where, info.errorCode, info.persistentId_); if (info.errorCode == static_cast(AAFwk::ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT) || info.errorCode == static_cast(AAFwk::ErrorLifecycleState::ABILITY_STATE_FOREGROUND_TIMEOUT)) { - WLOGD("NotifySessionClosed when ability load timeout " + TLOGND(WmsLogTag::WMS_LIFE, "NotifySessionClosed when ability load timeout " "or foreground timeout, id: %{public}d", info.persistentId_); listenerController_->NotifySessionClosed(info.persistentId_); } }; taskScheduler_->PostVoidSyncTask(task, "sessionException"); - }; - sceneSession->SetSessionExceptionListener(sessionExceptionFunc, false); + }, false); TLOGD(WmsLogTag::WMS_LIFE, "success, id: %{public}d", sceneSession->GetPersistentId()); } diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 80d142232b..f4ba49a12f 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -1195,9 +1195,9 @@ HWTEST_F(SceneSessionLifecycleTest, NotifySessionExceptionInner, Function | Smal res = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, needRemoveSession, false); ASSERT_EQ(res, WSError::WS_OK); - sceneSession->sessionExceptionFunc_ = std::make_shared(); + sceneSession->sessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; ASSERT_NE(nullptr, sceneSession->sessionExceptionFunc_); - sceneSession->jsSceneSessionExceptionFunc_ = std::make_shared(); + sceneSession->jsSceneSessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; ASSERT_NE(nullptr, sceneSession->jsSceneSessionExceptionFunc_); res = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, needRemoveSession, false); ASSERT_EQ(res, WSError::WS_OK); diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index f510bf462a..ce399aaab5 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -504,10 +504,10 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions, Function | Small sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetCollaboratorType(CollaboratorType::DEFAULT_TYPE); - NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { ssm_->sceneSessionMap_.erase(info.persistentId_); - }; - sceneSession->SetTerminateSessionListenerNew(callback); + }); + usleep(WAIT_SYNC_IN_NS); ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], sceneSession); @@ -530,10 +530,10 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions02, Function | Sma sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetCollaboratorType(CollaboratorType::RESERVE_TYPE); - NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { ssm_->sceneSessionMap_.erase(info.persistentId_); - }; - sceneSession->SetTerminateSessionListenerNew(callback); + }); + usleep(WAIT_SYNC_IN_NS); ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr); @@ -556,10 +556,10 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions03, Function | Sma sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetCollaboratorType(CollaboratorType::OTHERS_TYPE); - NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { ssm_->sceneSessionMap_.erase(info.persistentId_); - }; - sceneSession->SetTerminateSessionListenerNew(callback); + }); + usleep(WAIT_SYNC_IN_NS); ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr); diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index c3f5c4f5e2..1f4217d374 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -1742,8 +1742,8 @@ HWTEST_F(SceneSessionTest2, OnMoveDragCallback02, Function | SmallTest | Level2) sceneSession->TerminateSession(abilitySessionInfo); bool needRemoveSession = true; - session.sessionExceptionFunc_ = std::make_shared(); - session.jsSceneSessionExceptionFunc_ = std::make_shared(); + session.sessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; + session.jsSceneSessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; sceneSession->NotifySessionException(abilitySessionInfo, needRemoveSession); sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 0bccc770ac..423a622f0f 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -1147,10 +1147,7 @@ HWTEST_F(SceneSessionTest4, TerminateSession01, Function | SmallTest | Level2) ASSERT_EQ(WSError::WS_OK, sceneSession->TerminateSession(abilitySessionInfo)); sceneSession->isTerminating_ = false; - NotifyTerminateSessionFunc func = [sceneSession](const SessionInfo& info) { - return; - }; - sceneSession->SetTerminateSessionListener(func); + sceneSession->SetTerminateSessionListener([sceneSession](const SessionInfo& info) {}); ASSERT_EQ(WSError::WS_OK, sceneSession->TerminateSession(abilitySessionInfo)); } diff --git a/window_scene/test/unittest/session_lifecycle_test.cpp b/window_scene/test/unittest/session_lifecycle_test.cpp index 2f94437742..1cb9a622c2 100644 --- a/window_scene/test/unittest/session_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_lifecycle_test.cpp @@ -362,15 +362,11 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionNew01, Function | SmallTest */ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionNew02, Function | SmallTest | Level2) { - NotifyTerminateSessionFuncNew callback = - [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) - { - }; - bool needStartCaller = true; bool isFromBroker = true; sptr info = new (std::nothrow)AAFwk::SessionInfo(); - session_->SetTerminateSessionListenerNew(callback); + session_->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {}); + usleep(WAIT_SYNC_IN_NS); auto result = session_->TerminateSessionNew(info, needStartCaller, isFromBroker); EXPECT_EQ(result, WSError::WS_OK); } @@ -571,8 +567,7 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionTotal03, Function | SmallTe ASSERT_NE(session_, nullptr); sptr abilitySessionInfo = new AAFwk::SessionInfo(); session_->isTerminating_ = false; - NotifyTerminateSessionFuncTotal func = nullptr; - session_->SetTerminateSessionListenerTotal(func); + session_->SetTerminateSessionListenerTotal(nullptr); ASSERT_EQ(WSError::WS_OK, session_->TerminateSessionTotal(abilitySessionInfo, TerminateType::CLOSE_AND_KEEP_MULTITASK)); } diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 35d5a6d171..dbf81f38c7 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -1210,8 +1210,7 @@ HWTEST_F(WindowSessionTest, SetTerminateSessionListener, Function | SmallTest | { ASSERT_NE(session_, nullptr); session_->state_ = SessionState::STATE_DISCONNECT; - NotifyTerminateSessionFunc func = nullptr; - session_->SetTerminateSessionListener(func); + session_->SetTerminateSessionListener(nullptr); ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } @@ -1225,8 +1224,7 @@ HWTEST_F(WindowSessionTest, SetTerminateSessionListenerTotal, Function | SmallTe { ASSERT_NE(session_, nullptr); session_->state_ = SessionState::STATE_DISCONNECT; - NotifyTerminateSessionFuncTotal func = nullptr; - session_->SetTerminateSessionListenerTotal(func); + session_->SetTerminateSessionListenerTotal(nullptr); ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } @@ -1269,8 +1267,7 @@ HWTEST_F(WindowSessionTest, SetPendingSessionToForegroundListener, Function | Sm { ASSERT_NE(session_, nullptr); session_->state_ = SessionState::STATE_DISCONNECT; - NotifyPendingSessionToForegroundFunc func = nullptr; - session_->SetPendingSessionToForegroundListener(func); + session_->SetPendingSessionToForegroundListener(nullptr); ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index 6227b57d11..6a64c5a5cb 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -2019,16 +2019,15 @@ HWTEST_F(WindowSessionTest2, UpdateSizeChangeReason, Function | SmallTest | Leve HWTEST_F(WindowSessionTest2, SetPendingSessionActivationEventListener, Function | SmallTest | Level2) { int resultValue = 0; - NotifyPendingSessionActivationFunc callback = [&resultValue](const SessionInfo& info) { - resultValue = 1; - }; - sptr info = new (std::nothrow)AAFwk::SessionInfo(); - session_->SetPendingSessionActivationEventListener(callback); - NotifyTerminateSessionFunc callback1 = [&resultValue](const SessionInfo& info) { + session_->SetPendingSessionActivationEventListener([&resultValue](const SessionInfo& info) { + resultValue = 1; + }); + usleep(WAIT_SYNC_IN_NS); + session_->SetTerminateSessionListener([&resultValue](const SessionInfo& info) { resultValue = 2; - }; - session_->SetTerminateSessionListener(callback1); + }); + usleep(WAIT_SYNC_IN_NS); LifeCycleTaskType taskType = LifeCycleTaskType{0}; session_->RemoveLifeCycleTask(taskType); ASSERT_EQ(resultValue, 0); @@ -2070,10 +2069,8 @@ HWTEST_F(WindowSessionTest2, SetSessionIcon, Function | SmallTest | Level2) HWTEST_F(WindowSessionTest2, SetSessionExceptionListener, Function | SmallTest | Level2) { session_->SetSessionExceptionListener(nullptr, true); - - NotifySessionExceptionFunc func = [](const SessionInfo& info, bool needRemoveSession, bool startFail) {}; - session_->SetSessionExceptionListener(func, true); - + session_->SetSessionExceptionListener([](const SessionInfo& info, bool removeSession, bool startFail) {}, true); + usleep(WAIT_SYNC_IN_NS); ASSERT_NE(nullptr, session_->jsSceneSessionExceptionFunc_); } @@ -2198,11 +2195,13 @@ HWTEST_F(WindowSessionTest2, SetOffset, Function | SmallTest | Level2) HWTEST_F(WindowSessionTest2, SetBackPressedListenser, Function | SmallTest | Level2) { ASSERT_NE(session_, nullptr); - WLOGFI("SetBackPressedListenser begin!"); - - session_->SetBackPressedListenser(session_->backPressedFunc_); - - WLOGFI("SetBackPressedListenser end!"); + int32_t result = 0; + session_->SetBackPressedListenser([&result](const bool needMoveToBackground) { + result = 1; + }); + usleep(WAIT_SYNC_IN_NS); + session_->backPressedFunc_(true); + ASSERT_EQ(result, 1); } /** From d35465acabda8749a5b76994393d71e9fb3c506c Mon Sep 17 00:00:00 2001 From: h00833914 Date: Thu, 14 Nov 2024 06:43:10 +0000 Subject: [PATCH 098/171] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: h00833914 Change-Id: I81d976ca337b8ecb68a033e0dc54769c21706795 --- .../wms/window_display_zoom_test.cpp | 18 ------- .../wms/window_input_method_test.cpp | 48 ------------------- 2 files changed, 66 deletions(-) diff --git a/test/systemtest/wms/window_display_zoom_test.cpp b/test/systemtest/wms/window_display_zoom_test.cpp index 6fc5cf4608..869cb13bbb 100644 --- a/test/systemtest/wms/window_display_zoom_test.cpp +++ b/test/systemtest/wms/window_display_zoom_test.cpp @@ -264,24 +264,6 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, Function | MediumTest | Level3) window->Destroy(); } -/** - * @tc.name: DisplayZoom06 - * @tc.desc: test speical window type - * @tc.type: FUNC - * @tc.require: issueI5NGWL - */ -HWTEST_F(WindowDisplayZoomTest, DisplayZoom06, Function | MediumTest | Level3) -{ - WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 2); - sleep(1); - windowInfo_.name = "DisplayZoom06"; - windowInfo_.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT; - sptr window = Utils::CreateTestWindow(windowInfo_); - ASSERT_NE(nullptr, window); - sleep(1); - WindowAccessibilityController::GetInstance().OffWindowZoom(); - window->Destroy(); -} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_input_method_test.cpp b/test/systemtest/wms/window_input_method_test.cpp index 7273f979c9..53af68245a 100644 --- a/test/systemtest/wms/window_input_method_test.cpp +++ b/test/systemtest/wms/window_input_method_test.cpp @@ -63,55 +63,7 @@ void WindowInputMethodTest::TearDown() } namespace { -/** - * @tc.name: InputMethodWindow01 - * @tc.desc: One InputMethod Floating Window - * @tc.type: FUNC - */ -HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Level3) -{ - inputMethodWindowInfo_.name = "input_method.1"; - const sptr& window = Utils::CreateTestWindow(inputMethodWindowInfo_); - ASSERT_NE(window, nullptr); - ASSERT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, window->GetType()); - window->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_BOTTOM, 0); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - window->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_FLOAT, 0); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); -} -/** - * @tc.name: InputMethodWindow02 - * @tc.desc: One InputMethod Floating Window & One KeyGuard Window - * @tc.type: FUNC - */ -HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3) -{ - inputMethodWindowInfo_.name = "input_method.2"; - const sptr& inputMethodWindow = Utils::CreateTestWindow(inputMethodWindowInfo_); - ASSERT_NE(inputMethodWindow, nullptr); - inputMethodWindow->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_BOTTOM, 0); - inputMethodWindow->Show(); - if (Utils::customAppRect_.width_ == inputMethodWindow->GetRect().width_) { - ASSERT_EQ(inputMethodWindow->GetRect().width_, Utils::customAppRect_.width_); - } - - if (inputMethodWindow->GetRect().height_ == Utils::customAppRect_.height_) { - ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_); - } - - inputMethodWindow->Hide(); - inputMethodWindow->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_FLOAT, 0); - inputMethodWindow->Show(); - - if (Utils::customAppRect_.width_ == inputMethodWindow->GetRect().width_) { - ASSERT_EQ(inputMethodWindow->GetRect().width_, Utils::customAppRect_.width_); - ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_); - } - inputMethodWindow->Hide(); -} } // namespace } // namespace Rosen } // namespace OHOS From 55b7dd73ed0fd7292e03d49b446c2641f637dfb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E7=80=9A=E6=9E=970424?= Date: Thu, 14 Nov 2024 15:39:01 +0800 Subject: [PATCH 099/171] update TDD ut case window_stub_test.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 闫瀚林0424 Change-Id: Idceb788ab3718c95bf03c6234eac44075fab5595 --- wm/test/unittest/window_stub_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/test/unittest/window_stub_test.cpp b/wm/test/unittest/window_stub_test.cpp index 401cbe85c5..5c122e3d38 100644 --- a/wm/test/unittest/window_stub_test.cpp +++ b/wm/test/unittest/window_stub_test.cpp @@ -457,6 +457,7 @@ HWTEST_F(WindowStubTest, OnRemoteRequest18, Function | SmallTest | Level2) MessageOption option(MessageOption::TF_ASYNC); data.WriteInterfaceToken(WindowStub::GetDescriptor()); + data.WriteUint32(1); uint32_t code = static_cast(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE); int res = windowStub_->OnRemoteRequest(code, data, reply, option); From 501fbd84271a88731abc63aaa30d1bb20fb108c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Thu, 14 Nov 2024 15:48:29 +0800 Subject: [PATCH 100/171] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- .../src/scene_session_manager.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 105974427f..a1b98b5f3c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2444,10 +2444,10 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co } auto pid = IPCSkeleton::GetCallingRealPid(); auto parentPid = extensionParentSession->GetCallingPid(); - bool checkIsPassed = false; + WSError result = WSError::WS_ERROR_INVALID_WINDOW; if (pid == parentPid) { TLOGI(WmsLogTag::WMS_UIEXT, "pid == parentPid"); - checkIsPassed = true; + result = WSError::WS_OK; } AAFwk::UIExtensionSessionInfo info; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info); @@ -2455,12 +2455,12 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co int32_t parentId = static_cast(info.hostWindowId); if (parentId == property->GetParentPersistentId()) { TLOGI(WmsLogTag::WMS_UIEXT, "parentId == property->GetParentPersistentId(parentId:%{public}d)", parentId); - checkIsPassed = true; + result = WSError::WS_OK; } } if (SessionPermission::IsSystemCalling()) { TLOGI(WmsLogTag::WMS_UIEXT, "is system app"); - checkIsPassed = true; + result = WSError::WS_OK; } if (property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); @@ -2472,18 +2472,18 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co hostInfo.elementName_.GetBundleName().c_str()); return WSError::WS_ERROR_INVALID_WINDOW; } - checkIsPassed = true; + result = WSError::WS_OK; } - if (checkIsPassed) { + if (result == WSError::WS_OK) { sptr parentProperty = extensionParentSession->GetSessionProperty(); if (sessionStage && parentProperty && property->GetIsUIExtFirstSubWindow()) { sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); property->SetDisplayId(parentProperty->GetDisplayId()); } - return WSError::WS_OK; + } else { + TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: persistentId %{public}d", property->GetPersistentId()); } - TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: persistentId %{public}d", property->GetPersistentId()); - return WSError::WS_ERROR_INVALID_WINDOW; + return result; } void SceneSessionManager::ClosePipWindowIfExist(WindowType type) From bda9ad4db68bc9dba2f0f3ba85619eac783603b6 Mon Sep 17 00:00:00 2001 From: hsc Date: Thu, 14 Nov 2024 16:13:29 +0800 Subject: [PATCH 101/171] add lock Signed-off-by: hsc --- utils/include/vsync_station.h | 6 +++--- utils/src/vsync_station.cpp | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/utils/include/vsync_station.h b/utils/include/vsync_station.h index c1b570dda3..cd0ae63e09 100644 --- a/utils/include/vsync_station.h +++ b/utils/include/vsync_station.h @@ -58,6 +58,7 @@ private: std::shared_ptr GetOrCreateVsyncReceiver(); std::shared_ptr GetOrCreateVsyncReceiverLocked(); std::shared_ptr GetFrameRateLinker(); + std::shared_ptr GetFrameRateLinkerLocked(); void VsyncCallbackInner(int64_t nanoTimestamp, int64_t frameCount); void OnVsyncTimeOut(); @@ -65,9 +66,6 @@ private: std::shared_ptr vsyncHandler_ = nullptr; std::string vsyncTimeoutTaskName_; - std::shared_ptr lastFrameRateRange_ = nullptr; - int32_t lastAnimatorExpectedFrameRate_ = 0; - std::mutex mutex_; bool isFirstVsyncRequest_ = true; bool isFirstVsyncBack_ = true; @@ -77,6 +75,8 @@ private: std::shared_ptr frameRateLinker_ = nullptr; using Callbacks = std::unordered_set>; Callbacks vsyncCallbacks_; + std::shared_ptr lastFrameRateRange_ = nullptr; + int32_t lastAnimatorExpectedFrameRate_ = 0; // Above guarded by mutex_ std::atomic requestVsyncTimes_ {0}; diff --git a/utils/src/vsync_station.cpp b/utils/src/vsync_station.cpp index 2e343bb5fe..9a08eaba12 100644 --- a/utils/src/vsync_station.cpp +++ b/utils/src/vsync_station.cpp @@ -204,6 +204,11 @@ void VsyncStation::OnVsyncTimeOut() std::shared_ptr VsyncStation::GetFrameRateLinker() { std::lock_guard lock(mutex_); + return GetFrameRateLinkerLocked(); +} + +std::shared_ptr VsyncStation::GetFrameRateLinkerLocked() +{ if (destroyed_) { TLOGW(WmsLogTag::WMS_MAIN, "VsyncStation has been destroyed"); return nullptr; @@ -221,7 +226,8 @@ FrameRateLinkerId VsyncStation::GetFrameRateLinkerId() void VsyncStation::FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType) { - if (auto frameRateLinker = GetFrameRateLinker()) { + std::lock_guard lock(mutex_); + if (auto frameRateLinker = GetFrameRateLinkerLocked()) { if (lastFrameRateRange_ == nullptr) { lastFrameRateRange_ = std::make_shared(0, RANGE_MAX_REFRESHRATE, rate, rateType); } else { @@ -237,7 +243,8 @@ void VsyncStation::FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRa void VsyncStation::SetFrameRateLinkerEnable(bool enabled) { - if (auto frameRateLinker = GetFrameRateLinker()) { + std::lock_guard lock(mutex_); + if (auto frameRateLinker = GetFrameRateLinkerLocked()) { if (!enabled) { // clear frameRate vote FrameRateRange range = {0, RANGE_MAX_REFRESHRATE, 0}; From 283ba98a5af224eb2c29ade242c496acf47d498d Mon Sep 17 00:00:00 2001 From: Krishhu Date: Thu, 14 Nov 2024 16:26:43 +0800 Subject: [PATCH 102/171] =?UTF-8?q?hidumper=20=E5=88=87=E5=B1=8F=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E5=8F=97=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1=E5=BC=8F?= =?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: Krishhu --- .../src/screen_session_dumper.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/window_scene/screen_session_manager/src/screen_session_dumper.cpp b/window_scene/screen_session_manager/src/screen_session_dumper.cpp index 735532838a..9c953566ba 100644 --- a/window_scene/screen_session_manager/src/screen_session_dumper.cpp +++ b/window_scene/screen_session_manager/src/screen_session_dumper.cpp @@ -152,6 +152,17 @@ void ScreenSessionDumper::ExcuteDumpCmd() void ScreenSessionDumper::ExcuteInjectCmd() { + bool isDeveloperMode = system::GetBoolParameter("const.security.developermode.state", false); + if (isDeveloperMode) { + if (params_.size() == 1 && IsValidDisplayModeCommand(params_[0])) { + int errCode = SetFoldDisplayMode(); + if (errCode != 0) { + ShowIllegalArgsInfo(); + } + return; + } + } + bool isDebugMode = system::GetBoolParameter("dms.hidumper.supportdebug", false); if (!isDebugMode) { TLOGI(WmsLogTag::DMS, "Can't use DMS hidumper inject methods."); @@ -170,12 +181,6 @@ void ScreenSessionDumper::ExcuteInjectCmd() } else if (params_[0].find(ARG_PUBLISH_CAST_EVENT) != std::string::npos) { MockSendCastPublishEvent(params_[0]); return; - } else if (params_.size() == 1 && IsValidDisplayModeCommand(params_[0])) { - int errCode = SetFoldDisplayMode(); - if (errCode != 0) { - ShowIllegalArgsInfo(); - } - return; } else if (params_.size() == 1 && (params_[0] == ARG_LOCK_FOLD_DISPLAY_STATUS || params_[0] == ARG_UNLOCK_FOLD_DISPLAY_STATUS)) { int errCode = SetFoldStatusLocked(); From 6897dcda1d92f8682056d032ab03810783f3e9dd Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 17:08:07 +0800 Subject: [PATCH 103/171] add code Signed-off-by: ZihaoWU --- .../unittest/scene_session_manager_test4.cpp | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 9923523181..2e232d60d1 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -772,7 +772,6 @@ HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest ASSERT_NE(nullptr, ssm_); uint64_t windowId = 10; int32_t pid = 1; - bool currentDrawingContentState = true; SessionInfo info; info.abilityName_ = "SetBrightness"; sptr sceneSession01 = nullptr; @@ -793,7 +792,7 @@ HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest sceneSession03->SetCallingPid(pid); sceneSession03->surfaceNode_ = nullptr; sceneSession04->SetCallingPid(6); - auto result = ssm_->GetProcessDrawingState(windowId, pid, currentDrawingContentState); + auto result = ssm_->GetProcessDrawingState(windowId, pid); EXPECT_EQ(result, true); } @@ -807,7 +806,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes ASSERT_NE(nullptr, ssm_); uint64_t surfaceId = 0; int32_t pid = 10; - bool result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true); + bool result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid); EXPECT_EQ(result, false); SessionInfo info; @@ -820,7 +819,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes ASSERT_NE(sceneSession01->surfaceNode_, nullptr); sceneSession01->surfaceNode_->id_ = 10; surfaceId = 10; - result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true); + result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid); EXPECT_EQ(result, false); } @@ -829,7 +828,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes * @tc.desc: GetWindowDrawingContentChangeInfo * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | SmallTest | Level3) +HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo01, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); SessionInfo info; @@ -858,6 +857,28 @@ HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | EXPECT_NE(result, currDrawingContentData); } +/** + * @tc.name: GetWindowDrawingContentChangeInfo + * @tc.desc: GetWindowDrawingContentChangeInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo02, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + SessionInfo info; + info.abilityName_ = "GetWindowDrawingContentChangeInfo02"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr)); + + std::vector> currDrawingContentData; + currDrawingContentData.push_back(std::make_pair(0, false)); + currDrawingContentData.push_back(std::make_pair(1, true)); + + auto result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData); + EXPECT_EQ(result, currDrawingContentData); +} + /** * @tc.name: DealwithDrawingContentChange * @tc.desc: DealwithDrawingContentChange From dc4767dacba3d4ae60c6d2b5097c4017749142db Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 17:09:43 +0800 Subject: [PATCH 104/171] add code Signed-off-by: ZihaoWU --- .../test/unittest/scene_session_manager_test4.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 2e232d60d1..fb165bfd17 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -824,8 +824,8 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes } /** - * @tc.name: GetWindowDrawingContentChangeInfo - * @tc.desc: GetWindowDrawingContentChangeInfo + * @tc.name: GetWindowDrawingContentChangeInfo01 + * @tc.desc: GetWindowDrawingContentChangeInfo01 * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo01, Function | SmallTest | Level3) @@ -858,8 +858,8 @@ HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo01, Function } /** - * @tc.name: GetWindowDrawingContentChangeInfo - * @tc.desc: GetWindowDrawingContentChangeInfo + * @tc.name: GetWindowDrawingContentChangeInfo02 + * @tc.desc: GetWindowDrawingContentChangeInfo02 * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo02, Function | SmallTest | Level3) From f04c99b829572bddf524ab0adc7668f52fec2a4c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 17:11:00 +0800 Subject: [PATCH 105/171] add code Signed-off-by: ZihaoWU --- window_scene/test/unittest/scene_session_manager_test4.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index fb165bfd17..d81e30436e 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -824,11 +824,11 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes } /** - * @tc.name: GetWindowDrawingContentChangeInfo01 - * @tc.desc: GetWindowDrawingContentChangeInfo01 + * @tc.name: GetWindowDrawingContentChangeInfo + * @tc.desc: GetWindowDrawingContentChangeInfo * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo01, Function | SmallTest | Level3) +HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); SessionInfo info; From 809470317085c444a1826dd8cb3d6094e1f4c98b Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Thu, 14 Nov 2024 17:24:00 +0800 Subject: [PATCH 106/171] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- .../js_scene_session.cpp | 19 +++++++++---------- .../session/host/include/scene_session.h | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 406241d306..47e868badc 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -2495,24 +2495,24 @@ napi_value JsSceneSession::OnSetSystemSceneForceUIFirst(napi_env env, napi_callb napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info) { size_t argc = ARG_COUNT_4; - napi_value argv[ARG_COUNT_4] = {nullptr}; + napi_value argv[ARG_COUNT_4] = { nullptr }; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < ARGC_TWO) { // 1: params num + if (argc < ARGC_TWO) { TLOGE(WmsLogTag::DEFAULT, "[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); } - bool isForceFlag = false; - if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForceFlag)) { - TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForceFlag"); + bool isForced = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForced)) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForced"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - bool isUifirstEnable = false; - if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isUifirstEnable)) { - TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUifirstEnable"); + bool isUIFirstEnabled = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], isUIFirstEnabled)) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUIFirstEnabled"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); @@ -2522,8 +2522,7 @@ napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_ TLOGE(WmsLogTag::DEFAULT, "[NAPI]session is nullptr, id:%{public}d", persistentId_); return NapiGetUndefined(env); } - session->MarkSystemSceneUIFirst(isForceFlag, isUifirstEnable); - TLOGD(WmsLogTag::DEFAULT, "[NAPI] end"); + session->MarkSystemSceneUIFirst(isForced, isUIFirstEnabled); return NapiGetUndefined(env); } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 37784e3bd6..44087efeb3 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -261,7 +261,7 @@ public: void SetSnapshotSkip(bool isSkip); void SetSystemSceneOcclusionAlpha(double alpha); void SetSystemSceneForceUIFirst(bool forceUIFirst); - void MarkSystemSceneUIFirst(bool isForceFlag, bool isUifirstEnable); + void MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled); void SetRequestedOrientation(Orientation orientation); WSError SetDefaultRequestedOrientation(Orientation orientation); void SetWindowAnimationFlag(bool needDefaultAnimationFlag); From d703555e4aff71375ac3f64e2697caa485136bf6 Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Thu, 14 Nov 2024 17:30:15 +0800 Subject: [PATCH 107/171] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- window_scene/session/host/src/scene_session.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 07a9b4f9da..aefec04814 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3145,7 +3145,7 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) } } -void SceneSession::MarkSystemSceneUIFirst(bool isForceFlag, bool isUifirstEnable) +void SceneSession::MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::MarkSystemSceneUIFirst"); auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); @@ -3154,13 +3154,13 @@ void SceneSession::MarkSystemSceneUIFirst(bool isForceFlag, bool isUifirstEnable return; } if (leashWinSurfaceNode != nullptr) { - TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForceFlag=%{public}d. isUifirstEnable=%{public}d", - leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isForceFlag, isUifirstEnable); - leashWinSurfaceNode->MarkUifirstNode(isForceFlag, isUifirstEnable); + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForced=%{public}d. isUIFirstEnabled=%{public}d", + leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isForced, isUIFirstEnabled); + leashWinSurfaceNode->MarkUifirstNode(isForced, isUIFirstEnabled); } else { - TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForceFlag=%{public}d. isUifirstEnable=%{public}d", - surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isForceFlag, isUifirstEnable); - surfaceNode_->MarkUifirstNode(isForceFlag, isUifirstEnable); + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForced=%{public}d. isUIFirstEnabled=%{public}d", + surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isForced, isUIFirstEnabled); + surfaceNode_->MarkUifirstNode(isForced, isUIFirstEnabled); } } From f12121d70d90b35bf97719f31941ef8bfb8040c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Wed, 13 Nov 2024 10:18:58 +0000 Subject: [PATCH 108/171] =?UTF-8?q?=E4=BF=AE=E5=A4=8DPAD=20=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E4=B8=8D=E6=94=AF=E6=8C=81=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E6=A0=8F=E4=B8=89=E9=94=AE=E6=98=BE=E9=9A=90=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 Signed-off-by: wanxiaoguo --- wm/include/window_session_impl.h | 2 +- wm/src/window_session_impl.cpp | 8 ++++---- wm/test/unittest/window_scene_session_impl_test2.cpp | 9 ++++++--- wm/test/unittest/window_session_impl_test2.cpp | 10 +++++----- wm/test/unittest/window_session_impl_test4.cpp | 12 ++++++++---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index a316cbce09..26415e5066 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -488,7 +488,7 @@ private: void NotifyRotationAnimationEnd(); void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener); bool IsUserOrientation(Orientation orientation) const; - void GetTitleButtonVisible(bool isPC, bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, + void GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, bool& hideCloseButton); WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config); void SetForceSplitEnable(bool isForceSplit, const std::string& homePage = ""); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 3683cab2a2..4ab4fd9f05 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -870,10 +870,11 @@ void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height) } } -void WindowSessionImpl::GetTitleButtonVisible(bool isPC, bool& hideMaximizeButton, bool& hideMinimizeButton, +void WindowSessionImpl::GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, bool& hideCloseButton) { - if (!isPC) { + if (!IsPcOrPadFreeMultiWindowMode()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "device not support"); return; } if (hideMaximizeButton > !windowTitleVisibleFlags_.isMaximizeVisible) { @@ -1203,7 +1204,6 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() if (uiContent == nullptr || !IsDecorEnable()) { return; } - auto isPC = windowSystemConfig_.IsPcWindow(); WindowType windowType = GetType(); bool isSubWindow = WindowHelper::IsSubWindow(windowType); bool isDialogWindow = WindowHelper::IsDialogWindow(windowType); @@ -1221,7 +1221,7 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() GetMode() == WindowMode::WINDOW_MODE_FULLSCREEN); bool hideMinimizeButton = false; bool hideCloseButton = false; - GetTitleButtonVisible(isPC, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); TLOGI(WmsLogTag::WMS_LAYOUT, "[hideSplit, hideMaximize, hideMinimizeButton, hideCloseButton]:" "[%{public}d, %{public}d, %{public}d, %{public}d]", hideSplitButton, hideMaximizeButton, hideMinimizeButton, hideCloseButton); diff --git a/wm/test/unittest/window_scene_session_impl_test2.cpp b/wm/test/unittest/window_scene_session_impl_test2.cpp index bda0e95668..33743ae8bc 100644 --- a/wm/test/unittest/window_scene_session_impl_test2.cpp +++ b/wm/test/unittest/window_scene_session_impl_test2.cpp @@ -1685,7 +1685,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible01, Function | SmallT bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); ASSERT_EQ(hideSplitButton, true); @@ -1713,7 +1714,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible02, Function | SmallT bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, false); ASSERT_EQ(hideMinimizeButton, false); ASSERT_EQ(hideSplitButton, false); @@ -1741,7 +1743,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible03, Function | SmallT bool hideMinimizeButton = true; bool hideSplitButton = true; bool hideCloseButton = true; - window->GetTitleButtonVisible(false, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); ASSERT_EQ(hideSplitButton, true); diff --git a/wm/test/unittest/window_session_impl_test2.cpp b/wm/test/unittest/window_session_impl_test2.cpp index 989664ea0a..b0e17f7658 100644 --- a/wm/test/unittest/window_session_impl_test2.cpp +++ b/wm/test/unittest/window_session_impl_test2.cpp @@ -107,20 +107,20 @@ HWTEST_F(WindowSessionImplTest2, GetTitleButtonVisible, Function | SmallTest | L { auto window = GetTestWindowImpl("GetTitleButtonVisible"); ASSERT_NE(window, nullptr); - bool isPC = false; + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; bool isMaximizeVisible = false; bool isMinimizeVisible = false; bool isSplitVisible = false; bool isCloseVisible = false; - window->GetTitleButtonVisible(isPC, isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); + window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); ASSERT_FALSE(isSplitVisible); - isPC = true; + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; window->windowTitleVisibleFlags_.isSplitVisible = false; window->windowTitleVisibleFlags_.isMaximizeVisible = false; window->windowTitleVisibleFlags_.isMinimizeVisible = false; window->windowTitleVisibleFlags_.isCloseVisible = false; - window->GetTitleButtonVisible(isPC, isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); + window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); ASSERT_TRUE(isSplitVisible); ASSERT_TRUE(isMaximizeVisible); ASSERT_TRUE(isMinimizeVisible); @@ -130,7 +130,7 @@ HWTEST_F(WindowSessionImplTest2, GetTitleButtonVisible, Function | SmallTest | L window->windowTitleVisibleFlags_.isMaximizeVisible = true; window->windowTitleVisibleFlags_.isMinimizeVisible = true; window->windowTitleVisibleFlags_.isCloseVisible = true; - window->GetTitleButtonVisible(isPC, isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); + window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); ASSERT_TRUE(isSplitVisible); ASSERT_TRUE(isMaximizeVisible); ASSERT_TRUE(isMinimizeVisible); diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index d808504f89..caaf8eb31c 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -871,7 +871,8 @@ HWTEST_F(WindowSessionImplTest4, SetTitleButtonVisible, Function | SmallTest | L bool &hideMinimizeButton = isMinimizeVisible; bool &hideSplitButton = isSplitVisible; bool &hideCloseButton = isCloseVisible; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); } @@ -1190,7 +1191,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible01, Function | SmallTest | bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); @@ -1259,7 +1261,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible02, Function | SmallTest | bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, false); ASSERT_EQ(hideMinimizeButton, false); ASSERT_EQ(hideSplitButton, false); @@ -1291,7 +1294,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible03, Function | SmallTest | bool hideMinimizeButton = true; bool hideSplitButton = true; bool hideCloseButton = true; - window->GetTitleButtonVisible(false, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); ASSERT_EQ(hideSplitButton, true); From 3f6b4dbfff41b0c8c0ebfd9f79aaad2ee358c043 Mon Sep 17 00:00:00 2001 From: wangziyao Date: Thu, 14 Nov 2024 19:17:41 +0800 Subject: [PATCH 109/171] Quick opening and close of DMS Signed-off-by: wangziyao --- .../single_display_pocket_fold_policy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp index 0eb1278cb9..9288d6e77d 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp @@ -108,7 +108,6 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp } ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); - RSInterfaces::GetInstance().SetScreenSwitching(true); ChangeScreenDisplayModeProc(screenSession, displayMode); { std::lock_guard lock_mode(displayModeMutex_); @@ -309,6 +308,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenO void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr screenSession) { + RSInterfaces::GetInstance().SetScreenSwitching(true); SetdisplayModeChangeStatus(true); if (onBootAnimation_) { ChangeScreenDisplayModeToMainOnBootAnimation(screenSession); @@ -326,6 +326,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr screenSession) { + RSInterfaces::GetInstance().SetScreenSwitching(true); SetdisplayModeChangeStatus(true); if (onBootAnimation_) { ChangeScreenDisplayModeToFullOnBootAnimation(screenSession); From 7c084b21f86576836648b6482a8276e0ca8e55ce Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 19:19:23 +0800 Subject: [PATCH 110/171] add code Signed-off-by: ZihaoWU --- wm/test/unittest/window_manager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/test/unittest/window_manager_test.cpp b/wm/test/unittest/window_manager_test.cpp index 28edb0db93..632727c38e 100644 --- a/wm/test/unittest/window_manager_test.cpp +++ b/wm/test/unittest/window_manager_test.cpp @@ -222,7 +222,7 @@ HWTEST_F(WindowManagerTest, GetSnapshotByWindowId01, Function | SmallTest | Leve WMError ret = windowManager.GetSnapshotByWindowId(windowId, pixelMap); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret); - }else { + } else { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret); } } From 54ef17cda87b54908575efa955f09f5f5f092260 Mon Sep 17 00:00:00 2001 From: wangziyao Date: Thu, 14 Nov 2024 19:25:06 +0800 Subject: [PATCH 111/171] Quick opening and close of DMS Signed-off-by: wangziyao --- .../src/fold_screen_controller/single_display_fold_policy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp index 13c5061ff2..6f07b52e87 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp @@ -107,7 +107,6 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod SetdisplayModeChangeStatus(true); ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); - RSInterfaces::GetInstance().SetScreenSwitching(true); switch (displayMode) { case FoldDisplayMode::MAIN: { ChangeScreenDisplayModeToMain(screenSession); @@ -235,6 +234,7 @@ void SingleDisplayFoldPolicy::ReportFoldStatusChangeBegin(int32_t offScreen, int void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToMain(sptr screenSession) { + RSInterfaces::GetInstance().SetScreenSwitching(true); if (onBootAnimation_) { ChangeScreenDisplayModeToMainOnBootAnimation(screenSession); return; @@ -286,6 +286,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToMain(sptr void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToFull(sptr screenSession) { + RSInterfaces::GetInstance().SetScreenSwitching(true); if (onBootAnimation_) { ChangeScreenDisplayModeToFullOnBootAnimation(screenSession); return; From 7c2724b7542b00d24f9b94f1ff1aa5dc0c08e594 Mon Sep 17 00:00:00 2001 From: nzy Date: Thu, 14 Nov 2024 16:28:38 +0800 Subject: [PATCH 112/171] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=B8=9C=E6=B9=96session=E6=97=A0=E6=B3=95=E6=B8=85=E7=90=86&G?= =?UTF-8?q?etAbilityInfo=E7=94=A8=E4=BE=8B=E8=A1=A5=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nzy --- .../common/include/window_session_property.h | 4 +- window_scene/interfaces/include/ws_common.h | 2 +- .../js_scene_session_manager.cpp | 1 + .../js_scene_session_manager.h | 4 +- .../include/scene_session_manager.h | 2 +- .../src/scene_session_manager.cpp | 2 +- window_scene/test/mock/mock_ibundle_mgr.h | 3 + .../unittest/scene_session_manager_test11.cpp | 117 ++++++++++++++++++ 8 files changed, 128 insertions(+), 7 deletions(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 48b7a3dea1..72c8c6e6bf 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -217,7 +217,7 @@ public: bool GetIsUIExtAnySubWindow() const; /** - * Multi instance + * Multi Instance */ void SetAppInstanceKey(const std::string& appInstanceKey); std::string GetAppInstanceKey() const; @@ -368,7 +368,7 @@ private: WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; /** - * Multi instance + * Multi Instance */ std::string appInstanceKey_; }; diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index e43413850b..2d9ae17925 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -358,7 +358,7 @@ struct SessionInfo { SessionViewportConfig config_; /** - * Multi instance + * Multi Instance */ bool isNewAppInstance_ = false; std::string appInstanceKey_; 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 49f7aab886..9e96a41bcb 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 @@ -1545,6 +1545,7 @@ napi_value JsSceneSessionManager::OnGetAbilityInfo(napi_env env, napi_callback_i if (ret != WSErrorCode::WS_OK) { napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_STATE_ABNORMALLY), "System is abnormal")); + return NapiGetUndefined(env); } return CreateSCBAbilityInfo(env, scbAbilityInfo); } 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 9129086125..9d3155faba 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 @@ -120,7 +120,7 @@ public: static napi_value SetIsWindowRectAutoSave(napi_env env, napi_callback_info info); /* - * Multi instance + * Multi Instance */ static napi_value GetMaxInstanceCount(napi_env env, napi_callback_info info); static napi_value GetInstanceCount(napi_env env, napi_callback_info info); @@ -196,7 +196,7 @@ private: napi_value OnSetIsWindowRectAutoSave(napi_env env, napi_callback_info info); /* - * multi instance + * Multi Instance */ napi_value OnGetMaxInstanceCount(napi_env env, napi_callback_info info); napi_value OnGetInstanceCount(napi_env env, napi_callback_info info); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 1806d07dd6..f028381d11 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -484,7 +484,7 @@ public: const std::vector& bundleNameList) override; /* - * Multi instance + * Multi Instance */ int32_t GetMaxInstanceCount(const std::string& bundleName); int32_t GetInstanceCount(const std::string& bundleName); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 560655b29e..e87cd15a00 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8871,7 +8871,7 @@ bool SceneSessionManager::IsSessionClearable(sptr sceneSession) WLOGFI("sceneSession abilityInfo is nullptr"); return false; } - if (sessionInfo.abilityInfo->excludeFromMissions) { + if (sessionInfo.abilityInfo->excludeFromMissions && !sceneSession->IsAnco()) { WLOGFI("persistentId %{public}d is excludeFromMissions", sceneSession->GetPersistentId()); return false; } diff --git a/window_scene/test/mock/mock_ibundle_mgr.h b/window_scene/test/mock/mock_ibundle_mgr.h index f9a60e1d8b..2c27c891f7 100644 --- a/window_scene/test/mock/mock_ibundle_mgr.h +++ b/window_scene/test/mock/mock_ibundle_mgr.h @@ -23,6 +23,7 @@ namespace OHOS::AppExecFwk { class IBundleMgr; struct ApplicationInfo; enum ApplicationFlag; +struct BundleInfo; } // namespace OHOS::AppExecFwk namespace OHOS { @@ -36,6 +37,8 @@ public: const int32_t userId, std::vector& appInfos)); MOCK_METHOD4(GetApplicationInfo, bool(const std::string& appName, const AppExecFwk::ApplicationFlag flag, const int32_t userId, AppExecFwk::ApplicationInfo& appInfo)); + MOCK_METHOD4(GetBundleInfoV9, ErrCode(const std::string& bundleName, int32_t flags, + AppExecFwk::BundleInfo& bundleInfo, int32_t userId)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test11.cpp b/window_scene/test/unittest/scene_session_manager_test11.cpp index 2abff7405f..eccc5113ea 100644 --- a/window_scene/test/unittest/scene_session_manager_test11.cpp +++ b/window_scene/test/unittest/scene_session_manager_test11.cpp @@ -285,6 +285,123 @@ HWTEST_F(SceneSessionManagerTest11, GetAllSessionDumpDetailInfo, Function | Smal std::string dumpInfo; ASSERT_EQ(ssm_->GetAllSessionDumpDetailInfo(dumpInfo), WSError::WS_OK); } + +/** + * @tc.name: GetAbilityInfo + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo, Function | SmallTest | Level1) +{ + ssm_->bundleMgr_ = nullptr; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR); +} + +/** + * @tc.name: GetAbilityInfo02 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo02, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce(Return(1)); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM); +} + +/** + * @tc.name: GetAbilityInfo03 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo03, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( + const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + bundleInfo.hapModuleInfos = {}; + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM); +} + +/** + * @tc.name: GetAbilityInfo04 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo04, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( + const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.moduleName = "moduleName"; + abilityInfo.name = "abilityName"; + AppExecFwk::HapModuleInfo hapModuleInfo; + hapModuleInfo.abilityInfos = { abilityInfo }; + bundleInfo.hapModuleInfos = { hapModuleInfo }; + bundleInfo.applicationInfo.codePath = "testCodePath"; + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_OK); + ASSERT_EQ(scbAbilityInfo.codePath_, "testCodePath"); +} + +/** + * @tc.name: GetAbilityInfo05 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo05, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( + const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.moduleName = "moduleName2"; + abilityInfo.name = "abilityName2"; + AppExecFwk::HapModuleInfo hapModuleInfo; + hapModuleInfo.abilityInfos = { abilityInfo }; + bundleInfo.hapModuleInfos = { hapModuleInfo }; + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM); +} } // namespace } } \ No newline at end of file From 7f1a14cb5085b7b7621ef9c44964d1d15322d060 Mon Sep 17 00:00:00 2001 From: shulssins Date: Thu, 14 Nov 2024 20:10:56 +0800 Subject: [PATCH 113/171] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shulssins --- .../screen_session_manager/src/screen_session_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 21617b0563..92efe42b9c 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -6119,7 +6119,6 @@ void ScreenSessionManager::InitFakeScreenSession(sptr screenSessi uint32_t screenHeight = screenProperty.GetBounds().rect_.GetHeight(); fakeScreenSession->UpdatePropertyByResolution(screenWidth, screenHeight / HALF_SCREEN_PARAM); screenSession->UpdatePropertyByFakeBounds(screenWidth, screenHeight / HALF_SCREEN_PARAM); - screenSession->UpdatePropertyByFakeInUse(true); screenSession->SetFakeScreenSession(fakeScreenSession); screenSession->SetIsFakeInUse(true); } From baccb495c54683c38c93dde03e9b7172c27fdf98 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 20:20:21 +0800 Subject: [PATCH 114/171] add code Signed-off-by: ZihaoWU --- .../session_manager/src/scene_session_manager.cpp | 9 +++++---- .../test/unittest/scene_session_manager_test4.cpp | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index ca8005be20..bdae041234 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7854,7 +7854,8 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector> windowDrawingContenInfos; for (const auto& elem : drawingContentChangeInfo) { - uint64_t surfaceId = elem.first; + + surfaceId = elem.first; bool drawingState = elem.second; int32_t winId = 0; int32_t pid = 0; @@ -7919,9 +7920,9 @@ std::vector> SceneSessionManager::GetWindowDrawingCont int32_t pid = 0; bool isDrawingStateChange = false; sptr session = SelectSesssionFromMap(windowId); - isDrawingStateChange = - session == nullptr || (GetPreWindowDrawingState(windowId, isWindowDrawing, pid) != isWindowDrawing && - GetProcessDrawingState(windowId, pid)); + bool isPreWindowDrawing = GetPreWindowDrawingState(windowId, isWindowDrawing, pid); + bool isStateChanged = GetProcessDrawingState(windowId, pid); + isDrawingStateChange = session == nullptr || (isPreWindowDrawing != isWindowDrawing && isStateChanged); if (isDrawingStateChange) { processDrawingContentChangeInfo.emplace_back(windowId, isWindowDrawing); } diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index d81e30436e..bab5b63a04 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -828,7 +828,9 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes * @tc.desc: GetWindowDrawingContentChangeInfo * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | SmallTest | Level3) +HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo + +, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); SessionInfo info; From a395db83ebaa5c63cf6324d232d02076301f05a6 Mon Sep 17 00:00:00 2001 From: z00899566 Date: Thu, 14 Nov 2024 15:54:18 +0800 Subject: [PATCH 115/171] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B1=8F=E5=B9=95?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=B7=9F=E9=9A=8F=E7=8A=B6=E6=80=81=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E7=9A=84=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z00899566 --- .../super_fold_state_manager.h | 5 ++- .../super_fold_state_manager.cpp | 42 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h index b08181e37b..577c7b6ff3 100644 --- a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h +++ b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h @@ -26,11 +26,14 @@ #include "dm_common.h" #include "wm_single_instance.h" +#include "transaction/rs_interfaces.h" namespace OHOS { namespace Rosen { +class RSInterfaces; + class SuperFoldStateManager final { WM_DECLARE_SINGLE_INSTANCE_BASE(SuperFoldStateManager) public: @@ -47,7 +50,7 @@ public: void HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents events); SuperFoldStatus GetCurrentStatus(); - + FoldStatus MatchSuperFoldStatusToFoldStatus(SuperFoldStatus superFoldStatus); private: std::atomic curState_ = SuperFoldStatus::HALF_FOLDED; diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp index f452711c2b..2228937c0d 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp @@ -41,14 +41,52 @@ void SuperFoldStateManager::DoAngleChangeExpanded(SuperFoldStatusChangeEvents ev void SuperFoldStateManager::DoKeyboardOn(SuperFoldStatusChangeEvents event) { + sptr meScreenSession = ScreenSessionManager::GetInstance(). + GetDefaultScreenSession(); + if (meScreenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screen session is null!"); + return; + } + auto screenProperty = meScreenSession->GetScreenProperty(); + auto screenWidth = screenProperty.GetFakeBounds().rect_.GetWidth(); + auto screenHeight = screenProperty.GetFakeBounds().rect_.GetHeight(); + + OHOS::Rect rectCur{ + .x = 0, + .y = 0, + .w = static_cast(screenWidth), + .h = static_cast(screenHeight), + }; + // SCREEN_ID_FULL = 0 + auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(true); - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOn()"); + TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld", + screenWidth, screenHeight, static_cast(response)); } void SuperFoldStateManager::DoKeyboardOff(SuperFoldStatusChangeEvents event) { + sptr meScreenSession = ScreenSessionManager::GetInstance(). + GetDefaultScreenSession(); + if (meScreenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screen session is null!"); + return; + } + auto screenProperty = meScreenSession->GetScreenProperty(); + auto screenWidth = screenProperty.GetBounds().rect_.GetWidth(); + auto screenHeight = screenProperty.GetBounds().rect_.GetHeight(); + + OHOS::Rect rectCur{ + .x = 0, + .y = 0, + .w = static_cast(screenWidth), + .h = static_cast(screenHeight), + }; + // SCREEN_ID_FULL = 0 + auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(false); - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOff()"); + TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld", + screenWidth, screenHeight, static_cast(response)); } void SuperFoldStateManager::DoFoldedToHalfFolded(SuperFoldStatusChangeEvents event) From f01b30b3273fe9938aab415c036410f2ac473a70 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 21:23:45 +0800 Subject: [PATCH 116/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 2 +- .../src/scene_session_manager.cpp | 20 +++++++++---------- .../unittest/scene_session_manager_test4.cpp | 4 +--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 15490a6212..7091fc2231 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1055,7 +1055,7 @@ private: int32_t uid_ = 0; }; - std::shared_mutex lastDrawingDataMutex_; + std::mutex lastDrawingDataMutex_; std::vector lastDrawingData_; /** diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index bdae041234..5cfd94e2eb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7854,8 +7854,7 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector> windowDrawingContenInfos; for (const auto& elem : drawingContentChangeInfo) { - - surfaceId = elem.first; + uint64_t surfaceId = elem.first; bool drawingState = elem.second; int32_t winId = 0; int32_t pid = 0; @@ -7889,7 +7888,7 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector lock(lastDrawingDataMutex_); + std::shared_lock lock(lastDrawingDataMutex_); auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); if (it != lastDrawingData_.end()) { @@ -7902,7 +7901,7 @@ bool SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId, int32_t& pi void SceneSessionManager::RemoveSpecifiedDrawingData(int windowId) { - std::unique_lock lock(lastDrawingDataMutex_); + std::unique_lock lock(lastDrawingDataMutex_); auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); if (it != lastDrawingData_.end()) { @@ -7918,12 +7917,13 @@ std::vector> SceneSessionManager::GetWindowDrawingCont uint64_t windowId = data.first; bool isWindowDrawing = data.second; int32_t pid = 0; - bool isDrawingStateChange = false; - sptr session = SelectSesssionFromMap(windowId); + bool isDrawingStateChanged = false; bool isPreWindowDrawing = GetPreWindowDrawingState(windowId, isWindowDrawing, pid); - bool isStateChanged = GetProcessDrawingState(windowId, pid); - isDrawingStateChange = session == nullptr || (isPreWindowDrawing != isWindowDrawing && isStateChanged); - if (isDrawingStateChange) { + bool isProcessDrawingStateChanged = GetProcessDrawingState(windowId, pid); + sptr session = SelectSesssionFromMap(windowId); + isDrawingStateChanged = + session == nullptr || (isPreWindowDrawing != isWindowDrawing && isProcessDrawingStateChanged); + if (isDrawingStateChanged) { processDrawingContentChangeInfo.emplace_back(windowId, isWindowDrawing); } } @@ -7947,7 +7947,7 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool curre void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) { RemoveSpecifiedDrawingData(windowId); - std::unique_lock lock(lastDrawingDataMutex_); + std::unique_lock lock(lastDrawingDataMutex_); lastDrawingData_.push_back({ windowId, pid, uid }); } diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index bab5b63a04..d81e30436e 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -828,9 +828,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes * @tc.desc: GetWindowDrawingContentChangeInfo * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo - -, Function | SmallTest | Level3) +HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); SessionInfo info; From 917e7c1a10cb3dbea6686fce4e38b8dea1a1b61c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 21:26:58 +0800 Subject: [PATCH 117/171] add code Signed-off-by: ZihaoWU --- 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 5cfd94e2eb..3df1b938ae 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7888,7 +7888,7 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector lock(lastDrawingDataMutex_); + std::unique_lock lock(lastDrawingDataMutex_); auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); if (it != lastDrawingData_.end()) { From f7d1492bf402427f58712f0d079a4e11809cd0fc Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 21:31:45 +0800 Subject: [PATCH 118/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 7091fc2231..0c567a7e3b 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -693,7 +693,7 @@ private: bool GetProcessDrawingState(uint64_t windowId, int32_t pid); void UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid); bool GetSpecifiedDrawingData(uint64_t windowId, int32_t& pid, int32_t& uid); - void RemoveSpecifiedDrawingData(int windowId); + void RemoveSpecifiedDrawingData(uint64_t windowId); /* * Window Rotate Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3df1b938ae..59427d8d84 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7899,7 +7899,7 @@ bool SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId, int32_t& pi return false; } -void SceneSessionManager::RemoveSpecifiedDrawingData(int windowId) +void SceneSessionManager::RemoveSpecifiedDrawingData(uint64_t windowId) { std::unique_lock lock(lastDrawingDataMutex_); auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), From 19e649898494874d1c405a29db0736c9a491cc81 Mon Sep 17 00:00:00 2001 From: kaicui Date: Thu, 14 Nov 2024 21:34:21 +0800 Subject: [PATCH 119/171] =?UTF-8?q?=E5=B5=8C=E5=85=A5=E5=BC=8FUIExtension?= =?UTF-8?q?=E6=94=AF=E6=8C=81windowRectChange=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kaicui --- .../kits/napi/extension_window/BUILD.gn | 1 + .../js_extension_window_listener.cpp | 58 ++++++++++++++++++- .../js_extension_window_listener.h | 7 ++- .../js_extension_window_register_manager.cpp | 22 +++++++ .../js_extension_window_register_manager.h | 3 + 5 files changed, 86 insertions(+), 5 deletions(-) diff --git a/interfaces/kits/napi/extension_window/BUILD.gn b/interfaces/kits/napi/extension_window/BUILD.gn index cb3a51d445..c4bcd5b7fa 100644 --- a/interfaces/kits/napi/extension_window/BUILD.gn +++ b/interfaces/kits/napi/extension_window/BUILD.gn @@ -90,6 +90,7 @@ ohos_shared_library("extensionwindow_napi") { ":extension_window_kit_config", "../../../../resources/config/build:coverage_flags", ] + public_configs = [":extension_window_kit_config"] include_dirs = [ "extension_window" ] deps = [ diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index 7ede0ce022..88ec7135d8 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -28,6 +28,7 @@ namespace Rosen { using namespace AbilityRuntime; namespace { const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; +const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange"; const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange"; const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; const std::string LIFECYCLE_EVENT_CB = "lifeCycleEvent"; @@ -70,7 +71,8 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r { TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]OnSizeChange, [%{public}u, %{public}u], reason=%{public}u", rect.width_, rect.height_, reason); - if (currentWidth_ == rect.width_ && currentHeight_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) { + if (currentRect_.width_ == rect.width_ && currentRect_.height_ == rect.height_ && + reason != WindowSizeChangeReason::DRAG_END) { TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]no need to change size"); return; } @@ -111,8 +113,58 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnSizeChange", 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } - currentWidth_ = rect.width_; - currentHeight_ = rect.height_; + currRect_ = rect; +} + +void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) +{ + if (currRect_ == rect && reason == WindowSizeChangeReason::UNDEFINED) { + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]Skip redundant rect update"); + return; + } + RectChangeReason rectChangReason = RectChangeReason::UNDEFINED; + if (JS_SIZE_CHANGE_REASON.count(reason) != 0 && + !(reason == WindowSizeChangeReason::MAXIMIZE && rect.posX_ != 0)) { + rectChangReason = JS_SIZE_CHANGE_REASON.at(reason); + } + if (currentReason_ != RectChangeReason::DRAG && rectChangReason == RectChangeReason::DRAG_END) { + rectChangReason = RectChangeReason::MOVE; + } + // js callback should run in js thread + auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_] () { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::OnRectChange"); + auto thisListener = self.promote(); + if (thisListener == nullptr || env == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]This listener or env is nullptr"); + return; + } + napi_handle_scope scope = nullptr; + napi_open_handle_scope(env, &scope); + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create js object"); + return; + } + napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect); + if (rectObjValue == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create rect js object"); + return; + } + napi_set_named_property(env, objValue, "rect", rectObjValue); + napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangReason)); + napi_value argv[] = {objValue}; + thisListener->CallJsMethod(WINDOW_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv)); + napi_close_handle_scope(env, scope); + }; + if (!eventHandler_) { + TLOGE(WmsLogTag::WMS_UIEXTJsExtensionWindowListener, "Get main event handler failed!"); + return; + } + eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnRectChange", 0, + AppExecFwk::EventQueue::Priority::IMMEDIATE); + currRect_ = rect; + currentReason_ = rectChangReason; } void JsExtensionWindowListener::OnModeChange(WindowMode mode, bool hasDeco) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.h b/interfaces/kits/napi/extension_window/js_extension_window_listener.h index 101d8c91ce..0f9151eb16 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.h @@ -26,11 +26,13 @@ #include "window.h" #include "window_manager.h" #include "wm_common.h" +#include "js_window_utils.h" #include "js_extension_window_utils.h" namespace OHOS { namespace Rosen { class JsExtensionWindowListener : public IWindowChangeListener, + public IWindowRectChangeListener, public IAvoidAreaChangedListener, public IWindowLifeCycle, public IOccupiedAreaChangeListener { @@ -41,6 +43,7 @@ public: ~JsExtensionWindowListener(); void OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; + void OnRectChange(Rect rect, WindowSizeChangeReason reason) override; void OnModeChange(WindowMode mode, bool hasDeco) override; void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; void AfterForeground() override; @@ -56,8 +59,8 @@ public: void SetMainEventHandler(); private: - uint32_t currentWidth_ = 0; - uint32_t currentHeight_ = 0; + Rect currRect_ = {0, 0, 0, 0}; + RectChangeReason currentReason_ = RectChangeReason::UNDEFINED; napi_env env_ = nullptr; WindowState state_ {WindowState::STATE_INITIAL}; std::shared_ptr jsCallBack_; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp index 397836f2df..fb4590fbf5 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp @@ -21,6 +21,7 @@ namespace OHOS { namespace Rosen { namespace { const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; +const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange"; const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent"; const std::string WINDOW_EVENT_CB = "windowEvent"; @@ -31,6 +32,7 @@ JsExtensionWindowRegisterManager::JsExtensionWindowRegisterManager() // white register list for window listenerCodeMap_[CaseType::CASE_WINDOW] = { {WINDOW_SIZE_CHANGE_CB, ListenerType::WINDOW_SIZE_CHANGE_CB}, + {WINDOW_RECT_CHANGE_CB, ListenerType::WINDOW_RECT_CHANGE_CB}, {AVOID_AREA_CHANGE_CB, ListenerType::AVOID_AREA_CHANGE_CB}, {WINDOW_EVENT_CB, ListenerType::WINDOW_EVENT_CB}, }; @@ -61,6 +63,23 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, + sptr window, bool isRegister) +{ + if (window == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + } + sptr thisListener(listener); + WmErrorCode ret = WmErrorCode::WM_OK; + if (isRegister) { + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowRectChangeListener(thisListener)); + } else { + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowRectChangeListener(thisListener)); + } + return ret; +} + WmErrorCode JsExtensionWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister) { @@ -208,6 +227,9 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessRegister(CaseType caseType, case ListenerType::WINDOW_SIZE_CHANGE_CB: ret = ProcessWindowChangeRegister(listener, window, isRegister); break; + case ListenerType::WINDOW_RECT_CHANGE_CB: + ret = ProcessWindowRectChangeRegister(listener, window, isRegister); + break; case ListenerType::AVOID_AREA_CHANGE_CB: ret = ProcessAvoidAreaChangeRegister(listener, window, isRegister); break; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h index dde8170577..428f4be6ea 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h @@ -39,6 +39,7 @@ public: private: enum class ListenerType : uint32_t { WINDOW_SIZE_CHANGE_CB, + WINDOW_RECT_CHANGE_CB, AVOID_AREA_CHANGE_CB, WINDOW_EVENT_CB, WINDOW_STAGE_EVENT_CB, @@ -47,6 +48,8 @@ private: bool IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject); WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister); + WmErrorCode ProcessWindowRectChangeRegister(sptr listener, + sptr window, bool isRegister); WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister); WmErrorCode ProcessLifeCycleEventRegister(sptr listener, From b6ca4d2f077a7fa4616a9a611ff27d07914fb003 Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Thu, 14 Nov 2024 21:37:16 +0800 Subject: [PATCH 120/171] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E9=9C=B2=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ning Yuanfeng --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a609284dcb..147be84ba2 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1302,7 +1302,7 @@ WMError WindowSessionImpl::InitUIContent(const std::string& contentInfo, napi_en break; case WindowSetUIContentType::BY_ABC: auto abcContent = GetAbcContent(contentInfo); - aceRet = uiContent->Initialize(this, abcContent, storage); + aceRet = uiContent->Initialize(this, abcContent, storage, contentInfo); break; } // make uiContent available after Initialize/Restore From 948ba7be10fbce2770956be65a727c9fd8a6d2c5 Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Thu, 14 Nov 2024 21:52:34 +0800 Subject: [PATCH 121/171] ammend Signed-off-by: Ning Yuanfeng --- wm/src/window_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index cbb4b03de2..698d739bde 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -640,7 +640,7 @@ WMError WindowImpl::SetUIContentInner(const std::string& contentInfo, napi_env e break; case WindowSetUIContentType::BY_ABC: auto abcContent = GetAbcContent(contentInfo); - aceRet = uiContent->Initialize(this, abcContent, storage); + aceRet = uiContent->Initialize(this, abcContent, storage, contentInfo); break; } // make uiContent available after Initialize/Restore From 0c739c41e13408d8d19405b9108de190e8ce455b Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Thu, 14 Nov 2024 19:05:57 +0800 Subject: [PATCH 122/171] =?UTF-8?q?=E8=A7=A3=E5=86=B3onWindowAnimationFlag?= =?UTF-8?q?Change=5F=E5=A4=9A=E7=BA=BF=E7=A8=8B=E8=AF=BB=E5=86=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangjiaqi --- .../session/host/include/scene_session.h | 4 +-- .../session/host/src/scene_session.cpp | 26 ++++++++----------- .../test/unittest/scene_session_test2.cpp | 5 +--- .../test/unittest/scene_session_test5.cpp | 8 ++---- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 6f8adc353f..005335d492 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -126,7 +126,6 @@ public: NotifySessionTopmostChangeFunc onSessionTopmostChange_; NotifyRaiseToTopFunc onRaiseToTop_; NotifySessionEventFunc OnSessionEvent_; - NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_; NotifyRaiseAboveTargetFunc onRaiseAboveTarget_; NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_; }; @@ -378,7 +377,6 @@ public: void NotifySessionForeground(uint32_t reason, bool withAnimation); void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits); void RegisterSessionChangeCallback(const sptr& sessionChangeCallback); - void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback); void RegisterSystemBarPropertyChangeCallback(NotifySystemBarPropertyChangeFunc&& callback); void RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback); void RegisterForceSplitListener(const NotifyForceSplitFunc& func); @@ -404,6 +402,7 @@ public: * Window Animation */ void RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback); + void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback); /** * Window Visibility @@ -842,6 +841,7 @@ private: * Window Animation */ NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_; + NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_; /** * Window Layout diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 687b2b19f7..2af9fb6b18 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -724,16 +724,13 @@ void SceneSession::RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimat auto task = [weakThis = wptr(this), callback = std::move(callback)] { auto session = weakThis.promote(); if (!session) { - TLOGE(WmsLogTag::WMS_LIFE, "session is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } - if (session->sessionChangeCallback_) { - session->sessionChangeCallback_->onWindowAnimationFlagChange_ = std::move(callback); - session->sessionChangeCallback_->onWindowAnimationFlagChange_(session->IsNeedDefaultAnimation()); - } - return WSError::WS_OK; + session->onWindowAnimationFlagChange_ = std::move(callback); + session->onWindowAnimationFlagChange_(session->IsNeedDefaultAnimation()); }; - PostTask(task, "RegisterDefaultAnimationFlagChangeCallback"); + PostTask(task, __func__); } void SceneSession::RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback) @@ -3151,26 +3148,26 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) WSError SceneSession::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) { - auto task = [weakThis = wptr(this), needDefaultAnimationFlag]() { + auto task = [weakThis = wptr(this), needDefaultAnimationFlag] { auto session = weakThis.promote(); if (!session) { - WLOGFE("session is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } session->needDefaultAnimationFlag_ = needDefaultAnimationFlag; - if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onWindowAnimationFlagChange_) { - session->sessionChangeCallback_->onWindowAnimationFlagChange_(needDefaultAnimationFlag); + if (session->onWindowAnimationFlagChange_) { + session->onWindowAnimationFlagChange_(needDefaultAnimationFlag); } return WSError::WS_OK; }; - return PostSyncTask(task, "UpdateWindowAnimationFlag"); + return PostSyncTask(task, __func__); } void SceneSession::SetWindowAnimationFlag(bool needDefaultAnimationFlag) { needDefaultAnimationFlag_ = needDefaultAnimationFlag; - if (sessionChangeCallback_ && sessionChangeCallback_->onWindowAnimationFlagChange_) { - sessionChangeCallback_->onWindowAnimationFlagChange_(needDefaultAnimationFlag); + if (onWindowAnimationFlagChange_) { + onWindowAnimationFlagChange_(needDefaultAnimationFlag); } return; } @@ -5494,7 +5491,6 @@ void SceneSession::UnregisterSessionChangeListeners() session->sessionChangeCallback_->onSessionTopmostChange_ = nullptr; session->sessionChangeCallback_->onRaiseToTop_ = nullptr; session->sessionChangeCallback_->OnSessionEvent_ = nullptr; - session->sessionChangeCallback_->onWindowAnimationFlagChange_ = nullptr; session->sessionChangeCallback_->onRaiseAboveTarget_ = nullptr; session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_ = nullptr; } diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index c3f5c4f5e2..9e19f025b7 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -2029,10 +2029,7 @@ HWTEST_F(SceneSessionTest2, SetWindowAnimationFlag, Function | SmallTest | Level sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); - sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr); - sceneSession->sessionChangeCallback_->onWindowAnimationFlagChange_ = []( - bool isNeedDefaultAnimationFlag) {}; + sceneSession->onWindowAnimationFlagChange_ = [](bool isNeedDefaultAnimationFlag) {}; sceneSession->SetWindowAnimationFlag(true); ASSERT_EQ(true, sceneSession->needDefaultAnimationFlag_); } diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index b481556853..7f879c7e61 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -1090,19 +1090,15 @@ HWTEST_F(SceneSessionTest5, UpdateWindowAnimationFlag, Function | SmallTest | Le sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - sptr sessionChangeCallback = - sptr::MakeSptr(); - session->RegisterSessionChangeCallback(nullptr); EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); - sessionChangeCallback->onWindowAnimationFlagChange_ = nullptr; - session->RegisterSessionChangeCallback(sessionChangeCallback); + session->onWindowAnimationFlagChange_ = nullptr; EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); NotifyWindowAnimationFlagChangeFunc func = [](const bool flag) { return; }; - sessionChangeCallback->onWindowAnimationFlagChange_ = func; + session->onWindowAnimationFlagChange_ = func; EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); } From 6544717e2d9dee9a4a20b084e95057274cd1b9fe Mon Sep 17 00:00:00 2001 From: kaicui Date: Thu, 14 Nov 2024 22:09:25 +0800 Subject: [PATCH 123/171] Fix typo Signed-off-by: kaicui --- .../napi/extension_window/js_extension_window_listener.cpp | 4 ++-- .../extension_window/js_extension_window_register_manager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index 88ec7135d8..dc02e21fa5 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -71,7 +71,7 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r { TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]OnSizeChange, [%{public}u, %{public}u], reason=%{public}u", rect.width_, rect.height_, reason); - if (currentRect_.width_ == rect.width_ && currentRect_.height_ == rect.height_ && + if (currRect_.width_ == rect.width_ && currRect_.height_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) { TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]no need to change size"); return; @@ -158,7 +158,7 @@ void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason r napi_close_handle_scope(env, scope); }; if (!eventHandler_) { - TLOGE(WmsLogTag::WMS_UIEXTJsExtensionWindowListener, "Get main event handler failed!"); + TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!"); return; } eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnRectChange", 0, diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp index fb4590fbf5..c0510dd45b 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp @@ -63,7 +63,7 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, +WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowRectChangeRegister(sptr listener, sptr window, bool isRegister) { if (window == nullptr) { From a5d9a6818fdcffcb865c3d1482c278c2f276f1b1 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 22:10:47 +0800 Subject: [PATCH 124/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 18 +++-- .../src/scene_session_manager.cpp | 71 ++++++++----------- 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 0c567a7e3b..e72d253ac3 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -689,11 +689,11 @@ private: */ std::vector> GetWindowDrawingContentChangeInfo( const std::vector>& currDrawingContentData); - bool GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawing, int32_t& pid); - bool GetProcessDrawingState(uint64_t windowId, int32_t pid); - void UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid); - bool GetSpecifiedDrawingData(uint64_t windowId, int32_t& pid, int32_t& uid); - void RemoveSpecifiedDrawingData(uint64_t windowId); + bool GetPreWindowDrawingState(uint64_t surfaceId, bool currentWindowDrawing, int32_t& pid); + bool GetProcessDrawingState(uint64_t surfaceId, int32_t pid); + void UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid); + bool GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& pid, int32_t& uid); + void RemoveSpecifiedDrawingData(uint64_t surfaceId); /* * Window Rotate Animation @@ -1049,14 +1049,12 @@ private: /* * Window Property */ - struct DrawingSessionIdInfo { - uint64_t windowId_ = 0; + struct DrawingSessionInfo { + uint64_t surfaceId_ = 0; int32_t pid_ = 0; int32_t uid_ = 0; }; - - std::mutex lastDrawingDataMutex_; - std::vector lastDrawingData_; + std::vector lastDrawingSessionInfoVec_; /** * PC Window diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 59427d8d84..1439cbd952 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7853,10 +7853,8 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector> windowDrawingContenInfos; - for (const auto& elem : drawingContentChangeInfo) { - uint64_t surfaceId = elem.first; - bool drawingState = elem.second; - int32_t winId = 0; + for (const auto& [surfaceId, drawingState] : drawingContentChangeInfo) { + int32_t windowId = 0; int32_t pid = 0; int32_t uid = 0; WindowType type = WindowType::APP_WINDOW_BASE; @@ -7867,12 +7865,12 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vectorGetWindowId(); + windowId = session->GetWindowId(); pid = session->GetCallingPid(); uid = session->GetCallingUid(); type = session->GetWindowType(); } - windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(winId, pid, uid, drawingState, type)); + windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(windowId, pid, uid, drawingState, type)); if (openDebugTrace_) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "Drawing status changed pid:(%d ) surfaceId:(%" PRIu64 ")" "drawingState:(%d )", pid, surfaceId, drawingState); @@ -7886,12 +7884,11 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector lock(lastDrawingDataMutex_); - auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), - [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); - if (it != lastDrawingData_.end()) { + auto it = std::find_if(lastDrawingSessionInfoVec_.begin(), lastDrawingSessionInfoVec_.end(), + [surfaceId](const DrawingSessionIdInfo& info) { return info.surfaceId_ == surfaceId; }); + if (it != lastDrawingSessionInfoVec_.end()) { pid = it->pid_; uid = it->uid_; return true; @@ -7899,13 +7896,12 @@ bool SceneSessionManager::GetSpecifiedDrawingData(uint64_t windowId, int32_t& pi return false; } -void SceneSessionManager::RemoveSpecifiedDrawingData(uint64_t windowId) +void SceneSessionManager::RemoveSpecifiedDrawingData(uint64_t surfaceId) { - std::unique_lock lock(lastDrawingDataMutex_); - auto it = std::find_if(lastDrawingData_.begin(), lastDrawingData_.end(), - [windowId](const DrawingSessionIdInfo& info) { return info.windowId_ == windowId; }); - if (it != lastDrawingData_.end()) { - lastDrawingData_.erase(it); + auto it = std::find_if(lastDrawingSessionInfoVec_.begin(), lastDrawingSessionInfoVec_.end(), + [surfaceId](const DrawingSessionIdInfo& info) { return info.surfaceId_ == surfaceId; }); + if (it != lastDrawingSessionInfoVec_.end()) { + lastDrawingSessionInfoVec_.erase(it); } } @@ -7913,47 +7909,42 @@ std::vector> SceneSessionManager::GetWindowDrawingCont const std::vector>& currDrawingContentData) { std::vector> processDrawingContentChangeInfo; - for (const auto& data : currDrawingContentData) { - uint64_t windowId = data.first; - bool isWindowDrawing = data.second; + for (const auto& [surfaceId, isWindowDrawing] : currDrawingContentData) { int32_t pid = 0; bool isDrawingStateChanged = false; - bool isPreWindowDrawing = GetPreWindowDrawingState(windowId, isWindowDrawing, pid); - bool isProcessDrawingStateChanged = GetProcessDrawingState(windowId, pid); - sptr session = SelectSesssionFromMap(windowId); + bool isPreWindowDrawing = GetPreWindowDrawingState(surfaceId, isWindowDrawing, pid); + bool isProcessDrawingStateChanged = GetProcessDrawingState(surfaceId, pid); + sptr session = SelectSesssionFromMap(surfaceId); isDrawingStateChanged = session == nullptr || (isPreWindowDrawing != isWindowDrawing && isProcessDrawingStateChanged); if (isDrawingStateChanged) { - processDrawingContentChangeInfo.emplace_back(windowId, isWindowDrawing); + processDrawingContentChangeInfo.emplace_back(surfaceId, isWindowDrawing); } } return processDrawingContentChangeInfo; } -bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, bool currentWindowDrawing, int32_t& pid) +bool SceneSessionManager::GetPreWindowDrawingState(uint64_t surfaceId, bool currentWindowDrawing, int32_t& pid) { - bool preWindowDrawing = true; - sptr session = SelectSesssionFromMap(windowId); + sptr session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { return false; } pid = session->GetCallingPid(); - preWindowDrawing = session->GetDrawingContentState(); + bool preWindowDrawing = session->GetDrawingContentState(); session->SetDrawingContentState(currentWindowDrawing); - UpdateWindowDrawingData(windowId, pid, session->GetCallingUid()); + UpdateWindowDrawingData(surfaceId, pid, session->GetCallingUid()); return preWindowDrawing; } -void SceneSessionManager::UpdateWindowDrawingData(uint64_t windowId, int32_t pid, int32_t uid) +void SceneSessionManager::UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid) { - RemoveSpecifiedDrawingData(windowId); - std::unique_lock lock(lastDrawingDataMutex_); - lastDrawingData_.push_back({ windowId, pid, uid }); + RemoveSpecifiedDrawingData(surfaceId); + lastDrawingSessionInfoVec_.push_back({ surfaceId, pid, uid }); } -bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid) +bool SceneSessionManager::GetProcessDrawingState(uint64_t surfaceId, int32_t pid) { - bool isChange = true; std::shared_lock lock(sceneSessionMapMutex_); for (const auto& item : sceneSessionMap_) { auto sceneSession = item.second; @@ -7961,13 +7952,13 @@ bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid) continue; } if (sceneSession->GetCallingPid() == pid && sceneSession->GetSurfaceNode() != nullptr && - windowId != sceneSession->GetSurfaceNode()->GetId()) { - if (sceneSession->GetDrawingContentState()) { - return false; - } + surfaceId != sceneSession->GetSurfaceNode()->GetId()) { + if (sceneSession->GetDrawingContentState()) { + return false; } } - return isChange; + } + return true; } void SceneSessionManager::InitWithRenderServiceAdded() From 51590fa78835a0985bd26f4d9147ffda13557205 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 22:13:57 +0800 Subject: [PATCH 125/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1439cbd952..9db6746736 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7911,11 +7911,10 @@ std::vector> SceneSessionManager::GetWindowDrawingCont std::vector> processDrawingContentChangeInfo; for (const auto& [surfaceId, isWindowDrawing] : currDrawingContentData) { int32_t pid = 0; - bool isDrawingStateChanged = false; bool isPreWindowDrawing = GetPreWindowDrawingState(surfaceId, isWindowDrawing, pid); bool isProcessDrawingStateChanged = GetProcessDrawingState(surfaceId, pid); sptr session = SelectSesssionFromMap(surfaceId); - isDrawingStateChanged = + bool isDrawingStateChanged = session == nullptr || (isPreWindowDrawing != isWindowDrawing && isProcessDrawingStateChanged); if (isDrawingStateChanged) { processDrawingContentChangeInfo.emplace_back(surfaceId, isWindowDrawing); From 0585a8ddcf4c83fd3c3df04450a243026bbc18c4 Mon Sep 17 00:00:00 2001 From: wangziyi Date: Thu, 14 Nov 2024 22:19:55 +0800 Subject: [PATCH 126/171] drag enable only set service Signed-off-by: wangziyi --- window_scene/session/host/include/scene_session.h | 7 +++++++ window_scene/session/host/src/scene_session.cpp | 4 +--- window_scene/session/host/src/session.cpp | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 6f8adc353f..17a09fc1a2 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -532,6 +532,8 @@ public: void SetTitleAndDockHoverShowChangeCallback(NotifyTitleAndDockHoverShowChangeFunc&& func); void SetRestoreMainWindowCallback(NotifyRestoreMainWindowFunc&& func); void SetWindowRectAutoSaveCallback(NotifySetWindowRectAutoSaveFunc&& func); + void SetClientDragEnable(bool dragEnable); + std::optional GetClientDragEnable() const; protected: void NotifySessionRectChange(const WSRect& rect, @@ -859,6 +861,11 @@ private: std::atomic_bool isDisplayStatusBarTemporarily_ { false }; bool isStatusBarVisible_ = true; IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc_; + + /** + * Window MoveDrag + */ + std::optional clientDragEnable_; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 687b2b19f7..b6d5ada7d3 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5069,9 +5069,7 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag) return; } sessionProperty->SetDragEnabled(enableDrag); - if (session->sessionStage_) { - session->sessionStage_->SetEnableDragBySystem(enableDrag); - } + session->SetClientDragEnable(enableDrag); }; PostTask(task, __func__); return WMError::WM_OK; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index df8a87585e..3d5d54cb50 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1089,7 +1089,10 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetCompatibleWindowSizeInPc(sessionProperty->GetCompatibleInPcPortraitWidth(), sessionProperty->GetCompatibleInPcPortraitHeight(), sessionProperty->GetCompatibleInPcLandscapeWidth(), sessionProperty->GetCompatibleInPcLandscapeHeight()); - property->SetDragEnabled(sessionProperty->GetDragEnabled()); + std::optional clientDragEnable = GetClientDragEnable(); + if (clientDragEnable.has_value()) { + property->SetDragEnabled(clientDragEnable.value()); + } } if (sessionProperty && SessionHelper::IsMainWindow(GetWindowType())) { property->SetIsPcAppInPad(sessionProperty->GetIsPcAppInPad()); From e9e2a348f871afd2969bac191f5edf61cd762904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Thu, 14 Nov 2024 22:25:44 +0800 Subject: [PATCH 127/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E3=80=81=E5=87=BD=E6=95=B0=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- window_scene/session/host/include/extension_session.h | 2 +- window_scene/session/host/src/extension_session.cpp | 2 +- wm/include/window_session_impl.h | 6 +++++- wm/src/window_session_impl.cpp | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/include/extension_session.h b/window_scene/session/host/include/extension_session.h index a930779f2e..40dc677820 100644 --- a/window_scene/session/host/include/extension_session.h +++ b/window_scene/session/host/include/extension_session.h @@ -88,6 +88,7 @@ public: const std::string& identityToken = "") override; AvoidArea GetAvoidAreaByType(AvoidAreaType type) override; + int32_t GetStatusBarHeight() override; WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override; @@ -115,7 +116,6 @@ public: WSError Background(bool isFromClient = false, const std::string& identityToken = "") override; void NotifyExtensionEventAsync(uint32_t notifyEvent) override; WSError NotifyDumpInfo(const std::vector& params, std::vector& info); - int32_t GetStatusBarHeight() override; private: sptr extSessionEventCallback_ = nullptr; diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index eecf497f69..2a32bde39c 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -480,7 +480,7 @@ WSError ExtensionSession::NotifyDumpInfo(const std::vector& params, int32_t ExtensionSession::GetStatusBarHeight() { - TLOGI(WmsLogTag::WMS_UIEXT, "called, persistenId=%{public}d", GetPersistentId()); + TLOGI(WmsLogTag::WMS_UIEXT, "persistenId=%{public}d", GetPersistentId()); if (extSessionEventCallback_ != nullptr && extSessionEventCallback_->getStatusBarHeightFunc_ != nullptr) { return extSessionEventCallback_->getStatusBarHeightFunc_(); } diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 53c853ef09..22f61bccf5 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -300,6 +300,11 @@ public: windowSystemConfig_.freeMultiWindowEnable_ = enable; } + /* + * Window Immersive + */ + uint32_t GetStatusBarHeight() override; + protected: WMError Connect(); bool IsWindowSessionInvalid() const; @@ -351,7 +356,6 @@ protected: void RefreshNoInteractionTimeoutMonitor(); WindowStatus GetWindowStatusInner(WindowMode mode); - uint32_t GetStatusBarHeight() override; /** * Sub Window diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 68b74b7451..1345acdc52 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3946,7 +3946,7 @@ uint32_t WindowSessionImpl::GetStatusBarHeight() auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, height); height = static_cast(hostSession->GetStatusBarHeight()); - TLOGI(WmsLogTag::WMS_IMMS, "StatusBarVectorHeight is %{public}d", height); + TLOGI(WmsLogTag::WMS_IMMS, "StatusBarVectorHeight is %{public}u", height); return height; } From eb0684fa87b945843396a42ad0b4ca28d2675473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Thu, 14 Nov 2024 22:30:41 +0800 Subject: [PATCH 128/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- wm/include/window_session_impl.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 22f61bccf5..20cf7cf94c 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -300,11 +300,6 @@ public: windowSystemConfig_.freeMultiWindowEnable_ = enable; } - /* - * Window Immersive - */ - uint32_t GetStatusBarHeight() override; - protected: WMError Connect(); bool IsWindowSessionInvalid() const; @@ -431,6 +426,11 @@ protected: void UpdateVirtualPixelRatio(const sptr& display); WMError GetVirtualPixelRatio(float& vpr); + /* + * Window Immersive + */ + uint32_t GetStatusBarHeight() override; + private: //Trans between colorGamut and colorSpace static ColorSpace GetColorSpaceFromSurfaceGamut(GraphicColorGamut colorGamut); From 0e9fd32385547306fb1ae519cdff56d6640a3b9b Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 14:39:39 +0000 Subject: [PATCH 129/171] update window_scene/session_manager/include/scene_session_manager.h. Signed-off-by: ZihaoWU --- 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 e72d253ac3..eca297a080 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1054,7 +1054,7 @@ private: int32_t pid_ = 0; int32_t uid_ = 0; }; - std::vector lastDrawingSessionInfoVec_; + std::vector lastDrawingSessionInfoVec_; /** * PC Window From 9b323b47e4e9efabd6f5913a3083ec04d7a8b011 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 14 Nov 2024 14:40:35 +0000 Subject: [PATCH 130/171] update window_scene/session_manager/src/scene_session_manager.cpp. Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 9db6746736..c989cbfe06 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7887,7 +7887,7 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vectorpid_; uid = it->uid_; @@ -7899,7 +7899,7 @@ bool SceneSessionManager::GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& p void SceneSessionManager::RemoveSpecifiedDrawingData(uint64_t surfaceId) { auto it = std::find_if(lastDrawingSessionInfoVec_.begin(), lastDrawingSessionInfoVec_.end(), - [surfaceId](const DrawingSessionIdInfo& info) { return info.surfaceId_ == surfaceId; }); + [surfaceId](const DrawingSessionInfo& info) { return info.surfaceId_ == surfaceId; }); if (it != lastDrawingSessionInfoVec_.end()) { lastDrawingSessionInfoVec_.erase(it); } From 1e3a61569cea52271472469b8d12d17e0f9655a9 Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Thu, 14 Nov 2024 22:47:59 +0800 Subject: [PATCH 131/171] 2248 Signed-off-by: wangjiaqi --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 2af9fb6b18..df1d1df916 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -725,7 +725,7 @@ void SceneSession::RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimat auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); - return WSError::WS_ERROR_DESTROYED_OBJECT; + return; } session->onWindowAnimationFlagChange_ = std::move(callback); session->onWindowAnimationFlagChange_(session->IsNeedDefaultAnimation()); From 1346db969de015658a9813a021654de4bcc2b991 Mon Sep 17 00:00:00 2001 From: wangziyi Date: Thu, 14 Nov 2024 23:08:57 +0800 Subject: [PATCH 132/171] dragEnable fix Signed-off-by: wangziyi --- window_scene/session/host/include/scene_session.h | 7 ------- window_scene/session/host/include/session.h | 12 +++++++++++- window_scene/session/host/src/session.cpp | 8 ++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 17a09fc1a2..6f8adc353f 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -532,8 +532,6 @@ public: void SetTitleAndDockHoverShowChangeCallback(NotifyTitleAndDockHoverShowChangeFunc&& func); void SetRestoreMainWindowCallback(NotifyRestoreMainWindowFunc&& func); void SetWindowRectAutoSaveCallback(NotifySetWindowRectAutoSaveFunc&& func); - void SetClientDragEnable(bool dragEnable); - std::optional GetClientDragEnable() const; protected: void NotifySessionRectChange(const WSRect& rect, @@ -861,11 +859,6 @@ private: std::atomic_bool isDisplayStatusBarTemporarily_ { false }; bool isStatusBarVisible_ = true; IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc_; - - /** - * Window MoveDrag - */ - std::optional clientDragEnable_; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 5265b8faf8..a880245321 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -536,7 +536,11 @@ public: */ void ProcessClickModalWindowOutside(int32_t posX, int32_t posY); void SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFunc&& func); - + /** + * Window MoveDrag + */ + void SetClientDragEnable(bool dragEnable); + std::optional GetClientDragEnable() const; protected: class SessionLifeCycleTask : public virtual RefBase { public: @@ -823,6 +827,12 @@ private: bool enableRemoveStartingWindow_ { false }; bool appBufferReady_ { false }; bool useStartingWindowAboveLocked_ { false }; + + /** + * Window MoveDrag + */ + std::optional clientDragEnable_; + }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 3d5d54cb50..3a644411dc 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1371,6 +1371,14 @@ void Session::SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFu PostTask(task, __func__); } +void Session::SetClientDragEnable(bool dragEnable) { + clientDragEnable_ = dragEnable; +} + +std::optional Session::GetClientDragEnable() const { + return clientDragEnable_; +} + void Session::NotifyForegroundInteractiveStatus(bool interactive) { SetForegroundInteractiveStatus(interactive); From 4855dc3f87b5b66fbefb3d8355ea16dbea01e560 Mon Sep 17 00:00:00 2001 From: wangziyi Date: Thu, 14 Nov 2024 23:10:01 +0800 Subject: [PATCH 133/171] dragEnable fix Signed-off-by: wangziyi --- window_scene/session/host/include/session.h | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index a880245321..b2a37af2ef 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -536,6 +536,7 @@ public: */ void ProcessClickModalWindowOutside(int32_t posX, int32_t posY); void SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFunc&& func); + /** * Window MoveDrag */ From 1338f3a0f6eacff341c21ce82adfd0faf76d2889 Mon Sep 17 00:00:00 2001 From: rookiiie Date: Fri, 15 Nov 2024 00:00:29 +0800 Subject: [PATCH 134/171] =?UTF-8?q?=E5=A2=9E=E5=8A=A0UIExtension=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=9C=A8=E9=94=81=E5=B1=8F=E4=B9=8B=E4=B8=8A=E7=9A=84?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=AE=A1=E6=8E=A7=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: rookiiie --- .../common/include/session_permission.h | 1 + .../js_scene_session_manager.cpp | 47 +++++++ .../js_scene_session_manager.h | 2 + window_scene/session/BUILD.gn | 1 + .../session/host/include/scene_session.h | 25 ++++ window_scene/session/host/include/session.h | 2 + .../session/host/include/sub_session.h | 2 + .../host/include/zidl/session_interface.h | 2 +- .../include/zidl/session_ipc_interface_code.h | 1 + .../session/host/include/zidl/session_proxy.h | 1 + .../session/host/include/zidl/session_stub.h | 1 + .../session/host/src/scene_session.cpp | 121 ++++++++++++++++++ window_scene/session/host/src/session.cpp | 17 +++ window_scene/session/host/src/sub_session.cpp | 17 ++- .../session/host/src/zidl/session_proxy.cpp | 21 +++ .../session/host/src/zidl/session_stub.cpp | 9 ++ .../include/scene_session_manager.h | 11 +- .../include/scene_session_manager_lite.h | 2 + .../scene_session_manager_lite_interface.h | 1 + .../zidl/scene_session_manager_lite_proxy.h | 2 + .../zidl/scene_session_manager_lite_stub.h | 1 + .../src/scene_session_manager.cpp | 120 ++++++++++++++++- .../src/scene_session_manager_lite.cpp | 6 + .../zidl/scene_session_manager_lite_proxy.cpp | 53 ++++++++ .../zidl/scene_session_manager_lite_stub.cpp | 40 ++++++ .../scene_session_manager_lite_stub_test.cpp | 5 + .../zidl/window_manager_lite_interface.h | 2 + 27 files changed, 508 insertions(+), 5 deletions(-) diff --git a/window_scene/common/include/session_permission.h b/window_scene/common/include/session_permission.h index a2bc8b201b..ec7356301d 100644 --- a/window_scene/common/include/session_permission.h +++ b/window_scene/common/include/session_permission.h @@ -24,6 +24,7 @@ namespace PermissionConstants { constexpr const char* PERMISSION_MANAGE_MISSION = "ohos.permission.MANAGE_MISSIONS"; constexpr const char* PERMISSION_KILL_APP_PROCESS = "ohos.permission.KILL_APP_PROCESSES"; constexpr const char* PERMISSION_MAIN_WINDOW_TOPMOST = "ohos.permission.WINDOW_TOPMOST"; +constexpr const char* PERMISSION_CALLED_EXTENSION_ON_LOCK_SCREEN = "ohos.permission.CALLED_UIEXTENSION_ON_LOCK_SCREEN"; } class SessionPermission { public: 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 49f7aab886..cfe82984c3 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 @@ -224,6 +224,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::ResetPcFoldScreenArrangeRule); BindNativeFunction(env, exportObj, "setIsWindowRectAutoSave", moduleName, JsSceneSessionManager::SetIsWindowRectAutoSave); + BindNativeFunction(env, exportObj, "NotifyAboveLockScreen", moduleName, + JsSceneSessionManager::NotifyAboveLockScreen); return NapiGetUndefined(env); } @@ -1158,6 +1160,16 @@ napi_value JsSceneSessionManager::SetIsWindowRectAutoSave(napi_env env, napi_cal return (me != nullptr) ? me->OnSetIsWindowRectAutoSave(env, info) : nullptr; } +napi_value JsSceneSessionManager::NotifyAboveLockScreen(napi_env env, napi_callback_info info) +{ + JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); + if (me == nullptr) { + TLOGW(WmsLogTag::WMS_SCB, "me is null"); + return nullptr; + } + return me->OnNotifyAboveLockScreen(env, info); +} + 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()); @@ -3407,6 +3419,41 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback return result; } +napi_value JsSceneSessionManager::OnNotifyAboveLockScreen(napi_env env, napi_callback_info info) +{ + size_t argc = ARGC_FOUR; + napi_value argv[ARGC_FOUR] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != ARGC_ONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "[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); + } + + std::vector windowIds; + if (!ConvertInt32ArrayFromJs(env, argv[0], windowIds)) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to convert windowIds"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + + std::string windowIdListStr = "none"; + if (!windowIds.empty()) { + windowIdListStr = std::accumulate(windowIds.begin() + 1, + windowIds.end(), + std::to_string(windowIds[0]), + [](const std::string &str, int32_t windowId) { return str + "," + std::to_string(windowId); }); + } + + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: OnNotifyAboveLockScreen, window list: %{public}s", + windowIdListStr.c_str()); + SceneSessionManager::GetInstance().OnNotifyAboveLockScreen(windowIds); + return NapiGetUndefined(env); +} + napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info) { size_t argc = 4; 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 9129086125..507ed3680c 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 @@ -118,6 +118,7 @@ public: static napi_value UpdatePcFoldScreenStatus(napi_env env, napi_callback_info info); static napi_value ResetPcFoldScreenArrangeRule(napi_env env, napi_callback_info info); static napi_value SetIsWindowRectAutoSave(napi_env env, napi_callback_info info); + static napi_value NotifyAboveLockScreen(napi_env env, napi_callback_info info); /* * Multi instance @@ -194,6 +195,7 @@ private: napi_value OnUpdatePcFoldScreenStatus(napi_env env, napi_callback_info info); napi_value OnResetPcFoldScreenArrangeRule(napi_env env, napi_callback_info info); napi_value OnSetIsWindowRectAutoSave(napi_env env, napi_callback_info info); + napi_value OnNotifyAboveLockScreen(napi_env env, napi_callback_info info); /* * multi instance diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index ab5fddc6d9..fc445e0ce3 100644 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -79,6 +79,7 @@ ohos_shared_library("scene_session") { ] external_deps = [ + "ability_runtime:ability_manager", "ability_runtime:ability_start_setting", "ability_runtime:process_options", "ability_runtime:start_window_option", diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 6f8adc353f..691ed98a62 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -98,6 +98,12 @@ using NotifySetWindowRectAutoSaveFunc = std::function; class SceneSession : public Session { public: + struct UIExtensionTokenInfo { + bool canShowOnLockScreen{false}; + uint32_t callingTokenId{0}; + sptr abilityToken; + }; + friend class HidumpController; // callback for notify SceneSessionManager struct SpecificSessionCallback : public RefBase { @@ -409,6 +415,10 @@ public: * Window Visibility */ void SetNotifyVisibleChangeFunc(const NotifyVisibleChangeFunc& func); + virtual WSError HideSync() + { + return WSError::WS_DO_NOTHING; + }; /** * Window Lifecycle @@ -460,6 +470,15 @@ public: WSPropertyChangeAction action) override; void SetSessionChangeByActionNotifyManagerListener(const SessionChangeByActionNotifyManagerFunc& func); + /** + * UIExtension + */ + bool IsShowOnLockScreen(uint32_t lockScreenZOrder); + void AddExtensionTokenInfo(const SceneSession::UIExtensionTokenInfo &tokenInfo); + void RemoveExtensionTokenInfo(sptr abilityToken); + void CheckExtensionOnLockScreenToClose(); + void CloseExtensionSync(const SceneSession::UIExtensionTokenInfo& tokenInfo); + void OnNotifyAboveLockScreen(); void AddModalUIExtension(const ExtensionWindowEventInfo& extensionInfo); void RemoveModalUIExtension(int32_t persistentId); bool HasModalUIExtension(); @@ -766,10 +785,16 @@ private: std::atomic_bool isStartMoving_ { false }; std::atomic_bool isVisibleForAccessibility_ { true }; bool isSystemSpecificSession_ { false }; + + /** + * UIExtension + */ std::atomic_bool shouldHideNonSecureWindows_ { false }; std::shared_mutex combinedExtWindowFlagsMutex_; ExtensionWindowFlags combinedExtWindowFlags_ { 0 }; std::map extWindowFlagsMap_; + mutable std::recursive_mutex extensionTokenInfosMutex_; + std::vector extensionTokenInfos_; /** * Window Decor diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 5265b8faf8..cb0657f3cb 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -101,6 +101,7 @@ public: virtual void OnRemoveBlank() {} virtual void OnDrawingCompleted() {} virtual void OnExtensionDied() {} + virtual void OnExtensionDetachToDisplay() {} virtual void OnExtensionTimeout(int32_t errorCode) {} virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) {} @@ -167,6 +168,7 @@ public: void NotifyExtensionTimeout(int32_t errorCode) override; void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; + void NotifyExtensionDetachToDisplay() override; /** * Cross Display Move Drag diff --git a/window_scene/session/host/include/sub_session.h b/window_scene/session/host/include/sub_session.h index 387817034d..9362a1eee8 100644 --- a/window_scene/session/host/include/sub_session.h +++ b/window_scene/session/host/include/sub_session.h @@ -26,6 +26,8 @@ public: WSError Show(sptr property) override; WSError Hide() override; + WSError HideSync() override; + WSError Hide(bool needSyncHide); WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; int32_t GetMissionId() const override; WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index f274a68845..665d844279 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -273,7 +273,7 @@ public: virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; } virtual int32_t GetStatusBarHeight() { return 0; } virtual WSError SetDialogSessionBackGestureEnabled(bool isEnabled) { return WSError::WS_OK; } - + virtual void NotifyExtensionDetachToDisplay() {} /** * @brief Request to get focus or lose focus. * diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index b5769c12ca..ab155e6dbf 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -86,6 +86,7 @@ enum class SessionInterfaceCode { TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION, TRANS_ID_NOTIFY_EXTENSION_TIMEOUT, TRANS_ID_NOTIFY_EXTENSION_EVENT_ASYNC, + TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY, // PictureInPicture TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE = 800, diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index b0fa246ff3..3c02ebdac1 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -103,6 +103,7 @@ public: WMError SetSystemWindowEnableDrag(bool enableDrag) override; WSError RequestFocus(bool isFocused) override; void NotifyExtensionEventAsync(uint32_t notifyEvent) override; + void NotifyExtensionDetachToDisplay() override; WSError OnSessionModalTypeChange(SubWindowModalType subWindowModalType) override; WSError OnMainSessionModalTypeChange(bool isModal) override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 614f5501d5..272873ba78 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -98,6 +98,7 @@ private: int HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply); int HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply); int HandleNotifyExtensionEventAsync(MessageParcel& data, MessageParcel& reply); + int HandleNotifyExtensionDetachToDisplay(MessageParcel& data, MessageParcel& reply); // PictureInPicture int HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 687b2b19f7..16f46ff1bd 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -199,6 +199,127 @@ WSError SceneSession::ReconnectInner(sptr property) return ret; } +bool SceneSession::IsShowOnLockScreen(uint32_t lockScreenZorder) +{ + TLOGD(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: lockScreenZorder: %{public}d, zOrder_: %{public}d", + lockScreenZorder, + zOrder_); + + // must be default screen + ScreenId defaultScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); + auto sessionProperty = GetSessionProperty(); + if (sessionProperty != nullptr && defaultScreenId != sessionProperty->GetDisplayId()) { + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not default display"); + return false; + } + + if (!GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED)) { + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not in lock screen"); + return false; + } + + // current window on lock screen jurded by zorder + if (zOrder_ > lockScreenZorder) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: zOrder_ is bigger"); + return true; + } + + return false; +} + +void SceneSession::AddExtensionTokenInfo(const SceneSession::UIExtensionTokenInfo &tokenInfo) +{ + { + std::lock_guard lock(extensionTokenInfosMutex_); + extensionTokenInfos_.push_back(tokenInfo); + } + + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: canShowOnLockScreen: %{public}u, persistentId: %{public}u", + tokenInfo.canShowOnLockScreen, + GetPersistentId()); +} + +void SceneSession::RemoveExtensionTokenInfo(sptr abilityToken) +{ + std::lock_guard lock(extensionTokenInfosMutex_); + auto persistentId = GetPersistentId(); + auto itr = std::remove_if( + extensionTokenInfos_.begin(), extensionTokenInfos_.end(), [&abilityToken, persistentId](const auto &tokenInfo) { + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: need remove, calling token: %{public}u, persistentId: %{public}u", + tokenInfo.callingTokenId, + persistentId); + return tokenInfo.abilityToken == abilityToken; + }); + + extensionTokenInfos_.erase(itr, extensionTokenInfos_.end()); +} + +void SceneSession::OnNotifyAboveLockScreen() +{ + CheckExtensionOnLockScreenToClose(); +} + +void SceneSession::CheckExtensionOnLockScreenToClose() +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: %{public}u", GetPersistentId()); + + // 1. check sub session + for (auto session : GetSubSession()) { + if (!session) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: session is null"); + continue; + } + session->CheckExtensionOnLockScreenToClose(); + } + + // 2. check self permission + std::vector tokenInfosToClose; + { + std::lock_guard lock(extensionTokenInfosMutex_); + for (auto &tokenInfo : extensionTokenInfos_) { + if (tokenInfo.canShowOnLockScreen) { + continue; + } + tokenInfosToClose.push_back(tokenInfo); + } + } + + // 3. close ui extension without lock screen permisson + std::for_each(tokenInfosToClose.rbegin(), + tokenInfosToClose.rend(), + [this](SceneSession::UIExtensionTokenInfo &tokenInfo) { CloseExtensionSync(tokenInfo); }); +} + +void SceneSession::CloseExtensionSync(const SceneSession::UIExtensionTokenInfo &tokenInfo) +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock"); + + // hide sub window + auto subSceneSessions = GetSubSession(); + for (auto session : subSceneSessions) { + if (!session) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: session is null"); + continue; + } + // hide sub window of ui extension + if (session->GetAbilityToken() == tokenInfo.abilityToken) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: hide sub window %{public}u", session->GetWindowId()); + session->HideSync(); + } + } + + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: close ui extension, callerToken: %{public}u, persistent id %{public}u", + tokenInfo.callingTokenId, + GetPersistentId()); + + // kill ui extension ability + AAFwk::AbilityManagerClient::GetInstance()->CloseUIExtensionAbilityBySCB(tokenInfo.abilityToken); +} + WSError SceneSession::Foreground( sptr property, bool isFromClient, const std::string& identityToken) { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index df8a87585e..20d66ade6d 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -471,6 +471,23 @@ void Session::NotifyTransferAccessibilityEvent(const Accessibility::Accessibilit } } +void Session::NotifyExtensionDetachToDisplay() +{ + if (!SessionPermission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_UIEXT, "permission denied!"); + return; + } + + auto lifecycleListeners = GetListeners(); + for (auto &listener : lifecycleListeners) { + if (auto listenerPtr = listener.lock()) { + listenerPtr->OnExtensionDetachToDisplay(); + } + } + + TLOGI(WmsLogTag::WMS_UIEXT, "called"); +} + float Session::GetAspectRatio() const { return aspectRatio_; diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index 6b5b8e6b7e..73d8d98403 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -69,6 +69,16 @@ WSError SubSession::Show(sptr property) } WSError SubSession::Hide() +{ + return Hide(false); // async mode +} + +WSError SubSession::HideSync() +{ + return Hide(true); // sync mode +} + +WSError SubSession::Hide(bool needSyncHide) { if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -95,7 +105,12 @@ WSError SubSession::Hide() ret = session->SceneSession::Background(); return ret; }; - PostTask(task, "Hide"); + + if (needSyncHide) { + return PostSyncTask(task, "HideSync"); + } + + PostTask(task, "HideAsync"); return WSError::WS_OK; } diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 66676857ee..16ccb02566 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -1997,6 +1997,27 @@ void SessionProxy::NotifyExtensionEventAsync(uint32_t notifyEvent) } } +void SessionProxy::NotifyExtensionDetachToDisplay() +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: UIExtcalled"); + + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: WriteInterfaceToken failed"); + return; + } + + sptr remote = Remote(); + auto ret = remote->SendRequest( + static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY), data, reply, option); + if (ret != ERR_NONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: SendRequest failed"); + } +} + WMError SessionProxy::SetGestureBackEnabled(bool isEnabled) { MessageParcel data; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index f76cd619a8..782bb78442 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -222,6 +222,8 @@ int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleMainSessionModalTypeChange(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_SET_WINDOW_RECT_AUTO_SAVE): return HandleSetWindowRectAutoSave(data, reply); + case static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY): + return HandleNotifyExtensionDetachToDisplay(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -1202,6 +1204,13 @@ int SessionStub::HandleSetDialogSessionBackGestureEnabled(MessageParcel& data, M return ERR_NONE; } +int SessionStub::HandleNotifyExtensionDetachToDisplay(MessageParcel &data, MessageParcel &reply) +{ + TLOGD(WmsLogTag::WMS_UIEXT, "in"); + NotifyExtensionDetachToDisplay(); + return ERR_NONE; +} + int SessionStub::HandleRequestFocus(MessageParcel& data, MessageParcel& reply) { TLOGD(WmsLogTag::WMS_FOCUS, "in"); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 3e8ce53740..5b6b7a1962 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -352,7 +352,6 @@ public: void UpdateRecoveredSessionInfo(const std::vector& recoveredPersistentIds); void SetAlivePersistentIds(const std::vector& alivePersistentIds); void NotifyRecoveringFinished(); - WMError CheckWindowId(int32_t windowId, int32_t& pid) override; void GetSceneSessionPrivacyModeBundles(DisplayId displayId, std::unordered_set& privacyBundles); BrokerStates CheckIfReuseSession(SessionInfo& sessionInfo); @@ -404,6 +403,16 @@ public: int32_t StartUIAbilityBySCB(sptr& abilitySessionInfo); int32_t StartUIAbilityBySCB(sptr& sceneSessions); int32_t ChangeUIAbilityVisibilityBySCB(sptr& sceneSessions, bool visibility); + + /* + * UIExtension + */ + uint32_t GetLockScreenZorder(); + WMError CheckUIExtensionCreation(int32_t windowId, + uint32_t tokenId, + const AppExecFwk::ElementName& element, + int32_t& pid); + void OnNotifyAboveLockScreen(const std::vector& windowIds); void AddExtensionWindowStageToSCB(const sptr& sessionStage, const sptr& token, uint64_t surfaceNodeId) override; void RemoveExtensionWindowStageFromSCB(const sptr& sessionStage, diff --git a/window_scene/session_manager/include/scene_session_manager_lite.h b/window_scene/session_manager/include/scene_session_manager_lite.h index 86595e1d51..ebf5fb2183 100644 --- a/window_scene/session_manager/include/scene_session_manager_lite.h +++ b/window_scene/session_manager/include/scene_session_manager_lite.h @@ -58,6 +58,8 @@ public: WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; WMError CheckWindowId(int32_t windowId, int32_t& pid) override; + WMError CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) override; WMError GetVisibilityWindowInfo(std::vector>& infos) override; WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode); WMError GetWindowModeType(WindowModeType& windowModeType) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h index 8993e5054b..3da4176936 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h @@ -81,6 +81,7 @@ public: TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO, TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID, TRANS_ID_GET_ROOT_MAIN_WINDOW_ID, + TRANS_ID_UI_EXTENSION_CREATION_CHECK, }; virtual WSError SetSessionLabel(const sptr& token, const std::string& label) = 0; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h index 0b911bffe2..7530c72496 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h @@ -69,6 +69,8 @@ public: WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; WMError CheckWindowId(int32_t windowId, int32_t& pid) override; + WMError CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) override; WMError GetVisibilityWindowInfo(std::vector>& infos) override; WMError GetWindowModeType(WindowModeType& windowModeType) override; WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h index f0227efa40..4c50c17ebf 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h @@ -59,6 +59,7 @@ private: int HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply); int HandleUnregisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply); int HandleCheckWindowId(MessageParcel& data, MessageParcel& reply); + int HandleCheckUIExtensionCreation(MessageParcel& data, MessageParcel& reply); int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply); int HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply); int HandleGetMainWinodowInfo(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0aae64be35..090307abf3 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -183,6 +183,46 @@ bool GetEnableRemoveStartingWindowFromBMS(const std::shared_ptr> whitelist = { + std::make_tuple("com.huawei.hmos.settings", "AccessibilityReConfirmDialog", "phone_settings"), + std::make_tuple("com.huawei.hmos.settings", "AccessibilityShortKeyDialog", "phone_settings"), + std::make_tuple("com.huawei.hmos.settings", "DefaultIntentUiExtensionAbility", "phone_settings"), + std::make_tuple("com.ohos.sceneboard", "ScbIntentUIExtensionAbility", "phone_sceneboard"), + std::make_tuple("com.huawei.hmos.motiongesture", "IntentUIExtensionAbility", "entry"), + }; + + auto itr = std::find_if(whitelist.begin(), whitelist.end(), [element](const auto &item) { + auto [bundleName, abilityName, moduleName] = item; + if (element.GetBundleName() != bundleName) { + return false; + } + if (element.GetAbilityName() != abilityName) { + return false; + } + return true; + }); + + if (itr != whitelist.end()) { + return true; + } + + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not in white list"); + if (SessionPermission::VerifyPermissionByCallerToken( + callingTokenId, PermissionConstants::PERMISSION_CALLED_EXTENSION_ON_LOCK_SCREEN)) { + return true; + } + + return false; +} + class BundleStatusCallback : public IRemoteStub { public: BundleStatusCallback() = default; @@ -1422,6 +1462,71 @@ WMError SceneSessionManager::CheckWindowId(int32_t windowId, int32_t& pid) return taskScheduler_->PostSyncTask(task, "CheckWindowId:" + std::to_string(windowId)); } +uint32_t SceneSessionManager::GetLockScreenZorder() +{ + std::shared_lock lock(sceneSessionMapMutex_); + for (auto &[sessionId, session] : sceneSessionMap_) { + if (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: found window %{public}d: ", sessionId); + return session->GetZOrder(); + } + } + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not found"); + return 0; +} + +WMError SceneSessionManager::CheckUIExtensionCreation( + int32_t windowId, uint32_t callingTokenId, const AppExecFwk::ElementName &element, int32_t &pid) +{ + auto task = [this, windowId, &pid, &callingTokenId, element]() -> WMError { + pid = INVALID_PID; + auto sceneSession = GetSceneSession(windowId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: sceneSession(%{public}d) is nullptr", windowId); + return WMError::WM_ERROR_INVALID_WINDOW; + } + pid = sceneSession->GetCallingPid(); + + // 1. check window whether can show on main window + if (!sceneSession->IsShowOnLockScreen(GetLockScreenZorder())) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not called on lock screen"); + return WMError::WM_OK; + } + + // 2. check permission + if (!IsUIExtCanShowOnLockScreen(element, callingTokenId)) { + TLOGE(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: no permisson, window id %{public}d, %{public}d", + windowId, + callingTokenId); + return WMError::WM_ERROR_INVALID_PERMISSION; + } + + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: IsShowOnLockScreen: The caller permission has granted"); + return WMError::WM_OK; + }; + + std::stringstream ss; + ss << "UIExtOnLockCheck" + << "_" << windowId << "_" << callingTokenId; + return taskScheduler_->PostSyncTask(task, ss.str()); +} + +// windowIds are all main window +void SceneSessionManager::OnNotifyAboveLockScreen(const std::vector &windowIds) +{ + // check every window + for (auto windowId : windowIds) { + auto sceneSession = GetSceneSession(windowId); + if (!sceneSession) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: sesssion is null for %{public}d", windowId); + continue; + } + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: check for %{public}d", windowId); + sceneSession->OnNotifyAboveLockScreen(); + } +} + void SceneSessionManager::CreateKeyboardPanelSession(sptr keyboardSession) { if (!isKeyboardPanelEnabled_) { @@ -9895,7 +10000,9 @@ void SceneSessionManager::DestroyExtensionSession(const sptr& rem } int32_t persistentId = INVALID_SESSION_ID; int32_t parentId = INVALID_SESSION_ID; - if (!GetExtensionWindowIds(iter->second, persistentId, parentId)) { + + auto abilityToken = iter->second; + if (!GetExtensionWindowIds(abilityToken, persistentId, parentId)) { TLOGE(WmsLogTag::WMS_UIEXT, "Get UIExtension window ids by token failed"); return; } @@ -9917,6 +10024,7 @@ void SceneSessionManager::DestroyExtensionSession(const sptr& rem } sceneSession->RemoveModalUIExtension(persistentId); sceneSession->RemoveUIExtSurfaceNodeId(persistentId); + sceneSession->RemoveExtensionTokenInfo(abilityToken); } else { ExtensionWindowFlags actions; actions.SetAllActive(); @@ -9984,7 +10092,9 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr const sptr& token, uint64_t surfaceNodeId) { auto pid = IPCSkeleton::GetCallingRealPid(); - auto task = [this, sessionStage, token, surfaceNodeId, pid]() { + auto callingTokenId = IPCSkeleton::GetCallingTokenID(); + + auto task = [this, sessionStage, token, surfaceNodeId, pid, callingTokenId]() { if (sessionStage == nullptr || token == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr"); return; @@ -10031,6 +10141,12 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr }; parentSession->AddModalUIExtension(extensionInfo); } + + SceneSession::UIExtensionTokenInfo tokenInfo; + tokenInfo.abilityToken = token; + tokenInfo.callingTokenId = callingTokenId; + tokenInfo.canShowOnLockScreen = IsUIExtCanShowOnLockScreen(info.elementName, callingTokenId); + parentSession->AddExtensionTokenInfo(tokenInfo); }; taskScheduler_->PostAsyncTask(task, "AddExtensionWindowStageToSCB"); } diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index ffe4df864c..1992e85bc2 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -190,6 +190,12 @@ WMError SceneSessionManagerLite::CheckWindowId(int32_t windowId, int32_t& pid) return SceneSessionManager::GetInstance().CheckWindowId(windowId, pid); } +WMError SceneSessionManagerLite::CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) +{ + return SceneSessionManager::GetInstance().CheckUIExtensionCreation(windowId, tokenId, element, pid); +} + WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector>& infos) { return SceneSessionManager::GetInstance().GetVisibilityWindowInfo(infos); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index a311a5562d..27c1a76251 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -890,6 +890,59 @@ WMError SceneSessionManagerLiteProxy::CheckWindowId(int32_t windowId, int32_t& p return WMError::WM_OK; } +WMError SceneSessionManagerLiteProxy::CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write interfaceToken"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (!data.WriteInt32(windowId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write windowId"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteUint32(tokenId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write tokenId"); + return WMError::WM_ERROR_IPC_FAILED; + } + + data.WriteParcelable(&element); + + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write tokenId"); + return WMError::WM_ERROR_NULLPTR; + } + + int32_t ret = + remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UI_EXTENSION_CREATION_CHECK), + data, + reply, + option); + if (ret != ERR_NONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Send request failed, ret:%{public}d", ret); + return WMError::WM_ERROR_IPC_FAILED; + } + + int32_t errCode = 0; + if (!reply.ReadInt32(errCode)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to read errcode"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!reply.ReadInt32(pid)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to read pid"); + return WMError::WM_ERROR_IPC_FAILED; + } + + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: errcode %{public}u", errCode); + return static_cast(errCode); +} + WMError SceneSessionManagerLiteProxy::GetVisibilityWindowInfo(std::vector>& infos) { MessageParcel data; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index c233ee9ff4..19e5bfeffd 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -94,6 +94,8 @@ int SceneSessionManagerLiteStub::ProcessRemoteRequest(uint32_t code, MessageParc return HandleUnregisterWindowManagerAgent(data, reply); case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CHECK_WINDOW_ID): return HandleCheckWindowId(data, reply); + case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UI_EXTENSION_CREATION_CHECK): + return HandleCheckUIExtensionCreation(data, reply); case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID): return HandleGetVisibilityWindowInfo(data, reply); case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_MODE_TYPE): @@ -527,6 +529,44 @@ int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel& data, Messag return ERR_NONE; } +int SceneSessionManagerLiteStub::HandleCheckUIExtensionCreation(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: called"); + + int32_t windowId = INVALID_WINDOW_ID; + if (!data.ReadInt32(windowId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get windowId"); + return ERR_INVALID_DATA; + } + + uint32_t token = -1; + if (!data.ReadUint32(token)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get token"); + return ERR_INVALID_DATA; + } + + sptr element = data.ReadParcelable(); + if (!element) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get element"); + return ERR_INVALID_DATA; + } + + int32_t pid = INVALID_PID; + WMError errCode = CheckUIExtensionCreation(windowId, token, *element, pid); + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: ret %{public}u", errCode); + + if (!reply.WriteInt32(static_cast(errCode))) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write errcode"); + return ERR_INVALID_DATA; + } + + if (!reply.WriteInt32(pid)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write pid"); + return ERR_INVALID_DATA; + } + + return ERR_NONE; +} int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply) { diff --git a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp index 990b7f7993..70b71b72f0 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp @@ -198,6 +198,11 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { { return nullptr; } + WMError CheckUIExtensionCreation(int32_t windowId, uint32_t tokenId, + const AppExecFwk::ElementName& element, int32_t& pid) override + { + return WMError::WM_OK; + } }; class SceneSessionManagerLiteStubTest : public testing::Test { diff --git a/wmserver/include/zidl/window_manager_lite_interface.h b/wmserver/include/zidl/window_manager_lite_interface.h index 57b5c221a5..f6ddbe0ce8 100644 --- a/wmserver/include/zidl/window_manager_lite_interface.h +++ b/wmserver/include/zidl/window_manager_lite_interface.h @@ -40,6 +40,8 @@ public: virtual WMError GetVisibilityWindowInfo(std::vector>& infos) { return WMError::WM_OK; }; virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo) = 0; virtual WMError CheckWindowId(int32_t windowId, int32_t& pid) = 0; + virtual WMError CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) = 0; virtual WMError GetWindowModeType(WindowModeType& windowModeType) { return WMError::WM_OK; } virtual WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo) = 0; virtual WMError GetAllMainWindowInfos(std::vector& infos) = 0; From 76646b0b1445cae0cf83c71592d1ad65ea9db8a7 Mon Sep 17 00:00:00 2001 From: wangziyi Date: Fri, 15 Nov 2024 09:44:45 +0800 Subject: [PATCH 135/171] fix dragEnable Signed-off-by: wangziyi --- window_scene/session/host/include/session.h | 6 +++--- window_scene/session/host/src/session.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index b2a37af2ef..f4d0e623a5 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -538,10 +538,11 @@ public: void SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFunc&& func); /** - * Window MoveDrag + * Window Layout */ void SetClientDragEnable(bool dragEnable); std::optional GetClientDragEnable() const; + protected: class SessionLifeCycleTask : public virtual RefBase { public: @@ -830,10 +831,9 @@ private: bool useStartingWindowAboveLocked_ { false }; /** - * Window MoveDrag + * Window Layout */ std::optional clientDragEnable_; - }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 3a644411dc..03e613ce80 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1371,11 +1371,13 @@ void Session::SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFu PostTask(task, __func__); } -void Session::SetClientDragEnable(bool dragEnable) { +void Session::SetClientDragEnable(bool dragEnable) +{ clientDragEnable_ = dragEnable; } -std::optional Session::GetClientDragEnable() const { +std::optional Session::GetClientDragEnable() const +{ return clientDragEnable_; } From 46065f83562b8151614155fe0c740e217d90dbd9 Mon Sep 17 00:00:00 2001 From: kaicui Date: Fri, 15 Nov 2024 10:06:53 +0800 Subject: [PATCH 136/171] gn file format Signed-off-by: kaicui --- interfaces/kits/napi/extension_window/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/extension_window/BUILD.gn b/interfaces/kits/napi/extension_window/BUILD.gn index c4bcd5b7fa..6c92ac75cf 100644 --- a/interfaces/kits/napi/extension_window/BUILD.gn +++ b/interfaces/kits/napi/extension_window/BUILD.gn @@ -90,7 +90,7 @@ ohos_shared_library("extensionwindow_napi") { ":extension_window_kit_config", "../../../../resources/config/build:coverage_flags", ] - public_configs = [":extension_window_kit_config"] + public_configs = [ ":extension_window_kit_config" ] include_dirs = [ "extension_window" ] deps = [ From 664b3d637408ee4a840d497ecc9ae9bcdaad49b7 Mon Sep 17 00:00:00 2001 From: nzy Date: Fri, 15 Nov 2024 09:54:33 +0800 Subject: [PATCH 137/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nzy --- window_scene/session/host/include/session.h | 54 ++++++++++--------- window_scene/session/host/src/session.cpp | 20 +++---- .../src/scene_session_manager.cpp | 2 +- window_scene/test/unittest/session_test2.cpp | 1 - 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index eda4a86843..d9c0c210fb 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -133,6 +133,9 @@ public: void SetEventHandler(const std::shared_ptr& handler, const std::shared_ptr& exportHandler = nullptr); + /** + * Window LifeCycle + */ virtual WSError ConnectInner(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property = nullptr, sptr token = nullptr, @@ -149,9 +152,21 @@ public: WSError DrawingCompleted() override; void ResetSessionConnectState(); void ResetIsActive(); - + WSError PendingSessionToForeground(); + WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); bool RegisterLifecycleListener(const std::shared_ptr& listener); bool UnregisterLifecycleListener(const std::shared_ptr& listener); + void SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func); + void SetTerminateSessionListener(NotifyTerminateSessionFunc&& func); + void SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func); + void SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene); + void SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func); + void SetBackPressedListenser(NotifyBackPressedFunc&& func); + void SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func); + void SetPendingSessionToBackgroundForDelegatorListener(NotifyPendingSessionToBackgroundForDelegatorFunc&& func); + void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func); + WSError TerminateSessionNew(const sptr info, bool needStartCaller, bool isFromBroker); + WSError TerminateSessionTotal(const sptr info, TerminateType terminateType); /** * Callbacks for ILifecycleListener @@ -255,16 +270,8 @@ public: virtual bool IsExitSplitOnBackground() const; virtual bool NeedStartingWindowExitAnimation() const { return true; } - void SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func); void SetChangeSessionVisibilityWithStatusBarEventListener( const NotifyChangeSessionVisibilityWithStatusBarFunc& func); - void SetTerminateSessionListener(NotifyTerminateSessionFunc&& func); - WSError TerminateSessionNew(const sptr info, bool needStartCaller, bool isFromBroker); - void SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func); - void SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene); - void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func); - WSError TerminateSessionTotal(const sptr info, TerminateType terminateType); - void SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func); WSError Clear(bool needStartCaller = false); WSError SetSessionLabel(const std::string& label); void SetUpdateSessionLabelListener(const NofitySessionLabelUpdatedFunc& func); @@ -283,7 +290,6 @@ public: void SetSystemConfig(const SystemSessionConfig& systemConfig); void SetSnapshotScale(const float snapshotScale); - void SetBackPressedListenser(NotifyBackPressedFunc&& func); virtual WSError ProcessBackEvent(); // send back event to session_stage sptr GetScenePersistence() const; @@ -297,12 +303,6 @@ public: WSError NotifyDestroy(); WSError NotifyCloseExistPipWindow(); - void SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func); - WSError PendingSessionToForeground(); - void SetPendingSessionToBackgroundForDelegatorListener(NotifyPendingSessionToBackgroundForDelegatorFunc&& - func); - WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); - void SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func); void SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func); void SetClickListener(const NotifyClickFunc& func); @@ -618,7 +618,6 @@ protected: SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; NotifySessionRectChangeFunc sessionRectChangeFunc_; - NotifyPendingSessionActivationFunc pendingSessionActivationFunc_; NotifyChangeSessionVisibilityWithStatusBarFunc changeSessionVisibilityWithStatusBarFunc_; NotifySessionStateChangeFunc sessionStateChangeFunc_; NotifyBufferAvailableChangeFunc bufferAvailableChangeFunc_; @@ -629,20 +628,12 @@ protected: NotifyUIRequestFocusFunc requestFocusFunc_; NotifyUILostFocusFunc lostFocusFunc_; GetStateFromManagerFunc getStateFromManagerFunc_; - NotifyBackPressedFunc backPressedFunc_; NotifySessionFocusableChangeFunc sessionFocusableChangeFunc_; NotifySessionTouchableChangeFunc sessionTouchableChangeFunc_; NotifyClickFunc clickFunc_; - NotifyTerminateSessionFunc terminateSessionFunc_; - NotifyTerminateSessionFuncNew terminateSessionFuncNew_; - NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; NofitySessionLabelUpdatedFunc updateSessionLabelFunc_; NofitySessionIconUpdatedFunc updateSessionIconFunc_; - NotifySessionExceptionFunc sessionExceptionFunc_; - NotifySessionExceptionFunc jsSceneSessionExceptionFunc_; NotifySessionSnapshotFunc notifySessionSnapshotFunc_; - NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; - NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; NotifyRaiseToTopForPointDownFunc raiseToTopForPointDownFunc_; NotifySessionInfoLockedStateChangeFunc sessionInfoLockedStateChangeFunc_; NotifySystemSessionPointerEventFunc systemSessionPointerEventFunc_; @@ -651,6 +642,19 @@ protected: NotifyFrameLayoutFinishFunc frameLayoutFinishFunc_; VisibilityChangedDetectFunc visibilityChangedDetectFunc_; + /** + * Window LifeCycle + */ + NotifyPendingSessionActivationFunc pendingSessionActivationFunc_; + NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; + NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; + NotifyBackPressedFunc backPressedFunc_; + NotifyTerminateSessionFunc terminateSessionFunc_; + NotifyTerminateSessionFuncNew terminateSessionFuncNew_; + NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; + NotifySessionExceptionFunc sessionExceptionFunc_; + NotifySessionExceptionFunc jsSceneSessionExceptionFunc_; + /** * Window Rotate Animation */ diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 8180cd5411..9f837443c0 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1478,7 +1478,7 @@ void Session::SetPendingSessionActivationEventListener(NotifyPendingSessionActiv TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); return; } - session->pendingSessionActivationFunc_ = func; + session->pendingSessionActivationFunc_ = std::move(func); }; PostTask(task, where); } @@ -1492,7 +1492,7 @@ void Session::SetBackPressedListenser(NotifyBackPressedFunc&& func) TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); return; } - session->backPressedFunc_ = func; + session->backPressedFunc_ = std::move(func); }; PostTask(task, where); } @@ -1506,7 +1506,7 @@ void Session::SetTerminateSessionListener(NotifyTerminateSessionFunc&& func) TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); return; } - session->terminateSessionFunc_ = func; + session->terminateSessionFunc_ = std::move(func); }; PostTask(task, where); } @@ -1621,7 +1621,7 @@ void Session::SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& fun TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); return; } - session->terminateSessionFuncNew_ = func; + session->terminateSessionFuncNew_ = std::move(func); }; PostTask(task, where); } @@ -1662,7 +1662,7 @@ void Session::SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); return; } - session->terminateSessionFuncTotal_ = func; + session->terminateSessionFuncTotal_ = std::move(func); }; PostTask(task, where); } @@ -1730,9 +1730,9 @@ void Session::SetSessionExceptionListener(NotifySessionExceptionFunc&& func, boo return; } if (fromJsScene) { - session->jsSceneSessionExceptionFunc_ = func; + session->jsSceneSessionExceptionFunc_ = std::move(func); } else { - session->sessionExceptionFunc_ = func; + session->sessionExceptionFunc_ = std::move(func); } }; PostTask(task, where); @@ -1756,7 +1756,7 @@ void Session::SetPendingSessionToForegroundListener(NotifyPendingSessionToForegr TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); return; } - session->pendingSessionToForegroundFunc_ = func; + session->pendingSessionToForegroundFunc_ = std::move(func); }; PostTask(task, where); } @@ -1767,7 +1767,7 @@ WSError Session::PendingSessionToForeground() SessionInfo info = GetSessionInfo(); if (pendingSessionActivationFunc_) { pendingSessionActivationFunc_(info); - }; + } return WSError::WS_OK; } @@ -1781,7 +1781,7 @@ void Session::SetPendingSessionToBackgroundForDelegatorListener( TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); return; } - session->pendingSessionToBackgroundForDelegatorFunc_ = func; + session->pendingSessionToBackgroundForDelegatorFunc_ = std::move(func); }; PostTask(task, where); } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 07aa481146..c3ef1de7e7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4095,7 +4095,7 @@ void SceneSessionManager::RegisterSessionExceptionFunc(const sptr& TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s id: %{public}d is system", where, session->GetPersistentId()); return; } - TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s errorCode: %{public}d, id: %{public}d", + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s errorCode: %{public}d, id: %{public}d", where, info.errorCode, info.persistentId_); if (info.errorCode == static_cast(AAFwk::ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT) || info.errorCode == static_cast(AAFwk::ErrorLifecycleState::ABILITY_STATE_FOREGROUND_TIMEOUT)) { diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index 6a64c5a5cb..ac1f38421d 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -2019,7 +2019,6 @@ HWTEST_F(WindowSessionTest2, UpdateSizeChangeReason, Function | SmallTest | Leve HWTEST_F(WindowSessionTest2, SetPendingSessionActivationEventListener, Function | SmallTest | Level2) { int resultValue = 0; - sptr info = new (std::nothrow)AAFwk::SessionInfo(); session_->SetPendingSessionActivationEventListener([&resultValue](const SessionInfo& info) { resultValue = 1; }); From 565959883eb277ba4dd2a83f5725a106cc79562f Mon Sep 17 00:00:00 2001 From: wangziyi Date: Fri, 15 Nov 2024 10:58:06 +0800 Subject: [PATCH 138/171] fix dragEnable Signed-off-by: wangziyi --- window_scene/session/host/src/scene_session.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index b6d5ada7d3..737f28cfc8 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5061,6 +5061,7 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag) TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null"); return; } + session->SetClientDragEnable(enableDrag); TLOGNI(WmsLogTag::WMS_LAYOUT, "id: %{public}d, enableDrag: %{public}d", session->GetPersistentId(), enableDrag); auto sessionProperty = session->GetSessionProperty(); @@ -5069,7 +5070,9 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag) return; } sessionProperty->SetDragEnabled(enableDrag); - session->SetClientDragEnable(enableDrag); + if (session->sessionStage_) { + session->sessionStage_->SetEnableDragBySystem(enableDrag); + } }; PostTask(task, __func__); return WMError::WM_OK; From bf34e3b7689ccb0eef57cbe380a8fb2418b83686 Mon Sep 17 00:00:00 2001 From: Krishhu Date: Fri, 15 Nov 2024 11:47:43 +0800 Subject: [PATCH 139/171] =?UTF-8?q?ShwoDisplayIdList=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Krishhu --- dm/src/display_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index a437f5f7da..23e05ec22c 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -877,9 +877,9 @@ void DisplayManager::ShowDisplayIdList(bool isShowLog) oss << iter.second << ","; } if (isShowLog) { - WLOGFD("%{public}s]", oss.str().c_str()); - } else { WLOGFI("%{public}s]", oss.str().c_str()); + } else { + WLOGFD("%{public}s]", oss.str().c_str()); } } From eceecd2cabb9248f0763434567d763e4059092d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9C=89=E5=BA=B7?= Date: Thu, 7 Nov 2024 11:17:47 +0800 Subject: [PATCH 140/171] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张有康 --- .../kits/napi/screen_session_manager/BUILD.gn | 2 + .../js_screen_session.cpp | 42 +++++++++++++++++++ .../js_screen_session.h | 2 + wm/include/screen_scene.h | 8 +--- wm/src/screen_scene.cpp | 11 +++++ 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn index bc66263aa1..25dfba113a 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn @@ -43,8 +43,10 @@ ohos_shared_library("screensessionmanager_napi") { ] external_deps = [ + "ability_runtime:ability_context_native", "ability_runtime:app_manager", "ability_runtime:runtime", + "ace_engine:ace_uicontent", "c_utils:utils", "eventhandler:libeventhandler", "graphic_2d:librender_service_base", diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp index daae796415..6cbf7a8125 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "interfaces/include/ws_common.h" #include "js_screen_utils.h" @@ -68,6 +69,8 @@ napi_value JsScreenSession::Create(napi_env env, const sptr& scre BindNativeFunction(env, objValue, "setTouchEnabled", moduleName, JsScreenSession::SetTouchEnabled); BindNativeFunction(env, objValue, "loadContent", moduleName, JsScreenSession::LoadContent); + BindNativeFunction(env, objValue, "getScreenUIContext", moduleName, + JsScreenSession::GetScreenUIContext); return objValue; } @@ -322,6 +325,45 @@ napi_value JsScreenSession::OnRegisterCallback(napi_env env, napi_callback_info return NapiGetUndefined(env); } +napi_value JsScreenSession::GetScreenUIContext(napi_env env, napi_callback_info info) +{ + JsScreenSession* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetScreenUIContext(env, info) : nullptr; +} + +napi_value JsScreenSession::OnGetScreenUIContext(napi_env env, napi_callback_info info) +{ + WLOGI("[NAPI]OnGetScreenUIContext"); + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc > 0) { // 0: params num + WLOGFE("Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM))); + return NapiGetUndefined(env); + } + + if (screenScene_ == nullptr) { + WLOGFE("screenScene_ is nullptr"); + napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + return NapiGetUndefined(env); + } + const auto& uiContent = screenScene_->GetUIContent(); + if (uiContent == nullptr) { + WLOGFE("uiContent is nullptr"); + napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + return NapiGetUndefined(env); + } + napi_value uiContext = uiContent->GetUINapiContext(); + if (uiContext == nullptr) { + WLOGFE("uiContext obtained from jsEngine is nullptr"); + napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + return NapiGetUndefined(env); + } + WLOGI("success"); + return uiContext; +} + void JsScreenSession::CallJsCallback(const std::string& callbackType) { WLOGI("Call js callback: %{public}s.", callbackType.c_str()); diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h index 44f4b417ac..655d0c9867 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h @@ -43,6 +43,8 @@ private: napi_value OnSetScreenRotationLocked(napi_env env, napi_callback_info info); static napi_value SetTouchEnabled(napi_env env, napi_callback_info info); napi_value OnSetTouchEnabled(napi_env env, napi_callback_info info); + static napi_value GetScreenUIContext(napi_env env, napi_callback_info info); + napi_value OnGetScreenUIContext(napi_env env, napi_callback_info info); void CallJsCallback(const std::string& callbackType); void RegisterScreenChangeListener(); diff --git a/wm/include/screen_scene.h b/wm/include/screen_scene.h index ed76920c45..6e5b43650f 100644 --- a/wm/include/screen_scene.h +++ b/wm/include/screen_scene.h @@ -76,15 +76,11 @@ public: return 1; // 1 for root and screen } - Ace::UIContent* GetUIContent() const override - { - return uiContent_.get(); - } - + Ace::UIContent* GetUIContent() const override; WMError Destroy() override; private: - std::mutex mutex_; + mutable std::mutex mutex_; std::unique_ptr uiContent_; float density_ = 1.0f; int32_t orientation_; diff --git a/wm/src/screen_scene.cpp b/wm/src/screen_scene.cpp index 81b8cfb948..3ce873606f 100644 --- a/wm/src/screen_scene.cpp +++ b/wm/src/screen_scene.cpp @@ -201,5 +201,16 @@ void ScreenScene::SetDisplayOrientation(int32_t orientation) } orientation_ = orientation; } + +Ace::UIContent* ScreenScene::GetUIContent() const +{ + std::lock_guard lock(mutex_); + if (uiContent_) { + return uiContent_.get(); + } else { + TLOGE(WmsLogTag::DMS, "uiContent_ is nullptr!"); + return nullptr; + } +} } // namespace Rosen } // namespace OHOS From d6c8596905cc183f751c66b702c98c27de235379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9C=89=E5=BA=B7?= Date: Fri, 15 Nov 2024 14:12:16 +0800 Subject: [PATCH 141/171] fix code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张有康 --- .../screen_session_manager/src/screen_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 92efe42b9c..d3496b6a2b 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -4401,13 +4401,13 @@ std::shared_ptr ScreenSessionManager::GetDisplaySnapshotWithOpt HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetDisplaySnapshot(%" PRIu64")", option.displayId_); auto res = GetScreenSnapshot(option.displayId_); if (res != nullptr) { - NotifyScreenshot(option.displayId_); if (SessionPermission::IsBetaVersion()) { CheckAndSendHiSysEvent("GET_DISPLAY_SNAPSHOT", "hmos.screenshot"); } TLOGI(WmsLogTag::DMS, "isNeedNotify_:%{public}d", option.isNeedNotify_); if (option.isNeedNotify_) { isScreenShot_ = true; + NotifyScreenshot(option.displayId_); NotifyCaptureStatusChanged(); } } From 41205d6b5cc19d1982844ebe4ecf404fe4a3c6b8 Mon Sep 17 00:00:00 2001 From: kaicui Date: Fri, 15 Nov 2024 14:56:33 +0800 Subject: [PATCH 142/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=AE=8F=EF=BC=8C=E4=BC=98=E5=8C=96=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kaicui --- .../napi/extension_window/js_extension_window_listener.cpp | 6 +++--- .../napi/extension_window/js_extension_window_listener.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index dc02e21fa5..974c98fccf 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -135,7 +135,7 @@ void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason r HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::OnRectChange"); auto thisListener = self.promote(); if (thisListener == nullptr || env == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]This listener or env is nullptr"); + TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]This listener or env is nullptr"); return; } napi_handle_scope scope = nullptr; @@ -143,12 +143,12 @@ void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason r napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create js object"); + TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create js object"); return; } napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect); if (rectObjValue == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create rect js object"); + TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create rect js object"); return; } napi_set_named_property(env, objValue, "rect", rectObjValue); diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.h b/interfaces/kits/napi/extension_window/js_extension_window_listener.h index 0f9151eb16..0affae59d8 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.h @@ -59,7 +59,7 @@ public: void SetMainEventHandler(); private: - Rect currRect_ = {0, 0, 0, 0}; + Rect currRect_ = {}; RectChangeReason currentReason_ = RectChangeReason::UNDEFINED; napi_env env_ = nullptr; WindowState state_ {WindowState::STATE_INITIAL}; From bbcf0e679a27da3150113023830a84351c79e4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Fri, 15 Nov 2024 11:42:48 +0800 Subject: [PATCH 143/171] =?UTF-8?q?sizeChange=20log=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- .../window_napi/js_window_listener.cpp | 21 ++++++++++--------- wm/src/window_session_impl.cpp | 4 ++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index f3e538a7b2..5dd53afb74 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -73,18 +73,19 @@ napi_value JsWindowListener::CallJsMethod(const char* methodName, napi_value con void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction) { - WLOGI("[NAPI]OnSizeChange, wh[%{public}u, %{public}u], reason = %{public}u", rect.width_, rect.height_, reason); if (currRect_.width_ == rect.width_ && currRect_.height_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) { - WLOGFD("[NAPI]no need to change size"); + TLOGD(WmsLogTag::WMS_LAYOUT, "no need to change size"); return; } + TLOGI(WmsLogTag::WMS_LAYOUT, "wh[%{public}u, %{public}u], reason = %{public}u", + rect.width_, rect.height_, reason); // js callback should run in js thread - auto jsCallback = [self = weakRef_, rect, eng = env_] () { + auto jsCallback = [self = weakRef_, rect, eng = env_, funcName = __func__] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnSizeChange"); auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { - WLOGFE("[NAPI]this listener or eng is nullptr"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: this listener or eng is nullptr", funcName); return; } napi_handle_scope scope = nullptr; @@ -92,7 +93,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason, napi_value objValue = nullptr; napi_create_object(eng, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to convert rect to jsObject"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to convert rect to jsObject", funcName); napi_close_handle_scope(eng, scope); return; } @@ -106,7 +107,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason, jsCallback(); } else { if (!eventHandler_) { - WLOGFE("get main event handler failed!"); + TLOGE(WmsLogTag::WMS_LAYOUT, "get main event handler failed!"); return; } eventHandler_->PostTask(jsCallback, "wms:JsWindowListener::OnSizeChange", 0, @@ -524,11 +525,11 @@ void JsWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) rectChangReason = RectChangeReason::MOVE; } // js callback should run in js thread - auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_] () { + auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_, funcName = __func__] () { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnRectChange"); auto thisListener = self.promote(); if (thisListener == nullptr || env == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "this listener or env is nullptr"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: this listener or env is nullptr", funcName); return; } napi_handle_scope scope = nullptr; @@ -536,12 +537,12 @@ void JsWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create js object"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to create js object", funcName); return; } napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect); if (rectObjValue == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create rect js object"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to create rect js object", funcName); return; } napi_set_named_property(env, objValue, "rect", rectObjValue); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a609284dcb..766218d862 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -3046,6 +3046,8 @@ void WindowSessionImpl::NotifySizeChange(Rect rect, WindowSizeChangeReason reaso { std::lock_guard lockListener(windowChangeListenerMutex_); auto windowChangeListeners = GetListeners(); + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, sizeChange listenerSize:%{public}zu", + GetPersistentId(), windowChangeListeners.size()); for (auto& listener : windowChangeListeners) { if (listener != nullptr) { listener->OnSizeChange(rect, reason); @@ -3055,6 +3057,8 @@ void WindowSessionImpl::NotifySizeChange(Rect rect, WindowSizeChangeReason reaso { std::lock_guard lockRectListener(windowRectChangeListenerMutex_); auto windowRectChangeListeners = GetListeners(); + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, rectChange listenerSize:%{public}zu", + GetPersistentId(), windowRectChangeListeners.size()); for (auto& listener : windowRectChangeListeners) { if (listener != nullptr) { listener->OnRectChange(rect, reason); From cfb348dbf8b29066d3ebb7485323d303b9a18d09 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 15 Nov 2024 16:41:07 +0800 Subject: [PATCH 144/171] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 3 +-- .../src/scene_session_manager.cpp | 20 ++++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 3b74ded367..7142a5f574 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1059,11 +1059,10 @@ private: * Window Property */ struct DrawingSessionInfo { - uint64_t surfaceId_ = 0; int32_t pid_ = 0; int32_t uid_ = 0; }; - std::vector lastDrawingSessionInfoVec_; + std::unordered_map lastDrawingSessionInfoMap_; /** * PC Window diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5ea8cd9e62..c540a63e9d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8017,9 +8017,8 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vectorpid_; uid = it->uid_; return true; @@ -8029,10 +8028,9 @@ bool SceneSessionManager::GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& p void SceneSessionManager::RemoveSpecifiedDrawingData(uint64_t surfaceId) { - auto it = std::find_if(lastDrawingSessionInfoVec_.begin(), lastDrawingSessionInfoVec_.end(), - [surfaceId](const DrawingSessionInfo& info) { return info.surfaceId_ == surfaceId; }); - if (it != lastDrawingSessionInfoVec_.end()) { - lastDrawingSessionInfoVec_.erase(it); + auto it = lastDrawingSessionInfoMap_.find(surfaceId); + if (it != lastDrawingSessionInfoMap_.end()) { + lastDrawingSessionInfoMap_.erase(it); } } @@ -8042,11 +8040,10 @@ std::vector> SceneSessionManager::GetWindowDrawingCont std::vector> processDrawingContentChangeInfo; for (const auto& [surfaceId, isWindowDrawing] : currDrawingContentData) { int32_t pid = 0; - bool isPreWindowDrawing = GetPreWindowDrawingState(surfaceId, isWindowDrawing, pid); - bool isProcessDrawingStateChanged = GetProcessDrawingState(surfaceId, pid); sptr session = SelectSesssionFromMap(surfaceId); bool isDrawingStateChanged = - session == nullptr || (isPreWindowDrawing != isWindowDrawing && isProcessDrawingStateChanged); + session == nullptr || (GetPreWindowDrawingState(surfaceId, isWindowDrawing, pid) != isWindowDrawing && + GetProcessDrawingState(surfaceId, pid)); if (isDrawingStateChanged) { processDrawingContentChangeInfo.emplace_back(surfaceId, isWindowDrawing); } @@ -8069,8 +8066,7 @@ bool SceneSessionManager::GetPreWindowDrawingState(uint64_t surfaceId, bool curr void SceneSessionManager::UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid) { - RemoveSpecifiedDrawingData(surfaceId); - lastDrawingSessionInfoVec_.push_back({ surfaceId, pid, uid }); + lastDrawingSessionInfoMap_[surfaceId] = { pid, uid }; } bool SceneSessionManager::GetProcessDrawingState(uint64_t surfaceId, int32_t pid) From da2feebbcfb3d52c47986dccce7a975464089d19 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 15 Nov 2024 16:46:17 +0800 Subject: [PATCH 145/171] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c540a63e9d..0f613b59aa 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8019,8 +8019,8 @@ bool SceneSessionManager::GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& p { auto it = lastDrawingSessionInfoMap_.find(surfaceId); if (it != lastDrawingSessionInfoMap_.end()) { - pid = it->pid_; - uid = it->uid_; + pid = it->second.pid_; + uid = it->second.uid_; return true; } return false; From d5cc2c7604cc4a605aff081b1a050a00eb9c1513 Mon Sep 17 00:00:00 2001 From: tyh Date: Fri, 15 Nov 2024 17:10:22 +0800 Subject: [PATCH 146/171] repair_failed_tdd_1115 Signed-off-by: tyh --- .../unittest/session_listener_controller_test.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/session_listener_controller_test.cpp b/window_scene/test/unittest/session_listener_controller_test.cpp index 59145e3ad1..860b4fefc1 100644 --- a/window_scene/test/unittest/session_listener_controller_test.cpp +++ b/window_scene/test/unittest/session_listener_controller_test.cpp @@ -368,6 +368,8 @@ HWTEST_F(SessionListenerControllerTest, OnListenerDied, Function | SmallTest | L */ HWTEST_F(SessionListenerControllerTest, NotifySessionIconChanged, Function | SmallTest | Level2) { +#ifndef SUPPORT_GRAPHICS +#define SUPPORT_GRAPHICS int32_t persistentId = -1; int32_t pixelMapWidth = 4; @@ -380,10 +382,20 @@ HWTEST_F(SessionListenerControllerTest, NotifySessionIconChanged, Function | Sma pixelMap->SetImageInfo(info); std::shared_ptr icon = std::move(pixelMap); slController->NotifySessionIconChanged(persistentId, icon); + sptr myListener = new MyMissionListener(); + EXPECT_NE(myListener, nullptr); + bool res = myListener->IsMissionIconUpdated(); + EXPECT_EQ(res, false); persistentId = 1; + sptr listener = new MyMissionListener(); + EXPECT_NE(listener, nullptr); + slController->sessionListeners_.push_back(listener); slController->NotifySessionIconChanged(persistentId, icon); - ASSERT_EQ(persistentId, 1); + res = myListener->IsMissionIconUpdated(); + EXPECT_EQ(res, true); + slController->sessionListeners_.clear(); +#endif } /** From fed1a3c9d471205af69738caa030efa1798a4332 Mon Sep 17 00:00:00 2001 From: z00899566 Date: Fri, 15 Nov 2024 17:10:30 +0800 Subject: [PATCH 147/171] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=A6=E6=8E=A7?= =?UTF-8?q?=E6=94=BF=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z00899566 --- .../super_fold_state_manager.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp index 2228937c0d..97b96af9b2 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp @@ -24,6 +24,14 @@ namespace Rosen { WM_IMPLEMENT_SINGLE_INSTANCE(SuperFoldStateManager) +namespace { +#ifdef TP_FEATURE_ENABLE +const int32_t TP_TYPE = 12; +const char* KEYBOARD_ON_CONFIG = "version:3+main"; +const char* KEYBOARD_OFF_CONFIG = "version:3+whole"; +#endif +} + void SuperFoldStateManager::DoAngleChangeFolded(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeFolded()"); @@ -60,6 +68,10 @@ void SuperFoldStateManager::DoKeyboardOn(SuperFoldStatusChangeEvents event) // SCREEN_ID_FULL = 0 auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(true); +#ifdef TP_FEATURE_ENABLE + RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE, + KEYBOARD_ON_CONFIG, TpFeatureConfigType::AFT_TP_FEATURE); +#endif TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld", screenWidth, screenHeight, static_cast(response)); } @@ -85,6 +97,10 @@ void SuperFoldStateManager::DoKeyboardOff(SuperFoldStatusChangeEvents event) // SCREEN_ID_FULL = 0 auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(false); +#ifdef TP_FEATURE_ENABLE + RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE, + KEYBOARD_OFF_CONFIG, TpFeatureConfigType::DEFAULT_TP_FEATURE); +#endif TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld", screenWidth, screenHeight, static_cast(response)); } From a2044dcfaaac743c08b1e1696a0b8d7cf201e0cb Mon Sep 17 00:00:00 2001 From: kaicui Date: Fri, 15 Nov 2024 17:13:56 +0800 Subject: [PATCH 148/171] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81=E5=81=9A=E5=AF=B9=E5=BA=94=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kaicui --- .../js_extension_window_listener.cpp | 22 +++++++++---------- .../js_extension_window_listener.h | 8 +++---- .../js_extension_window_register_manager.cpp | 4 ++-- .../js_extension_window_register_manager.h | 4 ++-- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index 974c98fccf..e19a148d2c 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -116,30 +116,29 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r currRect_ = rect; } -void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) +void JsExtensionWindowListener::OnRectChange(const Rect& rect, WindowSizeChangeReason reason) { if (currRect_ == rect && reason == WindowSizeChangeReason::UNDEFINED) { TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]Skip redundant rect update"); return; } - RectChangeReason rectChangReason = RectChangeReason::UNDEFINED; + RectChangeReason rectChangeReason = RectChangeReason::UNDEFINED; if (JS_SIZE_CHANGE_REASON.count(reason) != 0 && !(reason == WindowSizeChangeReason::MAXIMIZE && rect.posX_ != 0)) { - rectChangReason = JS_SIZE_CHANGE_REASON.at(reason); + rectChangeReason = JS_SIZE_CHANGE_REASON.at(reason); } - if (currentReason_ != RectChangeReason::DRAG && rectChangReason == RectChangeReason::DRAG_END) { - rectChangReason = RectChangeReason::MOVE; + if (currentRectChangeReason_ != RectChangeReason::DRAG && rectChangeReason == RectChangeReason::DRAG_END) { + rectChangeReason = RectChangeReason::MOVE; } // js callback should run in js thread - auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_] () { + auto jsCallback = [self = weakRef_, rect, rectChangeReason, env = env_] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::OnRectChange"); auto thisListener = self.promote(); if (thisListener == nullptr || env == nullptr) { TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]This listener or env is nullptr"); return; } - napi_handle_scope scope = nullptr; - napi_open_handle_scope(env, &scope); + HandleScope handleScope(env); napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { @@ -152,10 +151,9 @@ void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason r return; } napi_set_named_property(env, objValue, "rect", rectObjValue); - napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangReason)); - napi_value argv[] = {objValue}; + napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangeReason)); + napi_value argv[] = { objValue }; thisListener->CallJsMethod(WINDOW_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv)); - napi_close_handle_scope(env, scope); }; if (!eventHandler_) { TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!"); @@ -164,7 +162,7 @@ void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason r eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnRectChange", 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); currRect_ = rect; - currentReason_ = rectChangReason; + currentRectChangeReason_ = rectChangeReason; } void JsExtensionWindowListener::OnModeChange(WindowMode mode, bool hasDeco) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.h b/interfaces/kits/napi/extension_window/js_extension_window_listener.h index 0affae59d8..65fd5083b5 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.h @@ -26,8 +26,8 @@ #include "window.h" #include "window_manager.h" #include "wm_common.h" -#include "js_window_utils.h" #include "js_extension_window_utils.h" +#include "js_window_utils.h" namespace OHOS { namespace Rosen { @@ -43,7 +43,7 @@ public: ~JsExtensionWindowListener(); void OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; - void OnRectChange(Rect rect, WindowSizeChangeReason reason) override; + void OnRectChange(const Rect& rect, WindowSizeChangeReason reason) override; void OnModeChange(WindowMode mode, bool hasDeco) override; void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; void AfterForeground() override; @@ -59,8 +59,8 @@ public: void SetMainEventHandler(); private: - Rect currRect_ = {}; - RectChangeReason currentReason_ = RectChangeReason::UNDEFINED; + Rect currRect_; + RectChangeReason currentRectChangeReason_ = RectChangeReason::UNDEFINED; napi_env env_ = nullptr; WindowState state_ {WindowState::STATE_INITIAL}; std::shared_ptr jsCallBack_; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp index c0510dd45b..f406003ef8 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp @@ -63,8 +63,8 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, - sptr window, bool isRegister) +WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowRectChangeRegister(const sptr& listener, + const sptr& window, bool isRegister) { if (window == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h index 428f4be6ea..dfe442d1b3 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h @@ -48,8 +48,8 @@ private: bool IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject); WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessWindowRectChangeRegister(sptr listener, - sptr window, bool isRegister); + WmErrorCode ProcessWindowRectChangeRegister(const sptr& listener, + const sptr& window, bool isRegister); WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister); WmErrorCode ProcessLifeCycleEventRegister(sptr listener, From edba45cce927e79363471f08f37794d4132ed112 Mon Sep 17 00:00:00 2001 From: yu Date: Fri, 15 Nov 2024 09:14:02 +0000 Subject: [PATCH 149/171] bugfix throw-slip Signed-off-by: yu Change-Id: I9d14d390a933767ed319a76c6fb5b5ccf43608e5 --- .../js_scene_session_manager.cpp | 2 +- .../host/include/pc_fold_screen_controller.h | 15 ++++----------- .../session/host/include/scene_session.h | 1 + .../host/src/pc_fold_screen_controller.cpp | 14 +++++++++++--- .../session/host/src/scene_session.cpp | 19 ++++++++++++++++--- 5 files changed, 33 insertions(+), 18 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 19a3d0e3a1..aedfc62631 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 @@ -3635,7 +3635,7 @@ napi_value JsSceneSessionManager::OnUpdatePcFoldScreenStatus(napi_env env, napi_ "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - ScreenFoldStatus status = static_cast(statusNum); + SuperFoldStatus status = static_cast(statusNum); WSRect defaultDisplayRect; if (argv[ARG_INDEX_TWO] == nullptr || !ConvertRectInfoFromJs(env, argv[ARG_INDEX_TWO], defaultDisplayRect)) { diff --git a/window_scene/session/host/include/pc_fold_screen_controller.h b/window_scene/session/host/include/pc_fold_screen_controller.h index 772931bcc9..d5efbd8ab9 100755 --- a/window_scene/session/host/include/pc_fold_screen_controller.h +++ b/window_scene/session/host/include/pc_fold_screen_controller.h @@ -34,14 +34,6 @@ class SceneSession; using RectRecordsVector = std::vector, WSRect>>; -enum class ScreenFoldStatus : uint8_t { - UNKNOWN = 0, - EXPANDED = 1, - FOLDED = 2, - HALF_FOLDED = 3, - HALF_FOLDED_KEYBOARD = 4, -}; - enum class ScreenSide : uint8_t { EXPAND = 0, FOLD_B = 1, @@ -51,7 +43,7 @@ enum class ScreenSide : uint8_t { class PcFoldScreenManager { WM_DECLARE_SINGLE_INSTANCE(PcFoldScreenManager); public: - void UpdateFoldScreenStatus(DisplayId displayId, ScreenFoldStatus status, + void UpdateFoldScreenStatus(DisplayId displayId, SuperFoldStatus status, const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect); bool IsHalfFolded(DisplayId displayId); @@ -85,7 +77,7 @@ public: const WSRect& limitRect, int32_t titleHeight); private: - void SetDisplayInfo(DisplayId displayId, ScreenFoldStatus status); + void SetDisplayInfo(DisplayId displayId, SuperFoldStatus status); void SetDisplayRects( const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect); float GetVpr(); @@ -97,7 +89,7 @@ private: std::shared_mutex displayInfoMutex_; // protect display infos DisplayId displayId_ { SCREEN_ID_INVALID }; float vpr_ { 1.5f }; // display vp ratio - ScreenFoldStatus screenFoldStatus_ { ScreenFoldStatus::UNKNOWN }; + SuperFoldStatus screenFoldStatus_ { SuperFoldStatus::UNKNOWN }; std::shared_mutex rectsMutex_; // protect rects WSRect defaultDisplayRect_; WSRect virtualDisplayRect_; @@ -117,6 +109,7 @@ class PcFoldScreenController : public RefBase { public: explicit PcFoldScreenController(wptr weakSession); bool IsHalfFolded(DisplayId displayId); + bool NeedFollowHandAnimation(); void RecordStartMoveRect(const WSRect& rect, bool isStartFullScreen); void RecordMoveRects(const WSRect& rect); bool ThrowSlip(DisplayId displayId, WSRect& rect, int32_t topAvoidHeight, int32_t botAvoidHeight); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 0e68efc0eb..bcf8ade48c 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -628,6 +628,7 @@ protected: * PC Fold Screen */ sptr pcFoldScreenController_ = nullptr; + std::atomic_bool throwSlipFullScreenFlag_ = false; /** * PC Window diff --git a/window_scene/session/host/src/pc_fold_screen_controller.cpp b/window_scene/session/host/src/pc_fold_screen_controller.cpp index d6cc439268..ac25929b49 100755 --- a/window_scene/session/host/src/pc_fold_screen_controller.cpp +++ b/window_scene/session/host/src/pc_fold_screen_controller.cpp @@ -14,6 +14,7 @@ */ #include "session/host/include/pc_fold_screen_controller.h" +#include #include "display_manager.h" #include "session/host/include/scene_session.h" #include "window_manager_hilog.h" @@ -50,14 +51,14 @@ const WSRect RECT_ZERO = { 0, 0, 0, 0 }; WM_IMPLEMENT_SINGLE_INSTANCE(PcFoldScreenManager); -void PcFoldScreenManager::UpdateFoldScreenStatus(DisplayId displayId, ScreenFoldStatus status, +void PcFoldScreenManager::UpdateFoldScreenStatus(DisplayId displayId, SuperFoldStatus status, const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect) { SetDisplayInfo(displayId, status); SetDisplayRects(defaultDisplayRect, virtualDisplayRect, foldCreaseRect); } -void PcFoldScreenManager::SetDisplayInfo(DisplayId displayId, ScreenFoldStatus status) +void PcFoldScreenManager::SetDisplayInfo(DisplayId displayId, SuperFoldStatus status) { std::unique_lock lock(displayInfoMutex_); if (displayId_ == displayId && screenFoldStatus_ == status) { @@ -89,7 +90,7 @@ void PcFoldScreenManager::SetDisplayRects( bool PcFoldScreenManager::IsHalfFolded(DisplayId displayId) { std::shared_lock lock(displayInfoMutex_); - return screenFoldStatus_ == ScreenFoldStatus::HALF_FOLDED && displayId_ == displayId; + return screenFoldStatus_ == SuperFoldStatus::HALF_FOLDED && displayId_ == displayId; } float PcFoldScreenManager::GetVpr() @@ -348,6 +349,13 @@ bool PcFoldScreenController::IsHalfFolded(DisplayId displayId) return PcFoldScreenManager::GetInstance().IsHalfFolded(displayId); } +bool PcFoldScreenController::NeedFollowHandAnimation() +{ + static bool needFollowHandAnimation = + system::GetParameter("persist.window.throw_slip_follow_animation.enabled", "0") == "1"; + return needFollowHandAnimation; +} + void PcFoldScreenController::RecordStartMoveRect(const WSRect& rect, bool isStartFullScreen) { TLOGI(WmsLogTag::WMS_LAYOUT, "rect: %{public}s, isStartFullScreen: %{public}d", diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 4fcb0e4290..af0b82af6d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2643,10 +2643,15 @@ void SceneSession::InitializeCrossMoveDrag() void SceneSession::HandleMoveDragSurfaceBounds(WSRect& rect, WSRect& globalRect, SizeChangeReason reason, bool isGlobal, bool needFlush) { + throwSlipFullScreenFlag_.store(false); if (pcFoldScreenController_ && pcFoldScreenController_->IsHalfFolded(GetScreenId())) { - auto movingPair = std::make_pair(pcFoldScreenController_->GetMovingTimingProtocol(), - pcFoldScreenController_->GetMovingTimingCurve()); - SetSurfaceBoundsWithAnimation(movingPair, globalRect, nullptr, isGlobal, needFlush); + if (pcFoldScreenController_->NeedFollowHandAnimation()) { + auto movingPair = std::make_pair(pcFoldScreenController_->GetMovingTimingProtocol(), + pcFoldScreenController_->GetMovingTimingCurve()); + SetSurfaceBoundsWithAnimation(movingPair, globalRect, nullptr, isGlobal, needFlush); + } else { + SetSurfaceBounds(globalRect, isGlobal, needFlush); + } if (reason == SizeChangeReason::MOVE) { pcFoldScreenController_->RecordMoveRects(rect); } @@ -2730,6 +2735,14 @@ bool SceneSession::MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeR TLOGNW(WmsLogTag::WMS_LAYOUT, "session is nullptr"); return; } + if (!session->IsVisibleForeground()) { + TLOGNW(WmsLogTag::WMS_LAYOUT, "session go background when throw"); + return; + } + if (!session->throwSlipFullScreenFlag_.load()) { + TLOGNW(WmsLogTag::WMS_LAYOUT, "session moved when throw"); + return; + } session->OnSessionEvent(SessionEvent::EVENT_MAXIMIZE_WITHOUT_ANIMATION, SessionEventParam {rect.posX_, rect.posY_, rect.width_, rect.height_}); }; From 09e4fa5a0338f43514ace36c5a6df8912742b8dc Mon Sep 17 00:00:00 2001 From: kaicui Date: Fri, 15 Nov 2024 17:29:13 +0800 Subject: [PATCH 150/171] =?UTF-8?q?=E4=BF=AE=E6=94=B9OnRectChange=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=85=A5=E5=8F=82rect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kaicui --- .../kits/napi/extension_window/js_extension_window_listener.cpp | 2 +- .../kits/napi/extension_window/js_extension_window_listener.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index e19a148d2c..828183888a 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -116,7 +116,7 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r currRect_ = rect; } -void JsExtensionWindowListener::OnRectChange(const Rect& rect, WindowSizeChangeReason reason) +void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) { if (currRect_ == rect && reason == WindowSizeChangeReason::UNDEFINED) { TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]Skip redundant rect update"); diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.h b/interfaces/kits/napi/extension_window/js_extension_window_listener.h index 65fd5083b5..757dae4c21 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.h @@ -43,7 +43,7 @@ public: ~JsExtensionWindowListener(); void OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; - void OnRectChange(const Rect& rect, WindowSizeChangeReason reason) override; + void OnRectChange(Rect rect, WindowSizeChangeReason reason) override; void OnModeChange(WindowMode mode, bool hasDeco) override; void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; void AfterForeground() override; From cf6989c1fb559ffec02d7379d877db4d14a7fda1 Mon Sep 17 00:00:00 2001 From: rsyys Date: Fri, 15 Nov 2024 17:34:08 +0800 Subject: [PATCH 151/171] fix: remove const Signed-off-by: rsyys --- utils/include/window_visibility_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/include/window_visibility_info.h b/utils/include/window_visibility_info.h index 937ba3565e..3cd8a8d253 100644 --- a/utils/include/window_visibility_info.h +++ b/utils/include/window_visibility_info.h @@ -71,7 +71,7 @@ public: WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState, WindowType winType, WindowStatus windowStatus, const Rect& rect, const std::string& bundleName, - const std::string& abilityName, const bool isFocused) : windowId_(winId), pid_(pid), uid_(uid), + const std::string& abilityName, bool isFocused) : windowId_(winId), pid_(pid), uid_(uid), visibilityState_(visibilityState), windowType_(winType), windowStatus_(windowStatus), rect_(rect), bundleName_(bundleName), abilityName_(abilityName), isFocused_(isFocused) {} From f57b6ee507aab20e168a0b2974bacf2033258ce5 Mon Sep 17 00:00:00 2001 From: meikun4 Date: Thu, 7 Nov 2024 20:44:34 +0800 Subject: [PATCH 152/171] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtdd=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun4 --- wm/src/window_scene_session_impl.cpp | 2 +- wm/test/unittest/window_scene_session_impl_test3.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index fd251ba010..1ae2b3ae4c 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2158,7 +2158,7 @@ WMError WindowSceneSessionImpl::SetFullScreen(bool status) } if (WindowHelper::IsMainWindow(GetType()) && - (IsFreeMultiWindowMode() || (!windowSystemConfig_.IsPhoneWindow() && !windowSystemConfig_.IsPadWindow()))) { + (IsFreeMultiWindowMode() || windowSystemConfig_.IsPcWindow())) { if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported"); return WMError::WM_ERROR_INVALID_WINDOW; diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index dee1f26b63..1c1385cb30 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -193,7 +193,7 @@ HWTEST_F(WindowSceneSessionImplTest3, UpdateTitleInTargetPos, Function | SmallTe EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); ret = windowSceneSessionImpl->UpdateTitleInTargetPos(false, 0); EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); - windowSceneSessionImpl->windowSessionMap_.clear(); + windowSceneSessionImpl->windowSessionMap_.erase(windowSceneSessionImpl->GetWindowName()); } /** From f54d17748af35a9858cd314744a5a72200b94c97 Mon Sep 17 00:00:00 2001 From: whqwe Date: Fri, 15 Nov 2024 17:43:40 +0800 Subject: [PATCH 153/171] fix: reduce ssm logs Signed-off-by: whqwe --- .../src/scene_session_manager.cpp | 225 +++++++++--------- 1 file changed, 106 insertions(+), 119 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5ea8cd9e62..165ee6d99e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -440,7 +440,7 @@ void SceneSessionManager::InitPrepareTerminateConfig() char value[PREPARE_TERMINATE_ENABLE_SIZE] = "false"; int32_t retSysParam = GetParameter(PREPARE_TERMINATE_ENABLE_PARAMETER, "false", value, PREPARE_TERMINATE_ENABLE_SIZE); - WLOGFI("InitPrepareTerminateConfig, %{public}s value is %{public}s.", PREPARE_TERMINATE_ENABLE_PARAMETER, value); + WLOGFI("%{public}s value is %{public}s.", PREPARE_TERMINATE_ENABLE_PARAMETER, value); if (retSysParam > 0 && !std::strcmp(value, "true")) { isPrepareTerminateEnable_ = true; } @@ -461,7 +461,7 @@ void SceneSessionManager::ConfigWindowSceneXml() item = config["backgroundswitch"]; int32_t param = -1; systemConfig_.backgroundswitch = GetSingleIntItem(item, param) && param == 1; - WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); + WLOGFD("Load backgroundswitch %{public}d", systemConfig_.backgroundswitch); item = config["defaultWindowMode"]; if (GetSingleIntItem(item, param) && (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || @@ -652,7 +652,7 @@ WSError SceneSessionManager::GetFreeMultiWindowEnableState(bool& enable) WSError SceneSessionManager::SetSessionContinueState(const sptr& token, const ContinueState& continueState) { - TLOGI(WmsLogTag::DEFAULT, "Enter"); + TLOGI(WmsLogTag::DEFAULT, "in"); int32_t callingUid = IPCSkeleton::GetCallingUid(); auto task = [this, token, continueState, callingUid]() { sptr sceneSession = FindSessionByToken(token); @@ -764,7 +764,7 @@ void SceneSessionManager::ConfigWindowEffect(const WindowSceneConfig::ConfigItem AddAlphaToColor(appWindowSceneConfig_.focusedShadow_.alpha_, appWindowSceneConfig_.focusedShadow_.color_); AddAlphaToColor(appWindowSceneConfig_.unfocusedShadow_.alpha_, appWindowSceneConfig_.unfocusedShadow_.color_); - WLOGFI("Config window effect successfully"); + WLOGFI("successfully"); } bool SceneSessionManager::ConfigAppWindowCornerRadius(const WindowSceneConfig::ConfigItem& item, float& out) @@ -822,7 +822,7 @@ void SceneSessionManager::ClearUnrecoveredSessions(const std::vector& r void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& recoveredPersistentIds) { - TLOGI(WmsLogTag::WMS_RECOVER, "Number of persistentIds recovered = %{public}zu. CurrentUserId = %{public}d", + TLOGI(WmsLogTag::WMS_RECOVER, "persistentIds recovered = %{public}zu. CurrentUserId = %{public}d", recoveredPersistentIds.size(), currentUserId_); auto task = [this, recoveredPersistentIds]() { @@ -1177,12 +1177,12 @@ void SceneSessionManager::ConfigSnapshotScale() void SceneSessionManager::ConfigSystemUIStatusBar(const WindowSceneConfig::ConfigItem& statusBarConfig) { - TLOGI(WmsLogTag::WMS_IMMS, "load ConfigSystemUIStatusBar"); + TLOGI(WmsLogTag::WMS_IMMS, "load"); WindowSceneConfig::ConfigItem item = statusBarConfig["showInLandscapeMode"]; if (item.IsInts() && item.intsValue_->size() == 1) { bool showInLandscapeMode = (*item.intsValue_)[0] > 0; appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_ = showInLandscapeMode; - TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar showInLandscapeMode:%{public}d", + TLOGI(WmsLogTag::WMS_IMMS, "showInLandscapeMode:%{public}d", appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_); } @@ -1194,7 +1194,7 @@ void SceneSessionManager::ConfigSystemUIStatusBar(const WindowSceneConfig::Confi return; } appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_ = color; - TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar immersiveStatusBarBgColor:%{public}s", + TLOGI(WmsLogTag::WMS_IMMS, "immersiveStatusBarBgColor:%{public}s", appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_.c_str()); } @@ -1206,7 +1206,7 @@ void SceneSessionManager::ConfigSystemUIStatusBar(const WindowSceneConfig::Confi return; } appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarContentColor_ = color; - TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar immersiveStatusBarContentColor:%{public}s", + TLOGI(WmsLogTag::WMS_IMMS, "immersiveStatusBarContentColor:%{public}s", appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarContentColor_.c_str()); } } @@ -1241,11 +1241,10 @@ sptr SceneSessionManager::GetRootSceneSession() AvoidArea SceneSessionManager::GetRootSessionAvoidAreaByType(AvoidAreaType type) { - sptr rootSession = GetRootSceneSession(); - if (rootSession == nullptr) { - return {}; + if (auto rootSession = GetRootSceneSession()) { + return rootSession->GetAvoidAreaByType(type); } - return rootSession->GetAvoidAreaByType(type); + return {}; } sptr SceneSessionManager::GetSceneSession(int32_t persistentId) @@ -1253,7 +1252,7 @@ sptr SceneSessionManager::GetSceneSession(int32_t persistentId) std::shared_lock lock(sceneSessionMapMutex_); auto iter = sceneSessionMap_.find(persistentId); if (iter == sceneSessionMap_.end()) { - WLOGFD("Error found scene session with id: %{public}d", persistentId); + WLOGFD("Not found scene session with id: %{public}d", persistentId); return nullptr; } return iter->second; @@ -1262,8 +1261,7 @@ sptr SceneSessionManager::GetSceneSession(int32_t persistentId) sptr SceneSessionManager::GetSceneSessionByIdentityInfo(const SessionIdentityInfo& info) { std::shared_lock lock(sceneSessionMapMutex_); - for (const auto &item : sceneSessionMap_) { - auto sceneSession = item.second; + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (!sceneSession) { return nullptr; } @@ -1307,8 +1305,7 @@ std::vector> SceneSessionManager::GetSceneSessionVectorByType } std::vector> sceneSessionVector; std::shared_lock lock(sceneSessionMapMutex_); - for (const auto &item : sceneSessionMap_) { - auto sceneSession = item.second; + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (sceneSession->GetWindowType() == type && sceneSession->GetSessionProperty() && sceneSession->GetSessionProperty()->GetDisplayId() == displayId) { @@ -1444,7 +1441,7 @@ sptr SceneSessionManager::CreateKeyboa WMError SceneSessionManager::CheckWindowId(int32_t windowId, int32_t& pid) { if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::WMS_EVENT, "CheckWindowId permission denied!"); + TLOGE(WmsLogTag::WMS_EVENT, "permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } @@ -1659,7 +1656,7 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s const char* const where = __func__; auto task = [this, sessionInfo, property, where] { - TLOGI(WmsLogTag::WMS_LIFE, "RequestSceneSession, appName: [%{public}s %{public}s %{public}s]" + TLOGNI(WmsLogTag::WMS_LIFE, "RequestSceneSession, appName: [%{public}s %{public}s %{public}s]" "appIndex %{public}d, type %{public}u system %{public}u, isPersistentRecover %{public}u", sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str(), sessionInfo.appIndex_, sessionInfo.windowType_, @@ -1703,7 +1700,7 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s } PerformRegisterInRequestSceneSession(sceneSession); NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); - TLOGI(WmsLogTag::WMS_LIFE, "RequestSceneSession id: %{public}d, type: %{public}d", + TLOGNI(WmsLogTag::WMS_LIFE, "RequestSceneSession id: %{public}d, type: %{public}d", sceneSession->GetPersistentId(), sceneSession->GetWindowType()); return sceneSession; }; @@ -1803,7 +1800,7 @@ void SceneSessionManager::UpdateSceneSessionWant(const SessionInfo& sessionInfo) UpdateCollaboratorSessionWant(session, sessionInfo.persistentId_); } } else { - TLOGI(WmsLogTag::WMS_MAIN, "Got session fail(%{public}d), id:%{public}d", + TLOGI(WmsLogTag::WMS_MAIN, "Get session fail(%{public}d), id:%{public}d", session == nullptr, sessionInfo.persistentId_); } } else { @@ -1813,12 +1810,10 @@ void SceneSessionManager::UpdateSceneSessionWant(const SessionInfo& sessionInfo) void SceneSessionManager::UpdateCollaboratorSessionWant(sptr& session, int32_t persistentId) { - if (session != nullptr) { - if (session->GetSessionInfo().ancoSceneState < AncoSceneState::NOTIFY_CREATE) { - FillSessionInfo(session); - if (CheckCollaboratorType(session->GetCollaboratorType())) { - PreHandleCollaborator(session, persistentId); - } + if (session != nullptr && session->GetSessionInfo().ancoSceneState < AncoSceneState::NOTIFY_CREATE) { + FillSessionInfo(session); + if (CheckCollaboratorType(session->GetCollaboratorType())) { + PreHandleCollaborator(session, persistentId); } } } @@ -1896,7 +1891,7 @@ WSError SceneSessionManager::PrepareTerminate(int32_t persistentId, bool& isPrep } auto errorCode = AAFwk::AbilityManagerClient::GetInstance()-> PrepareTerminateAbilityBySCB(sceneSessionInfo, isPrepareTerminate); - TLOGI(WmsLogTag::WMS_MAIN, "PrepareTerminateAbilityBySCB Id:%{public}d isPrepareTerminate:%{public}d " + TLOGNI(WmsLogTag::WMS_MAIN, "PrepareTerminateAbilityBySCB Id:%{public}d isPrepareTerminate:%{public}d " "errorCode:%{public}d", persistentId, isPrepareTerminate, errorCode); return WSError::WS_OK; }; @@ -1910,7 +1905,7 @@ WSError SceneSessionManager::RequestSceneSessionActivation(const sptr sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { - TLOGE(WmsLogTag::WMS_MAIN, "Request active session is nullptr"); + TLOGNE(WmsLogTag::WMS_MAIN, "Request active session is nullptr"); return WSError::WS_ERROR_NULLPTR; } auto persistentId = sceneSession->GetPersistentId(); @@ -1918,7 +1913,7 @@ WSError SceneSessionManager::RequestSceneSessionActivation(const sptrSetForegroundInteractiveStatus(true); } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSessionActivation(%d )", persistentId); - TLOGI(WmsLogTag::WMS_MAIN, "Request active id:%{public}d system:%{public}u isNewActive:%{public}d", + TLOGNI(WmsLogTag::WMS_MAIN, "Request active id:%{public}d system:%{public}u isNewActive:%{public}d", persistentId, static_cast(sceneSession->GetSessionInfo().isSystem_), isNewActive); if (!GetSceneSession(persistentId)) { TLOGE(WmsLogTag::WMS_MAIN, "Request active session invalid by %{public}d", persistentId); @@ -2123,11 +2118,11 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetPersistentId(); - TLOGI(WmsLogTag::WMS_MAIN, "Request background id:%{public}d isDelegator:%{public}d " + TLOGNI(WmsLogTag::WMS_MAIN, "Request background id:%{public}d isDelegator:%{public}d " "isToDesktop:%{public}d isSaveSnapshot:%{public}d", persistentId, isDelegator, isToDesktop, isSaveSnapshot); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSessionBackground (%d )", persistentId); @@ -2142,7 +2137,7 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrBackgroundTask(isSaveSnapshot); if (!GetSceneSession(persistentId)) { - TLOGE(WmsLogTag::WMS_MAIN, "Request background session invalid by %{public}d", persistentId); + TLOGNE(WmsLogTag::WMS_MAIN, "Request background session invalid by %{public}d", persistentId); return WSError::WS_ERROR_INVALID_SESSION; } if (persistentId == brightnessSessionId_) { @@ -2150,14 +2145,14 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrNotifySessionBackground(1, true, true); } else { - TLOGI(WmsLogTag::WMS_MAIN, "begin MinimzeUIAbility: %{public}d system: %{public}u", + TLOGNI(WmsLogTag::WMS_MAIN, "begin MinimzeUIAbility: %{public}d system: %{public}u", persistentId, static_cast(sceneSession->GetSessionInfo().isSystem_)); if (!isDelegator) { AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB(sceneSessionInfo); @@ -2180,15 +2175,14 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptr& sceneSession, bool interactive) { - wptr weakSceneSession(sceneSession); - auto task = [this, weakSceneSession, interactive]() { + auto task = [this, weakSceneSession = wptr(sceneSession), interactive]() { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { WLOGFE("session is nullptr"); return; } auto persistentId = sceneSession->GetPersistentId(); - WLOGFI("NotifyForeInteractive id: %{public}d, status: %{public}d", persistentId, interactive); + WLOGI("NotifyForeInteractive id: %{public}d, status: %{public}d", persistentId, interactive); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:NotifyForegroundInteractiveStatus (%d )", persistentId); if (!GetSceneSession(persistentId)) { WLOGFE("session is invalid with %{public}d", persistentId); @@ -2315,14 +2309,13 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrGetPersistentId(); - TLOGI(WmsLogTag::WMS_MAIN, "Destruct session id:%{public}d unfocus", persistentId); + TLOGNI(WmsLogTag::WMS_MAIN, "Destruct session id:%{public}d remove:%{public}d isSaveSnapshot:%{public}d " + "isForceClean:%{public}d", persistentId, needRemoveSession, isSaveSnapshot, isForceClean); RequestSessionUnfocus(persistentId, FocusChangeReason::SCB_SESSION_REQUEST_UNFOCUS); lastUpdatedAvoidArea_.erase(persistentId); DestroyDialogWithMainWindow(sceneSession); DestroyToastSession(sceneSession); DestroySubSession(sceneSession); // destroy sub session by destruction - TLOGI(WmsLogTag::WMS_MAIN, "Destruct session id:%{public}d remove:%{public}d isSaveSnapshot:%{public}d" - " isForceClean:%{public}d", persistentId, needRemoveSession, isSaveSnapshot, isForceClean); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSessionDestruction (%" PRIu32" )", persistentId); if (WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { auto sessionInfo = sceneSession->GetSessionInfo(); @@ -2332,7 +2325,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrGetSessionInfo(), ActionType::SINGLE_CLOSE); sceneSession->DisconnectTask(false, isSaveSnapshot); if (!GetSceneSession(persistentId)) { - TLOGE(WmsLogTag::WMS_MAIN, "Destruct session invalid by %{public}d", persistentId); + TLOGNE(WmsLogTag::WMS_MAIN, "Destruct session invalid by %{public}d", persistentId); return WSError::WS_ERROR_INVALID_SESSION; } auto sceneSessionInfo = SetAbilitySessionInfo(sceneSession); @@ -2424,7 +2417,7 @@ void SceneSessionManager::AddClientDeathRecipient(const sptr& ses TLOGE(WmsLogTag::WMS_LIFE, "failed to add death recipient"); return; } - WLOGFD("Id: %{public}d", sceneSession->GetPersistentId()); + TLOGD(WmsLogTag::WMS_LIFE, "Id: %{public}d", sceneSession->GetPersistentId()); } void SceneSessionManager::DestroySpecificSession(const sptr& remoteObject) @@ -2529,7 +2522,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetPersistentId(), newSession->GetParentPersistentId(), type); return errCode; @@ -2609,8 +2602,7 @@ void SceneSessionManager::ClosePipWindowIfExist(WindowType type) bool SceneSessionManager::CheckPiPPriority(const PiPTemplateInfo& pipTemplateInfo) { std::shared_lock lock(sceneSessionMapMutex_); - for (const auto& iter: sceneSessionMap_) { - auto& session = iter.second; + for (const auto& [_, session] : sceneSessionMap_) { if (session && session->GetWindowMode() == WindowMode::WINDOW_MODE_PIP && pipTemplateInfo.priority < session->GetPiPTemplateInfo().priority && session->IsSessionForeground()) { @@ -2719,7 +2711,7 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptr& alivePersistentIds) { TLOGI(WmsLogTag::WMS_RECOVER, "Number of persistentIds need to be recovered = %{public}zu. CurrentUserId = " - "%{public}d", alivePersistentIds.size(), currentUserId_); + "%{public}d", alivePersistentIds.size(), currentUserId_); alivePersistentIds_ = alivePersistentIds; } @@ -2809,7 +2801,7 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptrGetCallingSessionId()); + TLOGNI(WmsLogTag::WMS_RECOVER, "callingSessionId = %{public}" PRIu32, property->GetCallingSessionId()); ClosePipWindowIfExist(property->GetWindowType()); sptr sceneSession = RequestSceneSession(info, property); if (sceneSession == nullptr) { @@ -2982,7 +2974,7 @@ void SceneSessionManager::SetStartPiPFailedListener(NotifyStartPiPFailedFunc&& f void SceneSessionManager::RegisterCreateSubSessionListener(int32_t persistentId, const NotifyCreateSubSessionFunc& func) { - TLOGI(WmsLogTag::WMS_SUB, "RegisterCreateSubSessionListener, id: %{public}d", persistentId); + TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", persistentId); auto task = [this, persistentId, func]() { createSubSessionFuncMap_[persistentId] = func; RecoverCachedSubSession(persistentId); @@ -3067,7 +3059,7 @@ void SceneSessionManager::NotifyCreateSubSession(int32_t persistentId, sptrsecond) { iter->second(session); } - TLOGD(WmsLogTag::WMS_LIFE, "NotifyCreateSubSession success, parentId: %{public}d, subId: %{public}d", + TLOGD(WmsLogTag::WMS_LIFE, "Notify success, parentId: %{public}d, subId: %{public}d", persistentId, session->GetPersistentId()); } @@ -3112,13 +3104,13 @@ void SceneSessionManager::NotifyCreateToastSession(int32_t persistentId, sptrAddToastSession(session); session->SetParentSession(parentSession); - TLOGD(WmsLogTag::WMS_LIFE, "NotifyCreateToastSession success, parentId: %{public}d, toastId: %{public}d", + TLOGD(WmsLogTag::WMS_LIFE, "Notify success, parentId: %{public}d, toastId: %{public}d", persistentId, session->GetPersistentId()); } void SceneSessionManager::UnregisterCreateSubSessionListener(int32_t persistentId) { - TLOGI(WmsLogTag::WMS_SUB, "UnregisterCreateSubSessionListener, id: %{public}d", persistentId); + TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", persistentId); auto task = [this, persistentId]() { auto iter = createSubSessionFuncMap_.find(persistentId); if (iter != createSubSessionFuncMap_.end()) { @@ -3133,7 +3125,7 @@ void SceneSessionManager::UnregisterCreateSubSessionListener(int32_t persistentI void SceneSessionManager::SetStatusBarEnabledChangeListener(const ProcessStatusBarEnabledChangeFunc& func) { - WLOGFD("SetStatusBarEnabledChangeListener"); + WLOGFD("in"); if (!func) { WLOGFD("set func is null"); } @@ -3143,7 +3135,7 @@ void SceneSessionManager::SetStatusBarEnabledChangeListener(const ProcessStatusB void SceneSessionManager::SetGestureNavigationEnabledChangeListener( const ProcessGestureNavigationEnabledChangeFunc& func) { - WLOGFD("SetGestureNavigationEnabledChangeListener"); + WLOGFD("in"); if (!func) { WLOGFD("set func is null"); } @@ -3169,14 +3161,13 @@ void SceneSessionManager::NotifySessionTouchOutside(int32_t persistentId) persistentId, callingSessionId); } std::shared_lock lock(sceneSessionMapMutex_); - for (const auto &item : sceneSessionMap_) { - sceneSession = item.second; + for (const auto & [_, sceneSession] : sceneSessionMap_) { if (sceneSession == nullptr) { continue; } if (!(sceneSession->IsVisible() || - sceneSession->GetSessionState() == SessionState::STATE_FOREGROUND || - sceneSession->GetSessionState() == SessionState::STATE_ACTIVE)) { + sceneSession->GetSessionState() == SessionState::STATE_FOREGROUND || + sceneSession->GetSessionState() == SessionState::STATE_ACTIVE)) { continue; } auto sessionId = sceneSession->GetPersistentId(); @@ -3199,7 +3190,7 @@ void SceneSessionManager::NotifySessionTouchOutside(int32_t persistentId) void SceneSessionManager::SetOutsideDownEventListener(const ProcessOutsideDownEventFunc& func) { - WLOGFD("SetOutsideDownEventListener"); + WLOGFD("in"); outsideDownEventFunc_ = func; } @@ -3321,7 +3312,7 @@ WSError SceneSessionManager::DestroyAndDisconnectSpecificSessionWithDetachCallba void SceneSessionManager::DestroyUIServiceExtensionSubWindow(const sptr& sceneSession) { if (!sceneSession) { - TLOGE(WmsLogTag::WMS_SUB,"sceneSession is null"); + TLOGE(WmsLogTag::WMS_SUB, "sceneSession is null"); return; } auto sessionProperty = sceneSession->GetSessionProperty(); @@ -3387,7 +3378,7 @@ WSError SceneSessionManager::InitUserInfo(int32_t userId, std::string& fileDir) TLOGE(WmsLogTag::WMS_MAIN, "params invalid"); return WSError::WS_DO_NOTHING; } - TLOGI(WmsLogTag::WMS_MAIN, "userId : %{public}d, path : %{public}s", userId, fileDir.c_str()); + TLOGI(WmsLogTag::WMS_MAIN, "userId: %{public}d, path: %{public}s", userId, fileDir.c_str()); auto task = [this, userId, &fileDir]() { if (!ScenePersistence::CreateSnapshotDir(fileDir)) { TLOGD(WmsLogTag::WMS_MAIN, "Create snapshot directory failed"); @@ -3666,8 +3657,7 @@ void SceneSessionManager::OnBundleUpdated(const std::string& bundleName, int use if (iter != startingWindowMap_.end()) { startingWindowMap_.erase(iter); } - }, - "OnBundleUpdated"); + }, "OnBundleUpdated"); } void SceneSessionManager::OnConfigurationUpdated(const std::shared_ptr& configuration) @@ -3675,8 +3665,7 @@ void SceneSessionManager::OnConfigurationUpdated(const std::shared_ptrPostAsyncTask([this]() { std::unique_lock lock(startingWindowMapMutex_); startingWindowMap_.clear(); - }, - "OnConfigurationUpdated"); + }, "OnConfigurationUpdated"); } void SceneSessionManager::FillSessionInfo(sptr& sceneSession) @@ -4284,15 +4273,13 @@ void SceneSessionManager::RegisterVisibilityChangedDetectFunc(const sptr lock(sceneSessionMapMutex_); int32_t count = 0; - for (const auto& iter : sceneSessionMap_) { - auto& session = iter.second; + std::shared_lock lock(sceneSessionMapMutex_); + for (const auto& [_, session] : sceneSessionMap_) { if (session && session->GetCallingPid() == pid && session->IsVisible()) { count++; } } - if (count > 0) { visibleWindowCountMap_[pid] = count; } @@ -4389,7 +4376,7 @@ void SceneSessionManager::NotifySessionForCallback(const sptr& sce void SceneSessionManager::NotifyWindowInfoChangeFromSession(int32_t persistentId) { - WLOGFD("NotifyWindowInfoChange, persistentId = %{public}d", persistentId); + WLOGFD("persistentId = %{public}d", persistentId); sptr sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { WLOGFE("sceneSession nullptr"); @@ -4912,7 +4899,7 @@ void SceneSessionManager::RequestAllAppSessionUnfocus() */ WSError SceneSessionManager::RequestSessionFocusImmediately(int32_t persistentId) { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestSessionFocusImmediately, id: %{public}d", persistentId); + TLOGI(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); // base block WSError basicCheckRet = RequestFocusBasicCheck(persistentId); if (basicCheckRet != WSError::WS_OK) { @@ -4997,7 +4984,7 @@ WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byFo WSError SceneSessionManager::RequestSessionUnfocus(int32_t persistentId, FocusChangeReason reason) { - TLOGD(WmsLogTag::WMS_FOCUS, "RequestSessionUnfocus, id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); if (persistentId == INVALID_SESSION_ID) { WLOGFE("id is invalid"); return WSError::WS_ERROR_INVALID_SESSION; @@ -5033,7 +5020,7 @@ WSError SceneSessionManager::RequestSessionUnfocus(int32_t persistentId, FocusCh WSError SceneSessionManager::RequestAllAppSessionUnfocusInner() { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestAllAppSessionUnfocus"); + TLOGI(WmsLogTag::WMS_FOCUS, "in"); auto focusedSession = GetSceneSession(focusedSessionId_); if (!focusedSession) { TLOGE(WmsLogTag::WMS_FOCUS, "focused session is null"); @@ -5257,7 +5244,7 @@ void SceneSessionManager::DumpAllSessionFocusableInfo(int32_t persistentId) sptr SceneSessionManager::GetNextFocusableSession(int32_t persistentId) { - TLOGD(WmsLogTag::WMS_FOCUS, "GetNextFocusableSession, id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); bool previousFocusedSessionFound = false; sptr ret = nullptr; auto func = [this, persistentId, &previousFocusedSessionFound, &ret](sptr session) { @@ -5324,7 +5311,7 @@ sptr SceneSessionManager::GetTopNearestBlockingFocusSession(uint32 sptr SceneSessionManager::GetTopFocusableNonAppSession() { - TLOGD(WmsLogTag::WMS_FOCUS, "GetTopFocusableNonAppSession."); + TLOGD(WmsLogTag::WMS_FOCUS, "in."); sptr ret = nullptr; auto func = [this, &ret](sptr session) { if (session == nullptr) { @@ -5344,31 +5331,31 @@ sptr SceneSessionManager::GetTopFocusableNonAppSession() void SceneSessionManager::SetShiftFocusListener(const ProcessShiftFocusFunc& func) { - TLOGD(WmsLogTag::WMS_FOCUS, "SetShiftFocusListener"); + TLOGD(WmsLogTag::WMS_FOCUS, "in"); shiftFocusFunc_ = func; } void SceneSessionManager::SetSCBFocusedListener(const NotifySCBAfterUpdateFocusFunc& func) { - TLOGD(WmsLogTag::WMS_FOCUS, "SetSCBFocusedListener"); + TLOGD(WmsLogTag::WMS_FOCUS, "in"); notifySCBAfterFocusedFunc_ = func; } void SceneSessionManager::SetSCBUnfocusedListener(const NotifySCBAfterUpdateFocusFunc& func) { - TLOGD(WmsLogTag::WMS_FOCUS, "SetSCBUnfocusedListener"); + TLOGD(WmsLogTag::WMS_FOCUS, "in"); notifySCBAfterUnfocusedFunc_ = func; } void SceneSessionManager::SetCallingSessionIdSessionListenser(const ProcessCallingSessionIdChangeFunc& func) { - WLOGFD("SetCallingSessionIdSessionListenser"); + WLOGFD("in"); callingSessionIdChangeFunc_ = func; } void SceneSessionManager::SetStartUIAbilityErrorListener(const ProcessStartUIAbilityErrorFunc& func) { - WLOGFD("SetStartUIAbilityErrorListener"); + WLOGFD("in"); startUIAbilityErrorFunc_ = func; } @@ -5391,7 +5378,7 @@ WSError SceneSessionManager::ShiftFocus(sptr& nextSession, FocusCh int32_t nextId = INVALID_SESSION_ID; if (nextSession == nullptr) { std::string sessionLog(GetAllSessionFocusInfo()); - TLOGW(WmsLogTag::WMS_FOCUS, "ShiftFocus to nullptr! id: %{public}d, info: %{public}s", + TLOGW(WmsLogTag::WMS_FOCUS, "next session nullptr! id: %{public}d, info: %{public}s", focusedSessionId_, sessionLog.c_str()); } else { nextId = nextSession->GetPersistentId(); @@ -5423,7 +5410,7 @@ void SceneSessionManager::UpdateFocusStatus(sptr& sceneSession, bo } return; } - TLOGD(WmsLogTag::WMS_FOCUS, "UpdateFocusStatus, name: %{public}s, id: %{public}d, isFocused: %{public}d", + TLOGD(WmsLogTag::WMS_FOCUS, "name: %{public}s, id: %{public}d, isFocused: %{public}d", sceneSession->GetWindowNameAllType().c_str(), sceneSession->GetPersistentId(), isFocused); // set focused if (isFocused) { @@ -5506,8 +5493,7 @@ int32_t SceneSessionManager::NotifyRssThawApp(const int32_t uid, const std::stri payload.emplace("bundleName", bundleName); payload.emplace("reason", reason); nlohmann::json reply; - int32_t ret = ResourceSchedule::ResSchedClient::GetInstance().ReportSyncEvent(resType, 0, payload, reply); - return ret; + return ResourceSchedule::ResSchedClient::GetInstance().ReportSyncEvent(resType, 0, payload, reply); } void SceneSessionManager::NotifyFocusStatusByMission(sptr& prevSession, sptr& currSession) @@ -5550,7 +5536,7 @@ std::string SceneSessionManager::GetAllSessionFocusInfo() return false; } os << "WindowName: " << session->GetWindowName() << ", id: " << session->GetPersistentId() << - " ,focusable: "<< session->GetFocusable() << ";"; + " ,focusable: " << session->GetFocusable() << ";"; return false; }; TraverseSessionTree(func, true); @@ -5566,7 +5552,7 @@ WSError SceneSessionManager::UpdateFocus(int32_t persistentId, bool isFocused) WLOGFE("UpdateFocus could not find window, persistentId:%{public}d", persistentId); return WSError::WS_ERROR_INVALID_WINDOW; } - WLOGFI("UpdateFocus, name: %{public}s, id: %{public}d, isFocused: %{public}u", + WLOGI("UpdateFocus, name: %{public}s, id: %{public}d, isFocused: %{public}u", sceneSession->GetWindowName().c_str(), persistentId, static_cast(isFocused)); // focusId change if (isFocused) { @@ -5938,7 +5924,7 @@ __attribute__((no_sanitize("cfi"))) void SceneSessionManager::OnSessionStateChan int32_t persistentId, const SessionState& state) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:OnSessionStateChange%d", persistentId); - WLOGFD("Session state change, id: %{public}d, state:%{public}u", persistentId, state); + WLOGFD("id: %{public}d, state:%{public}u", persistentId, state); auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { WLOGFD("session is nullptr"); @@ -6466,7 +6452,7 @@ WSError SceneSessionManager::SetSessionLabel(const sptr& token, c WSError SceneSessionManager::SetSessionIcon(const sptr& token, const std::shared_ptr& icon) { - WLOGFI("Enter"); + WLOGFI("in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { WLOGFE("The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -6495,7 +6481,7 @@ WSError SceneSessionManager::SetSessionIcon(const sptr& token, WSError SceneSessionManager::IsValidSessionIds( const std::vector& sessionIds, std::vector& results) { - WLOGFI("Enter"); + WLOGFI("in"); std::shared_lock lock(sceneSessionMapMutex_); for (auto i = 0; i < static_cast(sessionIds.size()); ++i) { auto search = sceneSessionMap_.find(sessionIds.at(i)); @@ -6550,7 +6536,7 @@ WSError SceneSessionManager::UnRegisterSessionListener(const sptr& sessionInfos) { - WLOGFI("Enter num max %{public}d", numMax); + WLOGFI("num max %{public}d", numMax); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { WLOGFE("The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -6730,7 +6716,7 @@ WSError SceneSessionManager::GetSessionInfoByContinueSessionId(const std::string int SceneSessionManager::GetRemoteSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) { - WLOGFI("GetRemoteSessionInfoFromDms begin"); + WLOGFI("in"); std::vector sessionVector; int result = GetRemoteSessionInfos(deviceId, MAX_NUMBER_OF_DISTRIBUTED_SESSIONS, sessionVector); if (result != ERR_OK) { @@ -6749,19 +6735,19 @@ int SceneSessionManager::GetRemoteSessionInfo(const std::string& deviceId, bool SceneSessionManager::CheckIsRemote(const std::string& deviceId) { if (deviceId.empty()) { - WLOGFI("CheckIsRemote: deviceId is empty."); + WLOGFI("deviceId is empty."); return false; } std::string localDeviceId; if (!GetLocalDeviceId(localDeviceId)) { - WLOGFE("CheckIsRemote: get local deviceId failed"); + WLOGFE("get local deviceId failed"); return false; } if (localDeviceId == deviceId) { - WLOGFI("CheckIsRemote: deviceId is local."); + WLOGFI("deviceId is local."); return false; } - WLOGFD("CheckIsRemote, deviceId = %{public}s", AnonymizeDeviceId(deviceId).c_str()); + WLOGFD("Checked deviceId = %{public}s", AnonymizeDeviceId(deviceId).c_str()); return true; } @@ -6794,9 +6780,9 @@ std::string SceneSessionManager::AnonymizeDeviceId(const std::string& deviceId) WSError SceneSessionManager::DumpSessionAll(std::vector& infos) { - WLOGFI("Dump all session."); + WLOGFI("in."); if (!SessionPermission::IsSystemCalling()) { - WLOGFE("DumpSessionAll permission denied!"); + WLOGFE("permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } @@ -6818,9 +6804,9 @@ WSError SceneSessionManager::DumpSessionAll(std::vector& infos) WSError SceneSessionManager::DumpSessionWithId(int32_t persistentId, std::vector& infos) { - WLOGFI("Dump session with id %{public}d", persistentId); + WLOGFI("id %{public}d", persistentId); if (!SessionPermission::IsSystemCalling()) { - WLOGFE("DumpSessionWithId permission denied!"); + WLOGFE("permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } @@ -7228,7 +7214,8 @@ WSError SceneSessionManager::RequestSceneSessionByCall(const sptr& void SceneSessionManager::StartAbilityBySpecified(const SessionInfo& sessionInfo) { auto task = [this, sessionInfo]() { - WLOGFI("StartAbilityBySpecified: bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s", + TLOGNI(WmsLogTag::WMS_LIFE, "StartAbilityBySpecified: bundleName: %{public}s, " + "moduleName: %{public}s, abilityName: %{public}s", sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str()); AAFwk::Want want; want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); @@ -7305,7 +7292,7 @@ sptr SceneSessionManager::FindMainWindowWithToken(sptr targetToken) { if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::WMS_DIALOG, "BindDialogSessionTarget permission denied!"); + TLOGE(WmsLogTag::WMS_DIALOG, "permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } if (targetToken == nullptr) { @@ -7423,7 +7410,7 @@ WMError SceneSessionManager::UnregisterWindowManagerAgent(WindowManagerAgentType type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED || type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG) { if (!SessionPermission::IsSystemCalling()) { - WLOGFE("UnregisterWindowManagerAgent permission denied!"); + WLOGFE("IsSystemCalling permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } } @@ -7433,7 +7420,7 @@ WMError SceneSessionManager::UnregisterWindowManagerAgent(WindowManagerAgentType type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS || type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE) { if (!SessionPermission::IsSACalling()) { - TLOGE(WmsLogTag::WMS_LIFE, "permission denied!"); + TLOGE(WmsLogTag::WMS_LIFE, "IsSACalling permission denied!"); return WMError::WM_ERROR_INVALID_PERMISSION; } } @@ -7496,7 +7483,7 @@ void SceneSessionManager::InitPersistentStorage() WMError SceneSessionManager::GetAccessibilityWindowInfo(std::vector>& infos) { - WLOGFD("Called."); + WLOGFD("in."); if (!SessionPermission::IsSystemServiceCalling()) { WLOGFE("Only support for system service."); return WMError::WM_ERROR_NOT_SYSTEM_APP; @@ -7565,7 +7552,7 @@ static void FillUnreliableWindowInfo(const sptr& sceneSession, WMError SceneSessionManager::GetUnreliableWindowInfo(int32_t windowId, std::vector>& infos) { - TLOGD(WmsLogTag::DEFAULT, "Called."); + TLOGD(WmsLogTag::DEFAULT, "in."); if (!SessionPermission::IsSystemServiceCalling()) { TLOGE(WmsLogTag::DEFAULT, "only support for system service."); return WMError::WM_ERROR_NOT_SYSTEM_APP; @@ -8216,7 +8203,7 @@ sptr SceneSessionManager::FindSessionByAffinity(std::string affini void SceneSessionManager::PreloadInLakeApp(const std::string& bundleName) { - WLOGFD("Enter name %{public}s", bundleName.c_str()); + WLOGFD("name %{public}s", bundleName.c_str()); sptr collaborator = GetCollaboratorByType(CollaboratorType::RESERVE_TYPE); if (collaborator != nullptr) { WLOGFI("NotifyPreloadAbility: %{public}s", bundleName.c_str()); @@ -8226,7 +8213,7 @@ void SceneSessionManager::PreloadInLakeApp(const std::string& bundleName) WSError SceneSessionManager::PendingSessionToForeground(const sptr& token) { - TLOGI(WmsLogTag::DEFAULT, "Enter"); + TLOGI(WmsLogTag::DEFAULT, "in"); auto pid = IPCSkeleton::GetCallingRealPid(); if (!SessionPermission::IsSACalling() && !SessionPermission::CheckCallingIsUserTestMode(pid)) { TLOGE(WmsLogTag::DEFAULT, "Permission denied for going to foreground!"); @@ -8608,7 +8595,7 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR } } if (isNeedNotify) { - WLOGFI("NotifyAINavigationBar: enter: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", + WLOGFI("NotifyAINavigationBar inner: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); for (auto persistentId : avoidAreaListenerSessionSet_) { NotifySessionAINavigationBarChange(persistentId); @@ -8893,7 +8880,7 @@ WSError SceneSessionManager::ClearSession(int32_t persistentId) WSError SceneSessionManager::ClearSession(sptr sceneSession) { - WLOGFD("Enter"); + WLOGFD("in"); if (sceneSession == nullptr) { WLOGFE("session is nullptr"); return WSError::WS_ERROR_INVALID_SESSION; @@ -8908,7 +8895,7 @@ WSError SceneSessionManager::ClearSession(sptr sceneSession) WSError SceneSessionManager::ClearAllSessions() { - WLOGFI("Enter"); + WLOGFI("in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { WLOGFE("The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -8931,7 +8918,7 @@ WSError SceneSessionManager::ClearAllSessions() void SceneSessionManager::GetAllClearableSessions(std::vector>& sessionVector) { - WLOGFI("Enter"); + WLOGFI("in"); std::shared_lock lock(sceneSessionMapMutex_); for (const auto &item : sceneSessionMap_) { auto sceneSession = item.second; @@ -8989,7 +8976,7 @@ WSError SceneSessionManager::UnlockSession(int32_t sessionId) WSError SceneSessionManager::MoveSessionsToForeground(const std::vector& sessionIds, int32_t topSessionId) { - TLOGI(WmsLogTag::WMS_LIFE, "Enter"); + TLOGI(WmsLogTag::WMS_LIFE, "in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { TLOGE(WmsLogTag::WMS_LIFE, "The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -9005,7 +8992,7 @@ WSError SceneSessionManager::MoveSessionsToForeground(const std::vector WSError SceneSessionManager::MoveSessionsToBackground(const std::vector& sessionIds, std::vector& result) { - TLOGI(WmsLogTag::WMS_LIFE, "Enter"); + TLOGI(WmsLogTag::WMS_LIFE, "in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { TLOGE(WmsLogTag::WMS_LIFE, "The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -9249,7 +9236,7 @@ void SceneSessionManager::NotifyLoadAbility(int32_t collaboratorType, void SceneSessionManager::NotifyUpdateSessionInfo(sptr sceneSession) { - WLOGFD("Enter"); + WLOGFD("in"); if (sceneSession == nullptr) { WLOGFE("sceneSession is nullptr"); return; @@ -10182,7 +10169,7 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr void SceneSessionManager::RemoveExtensionWindowStageFromSCB(const sptr& sessionStage, const sptr& token) { - TLOGI(WmsLogTag::WMS_UIEXT, "called"); + TLOGI(WmsLogTag::WMS_UIEXT, "in"); auto task = [this, sessionStage, token]() { if (sessionStage == nullptr || token == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr"); @@ -11278,7 +11265,7 @@ WMError SceneSessionManager::TerminateSessionByPersistentId(int32_t persistentId void SceneSessionManager::SetRootSceneProcessBackEventFunc(const RootSceneProcessBackEventFunc& processBackEventFunc) { rootSceneProcessBackEventFunc_ = processBackEventFunc; - TLOGI(WmsLogTag::WMS_EVENT, "called"); + TLOGI(WmsLogTag::WMS_EVENT, "end"); } WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, From 9f6262d82683d0f538089659c2664ac06fef2261 Mon Sep 17 00:00:00 2001 From: kaicui Date: Fri, 15 Nov 2024 17:49:58 +0800 Subject: [PATCH 154/171] =?UTF-8?q?ProcessWindowRectChangeRegister?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=AE=9A=E4=B9=89=E5=85=A5=E5=8F=82=E6=8D=A2?= =?UTF-8?q?=E8=A1=8C=E4=BB=A5=E8=A7=A3=E5=86=B3=E8=A1=8C=E5=AE=BD=E8=BF=87?= =?UTF-8?q?=E5=AE=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kaicui --- .../extension_window/js_extension_window_register_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp index f406003ef8..2a3ff90a68 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp @@ -63,8 +63,8 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr& listener, - const sptr& window, bool isRegister) +WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowRectChangeRegister( + const sptr& listener, const sptr& window, bool isRegister) { if (window == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); From 00dfe53e99d0ea4e0dbb422e3a110f70868ecff0 Mon Sep 17 00:00:00 2001 From: whqwe Date: Fri, 15 Nov 2024 18:06:55 +0800 Subject: [PATCH 155/171] add fix Signed-off-by: whqwe --- .../session_manager/src/scene_session_manager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 165ee6d99e..e4175d3205 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1656,9 +1656,9 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s const char* const where = __func__; auto task = [this, sessionInfo, property, where] { - TLOGNI(WmsLogTag::WMS_LIFE, "RequestSceneSession, appName: [%{public}s %{public}s %{public}s]" + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: appName: [%{public}s %{public}s %{public}s] " "appIndex %{public}d, type %{public}u system %{public}u, isPersistentRecover %{public}u", - sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), + where, sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str(), sessionInfo.appIndex_, sessionInfo.windowType_, static_cast(sessionInfo.isSystem_), static_cast(sessionInfo.isPersistentRecover_)); sptr sceneSession = CreateSceneSession(sessionInfo, property); @@ -1700,8 +1700,8 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s } PerformRegisterInRequestSceneSession(sceneSession); NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); - TLOGNI(WmsLogTag::WMS_LIFE, "RequestSceneSession id: %{public}d, type: %{public}d", - sceneSession->GetPersistentId(), sceneSession->GetWindowType()); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: id: %{public}d, type: %{public}d", + where, sceneSession->GetPersistentId(), sceneSession->GetWindowType()); return sceneSession; }; return taskScheduler_->PostSyncTask(task, "RequestSceneSession:PID" + std::to_string(sessionInfo.persistentId_)); @@ -2744,8 +2744,8 @@ SessionInfo SceneSessionManager::RecoverSessionInfo(const sptr& alivePersistentIds) { - TLOGI(WmsLogTag::WMS_RECOVER, "Number of persistentIds need to be recovered = %{public}zu. CurrentUserId = " - "%{public}d", alivePersistentIds.size(), currentUserId_); + TLOGI(WmsLogTag::WMS_RECOVER, "PersistentIds need to be recovered=%{public}zu, CurrentUserId=%{public}d", + alivePersistentIds.size(), currentUserId_); alivePersistentIds_ = alivePersistentIds; } From a958efa5055a1cba474065718bdcd3ebe8bff9f3 Mon Sep 17 00:00:00 2001 From: whqwe Date: Fri, 15 Nov 2024 18:08:53 +0800 Subject: [PATCH 156/171] fix Signed-off-by: whqwe --- 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 e4175d3205..1042599845 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1701,7 +1701,7 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s PerformRegisterInRequestSceneSession(sceneSession); NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: id: %{public}d, type: %{public}d", - where, sceneSession->GetPersistentId(), sceneSession->GetWindowType()); + where, sceneSession->GetPersistentId(), sceneSession->GetWindowType()); return sceneSession; }; return taskScheduler_->PostSyncTask(task, "RequestSceneSession:PID" + std::to_string(sessionInfo.persistentId_)); From e5ad2b56aa2cb6d814831332c928abc5527a125c Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Sat, 16 Nov 2024 08:47:12 +0800 Subject: [PATCH 157/171] add visibility code Signed-off-by: ZihaoWU --- .../src/scene_session_manager.cpp | 8 +++++-- .../unittest/scene_session_manager_test6.cpp | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index b88c770609..64436c58f6 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7891,7 +7891,9 @@ std::vector> SceneSessionManager::Get i = j = 0; for (; i < lastVisibleData_.size() && j < currVisibleData.size();) { if (lastVisibleData_[i].first < currVisibleData[j].first) { - visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + if (lastVisibleData_[i].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { + visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + } i++; } else if (lastVisibleData_[i].first > currVisibleData[j].first) { if (currVisibleData[j].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { @@ -7907,7 +7909,9 @@ std::vector> SceneSessionManager::Get } } for (; i < lastVisibleData_.size(); ++i) { - visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + if (lastVisibleData_[i].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { + visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + } } for (; j < currVisibleData.size(); ++j) { if (currVisibleData[j].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index 2c701137f9..86f5bd6e7e 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -243,6 +243,29 @@ HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo03, Function | S ASSERT_EQ(visibilityChangeInfos[0].first, 2); } +/** + * @tc.name: GetWindowVisibilityChangeInfo04 + * @tc.desc: GetWindowVisibilityChangeInfo04 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo04, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + ssm_->lastVisibleData_.clear(); + std::vector> currVisibleData; + std::vector> visibilityChangeInfos; + ssm_->lastVisibleData_.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION)); + currVisibleData.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION)); + currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION)); + visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData); + ASSERT_EQ(visibilityChangeInfos.size(), 1); + + currVisibleData.clear(); + currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION)); + visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData); + ASSERT_EQ(visibilityChangeInfos.size(), 0); +} + /** * @tc.name: DealwithVisibilityChange01 * @tc.desc: DealwithVisibilityChange01 From 97a12488ba144ea36991d408e9e4eeabc3ea8966 Mon Sep 17 00:00:00 2001 From: whqwe Date: Sat, 16 Nov 2024 11:33:15 +0800 Subject: [PATCH 158/171] fix: remove codes 2 Signed-off-by: whqwe --- utils/src/vsync_station.cpp | 2 +- window_scene/common/include/task_scheduler.h | 9 ++-- window_scene/common/src/task_scheduler.cpp | 49 +++++++++---------- .../js_scene_session_manager.cpp | 2 +- .../scene_session_manager/js_scene_utils.cpp | 10 +--- .../js_transaction_manager.cpp | 10 ++-- window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/session.cpp | 4 +- .../include/scene_session_manager.h | 2 +- .../src/scene_session_manager.cpp | 38 +++++++------- .../test/unittest/task_scheduler_test.cpp | 5 +- 11 files changed, 59 insertions(+), 74 deletions(-) diff --git a/utils/src/vsync_station.cpp b/utils/src/vsync_station.cpp index 9a08eaba12..eb88c189e9 100644 --- a/utils/src/vsync_station.cpp +++ b/utils/src/vsync_station.cpp @@ -151,7 +151,7 @@ __attribute__((no_sanitize("cfi"))) void VsyncStation::RequestVsync( } }; receiver->RequestNextVSync({ - .userData_ = nullptr, .callbackWithId_ = task, + .userData_ = nullptr, .callbackWithId_ = std::move(task), }); } diff --git a/window_scene/common/include/task_scheduler.h b/window_scene/common/include/task_scheduler.h index 50bb4cda80..8d185b4a36 100644 --- a/window_scene/common/include/task_scheduler.h +++ b/window_scene/common/include/task_scheduler.h @@ -22,7 +22,7 @@ namespace OHOS::Rosen { -void StartTraceForSyncTask(std::string name); +void StartTraceForSyncTask(const std::string& name); void FinishTraceForSyncTask(); class TaskScheduler { @@ -31,11 +31,12 @@ public: ~TaskScheduler() = default; std::shared_ptr GetEventHandler(); + using Task = std::function; - void PostAsyncTask(Task&& task, const std::string& name = "ssmTask", int64_t delayTime = 0); - void PostVoidSyncTask(Task&& task, const std::string& name = "ssmTask"); + void PostAsyncTask(Task&& task, const std::string& name, int64_t delayTime = 0); void PostTask(Task&& task, const std::string& name, int64_t delayTime = 0); void RemoveTask(const std::string& name); + void PostVoidSyncTask(Task&& task, const std::string& name = "ssmTask"); template> Return PostSyncTask(SyncTask&& task, const std::string& name = "ssmTask") { @@ -46,7 +47,7 @@ public: FinishTraceForSyncTask(); return ret; } - auto syncTask = [this, &ret, task = std::move(task), name] { + auto syncTask = [this, &ret, &task, &name] { StartTraceForSyncTask(name); ret = task(); FinishTraceForSyncTask(); diff --git a/window_scene/common/src/task_scheduler.cpp b/window_scene/common/src/task_scheduler.cpp index 65facb7848..051fce86a1 100644 --- a/window_scene/common/src/task_scheduler.cpp +++ b/window_scene/common/src/task_scheduler.cpp @@ -44,21 +44,6 @@ void TaskScheduler::PostAsyncTask(Task&& task, const std::string& name, int64_t handler_->PostTask(std::move(localTask), "wms:" + name, delayTime, AppExecFwk::EventQueue::Priority::IMMEDIATE); } -void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name) -{ - if (handler_->GetEventRunner()->IsCurrentRunnerThread()) { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); - task(); - return; - } - auto localTask = [this, task = std::move(task), name] { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); - task(); - ExecuteExportTask(); - }; - handler_->PostSyncTask(std::move(localTask), "wms:" + name, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - void TaskScheduler::PostTask(Task&& task, const std::string& name, int64_t delayTime) { PostAsyncTask(std::move(task), name, delayTime); @@ -69,6 +54,26 @@ void TaskScheduler::RemoveTask(const std::string& name) handler_->RemoveTask("wms:" + name); } +void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name) +{ + if (handler_->GetEventRunner()->IsCurrentRunnerThread()) { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); + task(); + return; + } + auto localTask = [this, &task, &name] { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); + task(); + ExecuteExportTask(); + }; + handler_->PostSyncTask(std::move(localTask), "wms:" + name, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void TaskScheduler::SetExportHandler(const std::shared_ptr& handler) +{ + exportHandler_ = handler; +} + void TaskScheduler::AddExportTask(std::string taskName, Task&& task) { if (handler_->GetEventRunner()->IsCurrentRunnerThread()) { @@ -78,17 +83,9 @@ void TaskScheduler::AddExportTask(std::string taskName, Task&& task) } } -void TaskScheduler::SetExportHandler(const std::shared_ptr& handler) -{ - exportHandler_ = handler; -} - void TaskScheduler::ExecuteExportTask() { - if (exportFuncMap_.empty()) { - return; - } - if (!exportHandler_) { + if (!exportHandler_ || exportFuncMap_.empty()) { return; } auto task = [funcMap = std::move(exportFuncMap_)] { @@ -98,10 +95,10 @@ void TaskScheduler::ExecuteExportTask() } }; exportFuncMap_.clear(); - exportHandler_->PostTask(task, "wms:exportTask"); + exportHandler_->PostTask(std::move(task), "wms:exportTask"); } -void StartTraceForSyncTask(std::string name) +void StartTraceForSyncTask(const std::string& name) { StartTraceArgs(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); } 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 aedfc62631..6936ac5513 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 @@ -2603,7 +2603,7 @@ napi_value JsSceneSessionManager::OnPreloadInLakeApp(napi_env env, napi_callback auto preloadTask = [bundleName = std::move(bundleName)] { SceneSessionManager::GetInstance().PreloadInLakeApp(bundleName); }; - localScheduler->PostAsyncTask(preloadTask); + localScheduler->PostAsyncTask(preloadTask, __func__); return NapiGetUndefined(env); } diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 3a488140cc..68425c72af 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -1569,20 +1569,14 @@ MainThreadScheduler::MainThreadScheduler(napi_env env) inline void MainThreadScheduler::GetMainEventHandler() { - if (handler_ != nullptr) { - return; - } auto runner = OHOS::AppExecFwk::EventRunner::GetMainEventRunner(); - if (runner == nullptr) { - return; - } handler_ = std::make_shared(runner); } void MainThreadScheduler::PostMainThreadTask(Task&& localTask, std::string traceInfo, int64_t delayTime) { - GetMainEventHandler(); - auto task = [env = env_, localTask, traceInfo, envChecker = std::weak_ptr(envChecker_)]() { + auto task = [env = env_, localTask = std::move(localTask), traceInfo, + envChecker = std::weak_ptr(envChecker_)] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SCBCb:%s", traceInfo.c_str()); if (envChecker.expired()) { TLOGNE(WmsLogTag::WMS_MAIN, "post task expired because of invalid scheduler"); diff --git a/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp b/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp index 02d4e5019e..4ca565a4b2 100644 --- a/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp +++ b/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp @@ -98,15 +98,13 @@ napi_value JsTransactionManager::OnOpenSyncTransaction(napi_env env, napi_callba napi_value JsTransactionManager::OnCloseSyncTransaction(napi_env env, napi_callback_info info) { - auto task = []() { - auto transactionController = RSSyncTransactionController::GetInstance(); - if (transactionController) { + auto task = [] { + if (auto transactionController = RSSyncTransactionController::GetInstance()) { transactionController->CloseSyncTransaction(); } }; - auto handler = SceneSessionManager::GetInstance().GetTaskScheduler(); - if (handler) { - handler->PostAsyncTask(task); + if (auto handler = SceneSessionManager::GetInstance().GetTaskScheduler()) { + handler->PostAsyncTask(task, __func__); } else { task(); } diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 6eebcc5853..0555cd4809 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -589,7 +589,7 @@ protected: FinishTraceForSyncTask(); return ret; } - auto syncTask = [&ret, &task, name]() { + auto syncTask = [&ret, &task, &name] { StartTraceForSyncTask(name); ret = task(); FinishTraceForSyncTask(); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 48dac62965..96606036ba 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -121,7 +121,7 @@ void Session::PostTask(Task&& task, const std::string& name, int64_t delayTime) HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); return task(); } - auto localTask = [task = std::move(task), name]() { + auto localTask = [task = std::move(task), name] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); task(); }; @@ -134,7 +134,7 @@ void Session::PostExportTask(Task&& task, const std::string& name, int64_t delay HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); return task(); } - auto localTask = [task = std::move(task), name]() { + auto localTask = [task = std::move(task), name] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); task(); }; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 7142a5f574..82769fd744 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -174,7 +174,7 @@ public: sptr GetSceneSession(int32_t persistentId); sptr GetMainParentSceneSession(int32_t persistentId, const std::map>& sessionMap); - void PostFlushWindowInfoTask(FlushWindowInfoTask &&task, const std::string taskName, const int delayTime); + void PostFlushWindowInfoTask(FlushWindowInfoTask &&task, const std::string& taskName, const int delayTime); sptr GetSceneSessionByIdentityInfo(const SessionIdentityInfo& info); sptr GetSceneSessionByType(WindowType type); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index b88c770609..121182abcf 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2838,10 +2838,10 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptrPostAsyncTask([this]() { - TLOGI(WmsLogTag::WMS_RECOVER, "RecoverFinished clear recoverSubSessionCacheMap"); - recoveringFinished_ = true; - recoverSubSessionCacheMap_.clear(); - }, "NotifyRecoveringFinished"); + TLOGNI(WmsLogTag::WMS_RECOVER, "RecoverFinished clear recoverSubSessionCacheMap"); + recoveringFinished_ = true; + recoverSubSessionCacheMap_.clear(); + }, "NotifyRecoveringFinished"); } void SceneSessionManager::CacheSubSessionForRecovering( @@ -7173,8 +7173,7 @@ sptr SceneSessionManager::GetCollaboratorByT WSError SceneSessionManager::RequestSceneSessionByCall(const sptr& sceneSession) { - wptr weakSceneSession(sceneSession); - auto task = [this, weakSceneSession]() { + auto task = [this, weakSceneSession = wptr(sceneSession)] { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { WLOGFE("session is nullptr"); @@ -7625,7 +7624,7 @@ void SceneSessionManager::NotifyWindowInfoChange(int32_t persistentId, WindowUpd } SceneInputManager::GetInstance().NotifyWindowInfoChange(sceneSession, type); }; - taskScheduler_->PostAsyncTask(notifySceneInputTask); + taskScheduler_->PostAsyncTask(notifySceneInputTask, "notifySceneInputTask"); } bool SceneSessionManager::FillWindowInfo(std::vector>& infos, @@ -8431,18 +8430,16 @@ void SceneSessionManager::NotifyMMIWindowPidChange(int32_t windowId, bool startM return; } - wptr weakSceneSession(sceneSession); - WLOGFI("SceneSessionManager NotifyMMIWindowPidChange to notify window: %{public}d, pid: %{public}d", windowId, pid); - auto task = [weakSceneSession, startMoving]() -> WSError { + WLOGFI("Notify window: %{public}d, pid: %{public}d", windowId, pid); + auto task = [weakSceneSession = wptr(sceneSession), startMoving] { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { WLOGFW("session is null"); - return WSError::WS_ERROR_NULLPTR; + return; } SceneInputManager::GetInstance().NotifyMMIWindowPidChange(sceneSession, startMoving); - return WSError::WS_OK; }; - return taskScheduler_->PostAsyncTask(task); + taskScheduler_->PostAsyncTask(task, __func__); } void SceneSessionManager::UpdateAvoidArea(int32_t persistentId) @@ -8793,7 +8790,7 @@ void SceneSessionManager::ProcessDisplayScale(sptr& displayInfo) return; } - auto task = [displayInfo]() -> WSError { + auto task = [displayInfo] { ScreenSessionManagerClient::GetInstance().UpdateDisplayScale(displayInfo->GetScreenId(), displayInfo->GetScaleX(), displayInfo->GetScaleY(), @@ -8803,9 +8800,8 @@ void SceneSessionManager::ProcessDisplayScale(sptr& displayInfo) displayInfo->GetTranslateY()); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSessionManager::FlushWindowInfoToMMI"); SceneInputManager::GetInstance().FlushDisplayInfoToMMI(true); - return WSError::WS_OK; }; - return taskScheduler_->PostAsyncTask(task); + taskScheduler_->PostAsyncTask(task, __func__); } void DisplayChangeListener::OnDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, @@ -9934,7 +9930,7 @@ void SceneSessionManager::NotifyUpdateRectAfterLayout() WMError SceneSessionManager::GetVisibilityWindowInfo(std::vector>& infos) { if (!SessionPermission::IsSystemCalling()) { - WLOGFE("GetVisibilityWindowInfo permission denied!"); + WLOGFE("permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } auto task = [this, &infos]() { @@ -9974,17 +9970,17 @@ void SceneSessionManager::FlushWindowInfoToMMI(const bool forceFlush) { auto task = [this, forceFlush] { if (isUserBackground_) { - TLOGD(WmsLogTag::WMS_MULTI_USER, "The user is in the background, no need to flush info to MMI"); + TLOGND(WmsLogTag::WMS_MULTI_USER, "The user is in the background, no need to flush info to MMI"); return; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSessionManager::FlushWindowInfoToMMI"); SceneInputManager::GetInstance().FlushDisplayInfoToMMI(forceFlush); }; - taskScheduler_->PostAsyncTask(task); + taskScheduler_->PostAsyncTask(task, __func__); } -void SceneSessionManager::PostFlushWindowInfoTask(FlushWindowInfoTask &&task, - const std::string taskName, const int delayTime) +void SceneSessionManager::PostFlushWindowInfoTask(FlushWindowInfoTask&& task, + const std::string& taskName, const int delayTime) { taskScheduler_->PostAsyncTask(std::move(task), taskName, delayTime); } diff --git a/window_scene/test/unittest/task_scheduler_test.cpp b/window_scene/test/unittest/task_scheduler_test.cpp index 6d5c38b486..613a5e33d9 100644 --- a/window_scene/test/unittest/task_scheduler_test.cpp +++ b/window_scene/test/unittest/task_scheduler_test.cpp @@ -73,13 +73,12 @@ HWTEST_F(TaskSchedulerTest, PostTask, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "START_TASK"; resultValue = 1; }; - taskScheduler->PostAsyncTask(taskFunc); + taskScheduler->PostAsyncTask(taskFunc, "ssmTask"); EXPECT_NE(taskScheduler->handler_, nullptr); EXPECT_EQ(resultValue, 0); - std::string name = "ssmTask"; int64_t delayTime = 1; - taskScheduler->PostAsyncTask(taskFunc, name, delayTime); + taskScheduler->PostAsyncTask(taskFunc, "ssmTask", delayTime); EXPECT_EQ(resultValue, 0); } From ca7a70627479e57a626734f0d8773ecf07eda096 Mon Sep 17 00:00:00 2001 From: whqwe Date: Sat, 16 Nov 2024 11:46:38 +0800 Subject: [PATCH 159/171] add Signed-off-by: whqwe --- 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 82769fd744..ff97e44baf 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -174,7 +174,7 @@ public: sptr GetSceneSession(int32_t persistentId); sptr GetMainParentSceneSession(int32_t persistentId, const std::map>& sessionMap); - void PostFlushWindowInfoTask(FlushWindowInfoTask &&task, const std::string& taskName, const int delayTime); + void PostFlushWindowInfoTask(FlushWindowInfoTask&& task, const std::string& taskName, const int delayTime); sptr GetSceneSessionByIdentityInfo(const SessionIdentityInfo& info); sptr GetSceneSessionByType(WindowType type); From 80594c669fe33939ea0262c3ecf6201f31f962b9 Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Thu, 14 Nov 2024 10:13:26 +0800 Subject: [PATCH 160/171] =?UTF-8?q?startAbility=E6=94=AF=E6=8C=81=E4=BC=A0?= =?UTF-8?q?=E5=85=A5SupportWindowMode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyh990312 --- interfaces/innerkits/wm/window.h | 6 +- previewer/include/window.h | 4 +- previewer/include/window_impl.h | 4 +- previewer/src/window_impl.cpp | 4 +- test/common/mock/mock_IWindow.h | 2 +- .../wms/window_fuzzer/window_fuzzer.cpp | 14 ++-- .../window_agent_fuzzer.cpp | 6 +- .../wms/window_mode_support_info_test.cpp | 62 +++++++++--------- utils/include/window_helper.h | 38 +++++------ utils/include/window_property.h | 16 ++--- utils/include/wm_common_inner.h | 6 +- utils/src/window_property.cpp | 38 +++++------ utils/test/unittest/window_property_test.cpp | 34 +++++----- .../common/include/window_session_property.h | 22 +++---- .../common/src/window_session_property.cpp | 21 +++--- window_scene/interfaces/include/ws_common.h | 8 +++ .../scene_session_manager/js_scene_utils.cpp | 18 +++++ .../session/host/include/scene_session.h | 2 +- .../session/host/src/move_drag_controller.cpp | 2 +- .../session/host/src/scene_session.cpp | 23 ++++--- window_scene/session/host/src/session.cpp | 1 + .../session/host/src/zidl/session_proxy.cpp | 16 +++++ .../session/host/src/zidl/session_stub.cpp | 9 +++ .../session_manager/src/hidump_controller.cpp | 11 ++-- .../src/scene_session_manager.cpp | 6 +- .../unittest/scene_session_manager_test2.cpp | 12 ++-- .../unittest/scene_session_manager_test3.cpp | 2 +- .../test/unittest/scene_session_test5.cpp | 18 ++--- window_scene/test/unittest/session_test.cpp | 6 +- .../unittest/window_session_property_test.cpp | 12 ++-- wm/include/window_agent.h | 2 +- wm/include/window_impl.h | 10 +-- wm/include/zidl/window_interface.h | 2 +- wm/include/zidl/window_proxy.h | 2 +- wm/src/window_agent.cpp | 4 +- wm/src/window_impl.cpp | 65 ++++++++++--------- wm/src/window_scene_session_impl.cpp | 47 ++++++++------ wm/src/window_session_impl.cpp | 8 +-- wm/src/zidl/window_proxy.cpp | 4 +- wm/src/zidl/window_stub.cpp | 8 +-- wm/test/unittest/window_agent_test.cpp | 10 +-- wm/test/unittest/window_impl_test2.cpp | 16 ++--- wm/test/unittest/window_impl_test3.cpp | 6 +- wm/test/unittest/window_impl_test5.cpp | 4 +- wm/test/unittest/window_proxy_test.cpp | 6 +- .../window_scene_session_impl_test2.cpp | 14 ++-- .../window_scene_session_impl_test3.cpp | 2 +- .../window_scene_session_impl_test4.cpp | 4 +- .../unittest/window_session_impl_test4.cpp | 12 ++-- wm/test/unittest/window_test.cpp | 16 ++--- wmserver/include/window_node.h | 4 +- wmserver/include/window_node_container.h | 2 +- wmserver/src/remote_animation.cpp | 6 +- wmserver/src/starting_window.cpp | 4 +- wmserver/src/window_controller.cpp | 4 +- wmserver/src/window_layout_policy_cascade.cpp | 3 +- wmserver/src/window_layout_policy_tile.cpp | 4 +- wmserver/src/window_manager_service.cpp | 12 ++-- wmserver/src/window_node.cpp | 8 +-- wmserver/src/window_node_container.cpp | 17 ++--- wmserver/src/window_pair.cpp | 4 +- wmserver/src/window_root.cpp | 3 +- .../unittest/avoid_area_controller_test.cpp | 2 +- .../test/unittest/remote_animation_test.cpp | 4 +- .../test/unittest/starting_window_test.cpp | 12 ++-- .../test/unittest/window_controller_test.cpp | 6 +- .../unittest/window_manager_config_test.cpp | 14 ++-- wmserver/test/unittest/window_node_test.cpp | 14 ++-- wmserver/test/unittest/window_root_test.cpp | 4 +- 69 files changed, 432 insertions(+), 360 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 411938243b..8ac8ec7198 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1486,15 +1486,15 @@ public: /** * @brief Set requested mode support info. * - * @param modeSupportInfo Mode of window supported. + * @param windowModeSupportType Mode of window supported. */ - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) {} + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) {} /** * @brief Get requested mode support info. * * @return Enumeration values under WindowModeSupport. */ - virtual uint32_t GetRequestModeSupportInfo() const { return 0; } + virtual uint32_t GetRequestWindowModeSupportType() const { return 0; } /** * @brief Set touch hot areas. * diff --git a/previewer/include/window.h b/previewer/include/window.h index 9f33a0ad9a..07a30bfaaa 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -262,8 +262,8 @@ public: virtual void OnNewWant(const AAFwk::Want& want) = 0; virtual void SetRequestedOrientation(Orientation) = 0; virtual Orientation GetRequestedOrientation() = 0; - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0; - virtual uint32_t GetRequestModeSupportInfo() const = 0; + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) = 0; + virtual uint32_t GetRequestWindowModeSupportType() const = 0; virtual WMError SetTouchHotAreas(const std::vector& rects) = 0; virtual void GetRequestedTouchHotAreas(std::vector& rects) const = 0; virtual bool IsMainHandlerAvailable() const = 0; diff --git a/previewer/include/window_impl.h b/previewer/include/window_impl.h index 1ed3903f2d..792ebaaa61 100644 --- a/previewer/include/window_impl.h +++ b/previewer/include/window_impl.h @@ -74,7 +74,7 @@ public: virtual uint32_t GetWindowId() const override; uint64_t GetDisplayId() const override; virtual uint32_t GetWindowFlags() const override; - uint32_t GetRequestModeSupportInfo() const override; + uint32_t GetRequestWindowModeSupportType() const override; bool IsMainHandlerAvailable() const override; virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const override; virtual bool IsFullScreen() const override; @@ -167,7 +167,7 @@ public: virtual void RegisterDialogDeathRecipientListener(const sptr& listener) override; virtual void UnregisterDialogDeathRecipientListener(const sptr& listener) override; virtual void SetAceAbilityHandler(const sptr& handler) override; - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override; + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) override; virtual void ConsumeKeyEvent(const std::shared_ptr& inputEvent) override; virtual void ConsumePointerEvent(const std::shared_ptr& inputEvent) override; virtual void RequestVsync(const std::shared_ptr& vsyncCallback) override; diff --git a/previewer/src/window_impl.cpp b/previewer/src/window_impl.cpp index d52bc4ad5c..f984072447 100644 --- a/previewer/src/window_impl.cpp +++ b/previewer/src/window_impl.cpp @@ -196,7 +196,7 @@ uint32_t WindowImpl::GetWindowFlags() const return 0; } -uint32_t WindowImpl::GetRequestModeSupportInfo() const +uint32_t WindowImpl::GetRequestWindowModeSupportType() const { return 0; } @@ -786,7 +786,7 @@ void WindowImpl::SetAceAbilityHandler(const sptr& handler) return; } -void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::SetRequestWindowModeSupportType(uint32_t windowModeSupportType) { return; } diff --git a/test/common/mock/mock_IWindow.h b/test/common/mock/mock_IWindow.h index 6ca5f432d9..3b0d53ff76 100644 --- a/test/common/mock/mock_IWindow.h +++ b/test/common/mock/mock_IWindow.h @@ -31,7 +31,7 @@ public: MOCK_METHOD4(UpdateWindowRect, WMError(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction)); MOCK_METHOD1(UpdateWindowMode, WMError(WindowMode mode)); - MOCK_METHOD1(UpdateWindowModeSupportInfo, WMError(uint32_t modeSupportInfo)); + MOCK_METHOD1(UpdateWindowWindowModeSupportType, WMError(uint32_t windowModeSupportType)); MOCK_METHOD1(UpdateFocusStatus, WMError(bool focused)); MOCK_METHOD2(UpdateAvoidArea, WMError(const sptr& avoidArea, AvoidAreaType type)); MOCK_METHOD1(UpdateWindowState, WMError(WindowState state)); diff --git a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp index 8aac189cea..47fff1afc8 100644 --- a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp +++ b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp @@ -461,9 +461,9 @@ void CheckWindowImplFunctionsPart3(sptr window, const uint8_t* data, startPos += GetObject(mode, data + startPos, size - startPos); window->UpdateMode(mode); - uint32_t modeSupportInfo; - startPos += GetObject(modeSupportInfo, data + startPos, size - startPos); - window->UpdateModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType; + startPos += GetObject(windowModeSupportType, data + startPos, size - startPos); + window->UpdateWindowModeSupportType(windowModeSupportType); WindowState windowState; startPos += GetObject(windowState, data + startPos, size - startPos); @@ -596,7 +596,7 @@ void CheckWindowImplFunctionsPart6(sptr window, const uint8_t* data, uint32_t uint32Val[2]; startPos += GetObject(uint32Val[0], data + startPos, size - startPos); startPos += GetObject(uint32Val[1], data + startPos, size - startPos); - window->SetModeSupportInfo(uint32Val[0]); + window->SetWindowModeSupportType(uint32Val[0]); float floatVal; startPos += GetObject(floatVal, data + startPos, size - startPos); @@ -660,9 +660,9 @@ void CheckWindowImplFunctionsPart7(sptr window, const uint8_t* data, window->UnregisterDialogDeathRecipientListener(dialogDeathRecipientListener); sptr aceAbilityHandler = new AceAbilityHandler(); window->SetAceAbilityHandler(aceAbilityHandler); - uint32_t modeSupportInfo; - startPos += GetObject(modeSupportInfo, data + startPos, size - startPos); - window->SetRequestModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType; + startPos += GetObject(windowModeSupportType, data + startPos, size - startPos); + window->SetRequestWindowModeSupportType(windowModeSupportType); float ratio; startPos += GetObject(ratio, data + startPos, size - startPos); window->SetAspectRatio(ratio); diff --git a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp index f536e45d04..880d2deb3c 100644 --- a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp +++ b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp @@ -61,9 +61,9 @@ void CheckWindowAgentFunctionsPart1(sptr agent, const uint8_t* data startPos += GetObject(mode, data + startPos, size - startPos); agent->UpdateWindowMode(mode); - uint32_t modeSupportInfo; - startPos += GetObject(modeSupportInfo, data + startPos, size - startPos); - agent->UpdateWindowModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType; + startPos += GetObject(windowModeSupportType, data + startPos, size - startPos); + agent->UpdateWindowWindowModeSupportType(windowModeSupportType); agent->UpdateFocusStatus(boolVal); agent->NotifyForegroundInteractiveStatus(boolVal); diff --git a/test/systemtest/wms/window_mode_support_info_test.cpp b/test/systemtest/wms/window_mode_support_info_test.cpp index 03dfee6484..43fee13499 100644 --- a/test/systemtest/wms/window_mode_support_info_test.cpp +++ b/test/systemtest/wms/window_mode_support_info_test.cpp @@ -25,7 +25,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { using Utils = WindowTestUtils; -class WindowModeSupportInfoTest : public testing::Test { +class WindowWindowModeSupportTypeTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); @@ -37,7 +37,7 @@ private: static constexpr uint32_t WAIT_SYANC_US = 100000; }; -void WindowModeSupportInfoTest::SetUpTestCase() +void WindowWindowModeSupportTypeTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); @@ -45,11 +45,11 @@ void WindowModeSupportInfoTest::SetUpTestCase() Utils::InitByDisplayRect(displayRect); } -void WindowModeSupportInfoTest::TearDownTestCase() +void WindowWindowModeSupportTypeTest::TearDownTestCase() { } -void WindowModeSupportInfoTest::SetUp() +void WindowWindowModeSupportTypeTest::SetUp() { fullAppInfo_1_ = { .name = "FullWindow", @@ -71,39 +71,39 @@ void WindowModeSupportInfoTest::SetUp() }; } -void WindowModeSupportInfoTest::TearDown() +void WindowWindowModeSupportTypeTest::TearDown() { } namespace { /** - * @tc.name: WindowModeSupportInfo01 - * @tc.desc: SetRequestModeSupportInfo | GetRequestModeSupportInfo + * @tc.name: WindowWindowModeSupportType01 + * @tc.desc: SetRequestWindowModeSupportType | GetRequestWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3) +HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType01, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestModeSupportInfo()); + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestWindowModeSupportType()); window->Destroy(); } /** - * @tc.name: WindowModeSupportInfo02 - * @tc.desc: modeSupportInfo test for single window, only support fullScreen mode + * @tc.name: WindowWindowModeSupportType02 + * @tc.desc: windowModeSupportType test for single window, only support fullScreen mode * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3) +HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType02, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); @@ -121,17 +121,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo03 - * @tc.desc: modeSupportInfo test for single window, support both fullScreen and floating mode + * @tc.name: WindowWindowModeSupportType03 + * @tc.desc: windowModeSupportType test for single window, support both fullScreen and floating mode * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3) +HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType03, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); @@ -153,17 +153,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo04 - * @tc.desc: modeSupportInfo test for single window, window mode is not supported when show, show failed + * @tc.name: WindowWindowModeSupportType04 + * @tc.desc: windowModeSupportType test for single window, window mode is not supported when show, show failed * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3) +HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType04, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); ASSERT_NE(WMError::WM_OK, window->Show()); @@ -172,20 +172,20 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo05 - * @tc.desc: modeSupportInfo test for layout cascade + * @tc.name: WindowWindowModeSupportType05 + * @tc.desc: windowModeSupportType test for layout cascade * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) +HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType05, Function | MediumTest | Level3) { const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); if (window1 == nullptr) { return; } - window1->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window1->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); ASSERT_NE(nullptr, window2); - window2->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window2->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); @@ -203,17 +203,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo06 - * @tc.desc: modeSupportInfo test for layout tile + * @tc.name: WindowWindowModeSupportType06 + * @tc.desc: windowModeSupportType test for layout tile * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) +HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType06, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); diff --git a/utils/include/window_helper.h b/utils/include/window_helper.h index ecc6dfa1b3..95e8973569 100644 --- a/utils/include/window_helper.h +++ b/utils/include/window_helper.h @@ -208,19 +208,19 @@ public: static_cast(x_end - x_begin), static_cast(y_end - y_begin) }; } - static bool IsWindowModeSupported(uint32_t modeSupportInfo, WindowMode mode) + static bool IsWindowModeSupported(uint32_t windowModeSupportType, WindowMode mode) { switch (mode) { case WindowMode::WINDOW_MODE_FULLSCREEN: - return WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN & windowModeSupportType; case WindowMode::WINDOW_MODE_FLOATING: - return WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING & windowModeSupportType; case WindowMode::WINDOW_MODE_SPLIT_PRIMARY: - return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY & windowModeSupportType; case WindowMode::WINDOW_MODE_SPLIT_SECONDARY: - return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY & windowModeSupportType; case WindowMode::WINDOW_MODE_PIP: - return WindowModeSupport::WINDOW_MODE_SUPPORT_PIP & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_PIP & windowModeSupportType; case WindowMode::WINDOW_MODE_UNDEFINED: return false; default: @@ -228,10 +228,10 @@ public: } } - static WindowMode GetWindowModeFromModeSupportInfo(uint32_t modeSupportInfo) + static WindowMode GetWindowModeFromWindowModeSupportType(uint32_t windowModeSupportType) { // get the binary number consists of the last 1 and 0 behind it - uint32_t windowModeSupport = modeSupportInfo & (~modeSupportInfo + 1); + uint32_t windowModeSupport = windowModeSupportType & (~windowModeSupportType + 1); switch (windowModeSupport) { case WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN: @@ -249,20 +249,20 @@ public: } } - static uint32_t ConvertSupportModesToSupportInfo(const std::vector& supportModes) + static uint32_t ConvertSupportModesToSupportType(const std::vector& supportModes) { - uint32_t modeSupportInfo = 0; + uint32_t windowModeSupportType = 0; for (auto& mode : supportModes) { if (mode == AppExecFwk::SupportWindowMode::FULLSCREEN) { - modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; + windowModeSupportType |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; } else if (mode == AppExecFwk::SupportWindowMode::SPLIT) { - modeSupportInfo |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + windowModeSupportType |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); } else if (mode == AppExecFwk::SupportWindowMode::FLOATING) { - modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + windowModeSupportType |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; } } - return modeSupportInfo; + return windowModeSupportType; } static bool IsPointInTargetRect(int32_t pointPosX, int32_t pointPosY, const Rect& targetRect) @@ -522,11 +522,11 @@ public: return false; } - static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t modeSupportInfo) + static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t windowModeSupportType) { uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); - if (isShowWhenLocked && (splitModeInfo == modeSupportInfo)) { + if (isShowWhenLocked && (splitModeInfo == windowModeSupportType)) { return true; } return false; @@ -541,15 +541,15 @@ public: return false; } - static bool CheckSupportWindowMode(WindowMode winMode, uint32_t modeSupportInfo, + static bool CheckSupportWindowMode(WindowMode winMode, uint32_t windowModeSupportType, const sptr& info) { if (!WindowHelper::IsMainWindow(info->GetWindowType())) { return true; } - if ((!IsWindowModeSupported(modeSupportInfo, winMode)) || - (IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), modeSupportInfo))) { + if ((!IsWindowModeSupported(windowModeSupportType, winMode)) || + (IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), windowModeSupportType))) { return false; } return true; diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 000090246e..103091dc82 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -70,8 +70,8 @@ public: void SetAnimationFlag(uint32_t animationFlag); void SetWindowSizeChangeReason(WindowSizeChangeReason reason); void SetTokenState(bool hasToken); - void SetModeSupportInfo(uint32_t modeSupportInfo); - void SetRequestModeSupportInfo(uint32_t requestModeSupportInfo); + void SetWindowModeSupportType(uint32_t windowModeSupportType); + void SetRequestWindowModeSupportType(uint32_t requestWindowModeSupportType); void SetDragType(DragType dragType); void SetStretchable(bool stretchable); void SetOriginRect(const Rect& rect); @@ -122,8 +122,8 @@ public: bool GetDecorEnable() const; const PointInfo& GetHitOffset() const; uint32_t GetAnimationFlag() const; - uint32_t GetModeSupportInfo() const; - uint32_t GetRequestModeSupportInfo() const; + uint32_t GetWindowModeSupportType() const; + uint32_t GetRequestWindowModeSupportType() const; DragType GetDragType() const; bool GetStretchable() const; const Rect& GetOriginRect() const; @@ -190,10 +190,10 @@ private: uint32_t parentId_ = INVALID_WINDOW_ID; PointInfo hitOffset_ { 0, 0 }; uint32_t animationFlag_ { static_cast(WindowAnimation::DEFAULT) }; - // modeSupportInfo_ means supported modes in runtime, which can be changed - uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; - // requestModeSupportInfo_ is configured in abilityInfo, usually can't be changed - uint32_t requestModeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + // windowModeSupportType_ means supported modes in runtime, which can be changed + uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + // requestWindowModeSupportType_ is configured in abilityInfo, usually can't be changed + uint32_t requestWindowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED; std::unordered_map sysBarPropMap_ { { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() }, diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index a87b664cfc..ba1f8b3ee0 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -99,7 +99,7 @@ struct ModeChangeHotZonesConfig { struct SystemConfig : public Parcelable { bool isSystemDecorEnable_ = true; - uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; bool isStretchable_ = false; WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; KeyboardAnimationCurve animationIn_; @@ -110,7 +110,7 @@ struct SystemConfig : public Parcelable { virtual bool Marshalling(Parcel& parcel) const override { if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) || - !parcel.WriteUint32(decorModeSupportInfo_)) { + !parcel.WriteUint32(decorWindowModeSupportType_)) { return false; } @@ -135,7 +135,7 @@ struct SystemConfig : public Parcelable { SystemConfig* config = new SystemConfig(); config->isSystemDecorEnable_ = parcel.ReadBool(); config->isStretchable_ = parcel.ReadBool(); - config->decorModeSupportInfo_ = parcel.ReadUint32(); + config->decorWindowModeSupportType_ = parcel.ReadUint32(); config->defaultWindowMode_ = static_cast(parcel.ReadUint32()); sptr animationIn = parcel.ReadParcelable(); if (animationIn == nullptr) { diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index 7dbaff1739..c7d3abd1ce 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -61,7 +61,7 @@ void WindowProperty::SetWindowType(WindowType type) void WindowProperty::SetWindowMode(WindowMode mode) { - if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { + if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(windowModeSupportType_, mode)) { return; } if (!WindowHelper::IsSplitWindowMode(mode_)) { @@ -72,7 +72,7 @@ void WindowProperty::SetWindowMode(WindowMode mode) void WindowProperty::SetLastWindowMode(WindowMode mode) { - if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { + if (!WindowHelper::IsWindowModeSupported(windowModeSupportType_, mode)) { return; } lastMode_ = mode; @@ -331,8 +331,8 @@ WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const void WindowProperty::ResumeLastWindowMode() { // if lastMode isn't supported, get supported mode from supportModeInfo - if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, lastMode_)) { - auto mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo_); + if (!WindowHelper::IsWindowModeSupported(windowModeSupportType_, lastMode_)) { + auto mode = WindowHelper::GetWindowModeFromWindowModeSupportType(windowModeSupportType_); if (!WindowHelper::IsSplitWindowMode(mode)) { mode_ = mode; } @@ -481,14 +481,14 @@ void WindowProperty::SetTokenState(bool hasToken) tokenState_ = hasToken; } -void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowProperty::SetWindowModeSupportType(uint32_t windowModeSupportType) { - modeSupportInfo_ = modeSupportInfo; + windowModeSupportType_ = windowModeSupportType; } -void WindowProperty::SetRequestModeSupportInfo(uint32_t requestModeSupportInfo) +void WindowProperty::SetRequestWindowModeSupportType(uint32_t requestWindowModeSupportType) { - requestModeSupportInfo_ = requestModeSupportInfo; + requestWindowModeSupportType_ = requestWindowModeSupportType; } uint32_t WindowProperty::GetWindowId() const @@ -511,14 +511,14 @@ uint32_t WindowProperty::GetAnimationFlag() const return animationFlag_; } -uint32_t WindowProperty::GetModeSupportInfo() const +uint32_t WindowProperty::GetWindowModeSupportType() const { - return modeSupportInfo_; + return windowModeSupportType_; } -uint32_t WindowProperty::GetRequestModeSupportInfo() const +uint32_t WindowProperty::GetRequestWindowModeSupportType() const { - return requestModeSupportInfo_; + return requestWindowModeSupportType_; } bool WindowProperty::GetTokenState() const @@ -729,7 +729,7 @@ bool WindowProperty::Marshalling(Parcel& parcel) const parcel.WriteUint32(static_cast(windowSizeChangeReason_)) && parcel.WriteBool(tokenState_) && parcel.WriteUint32(callingWindow_) && parcel.WriteUint32(static_cast(requestedOrientation_)) && parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) && - parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(requestModeSupportInfo_) && + parcel.WriteUint32(windowModeSupportType_) && parcel.WriteUint32(requestWindowModeSupportType_) && parcel.WriteUint32(static_cast(dragType_)) && parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) && parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) && @@ -777,8 +777,8 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetRequestedOrientation(static_cast(parcel.ReadUint32())); property->SetTurnScreenOn(parcel.ReadBool()); property->SetKeepScreenOn(parcel.ReadBool()); - property->SetModeSupportInfo(parcel.ReadUint32()); - property->SetRequestModeSupportInfo(parcel.ReadUint32()); + property->SetWindowModeSupportType(parcel.ReadUint32()); + property->SetRequestWindowModeSupportType(parcel.ReadUint32()); property->SetDragType(static_cast(parcel.ReadUint32())); uint32_t w = parcel.ReadUint32(); uint32_t h = parcel.ReadUint32(); @@ -843,7 +843,7 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action) ret = ret && parcel.WriteFloat(brightness_); break; case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: - ret = ret && parcel.WriteUint32(modeSupportInfo_); + ret = ret && parcel.WriteUint32(windowModeSupportType_); break; case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: ret = ret && MarshallingTouchHotAreas(parcel); @@ -921,7 +921,7 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action) SetBrightness(parcel.ReadFloat()); break; case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: - SetModeSupportInfo(parcel.ReadUint32()); + SetWindowModeSupportType(parcel.ReadUint32()); break; case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: UnmarshallingTouchHotAreas(parcel, this); @@ -990,8 +990,8 @@ void WindowProperty::CopyFrom(const sptr& property) requestedOrientation_ = property->requestedOrientation_; turnScreenOn_ = property->turnScreenOn_; keepScreenOn_ = property->keepScreenOn_; - modeSupportInfo_ = property->modeSupportInfo_; - requestModeSupportInfo_ = property->requestModeSupportInfo_; + windowModeSupportType_ = property->windowModeSupportType_; + requestWindowModeSupportType_ = property->requestWindowModeSupportType_; dragType_ = property->dragType_; originRect_ = property->originRect_; isStretchable_ = property->isStretchable_; diff --git a/utils/test/unittest/window_property_test.cpp b/utils/test/unittest/window_property_test.cpp index f322667abf..ec2294090c 100644 --- a/utils/test/unittest/window_property_test.cpp +++ b/utils/test/unittest/window_property_test.cpp @@ -176,19 +176,19 @@ HWTEST_F(WindowPropertyTest, SetAbilityInfo, Function | SmallTest | Level2) HWTEST_F(WindowPropertyTest, ResumeLastWindowMode, Function | SmallTest | Level2) { WindowProperty winPropDst; - winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_PIP, winPropDst.mode_); - winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, winPropDst.mode_); - winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); @@ -453,31 +453,31 @@ HWTEST_F(WindowPropertyTest, GetAnimationFlag018, Function | SmallTest | Level2) } /** - * @tc.name: GetModeSupportInfo019 - * @tc.desc: GetModeSupportInfo test + * @tc.name: GetWindowModeSupportType019 + * @tc.desc: GetWindowModeSupportType test * @tc.type: FUNC */ -HWTEST_F(WindowPropertyTest, GetModeSupportInfo019, Function | SmallTest | Level2) +HWTEST_F(WindowPropertyTest, GetWindowModeSupportType019, Function | SmallTest | Level2) { WindowProperty winPropSrc; - uint32_t modeSupportInfo = 1; - winPropSrc.SetModeSupportInfo(modeSupportInfo); - uint32_t res = winPropSrc.GetModeSupportInfo(); - ASSERT_EQ(res, modeSupportInfo); + uint32_t windowModeSupportType = 1; + winPropSrc.SetWindowModeSupportType(windowModeSupportType); + uint32_t res = winPropSrc.GetWindowModeSupportType(); + ASSERT_EQ(res, windowModeSupportType); } /** - * @tc.name: GetRequestModeSupportInfo020 - * @tc.desc: GetRequestModeSupportInfo test + * @tc.name: GetRequestWindowModeSupportType020 + * @tc.desc: GetRequestWindowModeSupportType test * @tc.type: FUNC */ -HWTEST_F(WindowPropertyTest, GetRequestModeSupportInfo020, Function | SmallTest | Level2) +HWTEST_F(WindowPropertyTest, GetRequestWindowModeSupportType020, Function | SmallTest | Level2) { WindowProperty winPropSrc; - uint32_t requestModeSupportInfo = 1; - winPropSrc.SetRequestModeSupportInfo(requestModeSupportInfo); - uint32_t res = winPropSrc.GetRequestModeSupportInfo(); - ASSERT_EQ(res, requestModeSupportInfo); + uint32_t requestWindowModeSupportType = 1; + winPropSrc.SetRequestWindowModeSupportType(requestWindowModeSupportType); + uint32_t res = winPropSrc.GetRequestWindowModeSupportType(); + ASSERT_EQ(res, requestWindowModeSupportType); } /** diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 72c8c6e6bf..5c54c1c08f 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -84,7 +84,7 @@ public: void SetMainWindowTopmost(bool isTopmost); bool IsMainWindowTopmost() const; void AddWindowFlag(WindowFlag flag); - void SetModeSupportInfo(uint32_t modeSupportInfo); + void SetWindowModeSupportType(uint32_t windowModeSupportType); void SetFloatingWindowAppType(bool isAppType); void SetTouchHotAreas(const std::vector& rects); void KeepKeyboardOnFocus(bool keepKeyboardFlag); @@ -137,7 +137,7 @@ public: WindowLimits GetUserWindowLimits() const; WindowLimits GetConfigWindowLimitsVP() const; float GetLastLimitsVpr() const; - uint32_t GetModeSupportInfo() const; + uint32_t GetWindowModeSupportType() const; std::unordered_map GetSystemBarProperty() const; bool IsDecorEnable(); uint32_t GetAnimationFlag() const; @@ -248,7 +248,7 @@ private: bool WriteActionUpdateWindowMask(Parcel& parcel); bool WriteActionUpdateTopmost(Parcel& parcel); bool WriteActionUpdateMainWindowTopmost(Parcel& parcel); - bool WriteActionUpdateModeSupportInfo(Parcel& parcel); + bool WriteActionUpdateWindowModeSupportType(Parcel& parcel); void ReadActionUpdateTurnScreenOn(Parcel& parcel); void ReadActionUpdateKeepScreenOn(Parcel& parcel); void ReadActionUpdateFocusable(Parcel& parcel); @@ -272,7 +272,7 @@ private: void ReadActionUpdateWindowMask(Parcel& parcel); void ReadActionUpdateTopmost(Parcel& parcel); void ReadActionUpdateMainWindowTopmost(Parcel& parcel); - void ReadActionUpdateModeSupportInfo(Parcel& parcel); + void ReadActionUpdateWindowModeSupportType(Parcel& parcel); std::string windowName_; SessionInfo sessionInfo_; Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) @@ -311,7 +311,7 @@ private: float lastVpr_ = 0.0f; PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}}; KeyboardLayoutParams keyboardLayoutParams_; - uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; std::unordered_map sysBarPropMap_ { { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, @@ -375,14 +375,14 @@ private: struct FreeMultiWindowConfig : public Parcelable { bool isSystemDecorEnable_ = true; - uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; uint32_t maxMainFloatingWindowNumber_ = 0; virtual bool Marshalling(Parcel& parcel) const override { if (!parcel.WriteBool(isSystemDecorEnable_) || - !parcel.WriteUint32(decorModeSupportInfo_)) { + !parcel.WriteUint32(decorWindowModeSupportType_)) { return false; } @@ -400,7 +400,7 @@ struct FreeMultiWindowConfig : public Parcelable { return nullptr; } config->isSystemDecorEnable_ = parcel.ReadBool(); - config->decorModeSupportInfo_ = parcel.ReadUint32(); + config->decorWindowModeSupportType_ = parcel.ReadUint32(); config->defaultWindowMode_ = static_cast(parcel.ReadUint32()); config->maxMainFloatingWindowNumber_ = parcel.ReadUint32(); return config; @@ -437,7 +437,7 @@ struct AppForceLandscapeConfig : public Parcelable { struct SystemSessionConfig : public Parcelable { bool isSystemDecorEnable_ = true; - uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; bool isStretchable_ = false; WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; KeyboardAnimationCurve animationIn_; @@ -462,7 +462,7 @@ struct SystemSessionConfig : public Parcelable { virtual bool Marshalling(Parcel& parcel) const override { if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) || - !parcel.WriteUint32(decorModeSupportInfo_)) { + !parcel.WriteUint32(decorWindowModeSupportType_)) { return false; } @@ -508,7 +508,7 @@ struct SystemSessionConfig : public Parcelable { } config->isSystemDecorEnable_ = parcel.ReadBool(); config->isStretchable_ = parcel.ReadBool(); - config->decorModeSupportInfo_ = parcel.ReadUint32(); + config->decorWindowModeSupportType_ = parcel.ReadUint32(); config->defaultWindowMode_ = static_cast(parcel.ReadUint32()); sptr animationIn = parcel.ReadParcelable(); if (animationIn == nullptr) { diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 4291133eb7..1c0ab44a30 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -80,7 +80,7 @@ const std::map WindowSessionProperty::writeFun std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST), &WindowSessionProperty::WriteActionUpdateTopmost), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO), - &WindowSessionProperty::WriteActionUpdateModeSupportInfo), + &WindowSessionProperty::WriteActionUpdateWindowModeSupportType), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST), &WindowSessionProperty::WriteActionUpdateMainWindowTopmost), }; @@ -139,7 +139,7 @@ const std::map WindowSessionProperty::readFuncM std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST), &WindowSessionProperty::ReadActionUpdateTopmost), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO), - &WindowSessionProperty::ReadActionUpdateModeSupportInfo), + &WindowSessionProperty::ReadActionUpdateWindowModeSupportType), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST), &WindowSessionProperty::ReadActionUpdateMainWindowTopmost), }; @@ -544,14 +544,14 @@ bool WindowSessionProperty::IsDecorEnable() return isDecorEnable_; } -void WindowSessionProperty::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowSessionProperty::SetWindowModeSupportType(uint32_t windowModeSupportType) { - modeSupportInfo_ = modeSupportInfo; + windowModeSupportType_ = windowModeSupportType; } -uint32_t WindowSessionProperty::GetModeSupportInfo() const +uint32_t WindowSessionProperty::GetWindowModeSupportType() const { - return modeSupportInfo_; + return windowModeSupportType_; } void WindowSessionProperty::SetAnimationFlag(uint32_t animationFlag) @@ -1169,6 +1169,7 @@ void WindowSessionProperty::CopyFrom(const sptr& property maximizeMode_ = property->maximizeMode_; windowMode_ = property->windowMode_; limits_ = property->limits_; + windowModeSupportType_ = property->windowModeSupportType_; sysBarPropMap_ = property->sysBarPropMap_; isDecorEnable_ = property->isDecorEnable_; animationFlag_ = property->animationFlag_; @@ -1313,9 +1314,9 @@ bool WindowSessionProperty::WriteActionUpdateMainWindowTopmost(Parcel& parcel) return MarshallingMainWindowTopmost(parcel); } -bool WindowSessionProperty::WriteActionUpdateModeSupportInfo(Parcel& parcel) +bool WindowSessionProperty::WriteActionUpdateWindowModeSupportType(Parcel& parcel) { - return parcel.WriteUint32(modeSupportInfo_); + return parcel.WriteUint32(windowModeSupportType_); } void WindowSessionProperty::Read(Parcel& parcel, WSPropertyChangeAction action) @@ -1449,9 +1450,9 @@ void WindowSessionProperty::ReadActionUpdateMainWindowTopmost(Parcel& parcel) UnmarshallingMainWindowTopmost(parcel, this); } -void WindowSessionProperty::ReadActionUpdateModeSupportInfo(Parcel& parcel) +void WindowSessionProperty::ReadActionUpdateWindowModeSupportType(Parcel& parcel) { - SetModeSupportInfo(parcel.ReadUint32()); + SetWindowModeSupportType(parcel.ReadUint32()); } void WindowSessionProperty::SetTransform(const Transform& trans) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index 2d9ae17925..d773abeeff 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -32,12 +32,14 @@ class StartWindowOption; } namespace OHOS::AppExecFwk { struct AbilityInfo; +enum class SupportWindowMode; } namespace OHOS::Rosen { class RSTransaction; constexpr int32_t ROTATE_ANIMATION_DURATION = 400; constexpr int32_t INVALID_SESSION_ID = 0; +constexpr int32_t WINDOW_SUPPORT_MODE_MAX_SIZE = 4; enum class WSError : int32_t { WS_OK = 0, @@ -362,6 +364,12 @@ struct SessionInfo { */ bool isNewAppInstance_ = false; std::string appInstanceKey_; + + /** + * PC Window + */ + std::vector supportWindowModes; + uint32_t windowModeSupportType = 0; }; enum class SessionFlag : uint32_t { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 3a488140cc..8bb7484871 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -894,6 +894,22 @@ JsSessionType GetApiType(WindowType type) } } +static napi_value CreateSupportWindowModes(napi_env env, + const std::vector& supportWindowModes) +{ + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, supportWindowModes.size(), &arrayValue); + if (arrayValue == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "Failed to create napi array"); + return NapiGetUndefined(env); + } + int32_t index = 0; + for (const auto supportWindowMode : supportWindowModes) { + napi_set_element(env, arrayValue, index++, CreateJsValue(env, static_cast(supportWindowMode))); + } + return arrayValue; +} + napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) { napi_value objValue = nullptr; @@ -942,6 +958,8 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) CreateJsValue(env, sessionInfo.errorReason)); napi_set_named_property(env, objValue, "isFromIcon", CreateJsValue(env, sessionInfo.isFromIcon_)); SetJsSessionInfoByWant(env, sessionInfo, objValue); + napi_set_named_property(env, objValue, "supportWindowModes", + CreateSupportWindowModes(env, sessionInfo.supportWindowModes)); return objValue; } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 0e68efc0eb..1385909d2e 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -754,7 +754,7 @@ private: WSPropertyChangeAction action); WMError HandleActionUpdateMainWindowTopmost(const sptr& property, WSPropertyChangeAction action); - WMError HandleActionUpdateModeSupportInfo(const sptr& property, + WMError HandleActionUpdateWindowModeSupportType(const sptr& property, WSPropertyChangeAction action); WMError ProcessUpdatePropertyByAction(const sptr& property, WSPropertyChangeAction action); diff --git a/window_scene/session/host/src/move_drag_controller.cpp b/window_scene/session/host/src/move_drag_controller.cpp index d849b91fad..695039aca8 100644 --- a/window_scene/session/host/src/move_drag_controller.cpp +++ b/window_scene/session/host/src/move_drag_controller.cpp @@ -823,7 +823,7 @@ void MoveDragController::InitDecorValue(const sptr proper bool isDialogWindow = WindowHelper::IsDialogWindow(windowType); isDecorEnable_ = (isMainWindow || ((isSubWindow || isDialogWindow) && property->IsDecorEnable())) && sysConfig.isSystemDecorEnable_ && - WindowHelper::IsWindowModeSupported(sysConfig.decorModeSupportInfo_, property->GetWindowMode()); + WindowHelper::IsWindowModeSupported(sysConfig.decorWindowModeSupportType_, property->GetWindowMode()); } void MoveDragController::ProcessSessionRectChange(SizeChangeReason reason) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 9383782e87..fae3b3f8ee 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2342,7 +2342,7 @@ bool SceneSession::IsFullScreenMovable() return false; } return property->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && - WindowHelper::IsWindowModeSupported(property->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING); + WindowHelper::IsWindowModeSupported(property->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FLOATING); } bool SceneSession::IsMovable() @@ -2440,7 +2440,7 @@ bool SceneSession::IsDecorEnable() const bool isValidWindow = isMainWindow || ((isSubWindow || isDialogWindow) && property->IsDecorEnable()); bool isWindowModeSupported = WindowHelper::IsWindowModeSupported( - systemConfig_.decorModeSupportInfo_, property->GetWindowMode()); + systemConfig_.decorWindowModeSupportType_, property->GetWindowMode()); bool enable = isValidWindow && systemConfig_.isSystemDecorEnable_ && isWindowModeSupported; return enable; } @@ -3747,6 +3747,9 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptrIsPcOrPadEnableActivation()) { info.startWindowOption = abilitySessionInfo->startWindowOption; + info.supportWindowModes.assign(abilitySessionInfo->supportWindowModes.begin(), + abilitySessionInfo->supportWindowModes.end()); + info.windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(info.supportWindowModes); } if (info.want != nullptr) { info.windowMode = info.want->GetIntParam(AAFwk::Want::PARAM_RESV_WINDOW_MODE, 0); @@ -3759,11 +3762,13 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST): return HandleActionUpdateMainWindowTopmost(property, action); case static_cast(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO): - return HandleActionUpdateModeSupportInfo(property, action); + return HandleActionUpdateWindowModeSupportType(property, action); default: TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!"); return WMError::WM_DO_NOTHING; @@ -5215,17 +5220,17 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag) return WMError::WM_OK; } -WMError SceneSession::HandleActionUpdateModeSupportInfo(const sptr& property, +WMError SceneSession::HandleActionUpdateWindowModeSupportType(const sptr& property, WSPropertyChangeAction action) { if (!property->GetSystemCalling()) { - TLOGE(WmsLogTag::DEFAULT, "Update property modeSupportInfo permission denied!"); + TLOGE(WmsLogTag::DEFAULT, "Update property windowModeSupportType permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } auto sessionProperty = GetSessionProperty(); if (sessionProperty != nullptr) { - sessionProperty->SetModeSupportInfo(property->GetModeSupportInfo()); + sessionProperty->SetWindowModeSupportType(property->GetWindowModeSupportType()); } return WMError::WM_OK; } diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index d36a28d66a..66736fc1c1 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1088,6 +1088,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetWindowRect(rect); property->SetPersistentId(GetPersistentId()); property->SetFullScreenStart(GetSessionInfo().fullScreenStart_); + property->SetWindowModeSupportType(GetSessionInfo().windowModeSupportType); } if (sessionProperty && property) { property->SetRequestedOrientation(sessionProperty->GetRequestedOrientation()); diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 16ccb02566..934c33b8f4 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -299,6 +299,7 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt } property->SetCollaboratorType(reply.ReadInt32()); property->SetFullScreenStart(reply.ReadBool()); + property->SetWindowModeSupportType(reply.ReadUint32()); property->SetCompatibleModeInPc(reply.ReadBool()); property->SetCompatibleWindowSizeInPc(reply.ReadInt32(), reply.ReadInt32(), reply.ReadInt32(), reply.ReadInt32()); @@ -484,6 +485,21 @@ WSError SessionProxy::PendingSessionActivation(sptr abilityS return WSError::WS_ERROR_IPC_FAILED; } } + auto size = abilitySessionInfo->supportWindowModes.size(); + if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) { + if (!data.WriteUint32(static_cast(size))) { + return WSError::WS_ERROR_IPC_FAILED; + } + for (decltype(size) i = 0; i < size; i++) { + if (!data.WriteInt32(static_cast(abilitySessionInfo->supportWindowModes[i]))) { + return WSError::WS_ERROR_IPC_FAILED; + } + } + } else { + if (!data.WriteUint32(0)) { + return WSError::WS_ERROR_IPC_FAILED; + } + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 782bb78442..2f86a896e8 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -377,6 +377,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteUint32(winRect.height_); reply.WriteInt32(property->GetCollaboratorType()); reply.WriteBool(property->GetFullScreenStart()); + reply.WriteUint32(property->GetWindowModeSupportType()); reply.WriteBool(property->GetCompatibleModeInPc()); reply.WriteInt32(property->GetCompatibleInPcPortraitWidth()); reply.WriteInt32(property->GetCompatibleInPcPortraitHeight()); @@ -656,6 +657,14 @@ int SessionStub::HandlePendingSessionActivation(MessageParcel& data, MessageParc auto startWindowOption = data.ReadParcelable(); abilitySessionInfo->startWindowOption.reset(startWindowOption); } + uint32_t size = data.ReadUint32(); + if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) { + abilitySessionInfo->supportWindowModes.reserve(size); + for (uint32_t i = 0; i < size; i++) { + abilitySessionInfo->supportWindowModes.push_back( + static_cast(data.ReadInt32())); + } + } WSError errCode = PendingSessionActivation(abilitySessionInfo); reply.WriteUint32(static_cast(errCode)); return ERR_NONE; diff --git a/window_scene/session_manager/src/hidump_controller.cpp b/window_scene/session_manager/src/hidump_controller.cpp index acc919686a..5aedb4bda2 100644 --- a/window_scene/session_manager/src/hidump_controller.cpp +++ b/window_scene/session_manager/src/hidump_controller.cpp @@ -101,7 +101,8 @@ void HidumpController::DumpSessionParamList(std::ostringstream& oss) << std::endl << "callingPid callingUid isSystem reuse lockedState time type isSystemCalling topmost" << std::endl - << "isPrivacyMode isSystemPrivacyMode parentId flag parentPersistentId mode state modeSupportInfo animationFlag" + << "isPrivacyMode isSystemPrivacyMode parentId flag parentPersistentId mode " + << "state windowModeSupportType animationFlag" << std::endl << "isFloatingAppType isNonSystemFloating forceHide isNeedUpdateMode " << "meedDefaultAnimationFlag shouldHideNonSecure forceHideState" @@ -130,7 +131,7 @@ void HidumpController::DumpSessionParam( << property->GetParentPersistentId() << "|" << static_cast(property->GetWindowMode()) << "|" << static_cast(property->GetWindowState()) << "|" - << property->GetModeSupportInfo() << "|" + << property->GetWindowModeSupportType() << "|" << property->GetAnimationFlag() << "|" << std::endl << property->IsFloatingWindowAppType() << "|" @@ -343,7 +344,7 @@ void HidumpController::DumpSysconfigParamList(std::ostringstream& oss) { oss << "Sysconfig:" << std::endl - << "isSystemDecorEnable decorModeSupportInfo isStretchable defaultWindowMode " + << "isSystemDecorEnable decorWindowModeSupportType isStretchable defaultWindowMode " << "keyboardAnimationConfig maxFloatingWindowSize windowUIType" << std::endl << "miniWidthOfMainWindow miniHeightOfMainWindow miniWidthOfSubWindow miniHeightOfSubWindow backgroundswitch " @@ -358,7 +359,7 @@ void HidumpController::DumpSysconfigParam(std::ostringstream& oss, sptr(systemConfig.defaultWindowMode_) << "|" << "[" << systemConfig.animationIn_.curveType_ << " " @@ -377,7 +378,7 @@ void HidumpController::DumpSysconfigParam(std::ostringstream& oss, sptr(freeMultiWindowConfig.defaultWindowMode_) << " " << freeMultiWindowConfig.maxMainFloatingWindowNumber_<< "]|" << std::endl; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index f58e8f7912..a6b4c0016a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -597,7 +597,7 @@ void SceneSessionManager::LoadFreeMultiWindowConfig(bool enable) FreeMultiWindowConfig freeMultiWindowConfig = systemConfig_.freeMultiWindowConfig_; if (enable) { systemConfig_.defaultWindowMode_ = freeMultiWindowConfig.defaultWindowMode_; - systemConfig_.decorModeSupportInfo_ = freeMultiWindowConfig.decorModeSupportInfo_; + systemConfig_.decorWindowModeSupportType_ = freeMultiWindowConfig.decorWindowModeSupportType_; systemConfig_.isSystemDecorEnable_ = freeMultiWindowConfig.isSystemDecorEnable_; } else { const auto& config = WindowSceneConfig::GetConfig(); @@ -703,10 +703,10 @@ void SceneSessionManager::ConfigDecor(const WindowSceneConfig::ConfigItem& decor } } if (mainConfig && item.IsStrings()) { - systemConfig_.decorModeSupportInfo_ = support; + systemConfig_.decorWindowModeSupportType_ = support; } if (!mainConfig && item.IsStrings()) { - systemConfig_.freeMultiWindowConfig_.decorModeSupportInfo_ = support; + systemConfig_.freeMultiWindowConfig_.decorWindowModeSupportType_ = support; } } } diff --git a/window_scene/test/unittest/scene_session_manager_test2.cpp b/window_scene/test/unittest/scene_session_manager_test2.cpp index f42d59cc07..2abdeb206b 100644 --- a/window_scene/test/unittest/scene_session_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_test2.cpp @@ -507,7 +507,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, static_cast(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN)); } @@ -525,7 +525,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor02, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); } @@ -544,7 +544,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor03, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); } @@ -563,7 +563,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor04, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); } @@ -582,7 +582,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor05, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); } @@ -602,7 +602,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor06, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WINDOW_MODE_SUPPORT_ALL); } diff --git a/window_scene/test/unittest/scene_session_manager_test3.cpp b/window_scene/test/unittest/scene_session_manager_test3.cpp index e10dbbfcce..aa0eff850e 100644 --- a/window_scene/test/unittest/scene_session_manager_test3.cpp +++ b/window_scene/test/unittest/scene_session_manager_test3.cpp @@ -1369,7 +1369,7 @@ HWTEST_F(SceneSessionManagerTest3, HandleHideNonSystemFloatingWindows, Function property->SetFloatingWindowAppType(true); ssm_->UpdateForceHideState(sceneSession, property, true); ssm_->UpdateForceHideState(sceneSession, property, false); - uint32_t result = property->GetModeSupportInfo(); + uint32_t result = property->GetWindowModeSupportType(); ASSERT_EQ(result, WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); } diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 7f879c7e61..eed38c67ae 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -333,7 +333,7 @@ HWTEST_F(SceneSessionTest5, TransferPointerEvent01, Function | SmallTest | Level session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); SystemSessionConfig systemConfig; systemConfig.isSystemDecorEnable_ = false; - systemConfig.decorModeSupportInfo_ = 2; + systemConfig.decorWindowModeSupportType_ = 2; session->SetSystemConfig(systemConfig); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEvent(pointerEvent, false)); @@ -790,7 +790,7 @@ HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level SystemSessionConfig systemConfig; systemConfig.isSystemDecorEnable_ = true; - systemConfig.decorModeSupportInfo_ = 2; + systemConfig.decorWindowModeSupportType_ = 2; session->SetSystemConfig(systemConfig); EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); @@ -1302,27 +1302,27 @@ HWTEST_F(SceneSessionTest5, SetUniqueDensityDpi, Function | SmallTest | Level2) } /** - * @tc.name: HandleActionUpdateModeSupportInfo - * @tc.desc: HandleActionUpdateModeSupportInfo function01 + * @tc.name: HandleActionUpdateWindowModeSupportType + * @tc.desc: HandleActionUpdateWindowModeSupportType function01 * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest5, HandleActionUpdateModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest5, HandleActionUpdateWindowModeSupportType, Function | SmallTest | Level2) { SessionInfo info; - info.abilityName_ = "HandleActionUpdateModeSupportInfo"; - info.bundleName_ = "HandleActionUpdateModeSupportInfo"; + info.abilityName_ = "HandleActionUpdateWindowModeSupportType"; + info.bundleName_ = "HandleActionUpdateWindowModeSupportType"; sptr session = sptr::MakeSptr(info, nullptr); ASSERT_NE(session, nullptr); sptr property = sptr::MakeSptr(); property->isSystemCalling_ = true; ASSERT_NE(session, nullptr); session->SetSessionProperty(nullptr); - ASSERT_EQ(WMError::WM_OK, session->HandleActionUpdateModeSupportInfo(property, + ASSERT_EQ(WMError::WM_OK, session->HandleActionUpdateWindowModeSupportType(property, WSPropertyChangeAction::ACTION_UPDATE_RECT)); property->isSystemCalling_ = false; session->SetSessionProperty(property); - ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, session->HandleActionUpdateModeSupportInfo(property, + ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, session->HandleActionUpdateWindowModeSupportType(property, WSPropertyChangeAction::ACTION_UPDATE_RECT)); } diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 35d5a6d171..72c3ad1eae 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -709,7 +709,7 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent02, Function | SmallTest | Level2) SystemSessionConfig sessionConfig; sessionConfig.isSystemDecorEnable_ = true; sessionConfig.backgroundswitch = true; - sessionConfig.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); ASSERT_TRUE(pointerEvent); pointerEvent->SetAgentWindowId(1); @@ -771,7 +771,7 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent03, Function | SmallTest | Level2) SystemSessionConfig sessionConfig; sessionConfig.isSystemDecorEnable_ = true; sessionConfig.backgroundswitch = true; - sessionConfig.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); ASSERT_TRUE(pointerEvent); pointerEvent->SetAgentWindowId(1); @@ -830,7 +830,7 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent04, Function | SmallTest | Level2) SystemSessionConfig sessionConfig; sessionConfig.isSystemDecorEnable_ = true; sessionConfig.backgroundswitch = true; - sessionConfig.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); ASSERT_TRUE(pointerEvent); pointerEvent->SetAgentWindowId(1); diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index f3fcb69d38..c4f4c0ab31 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -406,17 +406,17 @@ HWTEST_F(WindowSessionPropertyTest, IsDecorEnable, Function | SmallTest | Level2 } /** - * @tc.name: SetModeSupportInfo - * @tc.desc: SetModeSupportInfo test + * @tc.name: SetWindowModeSupportType + * @tc.desc: SetWindowModeSupportType test * @tc.type: FUNC */ -HWTEST_F(WindowSessionPropertyTest, SetModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowSessionPropertyTest, SetWindowModeSupportType, Function | SmallTest | Level2) { - uint32_t modeSupportInfo = 1234567890; + uint32_t windowModeSupportType = 1234567890; WindowSessionProperty windowSessionProperty; - windowSessionProperty.SetModeSupportInfo(modeSupportInfo); + windowSessionProperty.SetWindowModeSupportType(windowModeSupportType); WindowSessionProperty *property = new WindowSessionProperty(); - ASSERT_NE(property->GetModeSupportInfo(), 0); + ASSERT_NE(property->GetWindowModeSupportType(), 0); } /** * @tc.name: IsFloatingWindowAppType diff --git a/wm/include/window_agent.h b/wm/include/window_agent.h index e34e9848cc..f155caa1cc 100644 --- a/wm/include/window_agent.h +++ b/wm/include/window_agent.h @@ -30,7 +30,7 @@ public: WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; WMError UpdateWindowMode(WindowMode mode) override; - WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; + WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override; WMError UpdateFocusStatus(bool focused) override; WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WMError UpdateWindowState(WindowState state) override; diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index bceac35e9d..e0bda5fb94 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -133,7 +133,7 @@ public: virtual uint32_t GetWindowId() const override; uint64_t GetDisplayId() const override; virtual uint32_t GetWindowFlags() const override; - uint32_t GetRequestModeSupportInfo() const override; + uint32_t GetRequestWindowModeSupportType() const override; bool IsMainHandlerAvailable() const override; inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback() { @@ -240,13 +240,13 @@ public: virtual void RegisterDialogDeathRecipientListener(const sptr& listener) override; virtual void UnregisterDialogDeathRecipientListener(const sptr& listener) override; virtual void SetAceAbilityHandler(const sptr& handler) override; - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override; + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) override; void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr); void ScheduleUpdateRectTask(const Rect& rectToAce, const Rect& lastOriRect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction, const sptr& display); void UpdateMode(WindowMode mode); - void UpdateModeSupportInfo(uint32_t modeSupportInfo); + void UpdateWindowModeSupportType(uint32_t windowModeSupportType); virtual void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; virtual void ConsumePointerEvent(const std::shared_ptr& inputEvent) override; virtual void RequestVsync(const std::shared_ptr& vsyncCallback) override; @@ -407,8 +407,8 @@ private: bool CheckCameraFloatingWindowMultiCreated(WindowType type); void GetConfigurationFromAbilityInfo(); void UpdateTitleButtonVisibility(); - void SetModeSupportInfo(uint32_t modeSupportInfo); - uint32_t GetModeSupportInfo() const; + void SetWindowModeSupportType(uint32_t windowModeSupportType); + uint32_t GetWindowModeSupportType() const; WMError PreProcessShow(uint32_t reason, bool withAnimation); bool NeedToStopShowing(); void CalculateStartRectExceptHotZone(float virtualPixelRatio); diff --git a/wm/include/zidl/window_interface.h b/wm/include/zidl/window_interface.h index 6719eb75ab..8cfe4d694f 100644 --- a/wm/include/zidl/window_interface.h +++ b/wm/include/zidl/window_interface.h @@ -58,7 +58,7 @@ public: virtual WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) = 0; virtual WMError UpdateWindowMode(WindowMode mode) = 0; - virtual WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) = 0; + virtual WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) = 0; virtual WMError UpdateFocusStatus(bool focused) = 0; virtual WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; virtual WMError UpdateWindowState(WindowState state) = 0; diff --git a/wm/include/zidl/window_proxy.h b/wm/include/zidl/window_proxy.h index b2b81aca06..52e1373e86 100644 --- a/wm/include/zidl/window_proxy.h +++ b/wm/include/zidl/window_proxy.h @@ -32,7 +32,7 @@ public: WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; WMError UpdateWindowMode(WindowMode mode) override; - WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; + WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override; WMError UpdateFocusStatus(bool focused) override; WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WMError UpdateWindowState(WindowState state) override; diff --git a/wm/src/window_agent.cpp b/wm/src/window_agent.cpp index 5f89988eed..824b69e2a2 100644 --- a/wm/src/window_agent.cpp +++ b/wm/src/window_agent.cpp @@ -49,13 +49,13 @@ WMError WindowAgent::UpdateWindowMode(WindowMode mode) return WMError::WM_OK; } -WMError WindowAgent::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +WMError WindowAgent::UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) { if (window_ == nullptr) { WLOGFE("window_ is nullptr"); return WMError::WM_ERROR_NULLPTR; } - window_->UpdateModeSupportInfo(modeSupportInfo); + window_->UpdateWindowModeSupportType(windowModeSupportType); return WMError::WM_OK; } diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 698d739bde..220e3c0ed1 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -365,14 +365,14 @@ uint32_t WindowImpl::GetWindowFlags() const return property_->GetWindowFlags(); } -uint32_t WindowImpl::GetRequestModeSupportInfo() const +uint32_t WindowImpl::GetRequestWindowModeSupportType() const { - return property_->GetRequestModeSupportInfo(); + return property_->GetRequestWindowModeSupportType(); } -uint32_t WindowImpl::GetModeSupportInfo() const +uint32_t WindowImpl::GetWindowModeSupportType() const { - return property_->GetModeSupportInfo(); + return property_->GetWindowModeSupportType(); } bool WindowImpl::IsMainHandlerAvailable() const @@ -434,7 +434,7 @@ WMError WindowImpl::SetWindowMode(WindowMode mode) if (!IsWindowValid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), mode)) { + if (!WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), mode)) { WLOGE("window %{public}u do not support mode: %{public}u", property_->GetWindowId(), static_cast(mode)); return WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE; @@ -955,7 +955,7 @@ WMError WindowImpl::SetLayoutFullScreen(bool status) { WLOGI("Window %{public}u status: %{public}u", property_->GetWindowId(), status); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -1002,7 +1002,7 @@ WMError WindowImpl::SetFullScreen(bool status) { WLOGI("Window %{public}u status: %{public}d", property_->GetWindowId(), status); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -1023,7 +1023,7 @@ WMError WindowImpl::SetFloatingMaximize(bool isEnter) { WLOGFI("id:%{public}d SetFloatingMaximize status: %{public}d", property_->GetWindowId(), isEnter); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { WLOGFE("invalid window or maximize mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -1147,13 +1147,13 @@ void WindowImpl::GetConfigurationFromAbilityInfo() } // get support modes configuration - uint32_t modeSupportInfo = WindowHelper::ConvertSupportModesToSupportInfo(abilityInfo->windowModes); - if (modeSupportInfo == 0) { + uint32_t windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(abilityInfo->windowModes); + if (windowModeSupportType == 0) { WLOGFD("mode config param is 0, all modes is supported"); - modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + windowModeSupportType = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; } - WLOGFD("winId: %{public}u, modeSupportInfo: %{public}u", GetWindowId(), modeSupportInfo); - SetRequestModeSupportInfo(modeSupportInfo); + WLOGFD("winId: %{public}u, windowModeSupportType: %{public}u", GetWindowId(), windowModeSupportType); + SetRequestWindowModeSupportType(windowModeSupportType); // get window size limits configuration WindowLimits sizeLimits; @@ -1187,12 +1187,12 @@ void WindowImpl::UpdateTitleButtonVisibility() if (uiContent_ == nullptr || !IsDecorEnable()) { return; } - auto modeSupportInfo = GetModeSupportInfo(); - bool hideSplitButton = !(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + auto windowModeSupportType = GetWindowModeSupportType(); + bool hideSplitButton = !(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); // not support fullscreen in split and floating mode, or not support float in fullscreen mode - bool hideMaximizeButton = (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && + bool hideMaximizeButton = (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && (GetMode() == WindowMode::WINDOW_MODE_FLOATING || WindowHelper::IsSplitWindowMode(GetMode()))) || - (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && + (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && GetMode() == WindowMode::WINDOW_MODE_FULLSCREEN); WLOGD("[Client] [hideSplit, hideMaximize]: [%{public}d, %{public}d]", hideSplitButton, hideMaximizeButton); uiContent_->HideWindowTitleButton(hideSplitButton, hideMaximizeButton, false, false); @@ -1587,10 +1587,11 @@ bool WindowImpl::NeedToStopShowing() } // show failed when current mode is not support or window only supports split mode and can show when locked bool isShowWhenLocked = GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED); - if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), GetMode()) || - WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetModeSupportInfo())) { - WLOGFE("current mode is not supported, windowId: %{public}u, modeSupportInfo: %{public}u, winMode: %{public}u", - property_->GetWindowId(), GetModeSupportInfo(), GetMode()); + if (!WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), GetMode()) || + WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetWindowModeSupportType())) { + WLOGFE("current mode is not supported, windowId: %{public}u, " + "windowModeSupportType: %{public}u, winMode: %{public}u", + property_->GetWindowId(), GetWindowModeSupportType(), GetMode()); return true; } return false; @@ -1649,7 +1650,7 @@ WMError WindowImpl::PreProcessShow(uint32_t reason, bool withAnimation) return WMError::WM_ERROR_INVALID_OPERATION; } SetDefaultOption(); - SetModeSupportInfo(GetRequestModeSupportInfo()); + SetWindowModeSupportType(GetRequestWindowModeSupportType()); AdjustWindowAnimationFlag(withAnimation); if (NeedToStopShowing()) { // true means stop showing @@ -2187,7 +2188,7 @@ WMError WindowImpl::SetImmersiveModeEnabledState(bool enable) TLOGD(WmsLogTag::WMS_IMMS, "WindowImpl id: %{public}u SetImmersiveModeEnabledState: %{public}u", property_->GetWindowId(), static_cast(enable)); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; @@ -2683,15 +2684,15 @@ void WindowImpl::SetAceAbilityHandler(const sptr& handler) aceAbilityHandler_ = handler; } -void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::SetRequestWindowModeSupportType(uint32_t windowModeSupportType) { - property_->SetRequestModeSupportInfo(modeSupportInfo); - SetModeSupportInfo(modeSupportInfo); + property_->SetRequestWindowModeSupportType(windowModeSupportType); + SetWindowModeSupportType(windowModeSupportType); } -void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::SetWindowModeSupportType(uint32_t windowModeSupportType) { - property_->SetModeSupportInfo(modeSupportInfo); + property_->SetWindowModeSupportType(windowModeSupportType); } void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, @@ -2787,10 +2788,10 @@ void WindowImpl::UpdateMode(WindowMode mode) UpdateDecorEnable(true); } -void WindowImpl::UpdateModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::UpdateWindowModeSupportType(uint32_t windowModeSupportType) { - WLOGFD("modeSupportInfo: %{public}u, winId: %{public}u", modeSupportInfo, GetWindowId()); - SetModeSupportInfo(modeSupportInfo); + WLOGFD("windowModeSupportType: %{public}u, winId: %{public}u", windowModeSupportType, GetWindowId()); + SetWindowModeSupportType(windowModeSupportType); UpdateTitleButtonVisibility(); } @@ -3449,7 +3450,7 @@ void WindowImpl::UpdateDecorEnable(bool needNotify) WLOGFD("Start"); if (WindowHelper::IsMainWindow(property_->GetWindowType())) { bool enable = windowSystemConfig_.isSystemDecorEnable_ && - WindowHelper::IsWindowModeSupported(windowSystemConfig_.decorModeSupportInfo_, GetMode()); + WindowHelper::IsWindowModeSupported(windowSystemConfig_.decorWindowModeSupportType_, GetMode()); WLOGFD("Decor enable: %{public}d", static_cast(enable)); property_->SetDecorEnable(enable); } else { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 1dd251c6ba..12960863e8 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -872,16 +872,21 @@ void WindowSceneSessionImpl::GetConfigurationFromAbilityInfo() UpdateWindowSizeLimits(); UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS); // get support modes configuration - uint32_t modeSupportInfo = WindowHelper::ConvertSupportModesToSupportInfo(abilityInfo->windowModes); - if (modeSupportInfo == 0) { - WLOGFI("mode config param is 0, all modes is supported"); - modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t windowModeSupportType = property_->GetWindowModeSupportType(); + if (windowModeSupportType == 0) { + TLOGI(WmsLogTag::WMS_LAYOUT, "startAbility support window mode param is 0, get modes from ability info"); + windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(abilityInfo->windowModes); + if (windowModeSupportType == 0) { + TLOGI(WmsLogTag::WMS_LAYOUT, "mode config param is 0, all modes is supported"); + windowModeSupportType = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + } } - WLOGFI("winId: %{public}u, modeSupportInfo: %{public}u", GetWindowId(), modeSupportInfo); - property_->SetModeSupportInfo(modeSupportInfo); - // update modeSupportInfo to server + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}u, windowModeSupportType: %{public}u", + GetWindowId(), windowModeSupportType); + property_->SetWindowModeSupportType(windowModeSupportType); + // update windowModeSupportType to server UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); - bool onlySupportFullScreen = (modeSupportInfo == WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && + bool onlySupportFullScreen = (windowModeSupportType == WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && ((!windowSystemConfig_.IsPhoneWindow() && !windowSystemConfig_.IsPadWindow()) || IsFreeMultiWindowMode()); if (onlySupportFullScreen || property_->GetFullScreenStart()) { TLOGI(WmsLogTag::WMS_LAYOUT, "onlySupportFullScreen:%{public}d fullScreenStart:%{public}d", @@ -1968,7 +1973,8 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) if (WindowHelper::IsMainWindow(GetType()) && !windowSystemConfig_.IsPhoneWindow() && !windowSystemConfig_.IsPadWindow()) { - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported"); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2156,7 +2162,8 @@ WMError WindowSceneSessionImpl::SetFullScreen(bool status) if (WindowHelper::IsMainWindow(GetType()) && (IsFreeMultiWindowMode() || windowSystemConfig_.IsPcWindow())) { - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported"); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2199,7 +2206,7 @@ bool WindowSceneSessionImpl::IsDecorEnable() const bool isValidWindow = isMainWindow || ((isSubWindow || isDialogWindow) && property_->IsDecorEnable()); bool isWindowModeSupported = WindowHelper::IsWindowModeSupported( - windowSystemConfig_.decorModeSupportInfo_, GetMode()); + windowSystemConfig_.decorWindowModeSupportType_, GetMode()); if (windowSystemConfig_.freeMultiWindowSupport_) { return isValidWindow && windowSystemConfig_.isSystemDecorEnable_; } @@ -2256,7 +2263,8 @@ WMError WindowSceneSessionImpl::Maximize(MaximizePresentation presentation) TLOGE(WmsLogTag::WMS_LAYOUT, "maximize fail, not main window"); return WMError::WM_ERROR_INVALID_CALLING; } - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { return WMError::WM_ERROR_INVALID_WINDOW; } // The device is not supported @@ -2310,7 +2318,7 @@ WMError WindowSceneSessionImpl::MaximizeFloating() TLOGW(WmsLogTag::WMS_LAYOUT, "SetGlobalMaximizeMode fail, not main window"); return WMError::WM_ERROR_INVALID_WINDOW; } - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2338,7 +2346,7 @@ WMError WindowSceneSessionImpl::Recover() WLOGFE("session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } - if (!(WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || + if (!(WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FLOATING) || property_->GetCompatibleModeInPc())) { TLOGE(WmsLogTag::WMS_LAYOUT, "not support floating, can not Recover"); return WMError::WM_ERROR_INVALID_OPERATION; @@ -2403,8 +2411,8 @@ WMError WindowSceneSessionImpl::Recover(uint32_t reason) WLOGFE("The device is not supported"); return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - if (!(WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || - property_->GetCompatibleModeInPc())) { + if (!(WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FLOATING) || property_->GetCompatibleModeInPc())) { TLOGE(WmsLogTag::WMS_LAYOUT, "not support floating, can not Recover"); return WMError::WM_ERROR_INVALID_OPERATION; } @@ -2686,7 +2694,7 @@ WMError WindowSceneSessionImpl::SetWindowMode(WindowMode mode) } bool isCompatibleModeInPcSetFloatingWindowMode = property_->GetCompatibleModeInPc() && (mode == WindowMode::WINDOW_MODE_FLOATING); - if (!(WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), mode) || + if (!(WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), mode) || isCompatibleModeInPcSetFloatingWindowMode)) { TLOGE(WmsLogTag::DEFAULT, "window %{public}u do not support mode: %{public}u", GetWindowId(), static_cast(mode)); @@ -3534,7 +3542,7 @@ WSError WindowSceneSessionImpl::UpdateWindowMode(WindowMode mode) if (IsWindowSessionInvalid()) { return WSError::WS_ERROR_INVALID_WINDOW; } - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), mode)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), mode)) { WLOGFE("%{public}u do not support mode: %{public}u", GetWindowId(), static_cast(mode)); return WSError::WS_ERROR_INVALID_WINDOW_MODE_OR_SIZE; @@ -4198,7 +4206,8 @@ WMError WindowSceneSessionImpl::SetImmersiveModeEnabledState(bool enable) } auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { return WMError::WM_ERROR_INVALID_WINDOW; } const WindowType curWindowType = GetType(); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 529b66d209..4763814e5e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1215,12 +1215,12 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() uiContent->HideWindowTitleButton(true, true, true, false); return; } - auto modeSupportInfo = property_->GetModeSupportInfo(); - bool hideSplitButton = !(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + auto windowModeSupportType = property_->GetWindowModeSupportType(); + bool hideSplitButton = !(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); // not support fullscreen in split and floating mode, or not support float in fullscreen mode - bool hideMaximizeButton = (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && + bool hideMaximizeButton = (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && (GetMode() == WindowMode::WINDOW_MODE_FLOATING || WindowHelper::IsSplitWindowMode(GetMode()))) || - (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && + (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && GetMode() == WindowMode::WINDOW_MODE_FULLSCREEN); bool hideMinimizeButton = false; bool hideCloseButton = false; diff --git a/wm/src/zidl/window_proxy.cpp b/wm/src/zidl/window_proxy.cpp index 343b559b55..eaa6487cbc 100644 --- a/wm/src/zidl/window_proxy.cpp +++ b/wm/src/zidl/window_proxy.cpp @@ -103,7 +103,7 @@ WMError WindowProxy::UpdateWindowMode(WindowMode mode) return WMError::WM_OK; } -WMError WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +WMError WindowProxy::UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) { MessageParcel data; MessageParcel reply; @@ -112,7 +112,7 @@ WMError WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) WLOGFE("WriteInterfaceToken failed"); return WMError::WM_ERROR_IPC_FAILED; } - if (!data.WriteUint32(modeSupportInfo)) { + if (!data.WriteUint32(windowModeSupportType)) { WLOGFE("Write WindowMode failed"); return WMError::WM_ERROR_IPC_FAILED; } diff --git a/wm/src/zidl/window_stub.cpp b/wm/src/zidl/window_stub.cpp index 93c359afe2..943335643d 100644 --- a/wm/src/zidl/window_stub.cpp +++ b/wm/src/zidl/window_stub.cpp @@ -99,12 +99,12 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParce break; } case WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO: { - uint32_t modeSupportInfo = 0; - if (!data.ReadUint32(modeSupportInfo)) { - TLOGE(WmsLogTag::WMS_LAYOUT, "read modeSupportInfo failed"); + uint32_t windowModeSupportType = 0; + if (!data.ReadUint32(windowModeSupportType)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "read windowModeSupportType failed"); return ERR_INVALID_DATA; } - UpdateWindowModeSupportInfo(modeSupportInfo); + UpdateWindowWindowModeSupportType(windowModeSupportType); break; } case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: { diff --git a/wm/test/unittest/window_agent_test.cpp b/wm/test/unittest/window_agent_test.cpp index 94683746be..66da5cba3f 100644 --- a/wm/test/unittest/window_agent_test.cpp +++ b/wm/test/unittest/window_agent_test.cpp @@ -87,17 +87,17 @@ HWTEST_F(WindowAgentTest, UpdateWindowMode, Function | SmallTest | Level2) } /** - * @tc.name: UpdateWindowModeSupportInfo - * @tc.desc: UpdateWindowModeSupportInfo + * @tc.name: UpdateWindowWindowModeSupportType + * @tc.desc: UpdateWindowWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowAgentTest, UpdateWindowModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowAgentTest, UpdateWindowWindowModeSupportType, Function | SmallTest | Level2) { - WMError err = windowAgent_->UpdateWindowModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + WMError err = windowAgent_->UpdateWindowWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(err, WMError::WM_OK); windowAgent_->window_ = nullptr; - err = windowAgent_->UpdateWindowModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + err = windowAgent_->UpdateWindowWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(err, WMError::WM_ERROR_NULLPTR); } diff --git a/wm/test/unittest/window_impl_test2.cpp b/wm/test/unittest/window_impl_test2.cpp index ed57cb35b9..63078293ae 100644 --- a/wm/test/unittest/window_impl_test2.cpp +++ b/wm/test/unittest/window_impl_test2.cpp @@ -799,10 +799,10 @@ HWTEST_F(WindowImplTest2, SetWindowMode, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_DO_NOTHING)); ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); window->SetWindowState(WindowState::STATE_FROZEN); @@ -967,9 +967,9 @@ HWTEST_F(WindowImplTest2, SetLayoutFullScreen, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), GetSystemConfig(_)).WillOnce(Return(WMError::WM_OK)); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(true)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -1025,9 +1025,9 @@ HWTEST_F(WindowImplTest2, SetImmersiveModeEnabledState, Function | SmallTest | L EXPECT_CALL(m->Mock(), GetSystemConfig(_)).WillOnce(Return(WMError::WM_OK)); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(true)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -1086,9 +1086,9 @@ HWTEST_F(WindowImplTest2, SetFullScreen, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(true)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); diff --git a/wm/test/unittest/window_impl_test3.cpp b/wm/test/unittest/window_impl_test3.cpp index 11057bb1f9..12085b41f9 100644 --- a/wm/test/unittest/window_impl_test3.cpp +++ b/wm/test/unittest/window_impl_test3.cpp @@ -771,7 +771,7 @@ HWTEST_F(WindowImplTest3, UpdateDecorEnable, Function | SmallTest | Level3) window->property_->mode_ = WindowMode::WINDOW_MODE_FULLSCREEN; window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; window->windowSystemConfig_.isSystemDecorEnable_ = true; - window->windowSystemConfig_.decorModeSupportInfo_ = WINDOW_MODE_SUPPORT_FLOATING; + window->windowSystemConfig_.decorWindowModeSupportType_ = WINDOW_MODE_SUPPORT_FLOATING; window->uiContent_ = std::make_unique(); Ace::UIContentMocker* content = reinterpret_cast(window->uiContent_.get()); sptr listener = new MockWindowChangeListener; @@ -782,7 +782,7 @@ HWTEST_F(WindowImplTest3, UpdateDecorEnable, Function | SmallTest | Level3) window->UpdateDecorEnable(true); ASSERT_TRUE(window->IsDecorEnable()); ASSERT_FALSE(window->property_->GetDecorEnable()); - window->windowSystemConfig_.decorModeSupportInfo_ = WINDOW_MODE_SUPPORT_ALL; + window->windowSystemConfig_.decorWindowModeSupportType_ = WINDOW_MODE_SUPPORT_ALL; window->UpdateDecorEnable(); ASSERT_TRUE(window->IsDecorEnable()); ASSERT_TRUE(window->property_->GetDecorEnable()); @@ -1255,7 +1255,7 @@ HWTEST_F(WindowImplTest3, SetFloatingMaximize, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), GetSystemConfig(_)).WillOnce(Return(WMError::WM_OK)); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFloatingMaximize(true)); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } diff --git a/wm/test/unittest/window_impl_test5.cpp b/wm/test/unittest/window_impl_test5.cpp index f5918a9d99..0835c2eeba 100644 --- a/wm/test/unittest/window_impl_test5.cpp +++ b/wm/test/unittest/window_impl_test5.cpp @@ -990,7 +990,7 @@ HWTEST_F(WindowImplTest5, SetImmersiveModeEnabledState02, Function | SmallTest | EXPECT_EQ(window->SetImmersiveModeEnabledState(true), WMError::WM_ERROR_INVALID_WINDOW); window->state_ = WindowState::STATE_CREATED; - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); window->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); EXPECT_EQ(window->SetImmersiveModeEnabledState(true), WMError::WM_ERROR_INVALID_WINDOW); @@ -1174,7 +1174,7 @@ HWTEST_F(WindowImplTest5, NeedToStopShowing, Function | SmallTest | Level1) window->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); EXPECT_EQ(window->NeedToStopShowing(), true); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); window->property_->SetWindowFlags(1 << 2); EXPECT_EQ(window->NeedToStopShowing(), false); diff --git a/wm/test/unittest/window_proxy_test.cpp b/wm/test/unittest/window_proxy_test.cpp index 2f32ede037..23ce1a36c4 100644 --- a/wm/test/unittest/window_proxy_test.cpp +++ b/wm/test/unittest/window_proxy_test.cpp @@ -76,13 +76,13 @@ HWTEST_F(WindowProxyTest, UpdateWindowMode01, Function | SmallTest | Level2) } /** - * @tc.name: UpdateWindowModeSupportInfo01 + * @tc.name: UpdateWindowWindowModeSupportType01 * @tc.desc: normal function * @tc.type: FUNC */ -HWTEST_F(WindowProxyTest, UpdateWindowModeSupportInfo01, Function | SmallTest | Level2) +HWTEST_F(WindowProxyTest, UpdateWindowWindowModeSupportType01, Function | SmallTest | Level2) { - WMError err = windowProxy_->UpdateWindowModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + WMError err = windowProxy_->UpdateWindowWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); ASSERT_EQ(err, WMError::WM_OK); } diff --git a/wm/test/unittest/window_scene_session_impl_test2.cpp b/wm/test/unittest/window_scene_session_impl_test2.cpp index f4dca2e59a..6ba89d4959 100644 --- a/wm/test/unittest/window_scene_session_impl_test2.cpp +++ b/wm/test/unittest/window_scene_session_impl_test2.cpp @@ -1481,7 +1481,7 @@ HWTEST_F(WindowSceneSessionImplTest2, Maximize02, Function | SmallTest | Level2) // window not support fullscreen window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - window->property_->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); + window->property_->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Maximize(presentation)); } @@ -1659,8 +1659,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible01, Function | SmallT option->SetWindowName("GetTitleButtonVisible01"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false}; @@ -1687,8 +1687,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible02, Function | SmallT sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { true, true, true, true}; @@ -1715,8 +1715,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible03, Function | SmallT sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false}; diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index c5ba1d8709..ef1ec7b0f0 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -1166,7 +1166,7 @@ HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating, Function | SmallTest | L ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); ASSERT_NE(nullptr, windowSceneSessionImpl->property_); - windowSceneSessionImpl->property_->SetModeSupportInfo(WINDOW_MODE_SUPPORT_FLOATING); + windowSceneSessionImpl->property_->SetWindowModeSupportType(WINDOW_MODE_SUPPORT_FLOATING); ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret); ret1 = windowSceneSessionImpl->GetGlobalMaximizeMode(); diff --git a/wm/test/unittest/window_scene_session_impl_test4.cpp b/wm/test/unittest/window_scene_session_impl_test4.cpp index be3e3abdf0..d81d31bbd3 100644 --- a/wm/test/unittest/window_scene_session_impl_test4.cpp +++ b/wm/test/unittest/window_scene_session_impl_test4.cpp @@ -1323,7 +1323,7 @@ HWTEST_F(WindowSceneSessionImplTest4, SetWindowMode01, Function | SmallTest | Le sptr subSession = new (std::nothrow) SessionMocker(subSessionInfo); ASSERT_NE(nullptr, subSession); subWindow->hostSession_ = subSession; - subWindow->property_->SetModeSupportInfo(0); + subWindow->property_->SetWindowModeSupportType(0); auto ret = subWindow->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, ret); } @@ -1344,7 +1344,7 @@ HWTEST_F(WindowSceneSessionImplTest4, SetWindowMode02, Function | SmallTest | Le SessionInfo subSessionInfo = {"CreateSubTestBundle", "CreateSubTestModule", "CreateSubTestAbility"}; sptr subSession = sptr::MakeSptr(subSessionInfo); subWindow->hostSession_ = subSession; - subWindow->property_->SetModeSupportInfo(1); + subWindow->property_->SetWindowModeSupportType(1); auto ret = subWindow->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); EXPECT_EQ(WMError::WM_OK, ret); } diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index f328a1b0fc..ed3ea469dc 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -1213,8 +1213,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible01, Function | SmallTest | sptr window = new (std::nothrow) WindowSessionImpl(option); ASSERT_NE(window, nullptr); ASSERT_NE(window->property_, nullptr); - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false }; @@ -1282,8 +1282,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible02, Function | SmallTest | ASSERT_NE(window, nullptr); ASSERT_NE(window->property_, nullptr); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { true, true, true, true }; @@ -1314,8 +1314,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible03, Function | SmallTest | ASSERT_NE(window->property_, nullptr); ASSERT_EQ(1, window->GetDisplayId()); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false }; diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 8446328973..e5fc3747f3 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -1577,30 +1577,30 @@ HWTEST_F(WindowTest, GetRequestedOrientation, Function | SmallTest | Level2) } /** - * @tc.name: SetRequestModeSupportInfo + * @tc.name: SetRequestWindowModeSupportType * @tc.desc: get * @tc.type: FUNC */ -HWTEST_F(WindowTest, SetRequestModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowTest, SetRequestWindowModeSupportType, Function | SmallTest | Level2) { sptr window = new Window(); ASSERT_NE(nullptr, window); - uint32_t modeSupportInfo = 0; - window->SetRequestModeSupportInfo(modeSupportInfo); - ASSERT_EQ(static_cast(Orientation::UNSPECIFIED), modeSupportInfo); + uint32_t windowModeSupportType = 0; + window->SetRequestWindowModeSupportType(windowModeSupportType); + ASSERT_EQ(static_cast(Orientation::UNSPECIFIED), windowModeSupportType); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } /** - * @tc.name: GetRequestModeSupportInfo + * @tc.name: GetRequestWindowModeSupportType * @tc.desc: get * @tc.type: FUNC */ -HWTEST_F(WindowTest, GetRequestModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowTest, GetRequestWindowModeSupportType, Function | SmallTest | Level2) { sptr window = new Window(); ASSERT_NE(nullptr, window); - uint32_t ret = window->GetRequestModeSupportInfo(); + uint32_t ret = window->GetRequestWindowModeSupportType(); ASSERT_EQ(true, ret == 0); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } diff --git a/wmserver/include/window_node.h b/wmserver/include/window_node.h index 2630f71353..cac2ba0b66 100644 --- a/wmserver/include/window_node.h +++ b/wmserver/include/window_node.h @@ -81,7 +81,7 @@ public: void SetWindowSizeChangeReason(WindowSizeChangeReason reason); void SetRequestedOrientation(Orientation orientation); void SetShowingDisplays(const std::vector& displayIdVec); - void SetModeSupportInfo(uint32_t modeSupportInfo); + void SetWindowModeSupportType(uint32_t windowModeSupportType); void SetDragType(DragType dragType); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); @@ -123,7 +123,7 @@ public: WindowSizeChangeReason GetWindowSizeChangeReason() const; Orientation GetRequestedOrientation() const; std::vector GetShowingDisplays() const; - uint32_t GetModeSupportInfo() const; + uint32_t GetWindowModeSupportType() const; DragType GetDragType() const; bool GetStretchable() const; const Rect& GetOriginRect() const; diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index b93ee0d3cc..7cdf01fff2 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -171,7 +171,7 @@ private: void UpdateRSTreeWhenShowingDisplaysChange(sptr& node, const std::vector& lastShowingDisplays); bool CheckWindowNodeWhetherInWindowTree(const sptr& node) const; - void UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up); + void UpdateWindowModeSupportTypeWhenKeyguardChange(const sptr& node, bool up); void RemoveFromRsTreeWhenRemoveWindowNode(sptr& node, bool fromAnimation); void UpdateSizeChangeReason(sptr& node, WindowMode srcMode, WindowMode dstMode); void UpdatePrivateWindowCount(); diff --git a/wmserver/src/remote_animation.cpp b/wmserver/src/remote_animation.cpp index b045a0a761..67d18b2e37 100644 --- a/wmserver/src/remote_animation.cpp +++ b/wmserver/src/remote_animation.cpp @@ -155,10 +155,10 @@ bool RemoteAnimation::CheckTransition(sptr srcInfo, const // check support window mode when one app starts another app if ((dstNode != nullptr && dstInfo != nullptr) && - !WindowHelper::CheckSupportWindowMode(dstNode->GetWindowMode(), dstNode->GetModeSupportInfo(), dstInfo)) { + !WindowHelper::CheckSupportWindowMode(dstNode->GetWindowMode(), dstNode->GetWindowModeSupportType(), dstInfo)) { WLOGFE("RSWindowAnimation: the mode of dstNode isn't supported, winId: %{public}u, mode: %{public}u, " - "modeSupportInfo: %{public}u", dstNode->GetWindowId(), dstNode->GetWindowMode(), - dstNode->GetModeSupportInfo()); + "windowModeSupportType: %{public}u", dstNode->GetWindowId(), dstNode->GetWindowMode(), + dstNode->GetWindowModeSupportType()); return false; } diff --git a/wmserver/src/starting_window.cpp b/wmserver/src/starting_window.cpp index 0950254bd9..044d08ff8e 100644 --- a/wmserver/src/starting_window.cpp +++ b/wmserver/src/starting_window.cpp @@ -77,8 +77,8 @@ sptr StartingWindow::CreateWindowNode(const sptrabilityInfo_.missionId_ = info->GetMissionId(); node->abilityInfo_.bundleName_ = info->GetBundleName(); node->abilityInfo_.abilityName_ = info->GetAbilityName(); - uint32_t modeSupportInfo = WindowHelper::ConvertSupportModesToSupportInfo(info->GetWindowSupportModes()); - node->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(info->GetWindowSupportModes()); + node->SetWindowModeSupportType(windowModeSupportType); if (CreateLeashAndStartingSurfaceNode(node) != WMError::WM_OK) { return nullptr; diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 71b42829db..0b284b17c6 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -96,7 +96,7 @@ void WindowController::StartingWindow(sptr info, std::shar } } - if (!WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), node->GetModeSupportInfo(), info)) { + if (!WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), node->GetWindowModeSupportType(), info)) { WLOGFE("need to cancel starting window"); return; } @@ -1519,7 +1519,7 @@ WMError WindowController::UpdateProperty(sptr& property, Propert break; } case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: { - node->SetModeSupportInfo(property->GetModeSupportInfo()); + node->SetWindowModeSupportType(property->GetWindowModeSupportType()); break; } case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: { diff --git a/wmserver/src/window_layout_policy_cascade.cpp b/wmserver/src/window_layout_policy_cascade.cpp index 6daa7ef4ba..160863d0ba 100644 --- a/wmserver/src/window_layout_policy_cascade.cpp +++ b/wmserver/src/window_layout_policy_cascade.cpp @@ -66,7 +66,8 @@ void WindowLayoutPolicyCascade::Reorder() continue; } // if window don't support floating mode, or default rect of cascade is not satisfied with limits - if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || + if (!WindowHelper::IsWindowModeSupported(node->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FLOATING) || !WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowUpdatedSizeLimits())) { MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_CASCADE); continue; diff --git a/wmserver/src/window_layout_policy_tile.cpp b/wmserver/src/window_layout_policy_tile.cpp index 591f641785..0eb8576e31 100644 --- a/wmserver/src/window_layout_policy_tile.cpp +++ b/wmserver/src/window_layout_policy_tile.cpp @@ -218,9 +218,9 @@ void WindowLayoutPolicyTile::PushBackNodeInTileQueue(const sptr& nod return; } - if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { + if (!WindowHelper::IsWindowModeSupported(node->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FLOATING)) { WLOGFD("Window don't support floating mode that should be minimized, winId: %{public}u, " - "modeSupportInfo: %{public}u", node->GetWindowId(), node->GetModeSupportInfo()); + "windowModeSupportType: %{public}u", node->GetWindowId(), node->GetWindowModeSupportType()); MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::INVALID_MODE_OR_SIZE_IN_TILE); return; } diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 4d128c33cd..5edb991bc3 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -466,22 +466,22 @@ void WindowManagerService::ConfigDecor(const WindowManagerConfig::ConfigItem& de std::vector supportedModes; item = decorConfig["supportedMode"]; if (item.IsStrings()) { - systemConfig_.decorModeSupportInfo_ = 0; + systemConfig_.decorWindowModeSupportType_ = 0; supportedModes = *item.stringsValue_; } for (auto mode : supportedModes) { if (mode == "fullscreen") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; } else if (mode == "floating") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; } else if (mode == "pip") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; } else if (mode == "split") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; } else { WLOGFW("Invalid supporedMode"); - systemConfig_.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + systemConfig_.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; break; } } diff --git a/wmserver/src/window_node.cpp b/wmserver/src/window_node.cpp index b6e80b1b96..0e552dd1d7 100644 --- a/wmserver/src/window_node.cpp +++ b/wmserver/src/window_node.cpp @@ -129,9 +129,9 @@ void WindowNode::SetShowingDisplays(const std::vector& displayIdVec) showingDisplays_.assign(displayIdVec.begin(), displayIdVec.end()); } -void WindowNode::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowNode::SetWindowModeSupportType(uint32_t windowModeSupportType) { - property_->SetModeSupportInfo(modeSupportInfo); + property_->SetWindowModeSupportType(windowModeSupportType); } void WindowNode::ResetWindowSizeChangeReason() @@ -372,9 +372,9 @@ std::vector WindowNode::GetShowingDisplays() const return showingDisplays_; } -uint32_t WindowNode::GetModeSupportInfo() const +uint32_t WindowNode::GetWindowModeSupportType() const { - return property_->GetModeSupportInfo(); + return property_->GetWindowModeSupportType(); } void WindowNode::GetTouchHotAreas(std::vector& rects) const diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 607464acb9..8f53c1bfe1 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -2213,22 +2213,23 @@ WMError WindowNodeContainer::SwitchLayoutPolicy(WindowLayoutMode dstMode, Displa return WMError::WM_OK; } -void WindowNodeContainer::UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up) +void WindowNodeContainer::UpdateWindowModeSupportTypeWhenKeyguardChange(const sptr& node, bool up) { - if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestModeSupportInfo(), + if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestWindowModeSupportType(), WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) { WLOGFD("window doesn't support split mode, winId: %{public}d", node->GetWindowId()); return; } - uint32_t modeSupportInfo; + uint32_t windowModeSupportType; if (up) { - modeSupportInfo = node->GetModeSupportInfo() & (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + windowModeSupportType = node->GetWindowModeSupportType() & + (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); } else { - modeSupportInfo = node->GetModeSupportInfo() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY; + windowModeSupportType = node->GetWindowModeSupportType() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY; } - node->SetModeSupportInfo(modeSupportInfo); + node->SetWindowModeSupportType(windowModeSupportType); if (node->GetWindowToken() != nullptr) { - node->GetWindowToken()->UpdateWindowModeSupportInfo(modeSupportInfo); + node->GetWindowToken()->UpdateWindowWindowModeSupportType(windowModeSupportType); } } @@ -2300,7 +2301,7 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up) } } - UpdateModeSupportInfoWhenKeyguardChange(needReZOrderNode, up); + UpdateWindowModeSupportTypeWhenKeyguardChange(needReZOrderNode, up); parentNode->children_.insert(position, needReZOrderNode); if (up && WindowHelper::IsSplitWindowMode(needReZOrderNode->GetWindowMode())) { diff --git a/wmserver/src/window_pair.cpp b/wmserver/src/window_pair.cpp index 2a0460ad43..31474aa8fb 100644 --- a/wmserver/src/window_pair.cpp +++ b/wmserver/src/window_pair.cpp @@ -199,7 +199,7 @@ void WindowPair::Clear() WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); if (primary_ != nullptr && primary_->GetWindowProperty() != nullptr && primary_->GetWindowToken() != nullptr) { - if (primary_->GetModeSupportInfo() == splitModeInfo) { + if (primary_->GetWindowModeSupportType() == splitModeInfo) { MinimizeApp::AddNeedMinimizeApp(primary_, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReasons(MinimizeReason::SPLIT_QUIT); } else { @@ -216,7 +216,7 @@ void WindowPair::Clear() } if (secondary_ != nullptr && secondary_->GetWindowProperty() != nullptr && secondary_->GetWindowToken() != nullptr) { - if (secondary_->GetModeSupportInfo() == splitModeInfo) { + if (secondary_->GetWindowModeSupportType() == splitModeInfo) { MinimizeApp::AddNeedMinimizeApp(secondary_, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReasons(MinimizeReason::SPLIT_QUIT); } else { diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index f811e7ddb9..901d32655b 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -678,7 +678,8 @@ bool WindowRoot::CheckAddingModeAndSize(sptr& node, const sptrGetModeSupportInfo(), container->GetCurrentLayoutMode())) { + if (WindowHelper::IsInvalidWindowInTileLayoutMode(node->GetWindowModeSupportType(), + container->GetCurrentLayoutMode())) { WLOGFE("window doesn't support floating mode in tile, windowId: %{public}u", node->GetWindowId()); return false; } diff --git a/wmserver/test/unittest/avoid_area_controller_test.cpp b/wmserver/test/unittest/avoid_area_controller_test.cpp index c1ec10cd89..944f41e7e6 100644 --- a/wmserver/test/unittest/avoid_area_controller_test.cpp +++ b/wmserver/test/unittest/avoid_area_controller_test.cpp @@ -80,7 +80,7 @@ public: } return WMError::WM_OK; } - WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override + WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override { return WMError::WM_OK; } diff --git a/wmserver/test/unittest/remote_animation_test.cpp b/wmserver/test/unittest/remote_animation_test.cpp index b35657476f..b02f096443 100644 --- a/wmserver/test/unittest/remote_animation_test.cpp +++ b/wmserver/test/unittest/remote_animation_test.cpp @@ -245,9 +245,9 @@ HWTEST_F(RemoteAnimationTest, CheckTransition02, Function | SmallTest | Level2) sptr dstNode = StartingWindow::CreateWindowNode(transitionInfo_, 1); ASSERT_NE(nullptr, dstNode); dstNode->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - dstNode->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + dstNode->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(dstNode->GetWindowMode(), - dstNode->GetModeSupportInfo(), transitionInfo_)); + dstNode->GetWindowModeSupportType(), transitionInfo_)); EXPECT_EQ(false, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, dstNode)); } diff --git a/wmserver/test/unittest/starting_window_test.cpp b/wmserver/test/unittest/starting_window_test.cpp index 37a5886ebb..7bca84f5f6 100644 --- a/wmserver/test/unittest/starting_window_test.cpp +++ b/wmserver/test/unittest/starting_window_test.cpp @@ -118,7 +118,7 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow01, Function | SmallTest | transitionInfo_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); sptr node = new WindowNode(CreateWindowProperty()); ASSERT_EQ(true, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** @@ -130,9 +130,9 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow02, Function | SmallTest | { sptr node = new WindowNode(CreateWindowProperty()); node->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - node->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + node->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** @@ -144,7 +144,7 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow03, Function | SmallTest | { sptr node = new WindowNode(CreateWindowProperty()); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** @@ -156,10 +156,10 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow04, Function | SmallTest | { sptr node = new WindowNode(CreateWindowProperty()); transitionInfo_->SetShowFlagWhenLocked(true); - node->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + node->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** diff --git a/wmserver/test/unittest/window_controller_test.cpp b/wmserver/test/unittest/window_controller_test.cpp index 9359ed6f78..754bcb776c 100644 --- a/wmserver/test/unittest/window_controller_test.cpp +++ b/wmserver/test/unittest/window_controller_test.cpp @@ -128,7 +128,7 @@ HWTEST_F(WindowControllerTest, StartingWindow, Function | SmallTest | Level3) transitionInfo_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); windowController_->StartingWindow(transitionInfo_, nullptr, 0, false); transitionInfo_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - node_->property_->modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + node_->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; windowController_->StartingWindow(transitionInfo_, nullptr, 0, false); ASSERT_EQ(1, windowRoot_->windowNodeMap_.size()); @@ -159,13 +159,13 @@ HWTEST_F(WindowControllerTest, NotifyWindowTransition, Function | SmallTest | Le sptr srcAbilityTokenMocker = new IRemoteObjectMocker(); srcInfo->SetAbilityToken(srcAbilityTokenMocker); sptr srcNode = StartingWindow::CreateWindowNode(srcInfo, 102); // 102 is windowId - srcNode->property_->modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + srcNode->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; dstInfo = new WindowTransitionInfo(); sptr dstAbilityTokenMocker = new IRemoteObjectMocker(); dstInfo->SetAbilityToken(dstAbilityTokenMocker); sptr dstNode = StartingWindow::CreateWindowNode(dstInfo, 103); // 103 is windowId - dstNode->property_->modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + dstNode->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; windowRoot_->windowNodeMap_.clear(); windowRoot_->windowNodeMap_.insert(std::make_pair(srcNode->GetWindowId(), srcNode)); diff --git a/wmserver/test/unittest/window_manager_config_test.cpp b/wmserver/test/unittest/window_manager_config_test.cpp index f901a1ef9c..f1c229b102 100644 --- a/wmserver/test/unittest/window_manager_config_test.cpp +++ b/wmserver/test/unittest/window_manager_config_test.cpp @@ -254,7 +254,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig01, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, WindowManagerService::GetInstance().systemConfig_.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorWindowModeSupportType_); xmlStr = "" "" @@ -263,7 +263,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig01, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(false, WindowManagerService::GetInstance().systemConfig_.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorWindowModeSupportType_); } /** @@ -284,7 +284,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig02, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN == sysConfig.decorWindowModeSupportType_); } /** @@ -305,7 +305,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig03, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING == sysConfig.decorWindowModeSupportType_); } /** @@ -327,7 +327,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig04, Function | SmallTest | Level2) WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); ASSERT_TRUE((WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | - WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) == sysConfig.decorModeSupportInfo_); + WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) == sysConfig.decorWindowModeSupportType_); } /** @@ -349,7 +349,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig05, Function | SmallTest | Level2) WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); ASSERT_TRUE((WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY) == sysConfig.decorModeSupportInfo_); + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY) == sysConfig.decorWindowModeSupportType_); } /** @@ -370,7 +370,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig06, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorWindowModeSupportType_); } } // namespace } // namespace Rosen diff --git a/wmserver/test/unittest/window_node_test.cpp b/wmserver/test/unittest/window_node_test.cpp index ad21a9ac47..a2774ce2ae 100644 --- a/wmserver/test/unittest/window_node_test.cpp +++ b/wmserver/test/unittest/window_node_test.cpp @@ -60,7 +60,7 @@ public: { return WMError::WM_OK; }; - virtual WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override + virtual WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override { return WMError::WM_OK; }; @@ -627,11 +627,11 @@ HWTEST_F(WindowNodeTest, SetShowingDisplays01, Function | SmallTest | Level1) ASSERT_EQ(1, windowNode->GetShowingDisplays().size()); } /** - * @tc.name: SetModeSupportInfo01 - * @tc.desc: SetModeSupportInfo & GetModeSupportInfo + * @tc.name: SetWindowModeSupportType01 + * @tc.desc: SetWindowModeSupportType & GetWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowNodeTest, SetModeSupportInfo01, Function | SmallTest | Level1) +HWTEST_F(WindowNodeTest, SetWindowModeSupportType01, Function | SmallTest | Level1) { std::string windowName = "WindowNode22"; auto property = CreateWindowProperty(22, windowName); @@ -639,9 +639,9 @@ HWTEST_F(WindowNodeTest, SetModeSupportInfo01, Function | SmallTest | Level1) sptr windowNode = new WindowNode(property); ASSERT_NE(nullptr, windowNode); windowNode->SetWindowProperty(property); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, windowNode->GetModeSupportInfo()); - windowNode->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, windowNode->GetModeSupportInfo()); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, windowNode->GetWindowModeSupportType()); + windowNode->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, windowNode->GetWindowModeSupportType()); } /** * @tc.name: SetDragType01 diff --git a/wmserver/test/unittest/window_root_test.cpp b/wmserver/test/unittest/window_root_test.cpp index 9e95a04209..666d4ae9bb 100644 --- a/wmserver/test/unittest/window_root_test.cpp +++ b/wmserver/test/unittest/window_root_test.cpp @@ -1167,7 +1167,7 @@ HWTEST_F(WindowRootTest, CheckAddingModeAndSize02, Function | SmallTest | Level2 sptr container = new WindowNodeContainer( defaultDisplay_->GetDisplayInfo(), defaultDisplay_->GetScreenId()); container->layoutMode_ = WindowLayoutMode::TILE; - node->property_->SetModeSupportInfo(0); + node->property_->SetWindowModeSupportType(0); ASSERT_TRUE((windowRoot_ != nullptr)); windowRoot_->CheckAddingModeAndSize(node, container); } @@ -1860,7 +1860,7 @@ HWTEST_F(WindowRootTest, AddWindowNode05, Function | SmallTest | Level2) WMError ret; sptr node = new WindowNode(); node->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); - node->property_->SetModeSupportInfo(0); + node->property_->SetWindowModeSupportType(0); ret = windowRoot_->AddWindowNode(INVALID_WINDOW_ID, node, false); ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_DISPLAY); From 4f2d7db8d1e70e806cce6d19faa1f488cd6c2b36 Mon Sep 17 00:00:00 2001 From: liubo Date: Sat, 16 Nov 2024 14:27:01 +0800 Subject: [PATCH 161/171] =?UTF-8?q?Description:=E4=BC=98=E5=8C=96cast?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=97=B6=E5=BA=8F=20IssueNo:https://gitee.co?= =?UTF-8?q?m/openharmony/window=5Fwindow=5Fmanager/issues/IAYAG6=20Binary?= =?UTF-8?q?=20Source:No=20Signed-off-by:=20liubo419=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connection/screen_session_ability_connection.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp b/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp index b26a97c88d..30159a812f 100644 --- a/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp +++ b/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp @@ -121,7 +121,9 @@ bool ScreenSessionAbilityConnectionStub::IsAbilityConnected() bool ScreenSessionAbilityConnectionStub::IsAbilityConnectedSync() { std::unique_lock lock(connectedMutex_); - connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + if (!isConnected_) { + connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + } return IsAbilityConnected(); } @@ -129,7 +131,9 @@ int32_t ScreenSessionAbilityConnectionStub::SendMessageSync(int32_t transCode, MessageParcel &data, MessageParcel &reply) { std::unique_lock lock(connectedMutex_); - connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + if (!isConnected_) { + connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + } if (!IsAbilityConnected()) { TLOGE(WmsLogTag::DMS, "ability connection is not established"); lock.unlock(); @@ -154,7 +158,9 @@ int32_t ScreenSessionAbilityConnectionStub::SendMessageSyncBlock(int32_t transCo MessageParcel &data, MessageParcel &reply) { std::unique_lock lock(connectedMutex_); - connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + if (!isConnected_) { + connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + } if (!IsAbilityConnected()) { TLOGE(WmsLogTag::DMS, "ability connection is not established"); lock.unlock(); From 14d1e717881943445a570e22ff8b68c5079dbec6 Mon Sep 17 00:00:00 2001 From: tyh Date: Sat, 16 Nov 2024 14:34:56 +0800 Subject: [PATCH 162/171] modified code smells bad Signed-off-by: tyh --- wmserver/test/unittest/window_snapshot_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wmserver/test/unittest/window_snapshot_test.cpp b/wmserver/test/unittest/window_snapshot_test.cpp index 13a4c984f4..e4985fcbc4 100644 --- a/wmserver/test/unittest/window_snapshot_test.cpp +++ b/wmserver/test/unittest/window_snapshot_test.cpp @@ -117,14 +117,14 @@ HWTEST_F(WindowSnapshotTest, GetSnapshot04, Function | SmallTest | Level3) sptr iRemoteObjectMocker = new IRemoteObjectMocker(); node->abilityToken_ = iRemoteObjectMocker; - sptr snapshotController_ = new SnapshotController(root, handler); - AAFwk::Snapshot snapshot_; + sptr snapshotController = new SnapshotController(root, handler); + AAFwk::Snapshot snapshot; ASSERT_EQ(static_cast(WMError::WM_ERROR_NULLPTR), - snapshotController_->GetSnapshot(iRemoteObjectMocker, snapshot_)); + snapshotController->GetSnapshot(iRemoteObjectMocker, snapshot_)); sptr iRemoteObjectMockerInvalid = new IRemoteObjectMocker(); ASSERT_EQ(static_cast(WMError::WM_ERROR_NULLPTR), - snapshotController_->GetSnapshot(iRemoteObjectMockerInvalid, snapshot_)); + snapshotController->GetSnapshot(iRemoteObjectMockerInvalid, snapshot_)); } } } // namespace Rosen From 84ee8896c57ca5b28564ecec1602b8a72559f5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sat, 16 Nov 2024 14:37:46 +0800 Subject: [PATCH 163/171] =?UTF-8?q?=E6=B7=BB=E5=8A=A0PC=20window=20?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E6=AE=B5=E8=90=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- wm/include/window_session_impl.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 26415e5066..9b9951a8ea 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -488,8 +488,6 @@ private: void NotifyRotationAnimationEnd(); void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener); bool IsUserOrientation(Orientation orientation) const; - void GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, - bool& hideCloseButton); WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config); void SetForceSplitEnable(bool isForceSplit, const std::string& homePage = ""); void SetFrameLayoutCallbackEnable(bool enable); @@ -562,6 +560,12 @@ private: * Multi Window */ bool isSplitButtonVisible_ = true; + + /** + * PC Window + */ + void GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, + bool& hideCloseButton); }; } // namespace Rosen } // namespace OHOS From a4edd348a4b9f19ca9d165ee2813422203b07489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sat, 16 Nov 2024 15:41:39 +0800 Subject: [PATCH 164/171] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=AE=B5=E8=90=BD?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- wm/include/window_session_impl.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 9b9951a8ea..c09d4274bb 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -495,6 +495,12 @@ private: bool IsNotifyInteractiveDuplicative(bool interactive); void SetUniqueVirtualPixelRatioForSub(bool useUniqueDensity, float virtualPixelRatio); + /** + * PC Window + */ + void GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, + bool& hideCloseButton); + static std::recursive_mutex lifeCycleListenerMutex_; static std::recursive_mutex windowChangeListenerMutex_; static std::recursive_mutex avoidAreaChangeListenerMutex_; @@ -560,12 +566,6 @@ private: * Multi Window */ bool isSplitButtonVisible_ = true; - - /** - * PC Window - */ - void GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, - bool& hideCloseButton); }; } // namespace Rosen } // namespace OHOS From 8714e389176cb351d77bdfbbfefcec61f1384373 Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Sat, 16 Nov 2024 16:34:30 +0800 Subject: [PATCH 165/171] =?UTF-8?q?startAbility=E6=94=AF=E6=8C=81ssupportW?= =?UTF-8?q?indowMode=E7=BC=96=E7=A0=81=E8=A7=84=E8=8C=83=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyh990312 --- test/common/mock/mock_IWindow.h | 2 +- .../window_agent_fuzzer.cpp | 2 +- .../wms/window_mode_support_info_test.cpp | 34 +++++++++---------- utils/include/window_helper.h | 10 +++--- utils/test/unittest/window_property_test.cpp | 12 +++---- .../session/host/src/scene_session.cpp | 2 +- wm/include/window_agent.h | 2 +- wm/include/zidl/window_interface.h | 2 +- wm/include/zidl/window_proxy.h | 2 +- wm/src/window_agent.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 3 +- wm/src/zidl/window_proxy.cpp | 2 +- wm/src/zidl/window_stub.cpp | 2 +- wm/test/unittest/window_agent_test.cpp | 10 +++--- wm/test/unittest/window_proxy_test.cpp | 6 ++-- wmserver/src/window_layout_policy_cascade.cpp | 2 +- wmserver/src/window_node_container.cpp | 2 +- wmserver/src/window_pair.cpp | 8 ++--- .../unittest/avoid_area_controller_test.cpp | 2 +- .../test/unittest/starting_window_test.cpp | 2 +- wmserver/test/unittest/window_node_test.cpp | 2 +- 21 files changed, 56 insertions(+), 55 deletions(-) diff --git a/test/common/mock/mock_IWindow.h b/test/common/mock/mock_IWindow.h index 3b0d53ff76..0a3004b087 100644 --- a/test/common/mock/mock_IWindow.h +++ b/test/common/mock/mock_IWindow.h @@ -31,7 +31,7 @@ public: MOCK_METHOD4(UpdateWindowRect, WMError(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction)); MOCK_METHOD1(UpdateWindowMode, WMError(WindowMode mode)); - MOCK_METHOD1(UpdateWindowWindowModeSupportType, WMError(uint32_t windowModeSupportType)); + MOCK_METHOD1(UpdateWindowModeSupportType, WMError(uint32_t windowModeSupportType)); MOCK_METHOD1(UpdateFocusStatus, WMError(bool focused)); MOCK_METHOD2(UpdateAvoidArea, WMError(const sptr& avoidArea, AvoidAreaType type)); MOCK_METHOD1(UpdateWindowState, WMError(WindowState state)); diff --git a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp index 880d2deb3c..04d93c8ae3 100644 --- a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp +++ b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp @@ -63,7 +63,7 @@ void CheckWindowAgentFunctionsPart1(sptr agent, const uint8_t* data uint32_t windowModeSupportType; startPos += GetObject(windowModeSupportType, data + startPos, size - startPos); - agent->UpdateWindowWindowModeSupportType(windowModeSupportType); + agent->UpdateWindowModeSupportType(windowModeSupportType); agent->UpdateFocusStatus(boolVal); agent->NotifyForegroundInteractiveStatus(boolVal); diff --git a/test/systemtest/wms/window_mode_support_info_test.cpp b/test/systemtest/wms/window_mode_support_info_test.cpp index 43fee13499..aa4f7c8f01 100644 --- a/test/systemtest/wms/window_mode_support_info_test.cpp +++ b/test/systemtest/wms/window_mode_support_info_test.cpp @@ -25,7 +25,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { using Utils = WindowTestUtils; -class WindowWindowModeSupportTypeTest : public testing::Test { +class WindowModeSupportTypeTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); @@ -37,7 +37,7 @@ private: static constexpr uint32_t WAIT_SYANC_US = 100000; }; -void WindowWindowModeSupportTypeTest::SetUpTestCase() +void WindowModeSupportTypeTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); @@ -45,11 +45,11 @@ void WindowWindowModeSupportTypeTest::SetUpTestCase() Utils::InitByDisplayRect(displayRect); } -void WindowWindowModeSupportTypeTest::TearDownTestCase() +void WindowModeSupportTypeTest::TearDownTestCase() { } -void WindowWindowModeSupportTypeTest::SetUp() +void WindowModeSupportTypeTest::SetUp() { fullAppInfo_1_ = { .name = "FullWindow", @@ -71,17 +71,17 @@ void WindowWindowModeSupportTypeTest::SetUp() }; } -void WindowWindowModeSupportTypeTest::TearDown() +void WindowModeSupportTypeTest::TearDown() { } namespace { /** - * @tc.name: WindowWindowModeSupportType01 + * @tc.name: WindowModeSupportType01 * @tc.desc: SetRequestWindowModeSupportType | GetRequestWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType01, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType01, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { @@ -93,11 +93,11 @@ HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType01, Functio } /** - * @tc.name: WindowWindowModeSupportType02 + * @tc.name: WindowModeSupportType02 * @tc.desc: windowModeSupportType test for single window, only support fullScreen mode * @tc.type: FUNC */ -HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType02, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType02, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { @@ -121,11 +121,11 @@ HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType02, Functio } /** - * @tc.name: WindowWindowModeSupportType03 + * @tc.name: WindowModeSupportType03 * @tc.desc: windowModeSupportType test for single window, support both fullScreen and floating mode * @tc.type: FUNC */ -HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType03, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType03, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { @@ -153,11 +153,11 @@ HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType03, Functio } /** - * @tc.name: WindowWindowModeSupportType04 + * @tc.name: WindowModeSupportType04 * @tc.desc: windowModeSupportType test for single window, window mode is not supported when show, show failed * @tc.type: FUNC */ -HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType04, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType04, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { @@ -172,11 +172,11 @@ HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType04, Functio } /** - * @tc.name: WindowWindowModeSupportType05 + * @tc.name: WindowModeSupportType05 * @tc.desc: windowModeSupportType test for layout cascade * @tc.type: FUNC */ -HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType05, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType05, Function | MediumTest | Level3) { const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); if (window1 == nullptr) { @@ -203,11 +203,11 @@ HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType05, Functio } /** - * @tc.name: WindowWindowModeSupportType06 + * @tc.name: WindowModeSupportType06 * @tc.desc: windowModeSupportType test for layout tile * @tc.type: FUNC */ -HWTEST_F(WindowWindowModeSupportTypeTest, WindowWindowModeSupportType06, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType06, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { diff --git a/utils/include/window_helper.h b/utils/include/window_helper.h index 95e8973569..755fe776e4 100644 --- a/utils/include/window_helper.h +++ b/utils/include/window_helper.h @@ -524,9 +524,9 @@ public: static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t windowModeSupportType) { - uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); - if (isShowWhenLocked && (splitModeInfo == windowModeSupportType)) { + uint32_t splitMode = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + if (isShowWhenLocked && (splitMode == windowModeSupportType)) { return true; } return false; @@ -548,8 +548,8 @@ public: return true; } - if ((!IsWindowModeSupported(windowModeSupportType, winMode)) || - (IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), windowModeSupportType))) { + if (!IsWindowModeSupported(windowModeSupportType, winMode) || + IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), windowModeSupportType)) { return false; } return true; diff --git a/utils/test/unittest/window_property_test.cpp b/utils/test/unittest/window_property_test.cpp index ec2294090c..2ad59afa7e 100644 --- a/utils/test/unittest/window_property_test.cpp +++ b/utils/test/unittest/window_property_test.cpp @@ -176,20 +176,20 @@ HWTEST_F(WindowPropertyTest, SetAbilityInfo, Function | SmallTest | Level2) HWTEST_F(WindowPropertyTest, ResumeLastWindowMode, Function | SmallTest | Level2) { WindowProperty winPropDst; - winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; - winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; + winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_PIP, winPropDst.mode_); - winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; - winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; + winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, winPropDst.mode_); - winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; - winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, winPropDst.mode_); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index fae3b3f8ee..d1c7057f39 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5224,7 +5224,7 @@ WMError SceneSession::HandleActionUpdateWindowModeSupportType(const sptrGetSystemCalling()) { - TLOGE(WmsLogTag::DEFAULT, "Update property windowModeSupportType permission denied!"); + TLOGE(WmsLogTag::DEFAULT, "permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } diff --git a/wm/include/window_agent.h b/wm/include/window_agent.h index f155caa1cc..eeb16092da 100644 --- a/wm/include/window_agent.h +++ b/wm/include/window_agent.h @@ -30,7 +30,7 @@ public: WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; WMError UpdateWindowMode(WindowMode mode) override; - WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override; + WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override; WMError UpdateFocusStatus(bool focused) override; WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WMError UpdateWindowState(WindowState state) override; diff --git a/wm/include/zidl/window_interface.h b/wm/include/zidl/window_interface.h index 8cfe4d694f..f6ef5a3824 100644 --- a/wm/include/zidl/window_interface.h +++ b/wm/include/zidl/window_interface.h @@ -58,7 +58,7 @@ public: virtual WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) = 0; virtual WMError UpdateWindowMode(WindowMode mode) = 0; - virtual WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) = 0; + virtual WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) = 0; virtual WMError UpdateFocusStatus(bool focused) = 0; virtual WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; virtual WMError UpdateWindowState(WindowState state) = 0; diff --git a/wm/include/zidl/window_proxy.h b/wm/include/zidl/window_proxy.h index 52e1373e86..682cad5b85 100644 --- a/wm/include/zidl/window_proxy.h +++ b/wm/include/zidl/window_proxy.h @@ -32,7 +32,7 @@ public: WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; WMError UpdateWindowMode(WindowMode mode) override; - WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override; + WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override; WMError UpdateFocusStatus(bool focused) override; WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WMError UpdateWindowState(WindowState state) override; diff --git a/wm/src/window_agent.cpp b/wm/src/window_agent.cpp index 824b69e2a2..cc78da80c0 100644 --- a/wm/src/window_agent.cpp +++ b/wm/src/window_agent.cpp @@ -49,7 +49,7 @@ WMError WindowAgent::UpdateWindowMode(WindowMode mode) return WMError::WM_OK; } -WMError WindowAgent::UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) +WMError WindowAgent::UpdateWindowModeSupportType(uint32_t windowModeSupportType) { if (window_ == nullptr) { WLOGFE("window_ is nullptr"); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 12960863e8..990fd69886 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2412,7 +2412,8 @@ WMError WindowSceneSessionImpl::Recover(uint32_t reason) return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } if (!(WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), - WindowMode::WINDOW_MODE_FLOATING) || property_->GetCompatibleModeInPc())) { + WindowMode::WINDOW_MODE_FLOATING) || + property_->GetCompatibleModeInPc())) { TLOGE(WmsLogTag::WMS_LAYOUT, "not support floating, can not Recover"); return WMError::WM_ERROR_INVALID_OPERATION; } diff --git a/wm/src/zidl/window_proxy.cpp b/wm/src/zidl/window_proxy.cpp index eaa6487cbc..0ac5fe14df 100644 --- a/wm/src/zidl/window_proxy.cpp +++ b/wm/src/zidl/window_proxy.cpp @@ -103,7 +103,7 @@ WMError WindowProxy::UpdateWindowMode(WindowMode mode) return WMError::WM_OK; } -WMError WindowProxy::UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) +WMError WindowProxy::UpdateWindowModeSupportType(uint32_t windowModeSupportType) { MessageParcel data; MessageParcel reply; diff --git a/wm/src/zidl/window_stub.cpp b/wm/src/zidl/window_stub.cpp index 943335643d..5e94e67fd8 100644 --- a/wm/src/zidl/window_stub.cpp +++ b/wm/src/zidl/window_stub.cpp @@ -104,7 +104,7 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParce TLOGE(WmsLogTag::WMS_LAYOUT, "read windowModeSupportType failed"); return ERR_INVALID_DATA; } - UpdateWindowWindowModeSupportType(windowModeSupportType); + UpdateWindowModeSupportType(windowModeSupportType); break; } case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: { diff --git a/wm/test/unittest/window_agent_test.cpp b/wm/test/unittest/window_agent_test.cpp index 66da5cba3f..1069e96972 100644 --- a/wm/test/unittest/window_agent_test.cpp +++ b/wm/test/unittest/window_agent_test.cpp @@ -87,17 +87,17 @@ HWTEST_F(WindowAgentTest, UpdateWindowMode, Function | SmallTest | Level2) } /** - * @tc.name: UpdateWindowWindowModeSupportType - * @tc.desc: UpdateWindowWindowModeSupportType + * @tc.name: UpdateWindowModeSupportType + * @tc.desc: UpdateWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowAgentTest, UpdateWindowWindowModeSupportType, Function | SmallTest | Level2) +HWTEST_F(WindowAgentTest, UpdateWindowModeSupportType, Function | SmallTest | Level2) { - WMError err = windowAgent_->UpdateWindowWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + WMError err = windowAgent_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(err, WMError::WM_OK); windowAgent_->window_ = nullptr; - err = windowAgent_->UpdateWindowWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + err = windowAgent_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(err, WMError::WM_ERROR_NULLPTR); } diff --git a/wm/test/unittest/window_proxy_test.cpp b/wm/test/unittest/window_proxy_test.cpp index 23ce1a36c4..66160503c2 100644 --- a/wm/test/unittest/window_proxy_test.cpp +++ b/wm/test/unittest/window_proxy_test.cpp @@ -76,13 +76,13 @@ HWTEST_F(WindowProxyTest, UpdateWindowMode01, Function | SmallTest | Level2) } /** - * @tc.name: UpdateWindowWindowModeSupportType01 + * @tc.name: UpdateWindowModeSupportType01 * @tc.desc: normal function * @tc.type: FUNC */ -HWTEST_F(WindowProxyTest, UpdateWindowWindowModeSupportType01, Function | SmallTest | Level2) +HWTEST_F(WindowProxyTest, UpdateWindowModeSupportType01, Function | SmallTest | Level2) { - WMError err = windowProxy_->UpdateWindowWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + WMError err = windowProxy_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); ASSERT_EQ(err, WMError::WM_OK); } diff --git a/wmserver/src/window_layout_policy_cascade.cpp b/wmserver/src/window_layout_policy_cascade.cpp index 160863d0ba..8f18280fea 100644 --- a/wmserver/src/window_layout_policy_cascade.cpp +++ b/wmserver/src/window_layout_policy_cascade.cpp @@ -67,7 +67,7 @@ void WindowLayoutPolicyCascade::Reorder() } // if window don't support floating mode, or default rect of cascade is not satisfied with limits if (!WindowHelper::IsWindowModeSupported(node->GetWindowModeSupportType(), - WindowMode::WINDOW_MODE_FLOATING) || + WindowMode::WINDOW_MODE_FLOATING) || !WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowUpdatedSizeLimits())) { MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_CASCADE); continue; diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 8f53c1bfe1..c8ff5cbac0 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -2229,7 +2229,7 @@ void WindowNodeContainer::UpdateWindowModeSupportTypeWhenKeyguardChange(const sp } node->SetWindowModeSupportType(windowModeSupportType); if (node->GetWindowToken() != nullptr) { - node->GetWindowToken()->UpdateWindowWindowModeSupportType(windowModeSupportType); + node->GetWindowToken()->UpdateWindowModeSupportType(windowModeSupportType); } } diff --git a/wmserver/src/window_pair.cpp b/wmserver/src/window_pair.cpp index 31474aa8fb..4e49dfc41f 100644 --- a/wmserver/src/window_pair.cpp +++ b/wmserver/src/window_pair.cpp @@ -195,11 +195,11 @@ void WindowPair::Clear() { WLOGI("Clear window pair."); DumpPairInfo(); - auto splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + auto splitMode = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); if (primary_ != nullptr && primary_->GetWindowProperty() != nullptr && primary_->GetWindowToken() != nullptr) { - if (primary_->GetWindowModeSupportType() == splitModeInfo) { + if (primary_->GetWindowModeSupportType() == splitMode) { MinimizeApp::AddNeedMinimizeApp(primary_, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReasons(MinimizeReason::SPLIT_QUIT); } else { @@ -216,7 +216,7 @@ void WindowPair::Clear() } if (secondary_ != nullptr && secondary_->GetWindowProperty() != nullptr && secondary_->GetWindowToken() != nullptr) { - if (secondary_->GetWindowModeSupportType() == splitModeInfo) { + if (secondary_->GetWindowModeSupportType() == splitMode) { MinimizeApp::AddNeedMinimizeApp(secondary_, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReasons(MinimizeReason::SPLIT_QUIT); } else { diff --git a/wmserver/test/unittest/avoid_area_controller_test.cpp b/wmserver/test/unittest/avoid_area_controller_test.cpp index 944f41e7e6..a2a62b375c 100644 --- a/wmserver/test/unittest/avoid_area_controller_test.cpp +++ b/wmserver/test/unittest/avoid_area_controller_test.cpp @@ -80,7 +80,7 @@ public: } return WMError::WM_OK; } - WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override + WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override { return WMError::WM_OK; } diff --git a/wmserver/test/unittest/starting_window_test.cpp b/wmserver/test/unittest/starting_window_test.cpp index 7bca84f5f6..c30e416dfa 100644 --- a/wmserver/test/unittest/starting_window_test.cpp +++ b/wmserver/test/unittest/starting_window_test.cpp @@ -157,7 +157,7 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow04, Function | SmallTest | sptr node = new WindowNode(CreateWindowProperty()); transitionInfo_->SetShowFlagWhenLocked(true); node->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), node->GetWindowModeSupportType(), transitionInfo_)); } diff --git a/wmserver/test/unittest/window_node_test.cpp b/wmserver/test/unittest/window_node_test.cpp index a2774ce2ae..f300d429c5 100644 --- a/wmserver/test/unittest/window_node_test.cpp +++ b/wmserver/test/unittest/window_node_test.cpp @@ -60,7 +60,7 @@ public: { return WMError::WM_OK; }; - virtual WMError UpdateWindowWindowModeSupportType(uint32_t windowModeSupportType) override + virtual WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override { return WMError::WM_OK; }; From f087f27c023ee81b832fab3fd8effb95c9783374 Mon Sep 17 00:00:00 2001 From: whqwe Date: Sat, 16 Nov 2024 18:16:04 +0800 Subject: [PATCH 166/171] fix diff of reduce logs Signed-off-by: whqwe --- .../src/scene_session_manager.cpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 91cbdf63d4..979c01fc5d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -868,7 +868,7 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& } RemoveFailRecoveredSession(); }; - return taskScheduler_->PostAsyncTask(task, "UpdateSessionInfoBySCB"); + taskScheduler_->PostAsyncTask(task, __func__); } bool SceneSessionManager::ConfigAppWindowShadow(const WindowSceneConfig::ConfigItem& shadowConfig, @@ -1700,8 +1700,9 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s } PerformRegisterInRequestSceneSession(sceneSession); NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); - TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: id: %{public}d, type: %{public}d", - where, sceneSession->GetPersistentId(), sceneSession->GetWindowType()); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: id: %{public}d, type: %{public}d, instanceKey: %{public}s", + where, sceneSession->GetPersistentId(), sceneSession->GetWindowType(), + sceneSession->GetAppInstanceKey.c_str()); return sceneSession; }; return taskScheduler_->PostSyncTask(task, "RequestSceneSession:PID" + std::to_string(sessionInfo.persistentId_)); @@ -2801,7 +2802,7 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptrGetCallingSessionId()); + TLOGNI(WmsLogTag::WMS_RECOVER, "callingWindowId = %{public}" PRIu32, property->GetCallingSessionId()); ClosePipWindowIfExist(property->GetWindowType()); sptr sceneSession = RequestSceneSession(info, property); if (sceneSession == nullptr) { @@ -3161,7 +3162,7 @@ void SceneSessionManager::NotifySessionTouchOutside(int32_t persistentId) persistentId, callingSessionId); } std::shared_lock lock(sceneSessionMapMutex_); - for (const auto & [_, sceneSession] : sceneSessionMap_) { + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (sceneSession == nullptr) { continue; } @@ -4899,7 +4900,7 @@ void SceneSessionManager::RequestAllAppSessionUnfocus() */ WSError SceneSessionManager::RequestSessionFocusImmediately(int32_t persistentId) { - TLOGI(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); // base block WSError basicCheckRet = RequestFocusBasicCheck(persistentId); if (basicCheckRet != WSError::WS_OK) { @@ -5536,7 +5537,7 @@ std::string SceneSessionManager::GetAllSessionFocusInfo() return false; } os << "WindowName: " << session->GetWindowName() << ", id: " << session->GetPersistentId() << - " ,focusable: " << session->GetFocusable() << ";"; + ", focusable: " << session->GetFocusable() << ";"; return false; }; TraverseSessionTree(func, true); @@ -8891,7 +8892,7 @@ WSError SceneSessionManager::ClearSession(sptr sceneSession) WSError SceneSessionManager::ClearAllSessions() { - WLOGFI("in"); + WLOGFD("in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { WLOGFE("The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -8914,7 +8915,7 @@ WSError SceneSessionManager::ClearAllSessions() void SceneSessionManager::GetAllClearableSessions(std::vector>& sessionVector) { - WLOGFI("in"); + WLOGFD("in"); std::shared_lock lock(sceneSessionMapMutex_); for (const auto &item : sceneSessionMap_) { auto sceneSession = item.second; @@ -9913,22 +9914,20 @@ const std::map> SceneSessionManager::GetSceneSession void SceneSessionManager::NotifyUpdateRectAfterLayout() { - auto transactionController = Rosen::RSSyncTransactionController::GetInstance(); std::shared_ptr rsTransaction = nullptr; - if (transactionController) { + if (auto transactionController = Rosen::RSSyncTransactionController::GetInstance()) { rsTransaction = transactionController->GetRSTransaction(); } - auto task = [this, rsTransaction]() { + auto task = [this, rsTransaction] { std::shared_lock lock(sceneSessionMapMutex_); - for (const auto& iter: sceneSessionMap_) { - auto sceneSession = iter.second; + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (sceneSession && sceneSession->IsDirtyWindow()) { sceneSession->NotifyClientToUpdateRect("AfterLayoutFromPersistentTask", rsTransaction); } } }; // need sync task since animation transcation need - return taskScheduler_->PostAsyncTask(task, "NotifyUpdateRectAfterLayout"); + taskScheduler_->PostAsyncTask(task, __func__); } WMError SceneSessionManager::GetVisibilityWindowInfo(std::vector>& infos) From b3d874dbdb2b235b63e3de75138113bb9f990a4b Mon Sep 17 00:00:00 2001 From: whqwe Date: Sat, 16 Nov 2024 18:18:01 +0800 Subject: [PATCH 167/171] fix Signed-off-by: whqwe --- 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 979c01fc5d..ca08d554d5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9915,7 +9915,7 @@ const std::map> SceneSessionManager::GetSceneSession void SceneSessionManager::NotifyUpdateRectAfterLayout() { std::shared_ptr rsTransaction = nullptr; - if (auto transactionController = Rosen::RSSyncTransactionController::GetInstance()) { + if (auto transactionController = RSSyncTransactionController::GetInstance()) { rsTransaction = transactionController->GetRSTransaction(); } auto task = [this, rsTransaction] { From 6d7518846ce36544ac09af9031612a2daf44f67d Mon Sep 17 00:00:00 2001 From: whqwe Date: Sat, 16 Nov 2024 18:35:20 +0800 Subject: [PATCH 168/171] add Signed-off-by: whqwe --- 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 ca08d554d5..4fac373de4 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1702,7 +1702,7 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: id: %{public}d, type: %{public}d, instanceKey: %{public}s", where, sceneSession->GetPersistentId(), sceneSession->GetWindowType(), - sceneSession->GetAppInstanceKey.c_str()); + sceneSession->GetAppInstanceKey().c_str()); return sceneSession; }; return taskScheduler_->PostSyncTask(task, "RequestSceneSession:PID" + std::to_string(sessionInfo.persistentId_)); From 14350e8a000ac427c2324b583ce6325a473dad83 Mon Sep 17 00:00:00 2001 From: wyk99 Date: Sat, 9 Nov 2024 17:13:41 +0800 Subject: [PATCH 169/171] =?UTF-8?q?Description:=E6=8F=90=E4=BE=9B=E5=B1=8F?= =?UTF-8?q?=E5=B9=95=E6=8E=A7=E4=BB=B6=E6=96=B9=E5=90=91=20IssueNo:https:/?= =?UTF-8?q?/gitee.com/openharmony/drivers=5Fhdf=5Fcore/issues/IB36TN=20Fea?= =?UTF-8?q?ture=20or=20Bugfix:Bugfix=20Binary=20Source:No=20Signed-off-by:?= =?UTF-8?q?=20wyk99=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/display_manager_interface_code.h | 1 + interfaces/innerkits/dm/dm_common.h | 9 +++ .../js_screen_session_manager.cpp | 15 +++-- .../js_screen_utils.cpp | 33 ++++++++++ .../screen_session_manager/js_screen_utils.h | 1 + .../include/screen_session_manager.h | 1 + .../zidl/screen_session_manager_interface.h | 1 + .../zidl/screen_session_manager_proxy.h | 1 + .../src/screen_session_manager.cpp | 15 ++++- .../src/zidl/screen_session_manager_proxy.cpp | 35 ++++++++++ .../src/zidl/screen_session_manager_stub.cpp | 7 ++ .../include/screen_session_manager_client.h | 2 +- .../src/screen_session_manager_client.cpp | 15 +++-- .../session/screen/include/screen_property.h | 4 ++ .../session/screen/include/screen_session.h | 1 + .../session/screen/src/screen_property.cpp | 10 +++ .../session/screen/src/screen_session.cpp | 6 ++ .../dms_unittest/screen_property_test.cpp | 66 +++++++++++++++++++ .../screen_session_manager_client_test.cpp | 21 ++++-- .../screen_session_manager_stub_test.cpp | 21 ++++++ .../test/dms_unittest/screen_session_test.cpp | 41 ++++++++++++ 21 files changed, 286 insertions(+), 20 deletions(-) diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index 1ccd335c20..c2f4803843 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -103,6 +103,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_SET_CLIENT = 2500, TRANS_ID_GET_SCREEN_PROPERTY, TRANS_ID_GET_DISPLAY_NODE, + TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO, TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY, TRANS_ID_UPDATE_AVAILABLE_AREA, TRANS_ID_SET_SCREEN_OFF_DELAY_TIME, diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index cfc3fa1695..0395af924a 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -462,6 +462,15 @@ struct ScrollableParam { std::string friction_; }; +/** + * @brief screen direction info + */ +struct ScreenDirectionInfo { + int32_t notifyRotation_; + int32_t screenRotation_; + int32_t rotation_; +}; + /** * @brief displayRect */ diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index b37baee066..bb8844628e 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -439,11 +439,14 @@ napi_value JsScreenSessionManager::OnUpdateScreenRotationProperty(napi_env env, TLOGE(WmsLogTag::DMS, "[NAPI]Failed to get bounds from js object"); return NapiGetUndefined(env); } - int rotation; - if (!ConvertFromJsValue(env, argv[2], rotation)) { // 2: the 3rd argv - TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to rotation"); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); + ScreenDirectionInfo directionInfo; + napi_value nativeObject = argv[2]; + if (nativeObject == nullptr) { + TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to ScreenDirectionInfo,the param is null"); + return NapiGetUndefined(env); + } + if (!ConvertScreenDirectionInfoFromJs(env, nativeObject, directionInfo)) { + TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to ScreenDirectionInfo"); return NapiGetUndefined(env); } ScreenPropertyChangeType type = ScreenPropertyChangeType::UNSPECIFIED; @@ -456,7 +459,7 @@ napi_value JsScreenSessionManager::OnUpdateScreenRotationProperty(napi_env env, return NapiGetUndefined(env); } } - ScreenSessionManagerClient::GetInstance().UpdateScreenRotationProperty(screenId, bounds, rotation, + ScreenSessionManagerClient::GetInstance().UpdateScreenRotationProperty(screenId, bounds, directionInfo, type); return NapiGetUndefined(env); } diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp index 9068bce3bf..db0ee3e3a5 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp @@ -236,6 +236,39 @@ bool ConvertRRectFromJs(napi_env env, napi_value jsObject, RRect& bound) return true; } +bool ConvertScreenDirectionInfoFromJs(napi_env env, napi_value jsObject, ScreenDirectionInfo& directionInfo) +{ + napi_value jsNotifyRotation = nullptr, jsScreenRotation = nullptr, jsRotation = nullptr; + napi_get_named_property(env, jsObject, "notifyRotation", &jsNotifyRotation); + napi_get_named_property(env, jsObject, "screenRotation", &jsScreenRotation); + napi_get_named_property(env, jsObject, "rotation", &jsRotation); + + if (GetType(env, jsNotifyRotation) != napi_undefined) { + int32_t notifyRotation; + if (!ConvertFromJsValue(env, jsNotifyRotation, notifyRotation)) { + WLOGFE("[NAPI]Failed to convert parameter to notifyRotation"); + return false; + } + directionInfo.notifyRotation_ = notifyRotation; + } + if (GetType(env, jsScreenRotation) != napi_undefined) { + int32_t screenRotation; + if (!ConvertFromJsValue(env, jsScreenRotation, screenRotation)) { + WLOGFE("[NAPI]Failed to convert parameter to screenRotation"); + return false; + } + directionInfo.screenRotation_ = screenRotation; + } + if (GetType(env, jsRotation) != napi_undefined) { + int32_t rotation; + if (!ConvertFromJsValue(env, jsRotation, rotation)) { + WLOGFE("[NAPI]Failed to convert parameter to rotation"); + return false; + } + directionInfo.rotation_ = rotation; + } + return true; +} bool ConvertDMRectFromJs(napi_env env, napi_value jsObject, DMRect& rect) { diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h index 08828e3620..8149e369e5 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h @@ -25,6 +25,7 @@ namespace OHOS::Rosen { bool ConvertRRectFromJs(napi_env env, napi_value jsObject, RRect& bound); bool ConvertDMRectFromJs(napi_env env, napi_value jsObject, DMRect& rect); +bool ConvertScreenDirectionInfoFromJs(napi_env env, napi_value jsObject, ScreenDirectionInfo& directionInfo); napi_value NapiGetUndefined(napi_env env); bool NapiIsCallable(napi_env env, napi_value value); class JsScreenUtils { diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index af08637a83..d54de0ef6c 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -267,6 +267,7 @@ public: std::shared_ptr GetDisplayNode(ScreenId screenId) override; void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) override; + void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) override; uint32_t GetCurvedCompressionArea() override; ScreenProperty GetPhyScreenProperty(ScreenId screenId) override; void SetScreenPrivacyState(bool hasPrivate) override; diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h index cecbefa7c9..1db266a826 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h @@ -162,6 +162,7 @@ public: virtual std::shared_ptr GetDisplayNode(ScreenId screenId) { return nullptr; } virtual void UpdateScreenRotationProperty(ScreenId screenId, const RRectT& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) {} + virtual void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) {} virtual void UpdateAvailableArea(ScreenId screenId, DMRect area) {} virtual int32_t SetScreenOffDelayTime(int32_t delay) { return 0; } virtual uint32_t GetCurvedCompressionArea() { return 0; } diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h index a2b12faf73..2fdb689dc5 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h @@ -154,6 +154,7 @@ public: std::shared_ptr GetDisplayNode(ScreenId screenId) override; void UpdateScreenRotationProperty(ScreenId screenId, const RRectT& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) override; + void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) override; void UpdateAvailableArea(ScreenId ScreenId, DMRect area) override; int32_t SetScreenOffDelayTime(int32_t delay) override; uint32_t GetCurvedCompressionArea() override; diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 97291bc483..93952ebf3b 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2569,6 +2569,20 @@ void ScreenSessionManager::NotifyAndPublishEvent(sptr displayInfo, IPCSkeleton::SetCallingIdentity(identity); } +void ScreenSessionManager::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) +{ + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "fail, cannot find screen %{public}" PRIu64"", + screenId); + return; + } + screenSession->SetPhysicalRotation(rotation, GetFoldStatus()); + screenSession->SetScreenComponentRotation(screenComponentRotation); + TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 ", rotation: %{public}f, screenComponentRotation: %{public}f", + screenId, rotation, screenComponentRotation); +} + void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) { @@ -2612,7 +2626,6 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const } { std::lock_guard lock_info(displayInfoMutex_); - screenSession->SetPhysicalRotation(rotation, GetFoldStatus()); screenSession->UpdatePropertyAfterRotation(bounds, rotation, GetFoldDisplayMode()); } sptr displayInfo = screenSession->ConvertToDisplayInfo(); diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp index 7423e9e3d7..e84dd7dbd6 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -2455,6 +2455,41 @@ std::shared_ptr ScreenSessionManagerProxy::GetDisplayNode(ScreenI return displayNode; } +void ScreenSessionManagerProxy::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, + float rotation) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("UpdateScreenDirectionInfo: remote is null"); + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + if (!data.WriteUint64(screenId)) { + WLOGFE("Write screenId failed"); + return; + } + if (!data.WriteFloat(screenComponentRotation)) { + WLOGFE("Write screenComponentRotation failed"); + return; + } + if (!data.WriteFloat(rotation)) { + WLOGFE("Write rotation failed"); + return; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return; + } +} + void ScreenSessionManagerProxy::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) { diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp index c5c58fd6d4..a83ba5d09a 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp @@ -695,6 +695,13 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& } break; } + case DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO: { + auto screenId = static_cast(data.ReadUint64()); + auto screenComponentRotation = data.ReadFloat(); + auto rotation = data.ReadFloat(); + UpdateScreenDirectionInfo(screenId, screenComponentRotation, rotation); + break; + } case DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY: { auto screenId = static_cast(data.ReadUint64()); RRect bounds; diff --git a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h index e8277fae61..1c28b7ce83 100644 --- a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h @@ -50,7 +50,7 @@ public: std::map GetAllScreensProperties() const; FoldDisplayMode GetFoldDisplayMode() const; - void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, + void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, ScreenDirectionInfo directionInfo, ScreenPropertyChangeType screenPropertyChangeType); uint32_t GetCurvedCompressionArea(); ScreenProperty GetPhyScreenProperty(ScreenId screenId); diff --git a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp index 1dadeac1ba..c494efbccf 100644 --- a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp @@ -20,7 +20,7 @@ #include #include #include - +#include "dm_common.h" #include "pipeline/rs_node_map.h" #include "window_manager_hilog.h" @@ -301,14 +301,16 @@ FoldDisplayMode ScreenSessionManagerClient::GetFoldDisplayMode() const return displayMode_; } -void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, - ScreenPropertyChangeType screenPropertyChangeType) +void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, + ScreenDirectionInfo directionInfo, ScreenPropertyChangeType screenPropertyChangeType) { if (!screenSessionManager_) { WLOGFE("screenSessionManager_ is null"); return; } - screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation, screenPropertyChangeType); + screenSessionManager_->UpdateScreenDirectionInfo(screenId, directionInfo.screenRotation_, directionInfo.rotation_); + screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, directionInfo.notifyRotation_, + screenPropertyChangeType); // not need update property to input manager if (screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_END || @@ -322,8 +324,9 @@ void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, } auto foldDisplayMode = screenSessionManager_->GetFoldDisplayMode(); auto foldStatus = screenSessionManager_->GetFoldStatus(); - screenSession->SetPhysicalRotation(rotation, foldStatus); - screenSession->UpdateToInputManager(bounds, rotation, foldDisplayMode); + screenSession->SetPhysicalRotation(directionInfo.rotation_, foldStatus); + screenSession->SetScreenComponentRotation(directionInfo.screenRotation_); + screenSession->UpdateToInputManager(bounds, directionInfo.notifyRotation_, foldDisplayMode); } void ScreenSessionManagerClient::SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) diff --git a/window_scene/session/screen/include/screen_property.h b/window_scene/session/screen/include/screen_property.h index 746406c250..4dd8740d0a 100644 --- a/window_scene/session/screen/include/screen_property.h +++ b/window_scene/session/screen/include/screen_property.h @@ -112,6 +112,9 @@ public: void SetPhysicalRotation(float rotation); float GetPhysicalRotation() const; + void SetScreenComponentRotation(float rotation); + float GetScreenComponentRotation() const; + float GetXDpi() const; float GetYDpi() const; @@ -153,6 +156,7 @@ private: } float rotation_ { 0.0f }; float physicalRotation_ { 0.0f }; + float screenComponentRotation_ { 0.0f }; RRect bounds_; RRect phyBounds_; diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 2c745750e0..4cce629e0e 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -241,6 +241,7 @@ public: MirrorScreenType GetMirrorScreenType(); Rotation ConvertIntToRotation(int rotation); void SetPhysicalRotation(int rotation, FoldStatus foldStatus); + void SetScreenComponentRotation(int rotation); void SetStartPosition(uint32_t startX, uint32_t startY); void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName); void SuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus); diff --git a/window_scene/session/screen/src/screen_property.cpp b/window_scene/session/screen/src/screen_property.cpp index f07e94246e..0c429a421e 100644 --- a/window_scene/session/screen/src/screen_property.cpp +++ b/window_scene/session/screen/src/screen_property.cpp @@ -47,6 +47,16 @@ float ScreenProperty::GetPhysicalRotation() const return physicalRotation_; } +void ScreenProperty::SetScreenComponentRotation(float rotation) +{ + screenComponentRotation_ = rotation; +} + +float ScreenProperty::GetScreenComponentRotation() const +{ + return screenComponentRotation_; +} + void ScreenProperty::SetBounds(const RRect& bounds) { bounds_ = bounds; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 5042928bd3..4838ef0f2d 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -606,6 +606,12 @@ void ScreenSession::SetPhysicalRotation(int rotation, FoldStatus foldStatus) property_.GetPhysicalRotation(), rotation, offsetRotation); } +void ScreenSession::SetScreenComponentRotation(int rotation) +{ + property_.SetScreenComponentRotation(static_cast(rotation)); + WLOGFI("screenComponentRotation :%{public}f ", property_.GetScreenComponentRotation()); +} + void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode) { Rotation targetRotation = ConvertIntToRotation(rotation); diff --git a/window_scene/test/dms_unittest/screen_property_test.cpp b/window_scene/test/dms_unittest/screen_property_test.cpp index e218ce935c..0603ab85a7 100644 --- a/window_scene/test/dms_unittest/screen_property_test.cpp +++ b/window_scene/test/dms_unittest/screen_property_test.cpp @@ -256,6 +256,72 @@ HWTEST_F(ScreenPropertyTest, GetRotation, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "ScreenPropertyTest: GetRotation end"; } +/** + * @tc.name: SetPhysicalRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, SetPhysicalRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhysicalRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = 2.0f; + property->SetPhysicalRotation(rotation); + ASSERT_EQ(property->physicalRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhysicalRotation end"; +} + +/** + * @tc.name: GetPhysicalRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, GetPhysicalRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhysicalRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = property->GetPhysicalRotation(); + ASSERT_EQ(property->physicalRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhysicalRotation end"; +} + +/** + * @tc.name: SetScreenComponentRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, SetScreenComponentRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenComponentRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = 2.0f; + property->SetScreenComponentRotation(rotation); + ASSERT_EQ(property->screenComponentRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenComponentRotation end"; +} + +/** + * @tc.name: GetScreenComponentRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, GetScreenComponentRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenComponentRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = property->GetScreenComponentRotation(); + ASSERT_EQ(property->screenComponentRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenComponentRotation end"; +} + /** * @tc.name: GetBounds * @tc.desc: normal function diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp index c6d794f9cd..45de1a9c37 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp @@ -415,11 +415,14 @@ HWTEST_F(ScreenSessionManagerClientTest, UpdateScreenRotationProperty, Function RRect bounds; bounds.rect_.width_ = 1344; bounds.rect_.height_ = 2772; - float rotation = 90; float scaleX = 1.0; float scaleY = 1.0; + ScreenDirectionInfo directionInfo; + directionInfo.notifyRotation_ = 90; + directionInfo.screenRotation_ = 90; + directionInfo.rotation_ = 90; ScreenPropertyChangeType screenPropertyChangeType = ScreenPropertyChangeType::ROTATION_BEGIN; - screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, rotation, + screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, directionInfo, screenPropertyChangeType); screenSessionManagerClient_->SetDisplayNodeScreenId(screenId, displayNodeScreenId); screenSessionManagerClient_->GetPhyScreenProperty(screenId); @@ -445,9 +448,12 @@ HWTEST_F(ScreenSessionManagerClientTest, GetScreenSnapshot, Function | SmallTest RRect bounds; bounds.rect_.width_ = 1344; bounds.rect_.height_ = 2772; - float rotation = 90; + ScreenDirectionInfo directionInfo; + directionInfo.notifyRotation_ = 90; + directionInfo.screenRotation_ = 90; + directionInfo.rotation_ = 90; ScreenPropertyChangeType screenPropertyChangeType = ScreenPropertyChangeType::ROTATION_BEGIN; - screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, rotation, + screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, directionInfo, screenPropertyChangeType); screenSessionManagerClient_->SetDisplayNodeScreenId(screenId, displayNodeScreenId); std::shared_ptr res = screenSessionManagerClient_->GetScreenSnapshot(screenId, scaleX, scaleY); @@ -1270,11 +1276,14 @@ HWTEST_F(ScreenSessionManagerClientTest, UpdateScreenRotationProperty02, Functio RRect bounds; bounds.rect_.width_ = 1344; bounds.rect_.height_ = 2772; - float rotation = 90; float scaleX = 1.0; float scaleY = 1.0; + ScreenDirectionInfo directionInfo; + directionInfo.notifyRotation_ = 90; + directionInfo.screenRotation_ = 90; + directionInfo.rotation_ = 90; ScreenPropertyChangeType screenPropertyChangeType = ScreenPropertyChangeType::ROTATION_BEGIN; - screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, rotation, + screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, directionInfo, screenPropertyChangeType); screenSessionManagerClient_->SetDisplayNodeScreenId(screenId, displayNodeScreenId); screenSessionManagerClient_->GetPhyScreenProperty(screenId); diff --git a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp index 702740268a..cfa0e05e64 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp @@ -2874,6 +2874,27 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest134, Function | SmallTest int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest135 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest135, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteUint64(0); + data.WriteFloat(0); + data.WriteFloat(0); + uint32_t code = static_cast( + DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} } } } \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 319f5e2fce..12f2e12027 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -382,6 +382,47 @@ HWTEST_F(ScreenSessionTest, GetVirtualScreenFlag, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "GetVirtualScreenFlag end"; } +/** + * @tc.name: SetPhysicalRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetPhysicalRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "SetPhysicalRotation start"; + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + int rotation = 0; + FoldStatus foldStatus = FoldStatus::UNKNOWN; + screenSession->SetPhysicalRotation(rotation, foldStatus); + GTEST_LOG_(INFO) << "SetPhysicalRotation end"; +} + +/** + * @tc.name: SetScreenComponentRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetScreenComponentRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "SetScreenComponentRotation start"; + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + int rotation = 0; + screenSession->SetScreenComponentRotation(rotation); + GTEST_LOG_(INFO) << "SetScreenComponentRotation end"; +} + /** * @tc.name: UpdateToInputManager * @tc.desc: normal function From 4cbea12cd94806e6828cb053e278d0190040e3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9C=89=E5=BA=B7?= Date: Mon, 18 Nov 2024 09:50:48 +0800 Subject: [PATCH 170/171] =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张有康 --- .../screen_session_manager/src/screen_session_dumper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/screen_session_manager/src/screen_session_dumper.cpp b/window_scene/screen_session_manager/src/screen_session_dumper.cpp index 9c953566ba..cc9ceaa3d3 100644 --- a/window_scene/screen_session_manager/src/screen_session_dumper.cpp +++ b/window_scene/screen_session_manager/src/screen_session_dumper.cpp @@ -750,12 +750,12 @@ void ScreenSessionDumper::SetHallAndPostureValue(std::string input) .angle = postureVal, }; SensorEvent hallEvent = { - .dataLen = sizeof(ExtHallData), .data = reinterpret_cast(&hallData), + .dataLen = sizeof(ExtHallData), }; SensorEvent postureEvent = { - .dataLen = sizeof(PostureData), .data = reinterpret_cast(&postureData), + .dataLen = sizeof(PostureData), }; OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandleHallData(&hallEvent); OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandlePostureData(&postureEvent); From 530b4b1097a90610ce6368dda6d9a4d2cb7e2b97 Mon Sep 17 00:00:00 2001 From: tanyuhang Date: Mon, 18 Nov 2024 02:23:18 +0000 Subject: [PATCH 171/171] update wmserver/test/unittest/window_snapshot_test.cpp. Signed-off-by: tanyuhang --- wmserver/test/unittest/window_snapshot_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wmserver/test/unittest/window_snapshot_test.cpp b/wmserver/test/unittest/window_snapshot_test.cpp index e4985fcbc4..ad575f26c6 100644 --- a/wmserver/test/unittest/window_snapshot_test.cpp +++ b/wmserver/test/unittest/window_snapshot_test.cpp @@ -120,11 +120,11 @@ HWTEST_F(WindowSnapshotTest, GetSnapshot04, Function | SmallTest | Level3) sptr snapshotController = new SnapshotController(root, handler); AAFwk::Snapshot snapshot; ASSERT_EQ(static_cast(WMError::WM_ERROR_NULLPTR), - snapshotController->GetSnapshot(iRemoteObjectMocker, snapshot_)); + snapshotController->GetSnapshot(iRemoteObjectMocker, snapshot)); sptr iRemoteObjectMockerInvalid = new IRemoteObjectMocker(); ASSERT_EQ(static_cast(WMError::WM_ERROR_NULLPTR), - snapshotController->GetSnapshot(iRemoteObjectMockerInvalid, snapshot_)); + snapshotController->GetSnapshot(iRemoteObjectMockerInvalid, snapshot)); } } } // namespace Rosen