From 8e96aeb72ddb6fc065318d18d8e3d7396af44aeb Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Fri, 12 Sep 2025 18:02:12 +0800 Subject: [PATCH 01/76] QXS pcmode setLayoutFullScreen Signed-off-by: zyh990312 --- .../common/include/window_session_property.h | 3 ++ .../common/src/window_session_property.cpp | 15 +++++- .../js_scene_session.cpp | 36 +++++++++++++ .../scene_session_manager/js_scene_session.h | 2 + window_scene/session/host/include/session.h | 1 + window_scene/session/host/src/session.cpp | 9 ++++ .../session/host/src/zidl/session_proxy.cpp | 1 + .../session/host/src/zidl/session_stub.cpp | 1 + window_scene/test/unittest/session_test3.cpp | 13 +++++ .../unittest/window_session_property_test.cpp | 14 +++++ wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 39 ++++++++++++++ .../window_scene_session_impl_test3.cpp | 51 +++++++++++++++++++ .../window_scene_session_impl_test5.cpp | 35 +++++++++++++ 14 files changed, 220 insertions(+), 1 deletion(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index b94b198143..e15a92c292 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -265,6 +265,8 @@ public: bool GetPcAppInpadSpecificSystemBarInvisible() const; void SetPcAppInpadOrientationLandscape(bool isPcAppInpadOrientationLandscape); bool GetPcAppInpadOrientationLandscape() const; + void SetMobileAppInPadLayoutFullScreen(bool isMobileAppInPadLayoutFullScreen); + bool GetMobileAppInPadLayoutFullScreen() const; /* * Window Lifecycle @@ -602,6 +604,7 @@ private: bool isPcAppInpadCompatibleMode_ = false; bool isPcAppInpadSpecificSystemBarInvisible_ = false; bool isPcAppInpadOrientationLandscape_ = false; + bool isMobileAppInPadLayoutFullScreen_ = false; sptr compatibleModeProperty_ = nullptr; diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 8f3dbcef49..341f490d87 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -1370,7 +1370,8 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const parcel.WriteBool(isPcAppInpadOrientationLandscape_) && parcel.WriteBool(isPcAppInpadCompatibleMode_) && parcel.WriteString(ancoRealBundleName_) && - parcel.WriteBool(isShowDecorInFreeMultiWindow_); + parcel.WriteBool(isShowDecorInFreeMultiWindow_) && + parcel.WriteBool(isMobileAppInPadLayoutFullScreen_); } WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) @@ -1488,6 +1489,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) property->SetPcAppInpadCompatibleMode(parcel.ReadBool()); property->SetAncoRealBundleName(parcel.ReadString()); property->SetIsShowDecorInFreeMultiWindow(parcel.ReadBool()); + property->SetMobileAppInPadLayoutFullScreen(parcel.ReadBool()); return property; } @@ -1601,6 +1603,7 @@ void WindowSessionProperty::CopyFrom(const sptr& property missionInfo_ = property->missionInfo_; } isShowDecorInFreeMultiWindow_ = property->isShowDecorInFreeMultiWindow_; + isMobileAppInPadLayoutFullScreen_ = property->isMobileAppInPadLayoutFullScreen_; } bool WindowSessionProperty::Write(Parcel& parcel, WSPropertyChangeAction action) @@ -2339,6 +2342,11 @@ void WindowSessionProperty::SetPcAppInpadOrientationLandscape(bool isPcAppInpadO isPcAppInpadOrientationLandscape_ = isPcAppInpadOrientationLandscape; } +void WindowSessionProperty::SetMobileAppInPadLayoutFullScreen(bool isMobileAppInPadLayoutFullScreen) +{ + isMobileAppInPadLayoutFullScreen_ = isMobileAppInPadLayoutFullScreen; +} + bool WindowSessionProperty::GetPcAppInpadCompatibleMode() const { return isPcAppInpadCompatibleMode_; @@ -2354,6 +2362,11 @@ bool WindowSessionProperty::GetPcAppInpadOrientationLandscape() const return isPcAppInpadOrientationLandscape_; } +bool WindowSessionProperty::GetMobileAppInPadLayoutFullScreen() const +{ + return isMobileAppInPadLayoutFullScreen_; +} + void WindowSessionProperty::SetAncoRealBundleName(const std::string& ancoRealBundleName) { ancoRealBundleName_ = ancoRealBundleName; 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 ecac2e5e4e..c0a313f688 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 @@ -567,6 +567,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c moduleName, JsSceneSession::SetPcAppInpadOrientationLandscape); BindNativeFunction(env, objValue, "setIsPcAppInpadCompatibleMode", moduleName, JsSceneSession::SetPcAppInpadCompatibleMode); + BindNativeFunction(env, objValue, "setMobileAppInPadLayoutFullScreen", + moduleName, JsSceneSession::SetMobileAppInPadLayoutFullScreen); } void JsSceneSession::BindNativeMethodForKeyboard(napi_env env, napi_value objValue, const char* moduleName) @@ -2854,6 +2856,13 @@ napi_value JsSceneSession::SetPcAppInpadCompatibleMode(napi_env env, napi_callba return (me != nullptr) ? me->OnSetPcAppInpadCompatibleMode(env, info) : nullptr; } +napi_value JsSceneSession::SetMobileAppInPadLayoutFullScreen(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_PC, "[NAPI]"); + JsSceneSession* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetMobileAppInPadLayoutFullScreen(env, info) : nullptr; +} + napi_value JsSceneSession::SetPcAppInpadSpecificSystemBarInvisible(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_PC, "[NAPI]"); @@ -6549,6 +6558,33 @@ napi_value JsSceneSession::OnSetPcAppInpadCompatibleMode(napi_env env, napi_call return NapiGetUndefined(env); } +napi_value JsSceneSession::OnSetMobileAppInPadLayoutFullScreen(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_SCB, "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 isMobileAppInPadLayoutFullScreen = false; + if (!ConvertFromJsValue(env, argv[0], isMobileAppInPadLayoutFullScreen)) { + TLOGE(WmsLogTag::WMS_SCB, "Failed to convert parameter to enable"); + 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::WMS_SCB, "session is nullptr, id:%{public}d", persistentId_); + return NapiGetUndefined(env); + } + session->SetMobileAppInPadLayoutFullScreen(isMobileAppInPadLayoutFullScreen); + return NapiGetUndefined(env); +} + napi_value JsSceneSession::OnSetPcAppInpadSpecificSystemBarInvisible(napi_env env, napi_callback_info info) { size_t argc = ARGC_FOUR; 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 6ef8959aaf..b53a17976d 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 @@ -260,6 +260,7 @@ private: static napi_value SetPcAppInpadCompatibleMode(napi_env env, napi_callback_info info); static napi_value SetPcAppInpadSpecificSystemBarInvisible(napi_env env, napi_callback_info info); static napi_value SetPcAppInpadOrientationLandscape(napi_env env, napi_callback_info info); + static napi_value SetMobileAppInPadLayoutFullScreen(napi_env env, napi_callback_info info); /* * PC Window */ @@ -351,6 +352,7 @@ private: napi_value OnSetPcAppInpadCompatibleMode(napi_env env, napi_callback_info info); napi_value OnSetPcAppInpadSpecificSystemBarInvisible(napi_env env, napi_callback_info info); napi_value OnSetPcAppInpadOrientationLandscape(napi_env env, napi_callback_info info); + napi_value OnSetMobileAppInPadLayoutFullScreen(napi_env env, napi_callback_info info); /* * PC Window diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index f6006edb8e..e3a2403ad8 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -430,6 +430,7 @@ public: WSError SetPcAppInpadCompatibleMode(bool enabled); WSError SetPcAppInpadSpecificSystemBarInvisible(bool isPcAppInpadSpecificSystemBarInvisible); WSError SetPcAppInpadOrientationLandscape(bool isPcAppInpadOrientationLandscape); + WSError SetMobileAppInPadLayoutFullScreen(bool isMobileAppInPadLayoutFullScreen); bool NeedNotify() const; void SetNeedNotify(bool needNotify); WSError SetTouchable(bool touchable); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 12f5080820..cbc0c1babb 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1384,6 +1384,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetPcAppInpadCompatibleMode(GetSessionProperty()->GetPcAppInpadCompatibleMode()); property->SetPcAppInpadSpecificSystemBarInvisible(GetSessionProperty()->GetPcAppInpadSpecificSystemBarInvisible()); property->SetPcAppInpadOrientationLandscape(GetSessionProperty()->GetPcAppInpadOrientationLandscape()); + property->SetMobileAppInPadLayoutFullScreen(GetSessionProperty()->GetMobileAppInPadLayoutFullScreen()) const bool isPcMode = system::GetBoolParameter("persist.sceneboard.ispcmode", false); const bool isShow = !(isScreenLockedCallback_ && isScreenLockedCallback_() && systemConfig_.IsFreeMultiWindowMode() && !isPcMode); @@ -3437,6 +3438,14 @@ WSError Session::SetPcAppInpadOrientationLandscape(bool isPcAppInpadOrientationL return WSError::WS_OK; } +WSError Session::SetMobileAppInPadLayoutFullScreen(bool isMobileAppInPadLayoutFullScreen) +{ + TLOGD(WmsLogTag::WMS_COMPAT, "isMobileAppInPadLayoutFullScreen: %{public}d", + isMobileAppInPadLayoutFullScreen); + GetSessionProperty()->SetMobileAppInPadLayoutFullScreen(isMobileAppInPadLayoutFullScreen); + return WSError::WS_OK; +} + WSError Session::PcAppInPadNormalClose() { TLOGD(WmsLogTag::WMS_COMPAT, "windowId:%{public}d", GetPersistentId()); diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index a0ce4a178e..afae3e2826 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -335,6 +335,7 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt property->SetPcAppInpadCompatibleMode(reply.ReadBool()); property->SetPcAppInpadSpecificSystemBarInvisible(reply.ReadBool()); property->SetPcAppInpadOrientationLandscape(reply.ReadBool()); + property->SetMobileAppInPadLayoutFullScreen(reply.ReadBool()); property->SetCompatibleModeProperty(reply.ReadParcelable()); property->SetUseControlState(reply.ReadBool()); property->SetAncoRealBundleName(reply.ReadString()); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 3f5b09367f..ec02ab4b87 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -509,6 +509,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteBool(property->GetPcAppInpadCompatibleMode()); reply.WriteBool(property->GetPcAppInpadSpecificSystemBarInvisible()); reply.WriteBool(property->GetPcAppInpadOrientationLandscape()); + reply.WriteBool(property->GetMobileAppInPadLayoutFullScreen()); reply.WriteParcelable(property->GetCompatibleModeProperty()); reply.WriteBool(property->GetUseControlState()); reply.WriteString(property->GetAncoRealBundleName()); diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index aa0ec8283b..933f6a96db 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -976,6 +976,19 @@ HWTEST_F(WindowSessionTest3, SetPcAppInpadOrientationLandscape, TestSize.Level1) EXPECT_EQ(result, WSError::WS_OK); } +/** + * @tc.name: SetMobileAppInPadLayoutFullScreen + * @tc.desc: SetMobileAppInPadLayoutFullScreen Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest3, SetMobileAppInPadLayoutFullScreen, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + bool isMobileAppInPadLayoutFullScreen = false; + auto result = session_->SetMobileAppInPadLayoutFullScreen(isMobileAppInPadLayoutFullScreen); + EXPECT_EQ(result, WSError::WS_OK); +} + /** * @tc.name: SetBufferAvailable * @tc.desc: SetBufferAvailable Test diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 5a46781c68..92a88aeaaa 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -1626,6 +1626,20 @@ HWTEST_F(WindowSessionPropertyTest, SetPcAppInpadOrientationLandscape, TestSize. ASSERT_EQ(result, isPcAppInpadOrientationLandscape); } +/** + * @tc.name: SetMobileAppInPadLayoutFullScreen + * @tc.desc: SetMobileAppInPadLayoutFullScreen + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, SetMobileAppInPadLayoutFullScreen, TestSize.Level1) +{ + sptr property = sptr::MakeSptr(); + bool isMobileAppInPadLayoutFullScreen = true; + property->SetMobileAppInPadLayoutFullScreen(isMobileAppInPadLayoutFullScreen); + auto result = property->GetMobileAppInPadLayoutFullScreen(); + ASSERT_EQ(result, isMobileAppInPadLayoutFullScreen); +} + /** * @tc.name: UnmarshallingFbTemplateInfoTest * @tc.desc: UnmarshallingFbTemplateInfoTest diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 98ea30f9d6..e4477fd153 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -442,6 +442,7 @@ private: bool titleHoverShowEnabled_ = true; bool dockHoverShowEnabled_ = true; void PreLayoutOnShow(WindowType type, const sptr& info = nullptr); + void MobileAppInPadLayoutFullScreenChange(bool statusBarEnable, bool navigationEnable); /* * Gesture Back diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 1778c8b74f..963e0eadcf 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3121,6 +3121,9 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( const std::unordered_map& systemBarProperties, const std::unordered_map& systemBarPropertyFlags) { + SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); + SystemBarProperty navigationIndicatorPorperty = + GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); for (auto [systemBarType, systemBarPropertyFlag] : systemBarPropertyFlags) { if (systemBarProperties.find(systemBarType) == systemBarProperties.end()) { TLOGE(WmsLogTag::WMS_IMMS, "system bar type is invalid"); @@ -3135,6 +3138,14 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( systemBarProperties.at(systemBarType).contentColor_ : property.contentColor_; property.enableAnimation_ = systemBarPropertyFlag.enableAnimationFlag ? systemBarProperties.at(systemBarType).enableAnimation_ : property.enableAnimation_; + if (systemBarType == WindowType::WINDOW_TYPE_STATUS_BAR) { + statusProperty.enable_ = systemBarPropertyFlag.enableFlag ? + systemBarProperties.at(systemBarType).enable_ : statusProperty.enable_; + } + if (navigationIndicatorPorperty == WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR) { + navigationIndicatorPorperty.enable_ = systemBarPropertyFlag.enableFlag ? + systemBarProperties.at(systemBarType).enable_ : navigationIndicatorPorperty.enable_; + } if (systemBarPropertyFlag.enableFlag) { property.settingFlag_ |= SystemBarSettingFlag::ENABLE_SETTING; @@ -3150,9 +3161,26 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( } } } + MobileAppInPadLayoutFullScreenChange(statusProperty.enable_, navigationIndicatorPorperty.enable_); return WMError::WM_OK; } +void WindowSceneSessionImpl::MobileAppInPadLayoutFullScreenChange(bool statusBarEnable, bool navigationEnable) +{ + TLOGI(WMError::WMS_COMPAT, "isMobileAppInPadLayoutFullScreen %{public}d", + property_->GetMobileAppInPadLayoutFullScreen()); + if(property_->GetMobileAppInPadLayoutFullScreen() && GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { + TLOGI(WMError::WMS_COMPAT, "statusProperty %{public}d, navigationIndicatorPorperty %{public}d", + statusBarEnable, navigationEnable); + if (!statusBarEnable && !navigationEnable) { + Maximize(MaximizePresentation::ENTER_IMMERSIVE); + } + if (statusBarEnable && navigationEnable) { + Maximize(MaximizePresentation::EXIT_IMMERSIVE); + } + } +} + WMError WindowSceneSessionImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) { return SetSpecificBarProperty(type, property); @@ -3474,6 +3502,17 @@ WMError WindowSceneSessionImpl::MaximizeFloating() TLOGW(WmsLogTag::WMS_COMPAT, "diable fullScreen in compatibleMode window ,id:%{public}d", GetPersistentId()); return WMError::WM_ERROR_INVALID_WINDOW; } + if (property_->GetMobileAppInPadLayoutFullScreen()) { + SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); + SystemBarProperty navigationIndicatorPorperty = + GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); + TLOGI(WMError::WMS_COMPAT, "statusProperty %{public}d, navigationIndicatorPorperty %{public}d", + statusProperty.enable_, navigationIndicatorPorperty.enable_); + if (!statusProperty.enable_ && !navigationIndicatorPorperty.enable_) { + Maximize(MaximizePresentation::ENTER_IMMERSIVE); + return WMError::WM_OK; + } + } if (GetGlobalMaximizeMode() != MaximizeMode::MODE_AVOID_SYSTEM_BAR) { hostSession->OnSessionEvent(SessionEvent::EVENT_MAXIMIZE); SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index fe2e951b18..99dbb7dbf6 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -1021,6 +1021,57 @@ HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating01, TestSize.Level1) EXPECT_EQ(WMError::WM_OK, ret); } +/** + * @tc.name: MaximizeFloating + * @tc.desc: MaximizeFloating + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("MaximizeFloating"); + sptr windowSceneSessionImpl = sptr::MakeSptr(option); + + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + windowSceneSessionImpl->property_->SetPersistentId(1); + windowSceneSessionImpl->hostSession_ = session; + windowSceneSessionImpl->state_ = WindowState::STATE_SHOWN; + windowSceneSessionImpl->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END); + auto ret = windowSceneSessionImpl->MaximizeFloating(); + EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret); + windowSceneSessionImpl->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + windowSceneSessionImpl->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR); + ret = windowSceneSessionImpl->MaximizeFloating(); + EXPECT_EQ(WMError::WM_OK, ret); + auto ret1 = windowSceneSessionImpl->GetGlobalMaximizeMode(); + EXPECT_EQ(MaximizeMode::MODE_RECOVER, ret1); + windowSceneSessionImpl->SetGlobalMaximizeMode(MaximizeMode::MODE_FULL_FILL); + ret = windowSceneSessionImpl->MaximizeFloating(); + EXPECT_EQ(WMError::WM_OK, ret); + SystemBarProperty statusProperty = + windowSceneSessionImpl->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); + SystemBarProperty navigationIndicatorPorperty = + windowSceneSessionImpl->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); + statusProperty.enable_ = false; + navigationIndicatorPorperty.enable_ = false; + ret = windowSceneSessionImpl->MaximizeFloating(); + EXPECT_EQ(WMError::WM_OK, ret); + tatusProperty.enable_ = true; + navigationIndicatorPorperty.enable_ = true; + ret = windowSceneSessionImpl->MaximizeFloating(); + EXPECT_EQ(WMError::WM_OK, ret); + tatusProperty.enable_ = true; + navigationIndicatorPorperty.enable_ = false; + ret = windowSceneSessionImpl->MaximizeFloating(); + EXPECT_EQ(WMError::WM_OK, ret); + tatusProperty.enable_ = false; + navigationIndicatorPorperty.enable_ = true; + ret = windowSceneSessionImpl->MaximizeFloating(); + EXPECT_EQ(WMError::WM_OK, ret); + +} + /** * @tc.name: Recover * @tc.desc: Recover diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index c4d0128fc2..fac8f654a9 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -995,6 +995,41 @@ HWTEST_F(WindowSceneSessionImplTest5, UpdateSystemBarProperties02, TestSize.Leve window->UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags)); } +/** + * @tc.name: MobileAppInPadLayoutFullScreenChange + * @tc.desc: MobileAppInPadLayoutFullScreenChange test + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, MobileAppInPadLayoutFullScreenChange, TestSize.Level0) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("MobileAppInPadLayoutFullScreenChange"); + option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); + option->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + + sptr window = sptr::MakeSptr(option); + window->hostSession_ = session; + window->property_->SetPersistentId(1); + window->state_ = WindowState::STATE_CREATED; + + window->property_->SetMobileAppInPadLayoutFullScreen(true); + window->property_->SetWidnowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + bool statusBarEnable = true; + bool navigationEnable = true; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + bool statusBarEnable = false; + bool navigationEnable = false; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + bool statusBarEnable = false; + bool navigationEnable = true; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + bool statusBarEnable = true; + bool navigationEnable = false; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); +} + /** * @tc.name: NotifyAfterDidForeground * @tc.desc: NotifyAfterDidForeground -- Gitee From 6f56b0d1ca7b5bbfaba69fe9ee1cac06e137b15d Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Sat, 13 Sep 2025 16:43:30 +0800 Subject: [PATCH 02/76] =?UTF-8?q?review=20=E6=84=8F=E8=A7=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyh990312 --- window_scene/session/host/src/session.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index cbc0c1babb..1fd393b002 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1384,7 +1384,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetPcAppInpadCompatibleMode(GetSessionProperty()->GetPcAppInpadCompatibleMode()); property->SetPcAppInpadSpecificSystemBarInvisible(GetSessionProperty()->GetPcAppInpadSpecificSystemBarInvisible()); property->SetPcAppInpadOrientationLandscape(GetSessionProperty()->GetPcAppInpadOrientationLandscape()); - property->SetMobileAppInPadLayoutFullScreen(GetSessionProperty()->GetMobileAppInPadLayoutFullScreen()) + property->SetMobileAppInPadLayoutFullScreen(GetSessionProperty()->GetMobileAppInPadLayoutFullScreen()); const bool isPcMode = system::GetBoolParameter("persist.sceneboard.ispcmode", false); const bool isShow = !(isScreenLockedCallback_ && isScreenLockedCallback_() && systemConfig_.IsFreeMultiWindowMode() && !isPcMode); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 963e0eadcf..ff2c3f0615 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3123,7 +3123,7 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( { SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); SystemBarProperty navigationIndicatorPorperty = - GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); + GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); for (auto [systemBarType, systemBarPropertyFlag] : systemBarPropertyFlags) { if (systemBarProperties.find(systemBarType) == systemBarProperties.end()) { TLOGE(WmsLogTag::WMS_IMMS, "system bar type is invalid"); @@ -3140,11 +3140,11 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( systemBarProperties.at(systemBarType).enableAnimation_ : property.enableAnimation_; if (systemBarType == WindowType::WINDOW_TYPE_STATUS_BAR) { statusProperty.enable_ = systemBarPropertyFlag.enableFlag ? - systemBarProperties.at(systemBarType).enable_ : statusProperty.enable_; + systemBarProperties.at(systemBarType).enable_ : statusProperty.enable_; } - if (navigationIndicatorPorperty == WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR) { + if (systemBarType == WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR) { navigationIndicatorPorperty.enable_ = systemBarPropertyFlag.enableFlag ? - systemBarProperties.at(systemBarType).enable_ : navigationIndicatorPorperty.enable_; + systemBarProperties.at(systemBarType).enable_ : statusProperty.enable_; } if (systemBarPropertyFlag.enableFlag) { @@ -3167,10 +3167,10 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( void WindowSceneSessionImpl::MobileAppInPadLayoutFullScreenChange(bool statusBarEnable, bool navigationEnable) { - TLOGI(WMError::WMS_COMPAT, "isMobileAppInPadLayoutFullScreen %{public}d", + TLOGI(WmsLogTag::WMS_COMPAT, "isMobileAppInPadLayoutFullScreen %{public}d", property_->GetMobileAppInPadLayoutFullScreen()); if(property_->GetMobileAppInPadLayoutFullScreen() && GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { - TLOGI(WMError::WMS_COMPAT, "statusProperty %{public}d, navigationIndicatorPorperty %{public}d", + TLOGI(WmsLogTag::WMS_COMPAT, "statusProperty %{public}d, navigationIndicatorPorperty %{public}d", statusBarEnable, navigationEnable); if (!statusBarEnable && !navigationEnable) { Maximize(MaximizePresentation::ENTER_IMMERSIVE); @@ -3506,7 +3506,7 @@ WMError WindowSceneSessionImpl::MaximizeFloating() SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); SystemBarProperty navigationIndicatorPorperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); - TLOGI(WMError::WMS_COMPAT, "statusProperty %{public}d, navigationIndicatorPorperty %{public}d", + TLOGI(WmsLogTag::WMS_COMPAT, "statusProperty %{public}d, navigationIndicatorPorperty %{public}d", statusProperty.enable_, navigationIndicatorPorperty.enable_); if (!statusProperty.enable_ && !navigationIndicatorPorperty.enable_) { Maximize(MaximizePresentation::ENTER_IMMERSIVE); -- Gitee From 292b78cbba3de1c70726c01f9a7e883807670347 Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Sat, 13 Sep 2025 18:38:35 +0800 Subject: [PATCH 03/76] =?UTF-8?q?review=20=E6=84=8F=E8=A7=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyh990312 --- wm/src/window_scene_session_impl.cpp | 2 +- wm/test/unittest/window_scene_session_impl_test3.cpp | 3 +-- wm/test/unittest/window_scene_session_impl_test5.cpp | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index ff2c3f0615..d12df9ce33 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3169,7 +3169,7 @@ void WindowSceneSessionImpl::MobileAppInPadLayoutFullScreenChange(bool statusBar { TLOGI(WmsLogTag::WMS_COMPAT, "isMobileAppInPadLayoutFullScreen %{public}d", property_->GetMobileAppInPadLayoutFullScreen()); - if(property_->GetMobileAppInPadLayoutFullScreen() && GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { + if (property_->GetMobileAppInPadLayoutFullScreen() && GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { TLOGI(WmsLogTag::WMS_COMPAT, "statusProperty %{public}d, navigationIndicatorPorperty %{public}d", statusBarEnable, navigationEnable); if (!statusBarEnable && !navigationEnable) { diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index 99dbb7dbf6..5ff40d1b83 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -1051,7 +1051,7 @@ HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating, TestSize.Level1) EXPECT_EQ(WMError::WM_OK, ret); SystemBarProperty statusProperty = windowSceneSessionImpl->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); - SystemBarProperty navigationIndicatorPorperty = + SystemBarProperty navigationIndicatorPorperty = windowSceneSessionImpl->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); statusProperty.enable_ = false; navigationIndicatorPorperty.enable_ = false; @@ -1069,7 +1069,6 @@ HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating, TestSize.Level1) navigationIndicatorPorperty.enable_ = true; ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); - } /** diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index fac8f654a9..fe2bee4790 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -1018,10 +1018,14 @@ HWTEST_F(WindowSceneSessionImplTest5, MobileAppInPadLayoutFullScreenChange, Test window->property_->SetWidnowMode(WindowMode::WINDOW_MODE_FULLSCREEN); bool statusBarEnable = true; bool navigationEnable = true; + window->enableImmersiveMode_ = true; window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + EXPECT_EQ(false, window->enableImmersiveMode_); bool statusBarEnable = false; bool navigationEnable = false; + window->enableImmersiveMode_ = false; window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + EXPECT_EQ(true, window->enableImmersiveMode_); bool statusBarEnable = false; bool navigationEnable = true; window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); -- Gitee From 18319a929062d852c88ea958b0c110d401428095 Mon Sep 17 00:00:00 2001 From: liuanguang Date: Thu, 4 Sep 2025 21:49:02 +0800 Subject: [PATCH 04/76] fix(dms): resolve potential deadlock by invoking listener callbacks outside of lock Signed-off-by: liuanguang --- .../src/screen_session_manager_client.cpp | 13 ++- .../session/screen/include/screen_session.h | 5 +- .../session/screen/src/screen_session.cpp | 14 ++- .../test/dms_unittest/screen_session_test.cpp | 102 ++++++++++++++---- 4 files changed, 103 insertions(+), 31 deletions(-) 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 14affb69bb..d767456f59 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 @@ -253,12 +253,15 @@ void ScreenSessionManagerClient::OnPropertyChanged(ScreenId screenId, void ScreenSessionManagerClient::OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status, PowerStateChangeReason reason) { - std::lock_guard lock(screenSessionMapMutex_); - if (screenSessionMap_.empty()) { - TLOGE(WmsLogTag::DMS, "[UL_POWER]screenSessionMap_ is nullptr"); - return; + sptr screenSession; + { + std::lock_guard lock(screenSessionMapMutex_); + if (screenSessionMap_.empty()) { + TLOGE(WmsLogTag::DMS, "[UL_POWER]screenSessionMap_ is empty"); + return; + } + screenSession = screenSessionMap_.begin()->second; } - auto screenSession = screenSessionMap_.begin()->second; if (!screenSession) { TLOGE(WmsLogTag::DMS, "[UL_POWER]screenSession is null"); return; diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 0b407a0467..c0031b2801 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -41,6 +41,7 @@ using DestroyScreenSceneFunc = std::function; class IScreenChangeListener { public: + virtual ~IScreenChangeListener() = default; virtual void OnConnect(ScreenId screenId) {} virtual void OnDisconnect(ScreenId screenId) {} virtual void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason, @@ -391,12 +392,14 @@ public: private: bool IsVertical(Rotation rotation) const; Orientation CalcDisplayOrientationToOrientation(DisplayOrientation displayOrientation) const; + std::vector GetScreenChangeListenerList() const; + ScreenProperty property_; mutable std::mutex propertyMutex_; // above guarded by clientProxyMutex_ std::shared_ptr displayNode_; ScreenState screenState_ { ScreenState::INIT }; std::vector screenChangeListenerList_; - std::mutex screenChangeListenerListMutex_; + mutable std::mutex screenChangeListenerListMutex_; ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; mutable std::mutex combinationMutex_; // above guarded by clientProxyMutex_ VirtualScreenFlag screenFlag_ { VirtualScreenFlag::DEFAULT }; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 8bdaac6cc9..8da8a14979 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -781,16 +781,16 @@ void ScreenSession::Disconnect() void ScreenSession::PropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason) { - std::lock_guard lock(screenChangeListenerListMutex_); - property_ = newProperty; + SetScreenProperty(newProperty); if (reason == ScreenPropertyChangeReason::VIRTUAL_PIXEL_RATIO_CHANGE) { return; } - if (screenChangeListenerList_.empty()) { + auto listeners = GetScreenChangeListenerList(); + if (listeners.empty()) { TLOGE(WmsLogTag::DMS, "screenChangeListenerList is empty."); return; } - for (auto& listener : screenChangeListenerList_) { + for (auto* listener : listeners) { if (!listener) { TLOGE(WmsLogTag::DMS, "screenChangeListener is null."); continue; @@ -2799,4 +2799,10 @@ uint32_t ScreenSession::GetScreenAreaHeight() const { return property_.GetScreenAreaHeight(); } + +std::vector ScreenSession::GetScreenChangeListenerList() const +{ + std::lock_guard lock(screenChangeListenerListMutex_); + return screenChangeListenerList_; +} } // namespace OHOS::Rosen diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 88a887886a..ef30eaf21b 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -14,10 +14,13 @@ */ #include "screen_session.h" + #include -#include "screen_session_manager/include/screen_session_manager.h" -#include "scene_board_judgement.h" +#include + #include "fold_screen_state_internel.h" +#include "scene_board_judgement.h" +#include "screen_session_manager/include/screen_session_manager.h" #include "window_manager_hilog.h" // using namespace FRAME_TRACE; @@ -34,28 +37,31 @@ namespace { g_errLog = msg; } } + class MockScreenChangeListener : public IScreenChangeListener { public: - void OnConnect(ScreenId screenId) override {} - void OnDisconnect(ScreenId screenId) override {} - void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason, - ScreenId screenId) override {} - void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status, - PowerStateChangeReason reason) override {} - void OnSensorRotationChange(float sensorRotation, ScreenId screenId) override {} - void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) override {} - void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override {} - void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) override {} - void OnHoverStatusChange(int32_t hoverStatus, bool needRotate, ScreenId screenId) override {} - void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override {} - void OnCameraBackSelfieChange(bool isCameraBackSelfie, ScreenId screenId) override {} - void OnSuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus) override {} - void OnSecondaryReflexionChange(ScreenId screenId, bool isSecondaryReflexion) override {} - void OnExtendScreenConnectStatusChange(ScreenId screenId, - ExtendScreenConnectStatus extendScreenConnectStatus) override {} - void OnBeforeScreenPropertyChange(FoldStatus foldStatus) override {} - void OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) override {} + MOCK_METHOD(void, OnConnect, (ScreenId screenId), (override)); + MOCK_METHOD(void, OnDisconnect, (ScreenId screenId), (override)); + MOCK_METHOD(void, OnPropertyChange, + (const ScreenProperty& newProperty, ScreenPropertyChangeReason reason, ScreenId screenId), (override)); + MOCK_METHOD(void, OnPowerStatusChange, + (DisplayPowerEvent event, EventStatus status, PowerStateChangeReason reason), (override)); + MOCK_METHOD(void, OnSensorRotationChange, (float sensorRotation, ScreenId screenId), (override)); + MOCK_METHOD(void, OnScreenOrientationChange, (float screenOrientation, ScreenId screenId), (override)); + MOCK_METHOD(void, OnScreenRotationLockedChange, (bool isLocked, ScreenId screenId), (override)); + MOCK_METHOD(void, OnScreenExtendChange, (ScreenId mainScreenId, ScreenId extendScreenId), (override)); + MOCK_METHOD(void, OnHoverStatusChange, (int32_t hoverStatus, bool needRotate, ScreenId screenId), (override)); + MOCK_METHOD(void, OnScreenCaptureNotify, + (ScreenId mainScreenId, int32_t uid, const std::string& clientName), (override)); + MOCK_METHOD(void, OnCameraBackSelfieChange, (bool isCameraBackSelfie, ScreenId screenId), (override)); + MOCK_METHOD(void, OnSuperFoldStatusChange, (ScreenId screenId, SuperFoldStatus superFoldStatus), (override)); + MOCK_METHOD(void, OnSecondaryReflexionChange, (ScreenId screenId, bool isSecondaryReflexion), (override)); + MOCK_METHOD(void, OnExtendScreenConnectStatusChange, + (ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus), (override)); + MOCK_METHOD(void, OnBeforeScreenPropertyChange, (FoldStatus foldStatus), (override)); + MOCK_METHOD(void, OnScreenModeChange, (ScreenModeChangeEvent screenModeChangeEvent), (override)); }; + class ScreenSessionTest : public testing::Test { public: void TearDown() override; @@ -4592,6 +4598,60 @@ HWTEST_F(ScreenSessionTest, GetScreenSnapshotWithAllWindows02, TestSize.Level2) pixelMap = screenSession->GetScreenSnapshotWithAllWindows(scaleX, scaleY, isNeedCheckDrmAndSurfaceLock); EXPECT_EQ(pixelMap, nullptr); } + +/** + * @tc.name: TestPropertyChangeAllCases + * @tc.desc: Verify PropertyChange behavior for multiple scenarios + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, TestPropertyChangeAllCases, TestSize.Level1) +{ + ScreenId screenId = 10000; + ScreenProperty screenProperty; + sptr session = sptr::MakeSptr(screenId, screenProperty, screenId); + + // Case 1: reason = VIRTUAL_PIXEL_RATIO_CHANGE -> no listener call + { + auto listener = std::make_unique(); + EXPECT_CALL(*listener, OnPropertyChange(_, _, _)).Times(0); + + session->screenChangeListenerList_.push_back(listener.get()); + session->PropertyChange(screenProperty, ScreenPropertyChangeReason::VIRTUAL_PIXEL_RATIO_CHANGE); + session->screenChangeListenerList_.clear(); + } + + // Case 2: listener list is empty -> early return + { + session->PropertyChange(screenProperty, ScreenPropertyChangeReason::UNDEFINED); + SUCCEED(); + } + + // Case 3: listener list contains nullptr -> skip safely + { + auto reason = ScreenPropertyChangeReason::UNDEFINED; + auto listener = std::make_unique(); + EXPECT_CALL(*listener, OnPropertyChange(_, reason, screenId)).Times(1); + + session->screenChangeListenerList_.push_back(nullptr); + session->screenChangeListenerList_.push_back(listener.get()); + session->PropertyChange(screenProperty, reason); + session->screenChangeListenerList_.clear(); + } + + // Case 4: normal case -> all valid listeners should be called + { + auto reason = ScreenPropertyChangeReason::UNDEFINED; + auto listener1 = std::make_unique(); + auto listener2 = std::make_unique(); + EXPECT_CALL(*listener1, OnPropertyChange(_, reason, screenId)).Times(1); + EXPECT_CALL(*listener2, OnPropertyChange(_, reason, screenId)).Times(1); + + session->screenChangeListenerList_.push_back(listener1.get()); + session->screenChangeListenerList_.push_back(listener2.get()); + session->PropertyChange(screenProperty, reason); + session->screenChangeListenerList_.clear(); + } +} } // namespace } // namespace Rosen } // namespace OHOS -- Gitee From 1359215443dd87b80ca65f7b558fd40b7a66057e Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Mon, 15 Sep 2025 10:45:31 +0800 Subject: [PATCH 05/76] =?UTF-8?q?UEC=E5=88=9B=E5=BB=BA=E5=AD=90=E7=AA=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peng fafu --- .../session_manager/src/scene_session_manager.cpp | 8 +++++++- .../test/mock/mock_ability_manager_client.cpp | 2 ++ .../scene_session_manager_extension_test.cpp | 11 +++++++++++ 3 files changed, 20 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 7f4390ebf5..3dffef0dd7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3976,6 +3976,11 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtension(const sptrGetParentPersistentId()); return WSError::WS_ERROR_NULLPTR; } + if (extensionParentSession->GetSessionInfo().isSystem_) { + TLOGE(WmsLogTag::WMS_UIEXT, "extensionParentSession is SCBSystemSession: %{public}d", + property->GetParentPersistentId()); + return WSError::WS_ERROR_INVALID_WINDOW; + } auto pid = IPCSkeleton::GetCallingRealPid(); auto parentPid = extensionParentSession->GetCallingPid(); if (pid == parentPid) { // Determine Whether to create a sub window in the same process. @@ -3992,7 +3997,8 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtension(const sptrhostElementName.SetBundleName(sessionInfo.hostElementName.GetBundleName()); g_uiExtensionSessionInfo->persistentId = sessionInfo.persistentId; g_uiExtensionSessionInfo->hostWindowId = sessionInfo.hostWindowId; + g_uiExtensionSessionInfo->extensionAbilityType = sessionInfo.extensionAbilityType; } ErrCode AbilityManagerClient::GetUIExtensionRootHostInfo(const sptr token, @@ -56,6 +57,7 @@ ErrCode AbilityManagerClient::GetUIExtensionSessionInfo(const sptrhostElementName.GetBundleName()); sessionInfo.persistentId = g_uiExtensionSessionInfo->persistentId; sessionInfo.hostWindowId = g_uiExtensionSessionInfo->hostWindowId; + sessionInfo.extensionAbilityType = g_uiExtensionSessionInfo->extensionAbilityType; } return 0; } diff --git a/window_scene/test/unittest/ui_extension/scene_session_manager_extension_test.cpp b/window_scene/test/unittest/ui_extension/scene_session_manager_extension_test.cpp index fc42082f2d..86f761ed19 100644 --- a/window_scene/test/unittest/ui_extension/scene_session_manager_extension_test.cpp +++ b/window_scene/test/unittest/ui_extension/scene_session_manager_extension_test.cpp @@ -129,6 +129,14 @@ HWTEST_F(SceneSessionManagerExtensionTest, CheckSubSessionStartedByExtension, Te EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_ERROR_NULLPTR); property->SetParentPersistentId(parentSession->GetPersistentId()); + info.isSystem_ = true; + parentSession->sessionInfo_ = info; + ssm_->sceneSessionMap_.insert({ parentSession->GetPersistentId(), parentSession }); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_ERROR_INVALID_WINDOW); + info.isSystem_ = false; + parentSession->sessionInfo_ = info; + ssm_->sceneSessionMap_.insert({ parentSession->GetPersistentId(), parentSession }); + LOCK_GUARD_EXPR(SCENE_GUARD, parentSession->SetCallingPid(IPCSkeleton::GetCallingPid())); EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_OK); LOCK_GUARD_EXPR(SCENE_GUARD, parentSession->SetCallingPid(IPCSkeleton::GetCallingPid() + 1)); @@ -152,6 +160,9 @@ HWTEST_F(SceneSessionManagerExtensionTest, CheckSubSessionStartedByExtension, Te MockUIExtSessionPermission::SetIsSystemCallingFlag(true); EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_OK); + extensionSessionInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::UI; + AAFwk::MockAbilityManagerClient::SetUIExtensionSessionInfo(extensionSessionInfo); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_ERROR_INVALID_WINDOW); MockUIExtSessionPermission::ClearAllFlag(); AAFwk::MockAbilityManagerClient::ClearAll(); -- Gitee From 738a525ace5f7ae15b665dd2310414686bf5be2d Mon Sep 17 00:00:00 2001 From: zh_qlong Date: Mon, 15 Sep 2025 10:46:17 +0800 Subject: [PATCH 06/76] =?UTF-8?q?=E9=95=9C=E5=83=8F=E9=BB=91=E8=BE=B9?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20Signed-off-by:=20zh=5Fqlong=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/screen_session_manager.h | 9 + .../include/screen_setting_helper.h | 7 +- .../super_fold_state_manager.cpp | 4 +- .../src/multi_screen_manager.cpp | 1 + .../src/screen_session_manager.cpp | 159 ++++++++++++++++++ .../src/screen_setting_helper.cpp | 48 ++++++ .../src/setting_provider.cpp | 7 +- .../session/screen/include/screen_property.h | 1 + .../session/screen/include/screen_session.h | 1 + .../session/screen/src/screen_property.cpp | 6 + .../session/screen/src/screen_session.cpp | 20 +++ .../dms_unittest/screen_property_test.cpp | 19 +++ .../screen_session_manager_test2.cpp | 136 +++++++++++++++ .../screen_setting_helper_test.cpp | 73 ++++++++ 14 files changed, 487 insertions(+), 4 deletions(-) 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 5ecf98da0e..019c62c544 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -500,6 +500,8 @@ public: Rotation GetConfigCorrectionByDisplayMode(FoldDisplayMode displayMode); Rotation RemoveRotationCorrection(Rotation rotation); void NotifySwitchUserAnimationFinish() override; + // mirror screen + bool HandleResolutionEffectChange(); protected: ScreenSessionManager(); @@ -930,6 +932,13 @@ private: void WaitSwitchUserAnimateFinish(int32_t newUserId, bool isColdSwitch); void MakeMirrorAfterSwitchUser(); + // mirror screen + bool SetResolutionEffect(ScreenId screenId, uint32_t width, uint32_t height); + bool RecoveryResolutionEffect(); + void RegisterSettingResolutionEffectObserver(); + void SetResolutionEffectFromSettingData(); + std::atomic curResolutionEffectEnable_ = false; + private: class ScbClientListenerDeathRecipient : public IRemoteObject::DeathRecipient { public: diff --git a/window_scene/screen_session_manager/include/screen_setting_helper.h b/window_scene/screen_session_manager/include/screen_setting_helper.h index 95b64bad1a..bb48061a49 100644 --- a/window_scene/screen_session_manager/include/screen_setting_helper.h +++ b/window_scene/screen_session_manager/include/screen_setting_helper.h @@ -67,7 +67,10 @@ public: static bool GetSettingExtendScreenDpi(float& coef, const std::string& key = SETTING_EXTEND_DPI_KEY); static bool ConvertStrToUint64(const std::string& str, uint64_t& num); static bool ConvertStrToInt32(const std::string& str, int32_t& num); - + static bool GetResolutionEffect(bool& enable, + const std::string& key = SETTING_RESOLUTION_EFFECT_KEY); + static void RegisterSettingResolutionEffectObserver(SettingObserver::UpdateFunc func); + static void UnregisterSettingResolutionEffectObserver(); private: static const constexpr char* SETTING_DPI_KEY {"user_set_dpi_value"}; static const constexpr char* SETTING_CAST_KEY {"huaweicast.data.privacy_projection_state"}; @@ -76,6 +79,7 @@ private: static const constexpr char* SETTING_SCREEN_MODE_KEY {"user_set_screen_mode_edid"}; static const constexpr char* SETTING_EXTEND_DPI_KEY {"user_set_dpi_extend"}; static const constexpr char* SETTING_DURING_CALL_KEY {"during_call_state"}; + static const constexpr char* SETTING_RESOLUTION_EFFECT_KEY {"user_set_resolution_effect_select"}; static const constexpr uint32_t BASE_TEN = 10; static sptr dpiObserver_; static sptr castObserver_; @@ -83,6 +87,7 @@ private: static sptr wireCastObserver_; static sptr extendScreenDpiObserver_; static sptr duringCallStateObserver_; + static sptr resolutionEffectObserver_; }; } // namespace Rosen } // namespace OHOS 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 f41cb52549..e656ef5643 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 @@ -578,7 +578,9 @@ DMError SuperFoldStateManager::RefreshMirrorRegionInner( mirrorRegion.height_ = mainScreenProperty.GetScreenRealHeight(); } mainScreenSession->UpdateMirrorWidth(mirrorRegion.width_); - mainScreenSession->UpdateMirrorHeight(mirrorRegion.height_); + mainScreenSession->UpdateMirrorHeight(mainScreenProperty.GetScreenRealHeight()); + secondarySession->UpdateMirrorWidth(mirrorRegion.width_); + secondarySession->UpdateMirrorHeight(mirrorRegion.height_); secondarySession->SetMirrorScreenRegion(secondarySession->GetScreenId(), mirrorRegion); secondarySession->SetIsPhysicalMirrorSwitch(true); secondarySession->EnableMirrorScreenRegion(); diff --git a/window_scene/screen_session_manager/src/multi_screen_manager.cpp b/window_scene/screen_session_manager/src/multi_screen_manager.cpp index cd93da7478..4325a95439 100644 --- a/window_scene/screen_session_manager/src/multi_screen_manager.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_manager.cpp @@ -369,6 +369,7 @@ void MultiScreenManager::MultiScreenModeChange(sptr firstSession, } else { TLOGW(WmsLogTag::DMS, "multi screen operate type change failed."); } + ScreenSessionManager::GetInstance().HandleResolutionEffectChange(); } void MultiScreenManager::DoFirstMainChangeExtend(sptr scbClient, 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 39b34b648a..e24289a376 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1747,6 +1747,7 @@ void ScreenSessionManager::HandlePhysicalMirrorDisconnect(sptr sc bool phyMirrorEnable) { if (phyMirrorEnable) { + RecoveryResolutionEffect(); NotifyCastWhenScreenConnectChange(false); FreeDisplayMirrorNodeInner(screenSession); isPhyScreenConnected_ = false; @@ -2624,6 +2625,144 @@ DMError ScreenSessionManager::SetResolution(ScreenId screenId, uint32_t width, u return DMError::DM_OK; } +bool ScreenSessionManager::HandleResolutionEffectChange() +{ + TLOGI(WmsLogTag::DMS, "start"); + if (!g_isPcDevice || FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + TLOGE(WmsLogTag::DMS, "not support"); + return false; + } + sptr internalSession = nullptr; + sptr externalSession = nullptr; + bool effectFlag = false; + ScreenSettingHelper::GetResolutionEffect(effectFlag); + GetInternalAndExternalSession(internalSession, externalSession); + if (!internalSession || !externalSession || + externalSession->GetScreenCombination() != ScreenCombination::SCREEN_MIRROR) { + TLOGE(WmsLogTag::DMS, "Session null or not mirror"); + RecoveryResolutionEffect(); + return false; + } + + uint32_t innerWidth = internalSession->GetScreenProperty().GetScreenRealWidth(); + uint32_t innerHeight = internalSession->GetScreenProperty().GetScreenRealHeight(); + uint32_t externalWidth = externalSession->GetScreenProperty().GetScreenRealWidth(); + uint32_t externalHeight = externalSession->GetScreenProperty().GetScreenRealHeight(); + uint32_t targetWidth = innerWidth; + uint32_t targetHeight = innerHeight; + if (innerHeight == 0 || externalHeight == 0) { + return false; + } + float innerResolution = static_cast(innerWidth) / innerHeight; + float externalResolution = static_cast(externalWidth) / externalHeight; + float diffResolution = innerResolution - externalResolution; + if (externalResolution == 0) { + return false; + } + if (effectFlag && std::fabs(diffResolution) >= FLT_EPSILON) { + if (externalResolution > innerResolution ) { + targetHeight = static_cast(innerWidth / externalResolution); + } else { + targetWidth = static_cast(innerHeight * externalResolution); + } + curResolutionEffectEnable_.store(true); + } else { + curResolutionEffectEnable_.store(false); + } + SetResolutionEffect(internalSession->GetScreenId(), targetWidth, targetHeight); + return true; +} + +bool ScreenSessionManager::SetResolutionEffect(ScreenId screenId, uint32_t width, uint32_t height) +{ + + if (!g_isPcDevice || FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + TLOGW(WmsLogTag::DMS, "not support"); + return false; + } + TLOGI(WmsLogTag::DMS, "change resolution according to extend screen when in mirror screen combination: " + "%{public}" PRIu64 " %{public}d %{public}d", screenId, width, height); + sptr internalSession = nullptr; + sptr externalSession = nullptr; + GetInternalAndExternalSession(internalSession, externalSession); + if (!externalSession || + externalSession->GetScreenCombination() != ScreenCombination::SCREEN_MIRROR) { + return false; + } + if (!internalSession || internalSession->GetScreenId() != screenId) { + TLOGE(WmsLogTag::DMS, "only internal session valid"); + return false; + } + uint32_t realWidth = internalSession->GetScreenProperty().GetScreenRealWidth(); + uint32_t realHeight = internalSession->GetScreenProperty().GetScreenRealHeight(); + // Calculate the center position + DMRect toRect = { + std::floor((realWidth - width) / 2), + std::floor((realHeight - height) / 2), + width, + height + }; + TLOGI(WmsLogTag::DMS, "toRect %{public}d %{public}d %{public}d %{public}d", + toRect.posX_, toRect.posY_, toRect.width_, toRect.height_); + // Setting the display area of the internal screen + internalSession->UpdatePropertyByResolution(toRect); + internalSession->PropertyChange(internalSession->GetScreenProperty(), ScreenPropertyChangeReason::CHANGE_MODE); + NotifyScreenChanged(internalSession->ConvertToScreenInfo(), ScreenChangeEvent::CHANGE_MODE); + NotifyDisplayChanged(internalSession->ConvertToDisplayInfo(), DisplayChangeEvent::DISPLAY_SIZE_CHANGED); + // Black out invalid area + auto displaynode = internalSession->GetDisplayNode(); + displaynode->SetClipToBounds(true); + RSTransactionAdapter::FlushImplicitTransaction(internalSession->GetRSUIContext()); + //Set up the external screen projection area ,all zero means turn off SetMirrorScreenVisibleRect + OHOS::Rect rsRect = {toRect.posX_, toRect.posY_, width, height}; + if (!curResolutionEffectEnable_.load()) { + rsRect = {0, 0, 0, 0}; + } + rsInterface_.SetMirrorScreenVisibleRect(externalSession->GetScreenId(), rsRect); + // Parameters required for multiinput cursor + externalSession->UpdateMirrorWidth(toRect.width_); + externalSession->UpdateMirrorHeight(toRect.height_); + NotifyScreenModeChange(); + return true; +} + +bool ScreenSessionManager::RecoveryResolutionEffect() +{ + TLOGI(WmsLogTag::DMS, "recovery inner and external screen resolution"); + if (!g_isPcDevice || FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + TLOGW(WmsLogTag::DMS, "not support"); + return false; + } + sptr internalSession = nullptr; + sptr externalSession = nullptr; + GetInternalAndExternalSession(internalSession, externalSession); + if (!curResolutionEffectEnable_.load() || !internalSession) { + return false; + } + DMRect RealResolutionRect = { 0, 0, + internalSession->GetScreenProperty().GetScreenRealWidth(), + internalSession->GetScreenProperty().GetScreenRealHeight()}; + TLOGI(WmsLogTag::DMS, "RealResolutionRect %{public}d %{public}d %{public}d %{public}d", + RealResolutionRect.posX_, RealResolutionRect.posY_, RealResolutionRect.width_, RealResolutionRect.height_); + internalSession->UpdatePropertyByResolution(RealResolutionRect); + internalSession->PropertyChange(internalSession->GetScreenProperty(), ScreenPropertyChangeReason::CHANGE_MODE); + NotifyScreenChanged(internalSession->ConvertToScreenInfo(), ScreenChangeEvent::CHANGE_MODE); + NotifyDisplayChanged(internalSession->ConvertToDisplayInfo(), DisplayChangeEvent::DISPLAY_SIZE_CHANGED); + auto displaynode = internalSession->GetDisplayNode(); + displaynode->SetClipToBounds(false); + RSTransactionAdapter::FlushImplicitTransaction(internalSession->GetRSUIContext()); + + if (externalSession) { + OHOS::Rect rsRect = {0, 0, 0, 0}; + rsInterface_.SetMirrorScreenVisibleRect(externalSession->GetScreenId(), rsRect); + externalSession->UpdateMirrorWidth(externalSession->GetScreenProperty().GetScreenRealWidth()); + externalSession->UpdateMirrorHeight(externalSession->GetScreenProperty().GetScreenRealHeight()); + } + NotifyScreenModeChange(); + curResolutionEffectEnable_.store(false); + return true; +} + DMError ScreenSessionManager::GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) { DmsXcollie dmsXcollie("DMS:GetDensityInCurResolution", XCOLLIE_TIMEOUT_10S); @@ -4285,6 +4424,7 @@ void ScreenSessionManager::BootFinishedCallback(const char *key, const char *val that.foldScreenPowerInit_(); } that.RegisterSettingRotationObserver(); + that.RegisterSettingResolutionEffectObserver(); if (that.defaultDpi) { auto ret = ScreenSettingHelper::SetSettingDefaultDpi(that.defaultDpi, SET_SETTING_DPI_KEY); if (!ret) { @@ -4337,6 +4477,22 @@ void ScreenSessionManager::SetRotateLockedFromSettingData() } } +void ScreenSessionManager::RegisterSettingResolutionEffectObserver() +{ + TLOGI(WmsLogTag::DMS, "Register Setting Observer"); + SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { SetResolutionEffectFromSettingData(); }; + ScreenSettingHelper::RegisterSettingResolutionEffectObserver(updateFunc); +} + +void ScreenSessionManager::SetResolutionEffectFromSettingData() +{ + bool enable = false; + if (ScreenSettingHelper::GetResolutionEffect(enable)) { + TLOGI(WmsLogTag::DMS, "update ResolutionEffect enable: %{public}u", enable); + HandleResolutionEffectChange(); + } +} + void ScreenSessionManager::RegisterSettingDpiObserver() { TLOGI(WmsLogTag::DMS, "Register Setting Dpi Observer"); @@ -9061,6 +9217,9 @@ void ScreenSessionManager::SwitchScbNodeHandle(int32_t newUserId, int32_t newScb } currentUserId_ = newUserId; currentScbPId_ = newScbPid; + // After switching users, the listener will become invalid and needs to be re-registered. + ScreenSettingHelper::UnregisterSettingResolutionEffectObserver(); + RegisterSettingResolutionEffectObserver(); scbSwitchCV_.notify_all(); oldScbDisplayMode_ = GetFoldDisplayMode(); #endif diff --git a/window_scene/screen_session_manager/src/screen_setting_helper.cpp b/window_scene/screen_session_manager/src/screen_setting_helper.cpp index 95e960d45f..8dfc6a3567 100644 --- a/window_scene/screen_session_manager/src/screen_setting_helper.cpp +++ b/window_scene/screen_session_manager/src/screen_setting_helper.cpp @@ -33,6 +33,7 @@ sptr ScreenSettingHelper::rotationObserver_; sptr ScreenSettingHelper::wireCastObserver_; sptr ScreenSettingHelper::extendScreenDpiObserver_; sptr ScreenSettingHelper::duringCallStateObserver_; +sptr ScreenSettingHelper::resolutionEffectObserver_; constexpr int32_t PARAM_NUM_TEN = 10; constexpr uint32_t EXPECT_SCREEN_MODE_SIZE = 2; constexpr uint32_t EXPECT_RELATIVE_POSITION_SIZE = 3; @@ -56,6 +57,7 @@ constexpr float EXTEND_SCREEN_DPI_ZERO_PARAMETER = 0.85f; constexpr float EXTEND_SCREEN_DPI_ONE_PARAMETER = 1.00f; const std::string SCREEN_SHAPE = system::GetParameter("const.window.screen_shape", "0:0"); constexpr int32_t INDEX_EXTEND_SCREEN_DPI_POSITION = -1; +constexpr int32_t ENABLE_RESOLUTION_EFFECT = 1; void ScreenSettingHelper::RegisterSettingDpiObserver(SettingObserver::UpdateFunc func) { @@ -677,5 +679,51 @@ bool ScreenSettingHelper::SetSettingDuringCallState(const std::string& key, bool TLOGI(WmsLogTag::DMS, "put during call state is %{public}d", value); return true; } + +void ScreenSettingHelper::RegisterSettingResolutionEffectObserver(SettingObserver::UpdateFunc func) +{ + if (resolutionEffectObserver_) { + TLOGE(WmsLogTag::DMS, "setting observer is registered"); + return; + } + SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); + resolutionEffectObserver_ = provider.CreateObserver(SETTING_RESOLUTION_EFFECT_KEY, func); + if (resolutionEffectObserver_ == nullptr) { + TLOGE(WmsLogTag::DMS, "create observer failed"); + return; + } + ErrCode ret = provider.RegisterObserver(resolutionEffectObserver_); + if (ret != ERR_OK) { + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); + resolutionEffectObserver_ = nullptr; + } +} + +void ScreenSettingHelper::UnregisterSettingResolutionEffectObserver() +{ + if (resolutionEffectObserver_ == nullptr) { + TLOGD(WmsLogTag::DMS, "setting observer is nullptr"); + return; + } + SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); + ErrCode ret = provider.UnregisterObserver(resolutionEffectObserver_); + if (ret != ERR_OK) { + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); + } + resolutionEffectObserver_ = nullptr; +} + +bool ScreenSettingHelper::GetResolutionEffect(bool& enable, const std::string& key) +{ + int value = 0; + SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); + ErrCode ret = settingProvider.GetIntValue(key, value); + if (ret != ERR_OK) { + TLOGE(WmsLogTag::DMS, "failed, ret=%{public}d", ret); + return false; + } + enable = (value == ENABLE_RESOLUTION_EFFECT); + return true; +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/screen_session_manager/src/setting_provider.cpp b/window_scene/screen_session_manager/src/setting_provider.cpp index 06397eac27..9a007782a0 100644 --- a/window_scene/screen_session_manager/src/setting_provider.cpp +++ b/window_scene/screen_session_manager/src/setting_provider.cpp @@ -36,6 +36,7 @@ const std::string SETTING_COLUMN_KEYWORD = "KEYWORD"; const std::string SETTING_COLUMN_VALUE = "VALUE"; const std::string SETTING_URI_PROXY = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true"; const std::string WALL_KEY = "wallpaperAodDisplay"; +const std::string SETTING_RESOLUTION_EFFECT_KEY = "user_set_resolution_effect_select"; const std::string DURING_CALL_KEY = "during_call_state"; const std::string SETTING_MULTI_USER_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/"; const std::string SETTING_MULTI_USER_TABLE = "USER_SETTINGSDATA_"; @@ -136,7 +137,8 @@ ErrCode SettingProvider::RegisterObserver(const sptr& observer) return ERR_NO_INIT; } std::string callingIdentity = IPCSkeleton::ResetCallingIdentity(); - Uri uri = (observer->GetKey() == DURING_CALL_KEY) ? + Uri uri = ((observer->GetKey() == DURING_CALL_KEY || + observer->GetKey() == SETTING_RESOLUTION_EFFECT_KEY)) ? AssembleUriMultiUser(observer->GetKey()) : AssembleUri(observer->GetKey()); auto helper = CreateDataShareHelper(); if (helper == nullptr) { @@ -198,7 +200,8 @@ ErrCode SettingProvider::GetStringValue(const std::string& key, std::string& val std::vector columns = {SETTING_COLUMN_VALUE}; DataShare::DataSharePredicates predicates; predicates.EqualTo(SETTING_COLUMN_KEYWORD, key); - Uri uri = (key == WALL_KEY || key == DURING_CALL_KEY) ? AssembleUriMultiUser(key) : AssembleUri(key); + Uri uri = (key == WALL_KEY || key == DURING_CALL_KEY || key == SETTING_RESOLUTION_EFFECT_KEY) ? + AssembleUriMultiUser(key) : AssembleUri(key); auto resultSet = helper->Query(uri, predicates, columns); ReleaseDataShareHelper(helper); if (resultSet == nullptr) { diff --git a/window_scene/session/screen/include/screen_property.h b/window_scene/session/screen/include/screen_property.h index 0f4ccde8a5..77298f1f5d 100644 --- a/window_scene/session/screen/include/screen_property.h +++ b/window_scene/session/screen/include/screen_property.h @@ -214,6 +214,7 @@ public: int32_t GetInputOffsetY(); void SetInputOffsetY(); + void SetInputOffset(int32_t x, int32_t y); void SetMirrorWidth(uint32_t mirrorWidth); uint32_t GetMirrorWidth() const; void SetMirrorHeight(uint32_t mirrorHeight); diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 0b407a0467..a1cf901ea9 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -209,6 +209,7 @@ public: void UpdateRefreshRate(uint32_t refreshRate); uint32_t GetRefreshRate(); void UpdatePropertyByResolution(uint32_t width, uint32_t height); + void UpdatePropertyByResolution(const DMRect& rect); void UpdatePropertyByFakeBounds(uint32_t width, uint32_t height); void SetName(std::string name); void SetInnerName(std::string innerName); diff --git a/window_scene/session/screen/src/screen_property.cpp b/window_scene/session/screen/src/screen_property.cpp index 8edb52dbf9..9078bae895 100644 --- a/window_scene/session/screen/src/screen_property.cpp +++ b/window_scene/session/screen/src/screen_property.cpp @@ -664,6 +664,12 @@ void ScreenProperty::SetInputOffsetY() } } +void ScreenProperty::SetInputOffset(int32_t x, int32_t y) +{ + inputOffsetX_ = x; + inputOffsetY_ = y; +} + float ScreenProperty::CalculatePPI() { int32_t phywidth = GetPhyWidth(); diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 8bdaac6cc9..67a52aa4da 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -724,6 +724,26 @@ void ScreenSession::UpdatePropertyByResolution(uint32_t width, uint32_t height) property_.SetBounds(screenBounds); } +void ScreenSession::UpdatePropertyByResolution(const DMRect& rect) +{ + auto screenBounds = property_.GetBounds(); + screenBounds.rect_.left_ = rect.posX_; + screenBounds.rect_.top_ = rect.posY_; + screenBounds.rect_.width_ = rect.width_; + screenBounds.rect_.height_ = rect.height_; + property_.SetBounds(screenBounds); + // Determine whether the touch is in a valid area. + property_.SetValidWidth(rect.width_); + property_.SetValidHeight(rect.height_); + property_.SetInputOffset(rect.posX_, rect.posY_); + // It is used to calculate the original screen size + property_.SetScreenAreaWidth(rect.width_); + property_.SetScreenAreaHeight(rect.height_); + // It is used to calculate the effective area of the inner screen for cursor + property_.SetMirrorWidth(rect.width_); + property_.SetMirrorHeight(rect.height_); +} + void ScreenSession::UpdatePropertyByFakeBounds(uint32_t width, uint32_t height) { auto screenFakeBounds = property_.GetFakeBounds(); diff --git a/window_scene/test/dms_unittest/screen_property_test.cpp b/window_scene/test/dms_unittest/screen_property_test.cpp index ca424ce58f..312369d680 100644 --- a/window_scene/test/dms_unittest/screen_property_test.cpp +++ b/window_scene/test/dms_unittest/screen_property_test.cpp @@ -970,6 +970,25 @@ HWTEST_F(ScreenPropertyTest, SetPhysicalTouchBounds, TestSize.Level1) EXPECT_EQ(property->physicalTouchBounds_.rect_.width_, 100); EXPECT_EQ(property->physicalTouchBounds_.rect_.height_, 200); } + +/** + * @tc.name: SetInputOffset + * @tc.desc: SetInputOffset + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, SetInputOffset, TestSize.Level1) +{ + std::shared_ptr property = std::make_shared(); + property->SetInputOffset(0, 0); + EXPECT_EQ(property->GetInputOffsetX(), 0); + EXPECT_EQ(property->GetInputOffsetY(), 0); + property->SetInputOffset(-1, -2); + EXPECT_EQ(property->GetInputOffsetX(), -1); + EXPECT_EQ(property->GetInputOffsetY(), -2); + property->SetInputOffset(1, 2); + EXPECT_EQ(property->GetInputOffsetX(), 1); + EXPECT_EQ(property->GetInputOffsetY(), 2); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp index b7e28ddc1b..95a99e608e 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -2159,6 +2159,142 @@ HWTEST_F(ScreenSessionManagerTest, HandleFoldDeviceScreenConnect, TestSize.Level EXPECT_TRUE(g_errLog.find("event: connect") != std::string::npos); g_errLog.clear(); } + +/** + * @tc.name: HandleResolutionEffectChange + * @tc.desc: HandleResolutionEffectChange + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, HandleResolutionEffectChange, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + + sptr screenSession1 = new ScreenSession(51, ScreenProperty(), 0); + ASSERT_NE(nullptr, screenSession1); + screenSession1->SetIsCurrentInUse(true); + screenSession1->SetScreenType(ScreenType::REAL); + screenSession1->isInternal_ = true; + + sptr screenSession2 = new ScreenSession(52, ScreenProperty(), 0); + ASSERT_NE(nullptr, screenSession2); + screenSession2->SetIsCurrentInUse(true); + screenSession2->SetScreenType(ScreenType::REAL); + screenSession2->isInternal_ = false; + auto ret = ssm_->HandleResolutionEffectChange(); + EXPECT_FALSE(ret); + + ssm_->screenSessionMap_[51] = screenSession1; + ssm_->screenSessionMap_[52] = screenSession2; + sptr externalSession = nullptr; + sptr internalSession = nullptr; + ssm_->GetInternalAndExternalSession(internalSession, externalSession); + EXPECT_EQ(internalSession, screenSession1); + EXPECT_EQ(externalSession, screenSession2); + + screenSession2->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + ret = ssm_->HandleResolutionEffectChange(); + EXPECT_TRUE(ret); + EXPECT_FALSE(ssm_->curResolutionEffectEnable_); + + ssm_->screenSessionMap_.erase(51); + ssm_->screenSessionMap_.erase(52); +} + +/** + * @tc.name: SetResolutionEffect + * @tc.desc: SetResolutionEffect + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetResolutionEffect, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + + sptr screenSession1 = new ScreenSession(51, ScreenProperty(), 0); + ASSERT_NE(nullptr, screenSession1); + screenSession1->SetIsCurrentInUse(true); + screenSession1->SetScreenType(ScreenType::REAL); + screenSession1->isInternal_ = true; + + sptr screenSession2 = new ScreenSession(52, ScreenProperty(), 0); + ASSERT_NE(nullptr, screenSession2); + screenSession2->SetIsCurrentInUse(true); + screenSession2->SetScreenType(ScreenType::REAL); + screenSession2->isInternal_ = false; + + ssm_->screenSessionMap_[51] = screenSession1; + ssm_->screenSessionMap_[52] = screenSession2; + sptr externalSession = nullptr; + sptr internalSession = nullptr; + ssm_->GetInternalAndExternalSession(internalSession, externalSession); + EXPECT_EQ(internalSession, screenSession1); + EXPECT_EQ(externalSession, screenSession2); + + auto ret = ssm_->SetResolutionEffect(51, 3120, 2080); + EXPECT_FALSE(ret); + + ret = ssm_->SetResolutionEffect(52, 3120, 2080); + EXPECT_FALSE(ret); + + screenSession2->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + ret = ssm_->SetResolutionEffect(51, 3120, 2080); + EXPECT_TRUE(ret); + EXPECT_EQ(screenSession1->GetScreenProperty().GetBounds().rect_.width_, 3120); + EXPECT_EQ(screenSession1->GetScreenProperty().GetBounds().rect_.height_, 2080); + EXPECT_EQ(screenSession2->GetScreenProperty().GetMirrorWidth(), 3120); + EXPECT_EQ(screenSession2->GetScreenProperty().GetMirrorHeight(), 2080); + + ssm_->screenSessionMap_.erase(51); + ssm_->screenSessionMap_.erase(52); +} + +/** + * @tc.name: SetResolutionEffect + * @tc.desc: SetResolutionEffect + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, RecoveryResolutionEffect, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + + sptr screenSession1 = new ScreenSession(51, ScreenProperty(), 0); + ASSERT_NE(nullptr, screenSession1); + screenSession1->SetIsCurrentInUse(true); + screenSession1->SetScreenType(ScreenType::REAL); + screenSession1->isInternal_ = true; + + sptr screenSession2 = new ScreenSession(52, ScreenProperty(), 0); + ASSERT_NE(nullptr, screenSession2); + screenSession2->SetIsCurrentInUse(true); + screenSession2->SetScreenType(ScreenType::REAL); + screenSession2->isInternal_ = false; + + ssm_->screenSessionMap_[51] = screenSession1; + ssm_->screenSessionMap_[52] = screenSession2; + sptr externalSession = nullptr; + sptr internalSession = nullptr; + ssm_->GetInternalAndExternalSession(internalSession, externalSession); + ASSERT_EQ(internalSession, screenSession1); + ASSERT_EQ(externalSession, screenSession2); + + auto ret = ssm_->RecoveryResolutionEffect(); + EXPECT_FALSE(ret); + + ssm_->curResolutionEffectEnable_ = true; + ret = ssm_->RecoveryResolutionEffect(); + EXPECT_TRUE(ret); + EXPECT_FALSE(ssm_->curResolutionEffectEnable_); + EXPECT_EQ(screenSession1->GetScreenProperty().GetBounds().rect_.width_, + screenSession1->GetScreenProperty().GetScreenRealWidth()); + EXPECT_EQ(screenSession1->GetScreenProperty().GetBounds().rect_.height_, + screenSession1->GetScreenProperty().GetScreenRealHeight()); + EXPECT_EQ(screenSession2->GetScreenProperty().GetMirrorWidth(), + screenSession1->GetScreenProperty().GetScreenRealWidth()); + EXPECT_EQ(screenSession2->GetScreenProperty().GetMirrorHeight(), + screenSession1->GetScreenProperty().GetScreenRealHeight()); + ssm_->curResolutionEffectEnable_ = false; + ssm_->screenSessionMap_.erase(51); + ssm_->screenSessionMap_.erase(52); +} } } } \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_setting_helper_test.cpp b/window_scene/test/dms_unittest/screen_setting_helper_test.cpp index d5033e6675..2a554a0f1b 100644 --- a/window_scene/test/dms_unittest/screen_setting_helper_test.cpp +++ b/window_scene/test/dms_unittest/screen_setting_helper_test.cpp @@ -953,6 +953,79 @@ namespace { screenSettingHelper.GetSettingDuringCallState(value); ASSERT_TRUE(value); } + + /** + * @tc.name: RegisterSettingResolutionEffectObserver + * @tc.desc: RegisterSettingResolutionEffectObserver + * @tc.type: FUNC + */ + HWTEST_F(ScreenSettingHelperTest, RegisterSettingResolutionEffectObserver, TestSize.Level1) + { + bool flag = false; + auto func = [&flag] (const std::string&) { + TLOGI(WmsLogTag::DMS, "UT test"); + flag = true; + }; + ScreenSettingHelper::RegisterSettingResolutionEffectObserver(func); + ASSERT_NE(ScreenSettingHelper::resolutionEffectObserver_, nullptr); + + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + bool flag1 = false; + auto func1 = [&flag1] (const std::string&) { + TLOGI(WmsLogTag::DMS, "UT test"); + flag1 = true; + }; + ScreenSettingHelper::RegisterSettingResolutionEffectObserver(func1); + EXPECT_TRUE(g_errLog.find("setting observer is registered") != std::string::npos); + LOG_SetCallback(nullptr); + ScreenSettingHelper::resolutionEffectObserver_ = nullptr; + } + + /** + * @tc.name: UnRegisterSettingResolutionEffectObserver + * @tc.desc: UnRegisterSettingResolutionEffectObserver + * @tc.type: FUNC + */ + HWTEST_F(ScreenSettingHelperTest, UnregisterSettingResolutionEffectObserver, TestSize.Level1) + { + ScreenSettingHelper::resolutionEffectObserver_ = new SettingObserver; + ScreenSettingHelper::UnregisterSettingResolutionEffectObserver(); + ASSERT_EQ(ScreenSettingHelper::resolutionEffectObserver_, nullptr); + + ScreenSettingHelper::resolutionEffectObserver_ = nullptr; + ScreenSettingHelper::UnregisterSettingResolutionEffectObserver(); + ASSERT_EQ(ScreenSettingHelper::resolutionEffectObserver_, nullptr); + } + + /** + * @tc.name: UnRegisterSettingResolutionEffectObserver + * @tc.desc: UnRegisterSettingResolutionEffectObserver + * @tc.type: FUNC + */ + HWTEST_F(ScreenSettingHelperTest, UnregisterSettingResolutionEffectObserver02, TestSize.Level1) + { + ScreenSettingHelper::resolutionEffectObserver_ = nullptr; + ScreenSettingHelper::UnregisterSettingResolutionEffectObserver(); + ASSERT_EQ(ScreenSettingHelper::resolutionEffectObserver_, nullptr); + } + + /** + * @tc.name: GetResolutionEffectTest + * @tc.desc: Test GetResolutionEffectTest func + * @tc.type: FUNC + */ + HWTEST_F(ScreenSettingHelperTest, GetResolutionEffectTestTest, Function | SmallTest | Level3) + { + ScreenSettingHelper screenSettingHelper = ScreenSettingHelper(); + bool value = false; + + if (screenSettingHelper.GetResolutionEffect(value)) { + ASSERT_TRUE(value); + } else { + ASSERT_FALSE(value); + } + } } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From a78786c848ce7eb9d610e7927c15e2cfd188a28a Mon Sep 17 00:00:00 2001 From: chuanstudy Date: Thu, 11 Sep 2025 08:18:56 +0000 Subject: [PATCH 07/76] del loadcontent s Signed-off-by: chuanstudy --- .../window_runtime/window_stage_ani/src/ani_window_stage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_stage.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_stage.cpp index 07c0cfa22e..50d35ae499 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_stage.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_stage.cpp @@ -278,7 +278,7 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) } std::array methods = { ani_native_function {"loadContentSync", - "JLstd/core/String;Larkui/stateManagement/storages/localStorage/LocalStorage;:V", + "JLstd/core/String;Larkui/stateManagement/storage/localStorage/LocalStorage;:V", reinterpret_cast(AniWindowStage::LoadContent)}, ani_native_function {"disableWindowDecorSync", nullptr, reinterpret_cast(AniWindowStage::DisableWindowDecor)}, -- Gitee From dd1ba470c71c8d74a41c5f83ac5b3a1a2fba25a4 Mon Sep 17 00:00:00 2001 From: gcw_bkPrirku Date: Mon, 15 Sep 2025 10:58:57 +0800 Subject: [PATCH 08/76] add innerProcess flag when sync. Signed-off-by: gcw_bkPrirku --- utils/include/rs_adapter.h | 2 + utils/src/rs_adapter.cpp | 12 ++++++ .../js_transaction_manager.cpp | 38 +++++++++++++++++-- .../src/zidl/session_stage_proxy.cpp | 6 ++- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/utils/include/rs_adapter.h b/utils/include/rs_adapter.h index 4c88fb9ab1..dec4e78434 100644 --- a/utils/include/rs_adapter.h +++ b/utils/include/rs_adapter.h @@ -109,6 +109,8 @@ public: static std::shared_ptr GetRSTransaction(const std::shared_ptr& rsUIContext); static std::shared_ptr GetRSTransaction(const std::shared_ptr& rsNode); + static void OpenSyncTransaction(const std::shared_ptr& rsUIContext, bool isInnerProcess, + const std::shared_ptr& handler = nullptr); static void OpenSyncTransaction(const std::shared_ptr& rsUIContext, const std::shared_ptr& handler = nullptr); static void OpenSyncTransaction(const std::shared_ptr& rsNode, diff --git a/utils/src/rs_adapter.cpp b/utils/src/rs_adapter.cpp index b2992bdb21..e68777fabc 100644 --- a/utils/src/rs_adapter.cpp +++ b/utils/src/rs_adapter.cpp @@ -362,6 +362,18 @@ std::shared_ptr RSSyncTransactionAdapter::GetRSTransaction(const return GetRSTransaction(rsNode ? rsNode->GetRSUIContext() : nullptr); } +void RSSyncTransactionAdapter::OpenSyncTransaction(const std::shared_ptr& rsUIContext, + bool isInnerProcess, const std::shared_ptr& handler) +{ + InvokeSyncTransaction( + rsUIContext, + [isInnerProcess, handler](auto& invoker) { + RETURN_IF_PARAM_IS_NULL(invoker); + invoker->OpenSyncTransaction(handler, isInnerProcess); + }, + __func__); +} + void RSSyncTransactionAdapter::OpenSyncTransaction( const std::shared_ptr& rsUIContext, const std::shared_ptr& handler) { 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 144dad2029..79ec13ab8b 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 @@ -120,13 +120,45 @@ ScreenId ParseScreenIdFromArgs(napi_env env, napi_callback_info info) return static_cast(screenIdValue); } +std::pair ParseScreenIdAndInnerProcessFromArgs(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value argv[2] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + int64_t screenIdValue = static_cast(SCREEN_ID_INVALID); + bool isInnerProcess = false; + if (argc != 2) { + TLOGW(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc); + return std::make_pair(SCREEN_ID_INVALID, isInnerProcess); + } + + if (!ConvertFromJsValue(env, argv[0], screenIdValue)) { + TLOGW(WmsLogTag::DEFAULT, "Failed to convert parameter to screenId"); + return std::make_pair(SCREEN_ID_INVALID, isInnerProcess); + } + + if (screenIdValue == static_cast(SCREEN_ID_INVALID)) { + TLOGW(WmsLogTag::DEFAULT, "Invalid screenId"); + return std::make_pair(SCREEN_ID_INVALID, isInnerProcess); + } + + if (!ConvertFromJsValue(env, argv[1], isInnerProcess)) { + TLOGW(WmsLogTag::DEFAULT, "Failed to convert parameter to isInnerProcess"); + return std::make_pair(SCREEN_ID_INVALID, isInnerProcess); + } + TLOGW(WmsLogTag::DEFAULT, "screenId: %{public}ld, isInnerProcess: %{public}d", screenIdValue, isInnerProcess); + return std::make_pair(static_cast(screenIdValue), isInnerProcess); +} + napi_value JsTransactionManager::OnOpenSyncTransaction(napi_env env, napi_callback_info info) { - ScreenId screenId = ParseScreenIdFromArgs(env, info); - auto task = [screenId] { + std::pair res = ParseScreenIdAndInnerProcessFromArgs(env, info); + ScreenId screenId = res.first; + bool isInnerProcess = res.second; + auto task = [screenId, isInnerProcess] { auto rsUIContext = ScreenSessionManagerClient::GetInstance().GetRSUIContext(screenId); RSTransactionAdapter::FlushImplicitTransaction(rsUIContext); - RSSyncTransactionAdapter::OpenSyncTransaction(rsUIContext); + RSSyncTransactionAdapter::OpenSyncTransaction(rsUIContext, isInnerProcess); }; auto handler = SceneSessionManager::GetInstance().GetTaskScheduler(); if (handler) { diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index 53ec21dbf6..973a0dbc84 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -199,7 +199,11 @@ WSError SessionStageProxy::UpdateRect(const WSRect& rect, SizeChangeReason reaso WLOGFE("Write has transaction failed"); return WSError::WS_ERROR_IPC_FAILED; } - if (hasRSTransaction) { + + bool isInnerProcess = hasRSTransaction ? rsTransaction->GetInnerProcessFlag() : false; + TLOGD(WmsLogTag::DEFAULT, "hasRSTransaction: %{public}d, isInnerProcess: %{public}d", hasRSTransaction, + isInnerProcess); + if (hasRSTransaction && !isInnerProcess) { auto pid = rsTransaction->GetParentPid(); rsTransaction->SetParentPid(getprocpid()); if (!data.WriteParcelable(rsTransaction.get())) { -- Gitee From c5c024142f4b177a3aefa766d7ea189f55975aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Mon, 15 Sep 2025 11:12:06 +0800 Subject: [PATCH 09/76] =?UTF-8?q?scopenapi=5Fopen=5Fhandle=5Fscop=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E=E5=80=BC=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=8F=8A=E5=BA=94=E7=94=A8=E5=90=8E=E5=8F=B0=E9=A2=91?= =?UTF-8?q?=E7=B9=81=E8=B0=83=E7=94=A8ipc=E6=8E=A5=E5=8F=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../window_napi/js_window_listener.cpp | 12 ++++++++++-- .../napi/scene_session_manager/js_scene_utils.cpp | 6 +++++- window_scene/session/host/src/scene_session.cpp | 11 +++++++++-- window_scene/test/unittest/scene_session_test3.cpp | 10 +++++++++- 4 files changed, 33 insertions(+), 6 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 a0cfa068a2..70c3f344f2 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 @@ -196,7 +196,11 @@ void JsWindowListener::LifeCycleCallBack(LifeCycleEventType eventType) return; } napi_handle_scope scope = nullptr; - napi_open_handle_scope(eng, &scope); + napi_status status = napi_open_handle_scope(eng, &scope); + if (status != napi_ok || scope == nullptr) { + TLOGNE(WmsLogTag::WMS_LIFE, "open handle scope failed."); + return; + } napi_value argv[] = {CreateJsValue(eng, static_cast(eventType))}; thisListener->CallJsMethod(LIFECYCLE_EVENT_CB.c_str(), argv, ArraySize(argv)); napi_close_handle_scope(eng, scope); @@ -220,7 +224,11 @@ void JsWindowListener::WindowStageLifecycleCallback(WindowStageLifeCycleEventTyp return; } napi_handle_scope scope = nullptr; - napi_open_handle_scope(eng, &scope); + napi_status status = napi_open_handle_scope(eng, &scope); + if (status != napi_ok || scope == nullptr) { + TLOGNE(WmsLogTag::WMS_LIFE, "open handle scope failed."); + return; + } napi_value argv[] = {CreateJsValue(eng, static_cast(eventType))}; thisListener->CallJsMethod(WINDOW_STAGE_LIFECYCLE_EVENT_CB.c_str(), argv, ArraySize(argv)); napi_close_handle_scope(eng, scope); 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 df8c80b2ce..a407e50069 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 @@ -2613,7 +2613,11 @@ void MainThreadScheduler::PostMainThreadTask(Task&& localTask, std::string trace return; } napi_handle_scope scope = nullptr; - napi_open_handle_scope(env, &scope); + napi_status status = napi_open_handle_scope(env, &scope); + if (status != napi_ok || scope == nullptr) { + TLOGNE(WmsLogTag::WMS_MAIN, "open handle scope failed."); + return; + } localTask(); napi_close_handle_scope(env, scope); }; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0e2db2ae87..c17ce02301 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1219,14 +1219,21 @@ void SceneSession::NotifyUpdateAppUseControl(ControlAppType type, const ControlI session->appUseControlMap_[type] = controlInfo; if (session->onUpdateAppUseControlFunc_) { bool isAppUseControl = (controlInfo.isNeedControl && !controlInfo.isControlRecentOnly); + bool isAppUseControlChanged = (session->isAppUseControl_ != isAppUseControl); session->isAppUseControl_ = isAppUseControl; session->onUpdateAppUseControlFunc_(type, controlInfo.isNeedControl, controlInfo.isControlRecentOnly); if (session->sessionStage_ == nullptr || type == ControlAppType::PRIVACY_WINDOW) { TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s sessionStage is nullptr or privacy mode control", where); return; } - TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s isAppUseControl: %{public}d, persistentId: %{public}d", where, - isAppUseControl, session->GetPersistentId()); + auto state = session->GetSessionState(); + TLOGNI(WmsLogTag::WMS_LIFE, + "%{public}s isAppUseControl: %{public}d, persistentId: %{public}d, state: %{public}d, " + "isAppUseControlChanged: %{public}d", where, isAppUseControl, session->GetPersistentId(), state, + isAppUseControlChanged); + if (state == SessionState::STATE_BACKGROUND && !isAppUseControlChanged) { + return; + } session->sessionStage_->NotifyAppUseControlStatus(isAppUseControl); } }, __func__); diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index 0c05c9b33d..d15d6818eb 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -1216,7 +1216,15 @@ HWTEST_F(SceneSessionTest3, NotifyUpdateAppUseControl, Function | SmallTest | Le .isControlRecentOnly = false }; sceneSession->NotifyUpdateAppUseControl(type, controlInfoSec); - EXPECT_TRUE(logMsg.find("begin call pause") == std::string::npos); + + sceneSession->Session::SetSessionState(SessionState::STATE_BACKGROUND); + sceneSession->NotifyUpdateAppUseControl(type, controlInfoSec); + ControlInfo controlInfoThd = { + .isNeedControl = true, + .isControlRecentOnly = false + }; + sceneSession->NotifyUpdateAppUseControl(type, controlInfoThd); + EXPECT_TRUE(logMsg.find("isAppUseControl:") != std::string::npos); LOG_SetCallback(nullptr); } -- Gitee From c642a42d51b9976e5d9b00c66ac8d874bb7b765a Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Sun, 14 Sep 2025 16:15:47 +0800 Subject: [PATCH 10/76] tdd Signed-off-by: zyh990312 --- .../scene_session_manager/js_scene_session.cpp | 2 +- .../unittest/window_session_property_test.cpp | 2 +- .../unittest/window_scene_session_impl_test3.cpp | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 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 c0a313f688..b0af1505a5 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 @@ -6570,7 +6570,7 @@ napi_value JsSceneSession::OnSetMobileAppInPadLayoutFullScreen(napi_env env, nap return NapiGetUndefined(env); } bool isMobileAppInPadLayoutFullScreen = false; - if (!ConvertFromJsValue(env, argv[0], isMobileAppInPadLayoutFullScreen)) { + if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isMobileAppInPadLayoutFullScreen)) { TLOGE(WmsLogTag::WMS_SCB, "Failed to convert parameter to enable"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 92a88aeaaa..9c1c9d741b 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -1637,7 +1637,7 @@ HWTEST_F(WindowSessionPropertyTest, SetMobileAppInPadLayoutFullScreen, TestSize. bool isMobileAppInPadLayoutFullScreen = true; property->SetMobileAppInPadLayoutFullScreen(isMobileAppInPadLayoutFullScreen); auto result = property->GetMobileAppInPadLayoutFullScreen(); - ASSERT_EQ(result, isMobileAppInPadLayoutFullScreen); + EXPECT_EQ(result, isMobileAppInPadLayoutFullScreen); } /** diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index 5ff40d1b83..7451c2c9a8 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -1022,11 +1022,11 @@ HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating01, TestSize.Level1) } /** - * @tc.name: MaximizeFloating - * @tc.desc: MaximizeFloating + * @tc.name: MaximizeFloating03 + * @tc.desc: MaximizeFloating03 * @tc.type: FUNC */ -HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating, TestSize.Level1) +HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating03, TestSize.Level1) { sptr option = sptr::MakeSptr(); option->SetWindowName("MaximizeFloating"); @@ -1049,23 +1049,23 @@ HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating, TestSize.Level1) windowSceneSessionImpl->SetGlobalMaximizeMode(MaximizeMode::MODE_FULL_FILL); ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); - SystemBarProperty statusProperty = + SystemBarProperty statusProperty = windowSceneSessionImpl->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); - SystemBarProperty navigationIndicatorPorperty = + SystemBarProperty navigationIndicatorPorperty = windowSceneSessionImpl->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); statusProperty.enable_ = false; navigationIndicatorPorperty.enable_ = false; ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); - tatusProperty.enable_ = true; + statusProperty.enable_ = true; navigationIndicatorPorperty.enable_ = true; ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); - tatusProperty.enable_ = true; + statusProperty.enable_ = true; navigationIndicatorPorperty.enable_ = false; ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); - tatusProperty.enable_ = false; + statusProperty.enable_ = false; navigationIndicatorPorperty.enable_ = true; ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); -- Gitee From 2cf6149489686cf2b6511ade02dd6b0d769957ae Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 15 Sep 2025 15:01:05 +0800 Subject: [PATCH 11/76] add check Signed-off-by: hejunfei --- dm/src/oh_display_manager.cpp | 4 +- .../kits/napi/display_runtime/js_display.cpp | 10 +- .../napi/screen_runtime/napi/js_screen.cpp | 6 +- .../js_screen_session_manager.cpp | 18 +++- .../include/screen_cutout_controller.h | 1 + .../src/screen_cutout_controller.cpp | 20 +++- .../screen_cutout_controller_test.cpp | 95 +++++++++++++++++++ 7 files changed, 142 insertions(+), 12 deletions(-) diff --git a/dm/src/oh_display_manager.cpp b/dm/src/oh_display_manager.cpp index 759885824c..b85044c422 100644 --- a/dm/src/oh_display_manager.cpp +++ b/dm/src/oh_display_manager.cpp @@ -874,7 +874,7 @@ static NativeDisplayManager_ErrorCode NativeDisplayManager_SetDisplaysInfo(const TLOGE(WmsLogTag::DMS, "[DMNDK] get display id[%{public}" PRIu64"] info null.", display->GetId()); continue; } - int ret = memcpy_s(displaysInfo[i].name, OH_DISPLAY_NAME_LENGTH, info->GetName().c_str(), + int ret = memcpy_s(displaysInfo[i].name, OH_DISPLAY_NAME_LENGTH + 1, info->GetName().c_str(), OH_DISPLAY_NAME_LENGTH); if (ret != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] failed to memcpy name."); @@ -1001,7 +1001,7 @@ static NativeDisplayManager_DisplayInfo* NativeDisplayManager_FillDisplayInfo(sp *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; return nullptr; } - int ret = memcpy_s(displayInner->name, OH_DISPLAY_NAME_LENGTH, info->GetName().c_str(), OH_DISPLAY_NAME_LENGTH); + int ret = memcpy_s(displayInner->name, OH_DISPLAY_NAME_LENGTH + 1, info->GetName().c_str(), OH_DISPLAY_NAME_LENGTH); if (ret != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memcpy display name failed."); DISPLAY_MANAGER_FREE_MEMORY(displayInner); diff --git a/interfaces/kits/napi/display_runtime/js_display.cpp b/interfaces/kits/napi/display_runtime/js_display.cpp index 68baf89684..c2da75f935 100644 --- a/interfaces/kits/napi/display_runtime/js_display.cpp +++ b/interfaces/kits/napi/display_runtime/js_display.cpp @@ -873,11 +873,11 @@ napi_value CreateJsDisplayObject(napi_env env, sptr& display) objValue = jsDisplayObj->GetNapiValue(); } if (objValue == nullptr) { - napi_create_object(env, &objValue); - } - if (objValue == nullptr) { - TLOGE(WmsLogTag::DMS, "Failed to get jsObject"); - return NapiGetUndefined(env); + auto status = napi_create_object(env, &objValue); + if ((status != napi_ok) || (objValue == nullptr)) { + TLOGE(WmsLogTag::DMS, "failed to create js obj, error:%{public}d", status); + return NapiGetUndefined(env); + } } auto info = display->GetDisplayInfoWithCache(); if (info == nullptr) { diff --git a/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp b/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp index 776c0c7306..bf5e6b7f15 100644 --- a/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp +++ b/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp @@ -287,7 +287,11 @@ napi_value CreateJsScreenObject(napi_env env, sptr& screen) objValue = jsScreenObj->GetNapiValue(); } if (objValue == nullptr) { - napi_create_object(env, &objValue); + auto status = napi_create_object(env, &objValue); + if ((status != napi_ok) || (objValue == nullptr)) { + TLOGE(WmsLogTag::DMS, "failed to create js obj, error:%{public}d", status); + return NapiGetUndefined(env); + } } if (objValue == nullptr) { TLOGE(WmsLogTag::DMS, "Failed to convert prop to jsObject"); 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 5dc9bbba1a..a0d80395ca 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 @@ -879,7 +879,11 @@ napi_value JsScreenSessionManager::OnSetScreenOffDelayTime(napi_env env, const n TLOGD(WmsLogTag::DMS, "[NAPI]OnSetScreenOffDelayTime"); size_t argc = 1; napi_handle_scope scope = nullptr; - napi_open_handle_scope(env, &scope); + auto status = napi_open_handle_scope(env, &scope); + if ((status != napi_ok) || (scope == nullptr)) { + TLOGD(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); + return NapiGetUndefined(env); + } napi_value argv[1] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { // 1: params num @@ -1126,7 +1130,11 @@ napi_value JsScreenSessionManager::OnSetCameraStatus(napi_env env, const napi_ca TLOGD(WmsLogTag::DMS, "[NAPI]OnSetCameraStatus"); size_t argc = 2; napi_handle_scope scope = nullptr; - napi_open_handle_scope(env, &scope); + auto status = napi_open_handle_scope(env, &scope); + if ((status != napi_ok) || (scope == nullptr)) { + TLOGD(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); + return NapiGetUndefined(env); + } napi_value argv[2] = {nullptr, nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 2) { // 2: params num @@ -1161,7 +1169,11 @@ napi_value JsScreenSessionManager::OnSetScreenOnDelayTime(napi_env env, const na { size_t argc = 1; napi_handle_scope scope = nullptr; - napi_open_handle_scope(env, &scope); + auto status = napi_open_handle_scope(env, &scope); + if ((status != napi_ok) || (scope == nullptr)) { + TLOGD(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); + return NapiGetUndefined(env); + } napi_value argv[1] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_ONE) { // 1: params num diff --git a/window_scene/screen_session_manager/include/screen_cutout_controller.h b/window_scene/screen_session_manager/include/screen_cutout_controller.h index 3749444932..9138f457fc 100644 --- a/window_scene/screen_session_manager/include/screen_cutout_controller.h +++ b/window_scene/screen_session_manager/include/screen_cutout_controller.h @@ -40,6 +40,7 @@ private: void CalcCutoutRects(const std::vector& boundaryRects, uint32_t width, uint32_t height, Rotation rotation, std::vector& cutoutRects) const; void InitRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height, DMRect& rect) const; + void CheckBoundaryRects(std::vector& boundaryRects, uint32_t screenWidth, uint32_t screenHeight) const; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCREEN_CUTOUT_CONTROLLER_H diff --git a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp index 257917ff8f..cfe9725fbd 100644 --- a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp @@ -70,7 +70,7 @@ void ScreenCutoutController::GetCutoutArea(DisplayId displayId, uint32_t width, } else { boundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); } - + CheckBoundaryRects(boundaryRects, width, height); if (!boundaryRects.empty()) { CalcCutoutRects(boundaryRects, width, height, rotation, cutoutArea); } @@ -106,6 +106,24 @@ void ScreenCutoutController::CalcCutoutRects(const std::vector& boundary } } +void ScreenCutoutController::CheckBoundaryRects(std::vector& boundaryRects, uint32_t screenWidth, + uint32_t screenHeight) const +{ + for (auto iter = boundaryRects.begin(); iter != boundaryRects.end(); ) { + DMRect boundaryRect = *iter; + if ((boundaryRect.posX_ < 0) || (boundaryRect.posY_ < 0) || + (static_cast(boundaryRect.width_) + boundaryRect.posX_ > static_cast(screenWidth)) || + (static_cast(boundaryRect.height_) + boundaryRect.posY_ > static_cast(screenHeight)) || + (boundaryRect.width_ > screenWidth) || (boundaryRect.height_ > screenHeight) || + boundaryRect.IsUninitializedRect()) { + TLOGE(WmsLogTag::DMS, "boundary is invalid"); + iter = boundaryRect.erase(iter); + } else { + iter++; + } + } +} + void ScreenCutoutController::GetWaterfallArea(uint32_t width, uint32_t height, Rotation rotation, WaterfallDisplayAreaRects& waterfallArea) const { diff --git a/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp b/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp index 99bc0fa964..3dbce5f3dd 100644 --- a/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp +++ b/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp @@ -281,6 +281,101 @@ HWTEST_F(ScreenCutoutControllerTest, InitRect, TestSize.Level1) EXPECT_EQ(emptyRect.width_, 100); EXPECT_EQ(emptyRect.height_, 100); } + +/** + * @tc.name: CheckBoundaryRects + * @tc.desc: ScreenCutoutController check boundary rects + * @tc.type: FUNC +*/ +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +{ + sptr controller = new ScreenCutoutController(); + DMRect emptyRect = {-15, -15, 8, 8}; + DMRect emptyRect_ = {21, 21, 3, 3}; + std::vector boundaryRects = {emptyRect_, emptyRect}; + ScreenProperty screenProperty; + auto screenBouns = RRect({0, 0, 35, 35}, 0.0f, 0.0f); + screenProperty.SetBounds(screenBouns); + ASSERT_TRUE(controller != nullptr); + controller->CheckBoundaryRects(boundaryRects, 0, 0); + EXPECT_EQ(boundaryRects, {emptyRect_}); +} + +/** + * @tc.name: CheckBoundaryRects + * @tc.desc: ScreenCutoutController check boundary rects + * @tc.type: FUNC +*/ +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +{ + sptr controller = new ScreenCutoutController(); + DMRect emptyRect = {1, 1, 7, 7}; + DMRect emptyRect_ = {21, 21, 3, 3}; + std::vector boundaryRects = {emptyRect_, emptyRect}; + ScreenProperty screenProperty; + auto screenBouns = RRect({0, 0, 35, 35}, 0.0f, 0.0f); + screenProperty.SetBounds(screenBouns); + ASSERT_TRUE(controller != nullptr); + controller->CheckBoundaryRects(boundaryRects, 7, 8); + EXPECT_EQ(boundaryRects, {emptyRect_}); +} + +/** + * @tc.name: CheckBoundaryRects + * @tc.desc: ScreenCutoutController check boundary rects + * @tc.type: FUNC +*/ +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +{ + sptr controller = new ScreenCutoutController(); + DMRect emptyRect = {1, 1, 7, 7}; + DMRect emptyRect_ = {21, 21, 3, 3}; + std::vector boundaryRects = {emptyRect_, emptyRect}; + ScreenProperty screenProperty; + auto screenBouns = RRect({0, 0, 35, 35}, 0.0f, 0.0f); + screenProperty.SetBounds(screenBouns); + ASSERT_TRUE(controller != nullptr); + controller->CheckBoundaryRects(boundaryRects, 8, 7); + EXPECT_EQ(boundaryRects, {emptyRect_}); +} + +/** + * @tc.name: CheckBoundaryRects + * @tc.desc: ScreenCutoutController check boundary rects + * @tc.type: FUNC +*/ +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +{ + sptr controller = new ScreenCutoutController(); + DMRect emptyRect = {1, 0, 8, 8}; + DMRect emptyRect_ = {21, 21, 3, 3}; + std::vector boundaryRects = {emptyRect_, emptyRect}; + ScreenProperty screenProperty; + auto screenBouns = RRect({0, 0, 35, 35}, 0.0f, 0.0f); + screenProperty.SetBounds(screenBouns); + ASSERT_TRUE(controller != nullptr); + controller->CheckBoundaryRects(boundaryRects, 9, 7); + EXPECT_EQ(boundaryRects, {emptyRect_}); +} + +/** + * @tc.name: CheckBoundaryRects + * @tc.desc: ScreenCutoutController check boundary rects + * @tc.type: FUNC +*/ +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +{ + sptr controller = new ScreenCutoutController(); + DMRect emptyRect = {0, 0, 0, 0}; + DMRect emptyRect_ = {21, 21, 3, 3}; + std::vector boundaryRects = {emptyRect_, emptyRect}; + ScreenProperty screenProperty; + auto screenBouns = RRect({0, 0, 35, 35}, 0.0f, 0.0f); + screenProperty.SetBounds(screenBouns); + ASSERT_TRUE(controller != nullptr); + controller->CheckBoundaryRects(boundaryRects, 0, 0); + EXPECT_EQ(boundaryRects, {emptyRect_}); +} } } // namespace Rosen } // namespace OHOS -- Gitee From 03d498d8a2add9a3ee172b6af0a7ef633e442d68 Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 15 Sep 2025 15:10:34 +0800 Subject: [PATCH 12/76] modify Signed-off-by: hejunfei --- .../screen_session_manager/js_screen_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 a0d80395ca..021d4aff7a 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 @@ -881,7 +881,7 @@ napi_value JsScreenSessionManager::OnSetScreenOffDelayTime(napi_env env, const n napi_handle_scope scope = nullptr; auto status = napi_open_handle_scope(env, &scope); if ((status != napi_ok) || (scope == nullptr)) { - TLOGD(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); + TLOGW(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); return NapiGetUndefined(env); } napi_value argv[1] = {nullptr}; @@ -1132,7 +1132,7 @@ napi_value JsScreenSessionManager::OnSetCameraStatus(napi_env env, const napi_ca napi_handle_scope scope = nullptr; auto status = napi_open_handle_scope(env, &scope); if ((status != napi_ok) || (scope == nullptr)) { - TLOGD(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); + TLOGW(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); return NapiGetUndefined(env); } napi_value argv[2] = {nullptr, nullptr}; @@ -1171,7 +1171,7 @@ napi_value JsScreenSessionManager::OnSetScreenOnDelayTime(napi_env env, const na napi_handle_scope scope = nullptr; auto status = napi_open_handle_scope(env, &scope); if ((status != napi_ok) || (scope == nullptr)) { - TLOGD(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); + TLOGW(WmsLogTag::DMS, "[NAPI]napi_open_handle_scope fail"); return NapiGetUndefined(env); } napi_value argv[1] = {nullptr}; -- Gitee From b78249b186d3c5e844a50addcc576cb21c80bf5b Mon Sep 17 00:00:00 2001 From: gcw_bkPrirku Date: Mon, 15 Sep 2025 16:11:02 +0800 Subject: [PATCH 13/76] fix codecheck Signed-off-by: gcw_bkPrirku --- .../napi/transaction_manager/js_transaction_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 79ec13ab8b..d6cf94a000 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 @@ -26,6 +26,8 @@ namespace OHOS::Rosen { using namespace AbilityRuntime; +constexpr size_t ARGC_ONE = 1; +constexpr size_t ARGC_TWO = 2; namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "JsTransactionManager" }; } // namespace @@ -127,7 +129,7 @@ std::pair ParseScreenIdAndInnerProcessFromArgs(napi_env env, nap napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); int64_t screenIdValue = static_cast(SCREEN_ID_INVALID); bool isInnerProcess = false; - if (argc != 2) { + if (argc != ARGC_TWO) { TLOGW(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc); return std::make_pair(SCREEN_ID_INVALID, isInnerProcess); } @@ -146,7 +148,7 @@ std::pair ParseScreenIdAndInnerProcessFromArgs(napi_env env, nap TLOGW(WmsLogTag::DEFAULT, "Failed to convert parameter to isInnerProcess"); return std::make_pair(SCREEN_ID_INVALID, isInnerProcess); } - TLOGW(WmsLogTag::DEFAULT, "screenId: %{public}ld, isInnerProcess: %{public}d", screenIdValue, isInnerProcess); + TLOGD(WmsLogTag::DEFAULT, "isInnerProcess: %{public}d", isInnerProcess); return std::make_pair(static_cast(screenIdValue), isInnerProcess); } -- Gitee From c3bd560362dda31071f8dd6b0577ac2359c1a3ac Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 15 Sep 2025 16:46:01 +0800 Subject: [PATCH 14/76] modify review Signed-off-by: hejunfei --- interfaces/kits/napi/screen_runtime/napi/js_screen.cpp | 4 ---- .../screen_session_manager/src/screen_cutout_controller.cpp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp b/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp index bf5e6b7f15..e92d425935 100644 --- a/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp +++ b/interfaces/kits/napi/screen_runtime/napi/js_screen.cpp @@ -293,10 +293,6 @@ napi_value CreateJsScreenObject(napi_env env, sptr& screen) return NapiGetUndefined(env); } } - if (objValue == nullptr) { - TLOGE(WmsLogTag::DMS, "Failed to convert prop to jsObject"); - return NapiGetUndefined(env); - } std::unique_ptr jsScreen = std::make_unique(screen); napi_wrap(env, objValue, jsScreen.release(), JsScreen::Finalizer, nullptr, nullptr); auto info = screen->GetScreenInfo(); diff --git a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp index cfe9725fbd..5f37b1cbf6 100644 --- a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp @@ -115,7 +115,7 @@ void ScreenCutoutController::CheckBoundaryRects(std::vector& boundaryRec (static_cast(boundaryRect.width_) + boundaryRect.posX_ > static_cast(screenWidth)) || (static_cast(boundaryRect.height_) + boundaryRect.posY_ > static_cast(screenHeight)) || (boundaryRect.width_ > screenWidth) || (boundaryRect.height_ > screenHeight) || - boundaryRect.IsUninitializedRect()) { + boundaryRects.IsUninitializedRect()) { TLOGE(WmsLogTag::DMS, "boundary is invalid"); iter = boundaryRect.erase(iter); } else { -- Gitee From d65af53454847ad5025e0f9360705549858fe2cc Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Mon, 15 Sep 2025 16:50:13 +0800 Subject: [PATCH 15/76] tdd review Signed-off-by: zyh990312 --- .../window_scene_session_impl_test5.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index fe2bee4790..f3a2769e51 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -1013,24 +1013,27 @@ HWTEST_F(WindowSceneSessionImplTest5, MobileAppInPadLayoutFullScreenChange, Test window->hostSession_ = session; window->property_->SetPersistentId(1); window->state_ = WindowState::STATE_CREATED; + window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; + window->windowSystemConfig_.freeMultiWindowEnable_ = true; + window->windowSystemConfig_.freeMultiWindowSupport_ = true; window->property_->SetMobileAppInPadLayoutFullScreen(true); - window->property_->SetWidnowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); bool statusBarEnable = true; bool navigationEnable = true; window->enableImmersiveMode_ = true; window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); EXPECT_EQ(false, window->enableImmersiveMode_); - bool statusBarEnable = false; - bool navigationEnable = false; + statusBarEnable = false; + navigationEnable = false; window->enableImmersiveMode_ = false; window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); EXPECT_EQ(true, window->enableImmersiveMode_); - bool statusBarEnable = false; - bool navigationEnable = true; + statusBarEnable = false; + navigationEnable = true; window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); - bool statusBarEnable = true; - bool navigationEnable = false; + statusBarEnable = true; + navigationEnable = false; window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); } -- Gitee From 5969a1f47c7e63a7dd27e5e7e66d15d9ff6ef80e Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 15 Sep 2025 17:13:01 +0800 Subject: [PATCH 16/76] add Signed-off-by: hejunfei --- .../screen_session_manager/src/screen_cutout_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp index 5f37b1cbf6..1b5b893113 100644 --- a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp @@ -117,7 +117,7 @@ void ScreenCutoutController::CheckBoundaryRects(std::vector& boundaryRec (boundaryRect.width_ > screenWidth) || (boundaryRect.height_ > screenHeight) || boundaryRects.IsUninitializedRect()) { TLOGE(WmsLogTag::DMS, "boundary is invalid"); - iter = boundaryRect.erase(iter); + iter = boundaryRects.erase(iter); } else { iter++; } -- Gitee From 476676d1e171cf46022acbdc13abd4541e836a7e Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 15 Sep 2025 17:22:24 +0800 Subject: [PATCH 17/76] codecheck Signed-off-by: hejunfei --- .../screen_session_manager/src/screen_cutout_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp index 1b5b893113..9f65fbecab 100644 --- a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp @@ -109,7 +109,7 @@ void ScreenCutoutController::CalcCutoutRects(const std::vector& boundary void ScreenCutoutController::CheckBoundaryRects(std::vector& boundaryRects, uint32_t screenWidth, uint32_t screenHeight) const { - for (auto iter = boundaryRects.begin(); iter != boundaryRects.end(); ) { + for (auto iter = boundaryRects.begin(); iter != boundaryRects.end();) { DMRect boundaryRect = *iter; if ((boundaryRect.posX_ < 0) || (boundaryRect.posY_ < 0) || (static_cast(boundaryRect.width_) + boundaryRect.posX_ > static_cast(screenWidth)) || -- Gitee From f57b276b7631a5f5c890b3493642e2f0c4e86c33 Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 15 Sep 2025 19:11:16 +0800 Subject: [PATCH 18/76] modify Signed-off-by: hejunfei --- .../screen_session_manager/src/screen_cutout_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp index 9f65fbecab..170fb9cbd0 100644 --- a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp @@ -115,7 +115,7 @@ void ScreenCutoutController::CheckBoundaryRects(std::vector& boundaryRec (static_cast(boundaryRect.width_) + boundaryRect.posX_ > static_cast(screenWidth)) || (static_cast(boundaryRect.height_) + boundaryRect.posY_ > static_cast(screenHeight)) || (boundaryRect.width_ > screenWidth) || (boundaryRect.height_ > screenHeight) || - boundaryRects.IsUninitializedRect()) { + boundaryRect.IsUninitializedRect()) { TLOGE(WmsLogTag::DMS, "boundary is invalid"); iter = boundaryRects.erase(iter); } else { -- Gitee From 91427c5754c564bf89cf8a11c6342220dbe74e16 Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 15 Sep 2025 19:52:44 +0800 Subject: [PATCH 19/76] modify tdd Signed-off-by: hejunfei --- .../screen_cutout_controller_test.cpp | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp b/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp index 3dbce5f3dd..0b4e4bc4af 100644 --- a/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp +++ b/window_scene/test/dms_unittest/screen_cutout_controller_test.cpp @@ -283,11 +283,11 @@ HWTEST_F(ScreenCutoutControllerTest, InitRect, TestSize.Level1) } /** - * @tc.name: CheckBoundaryRects + * @tc.name: CheckBoundaryRects01 * @tc.desc: ScreenCutoutController check boundary rects * @tc.type: FUNC */ -HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects01, TestSize.Level1) { sptr controller = new ScreenCutoutController(); DMRect emptyRect = {-15, -15, 8, 8}; @@ -298,15 +298,16 @@ HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) screenProperty.SetBounds(screenBouns); ASSERT_TRUE(controller != nullptr); controller->CheckBoundaryRects(boundaryRects, 0, 0); - EXPECT_EQ(boundaryRects, {emptyRect_}); + ASSERT_EQ(boundaryRects.size(), 1); + EXPECT_EQ(boundaryRects[0], emptyRect_); } /** - * @tc.name: CheckBoundaryRects + * @tc.name: CheckBoundaryRects02 * @tc.desc: ScreenCutoutController check boundary rects * @tc.type: FUNC */ -HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects02, TestSize.Level1) { sptr controller = new ScreenCutoutController(); DMRect emptyRect = {1, 1, 7, 7}; @@ -317,15 +318,16 @@ HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) screenProperty.SetBounds(screenBouns); ASSERT_TRUE(controller != nullptr); controller->CheckBoundaryRects(boundaryRects, 7, 8); - EXPECT_EQ(boundaryRects, {emptyRect_}); + ASSERT_EQ(boundaryRects.size(), 1); + EXPECT_EQ(boundaryRects[0], emptyRect_); } /** - * @tc.name: CheckBoundaryRects + * @tc.name: CheckBoundaryRects03 * @tc.desc: ScreenCutoutController check boundary rects * @tc.type: FUNC */ -HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects03, TestSize.Level1) { sptr controller = new ScreenCutoutController(); DMRect emptyRect = {1, 1, 7, 7}; @@ -336,15 +338,16 @@ HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) screenProperty.SetBounds(screenBouns); ASSERT_TRUE(controller != nullptr); controller->CheckBoundaryRects(boundaryRects, 8, 7); - EXPECT_EQ(boundaryRects, {emptyRect_}); + ASSERT_EQ(boundaryRects.size(), 1); + EXPECT_EQ(boundaryRects[0], emptyRect_); } /** - * @tc.name: CheckBoundaryRects + * @tc.name: CheckBoundaryRects04 * @tc.desc: ScreenCutoutController check boundary rects * @tc.type: FUNC */ -HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects04, TestSize.Level1) { sptr controller = new ScreenCutoutController(); DMRect emptyRect = {1, 0, 8, 8}; @@ -355,15 +358,16 @@ HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) screenProperty.SetBounds(screenBouns); ASSERT_TRUE(controller != nullptr); controller->CheckBoundaryRects(boundaryRects, 9, 7); - EXPECT_EQ(boundaryRects, {emptyRect_}); + ASSERT_EQ(boundaryRects.size(), 1); + EXPECT_EQ(boundaryRects[0], emptyRect_); } /** - * @tc.name: CheckBoundaryRects + * @tc.name: CheckBoundaryRects05 * @tc.desc: ScreenCutoutController check boundary rects * @tc.type: FUNC */ -HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) +HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects05, TestSize.Level1) { sptr controller = new ScreenCutoutController(); DMRect emptyRect = {0, 0, 0, 0}; @@ -374,7 +378,8 @@ HWTEST_F(ScreenCutoutControllerTest, CheckBoundaryRects, TestSize.Level1) screenProperty.SetBounds(screenBouns); ASSERT_TRUE(controller != nullptr); controller->CheckBoundaryRects(boundaryRects, 0, 0); - EXPECT_EQ(boundaryRects, {emptyRect_}); + ASSERT_EQ(boundaryRects.size(), 1); + EXPECT_EQ(boundaryRects[0], emptyRect_); } } } // namespace Rosen -- Gitee From 4933ca15d114ad1f65a9e20415b50b0563ff365b Mon Sep 17 00:00:00 2001 From: zyh990312 Date: Mon, 15 Sep 2025 20:14:26 +0800 Subject: [PATCH 20/76] =?UTF-8?q?review=20=E6=84=8F=E8=A7=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyh990312 --- wm/src/window_scene_session_impl.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index d12df9ce33..68b7eb677e 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3121,9 +3121,6 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( const std::unordered_map& systemBarProperties, const std::unordered_map& systemBarPropertyFlags) { - SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); - SystemBarProperty navigationIndicatorPorperty = - GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); for (auto [systemBarType, systemBarPropertyFlag] : systemBarPropertyFlags) { if (systemBarProperties.find(systemBarType) == systemBarProperties.end()) { TLOGE(WmsLogTag::WMS_IMMS, "system bar type is invalid"); @@ -3138,14 +3135,6 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( systemBarProperties.at(systemBarType).contentColor_ : property.contentColor_; property.enableAnimation_ = systemBarPropertyFlag.enableAnimationFlag ? systemBarProperties.at(systemBarType).enableAnimation_ : property.enableAnimation_; - if (systemBarType == WindowType::WINDOW_TYPE_STATUS_BAR) { - statusProperty.enable_ = systemBarPropertyFlag.enableFlag ? - systemBarProperties.at(systemBarType).enable_ : statusProperty.enable_; - } - if (systemBarType == WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR) { - navigationIndicatorPorperty.enable_ = systemBarPropertyFlag.enableFlag ? - systemBarProperties.at(systemBarType).enable_ : statusProperty.enable_; - } if (systemBarPropertyFlag.enableFlag) { property.settingFlag_ |= SystemBarSettingFlag::ENABLE_SETTING; @@ -3161,6 +3150,9 @@ WMError WindowSceneSessionImpl::UpdateSystemBarProperties( } } } + SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); + SystemBarProperty navigationIndicatorPorperty = + GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); MobileAppInPadLayoutFullScreenChange(statusProperty.enable_, navigationIndicatorPorperty.enable_); return WMError::WM_OK; } -- Gitee From 7fbacbf9fd084df722ced0dc59a1fcd416d0e8fb Mon Sep 17 00:00:00 2001 From: wkljy Date: Mon, 15 Sep 2025 20:28:08 +0800 Subject: [PATCH 21/76] jieou Signed-off-by: wkljy --- window_scene/test/unittest/animation/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/test/unittest/animation/BUILD.gn b/window_scene/test/unittest/animation/BUILD.gn index 0402d9cbcf..3c736ac730 100644 --- a/window_scene/test/unittest/animation/BUILD.gn +++ b/window_scene/test/unittest/animation/BUILD.gn @@ -72,6 +72,7 @@ ohos_unittest("ws_scene_session_animation_test") { external_deps = [ "ability_base:session_info", "ability_runtime:app_context", + "bundle_framework:appexecfwk_core", "c_utils:utils", "googletest:gmock", "googletest:gtest", -- Gitee From f1491b583348c1853d4006ee8e33c717cd36d25f Mon Sep 17 00:00:00 2001 From: l30067243 Date: Mon, 15 Sep 2025 20:30:20 +0800 Subject: [PATCH 22/76] fix: clear process watermark by edm self Signed-off-by: l30067243 --- 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 3dffef0dd7..02427aa2fe 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -16269,7 +16269,6 @@ void SceneSessionManager::ClearWatermarkRecordWhenAppExit(const sptrGetWindowId(), session->GetWindowName().c_str(), session->GetCallingPid()); appWatermarkPidMap_.erase(session->GetCallingPid()); - processWatermarkPidMap_.erase(session->GetCallingPid()); } WMError SceneSessionManager::GetRootMainWindowId(int32_t persistentId, int32_t& hostWindowId) -- Gitee From 8ec282455f0adb2c28fbb9c712e8a0ca909a48e9 Mon Sep 17 00:00:00 2001 From: moelight Date: Mon, 15 Sep 2025 21:38:50 +0800 Subject: [PATCH 23/76] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E7=83=AD?= =?UTF-8?q?=E5=8C=BA=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: moelight --- .../session/host/include/keyboard_session.h | 4 ++- .../session/host/include/scene_session.h | 4 +-- .../session/host/src/keyboard_session.cpp | 31 ++++++++++++++++++ .../session/host/src/scene_session.cpp | 10 ------ .../test/unittest/scene_session_test4.cpp | 32 ------------------- .../keyboard_session_test4.cpp | 31 ++++++++++++++++++ wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 16 ++++++---- 8 files changed, 78 insertions(+), 51 deletions(-) diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index 53bce41596..ec58941a08 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -118,7 +118,9 @@ private: bool stateChanged_ = false; void CalculateOccupiedAreaAfterUIRefresh() override; WSRect CalculateScaledRect(WSRect sessionRect, float scaleX, float scaleY); - + WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, + WSPropertyChangeAction action) override; + sptr keyboardCallback_ = nullptr; bool isKeyboardSyncTransactionOpen_ = false; NotifyKeyboarEffectOptionChangeFunc changeKeyboardEffectOptionFunc_; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 4034a899d6..acaa323999 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -837,6 +837,8 @@ public: void NotifyKeyboardDidHideRegistered(bool registered) override; bool isSubWindowResizingOrMoving_ = false; virtual void CalculateOccupiedAreaAfterUIRefresh() {} + virtual WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, + WSPropertyChangeAction action) { return WMError::WM_OK;} /* * Window Focus @@ -1174,8 +1176,6 @@ private: WSPropertyChangeAction action); WMError HandleActionUpdateTouchHotArea(const sptr& property, WSPropertyChangeAction action); - WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, - WSPropertyChangeAction action); WMError HandleActionUpdateDecorEnable(const sptr& property, WSPropertyChangeAction action); WMError HandleActionUpdateWindowLimits(const sptr& property, diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 1f7393b0fa..3da85d8920 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -1129,4 +1129,35 @@ void KeyboardSession::CalculateOccupiedAreaAfterUIRefresh() stateChanged_ = false; } } + + WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, + WSPropertyChangeAction action) + { + if (GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + return WMError::WM_ERROR_INVALID_TYPE; + } + auto displayID = GetSessionProperty()->GetDisplayId(); + std::map screensProperties = + ScreenSessionManagerClient::GetInstance()GetAllScreensProperties(); + if (screensProperties.find(displayId) == screensProperties.end()) { + return WMError::WM_ERROR_INVALID_DISPLAY; + } + const auto& screenBounds = screensProperties[displayId].GetBounds(); + bool isLandscape = screenBounds.rect_.GetWidth() > screenBounds.rect_GetHeight(); + if (isLandscape) { + GetSessionProperty()->SetTouchHotAreas(property->GetKeyboardTouchHotAreas().landscapeKeyboardHotAreas_); + keyboardPanelSession_->GetSessionProperty()->SetTouchHotAreas( + property->GetKeyboardTouchHotAreas().landscapePanelHotAreas_); + } else { + GetSessionProperty()->SetTouchHotAreas(property->GetKeyboardTouchHotAreas().portraitKeyboardHotAreas_); + keyboardPanelSession_->GetSessionProperty()->SetTouchHotAreas( + property->GetKeyboardTouchHotAreas().protraitPanelHotAreas_); + } + GetSessionProperty()->SetKeyboardTouchHotAreas(property->GetKeyboardTouchHotAreas()); + if (specificCallback_ != nullptr && specificCallback_->onWindowInfoUpdate_ != nullptr) { + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "id=%{public}d", GetPersistentId()); + specificCallback_->onWindowInfoUpdate_(GetPersistentId(), WindowUpdateType::WINDOW_UPDATE_PROPERTY); + } + return WMError::WM_OK; + } } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0e2db2ae87..d7e61dec4e 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -6357,16 +6357,6 @@ WMError SceneSession::HandleActionUpdateTouchHotArea(const sptr& property, - WSPropertyChangeAction action) -{ - if (GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { - return WMError::WM_ERROR_INVALID_TYPE; - } - GetSessionProperty()->SetKeyboardTouchHotAreas(property->GetKeyboardTouchHotAreas()); - return WMError::WM_OK; -} - WMError SceneSession::HandleActionUpdateDecorEnable(const sptr& property, WSPropertyChangeAction action) { diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index a8803654c5..f9daacac6b 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -118,38 +118,6 @@ HWTEST_F(SceneSessionTest4, HandleActionUpdateTouchHotArea, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, ret); } -/** - * @tc.name: HandleActionUpdateKeyboardTouchHotArea01 - * @tc.desc: normal function - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest4, HandleActionUpdateKeyboardTouchHotArea01, TestSize.Level1) -{ - SessionInfo info; - sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); - sptr property = sptr::MakeSptr(); - WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO; - WMError ret = sceneSession->HandleActionUpdateKeyboardTouchHotArea(property, action); - ASSERT_EQ(WMError::WM_OK, ret); -} - -/** - * @tc.name: HandleActionUpdateKeyboardTouchHotArea02 - * @tc.desc: normal function - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest4, HandleActionUpdateKeyboardTouchHotArea02, TestSize.Level1) -{ - SessionInfo info; - sptr sceneSession = sptr::MakeSptr(info, nullptr); - sptr property = sptr::MakeSptr(); - sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO; - WMError ret = sceneSession->HandleActionUpdateKeyboardTouchHotArea(property, action); - ASSERT_EQ(WMError::WM_ERROR_INVALID_TYPE, ret); -} - /** * @tc.name: HandleActionUpdateDecorEnable * @tc.desc: normal function diff --git a/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp b/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp index b466cc02bd..a98c4e666b 100644 --- a/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp +++ b/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp @@ -468,6 +468,37 @@ HWTEST_F(KeyboardSessionTest4, CalculateScaledRect01, TestSize.Level1) result = {667, 0, 1783, 1941}; EXPECT_TRUE(scaledRect == result); } + +/** + * @tc.name: HandleActionUpdateKeyboardTouchHotArea + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(KeyboardSessionTest4, HandleActionUpdateKeyboardTouchHotArea, TestSize.Level1) +{ + std::string abilityName = "HandleActionUpdateKeyboardTouchHotArea"; + std::string bundleName = "HandleActionUpdateKeyboardTouchHotArea"; + sptr keyboardSession = GetKeyboardSession(abilityName, bundlName); + sptr property = sptr::MakeSptr(); + KeyboardTouchHotAreas keyboardTouchHotAreas; + Rect rect = {800, 800, 1200, 1200}; + keyboardTouchHotAreas.landscapeKeyboardHotAreas_.push_back(rect); + keyboardTouchHotAreas.landscapePanelHotAreas_.push_back(rect); + keyboardTouchHotAreas.portraitKeyboardHotAreas.push_back(rect); + keyboardTouchHotAreas.portraitPanelHotAreas_.push_back(rect); + SessionInfo info; + info.abilityName_ = "keyboardPanelSession"; + info.bundleName_ = "keyboardPanelSession"; + sptr keyboardPanelSession = sptr::MakeSptr(info, nullptr); + keyboardSession->BindKeyboardPanelSession(keyboardPanelSession); + keyboardSession->GetSessionPropert()->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); + WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO; + WMError ret = keyboardSession->HandleActonUpdateKeyboardTouchHotArea(property, action); + ASSERT_EQ(WMError::WM_ERROR_INVALID_TYPE, ret); + keyboardSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); + ret = keyboardSession->HandleActionUpdateKeyboardTouchHotArea(property,action); + ASSERT_EQ(WMError::WM_OK, ret); +} } // namespace } // namespace Rosen } // namespace OHOS \ 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 98ea30f9d6..c669507ffd 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -430,6 +430,7 @@ private: * Window Immersive */ void UpdateDefaultStatusBarColor(); + bool IsLandscape(); WMError MoveAndResizeKeyboard(const KeyboardLayoutParams& params); bool userLimitsSet_ = false; bool forceLimits_ = false; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 1778c8b74f..78f518c43c 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6257,7 +6257,7 @@ void WindowSceneSessionImpl::NotifyDisplayInfoChange(const sptr& in SingletonContainer::Get().NotifyDisplayInfoChange(token, displayId, density, orientation); } -WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams& params) +WMError WindowSceneSessionImpl::IsLandscape() { int32_t displayWidth = 0; int32_t displayHeight = 0; @@ -6273,15 +6273,19 @@ WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams } else { TLOGE(WmsLogTag::WMS_KEYBOARD, "display is null, name: %{public}s, id: %{public}d", property_->GetWindowName().c_str(), GetPersistentId()); - return WMError::WM_ERROR_NULLPTR; + return false; } } - bool isLandscape = displayWidth > displayHeight ? true : false; + return displayWidth > displayHeight; +} + +WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams& params) +{ + bool isLandscape = IsLandscape(); Rect newRect = isLandscape ? params.LandscapeKeyboardRect_ : params.PortraitKeyboardRect_; property_->SetRequestRect(newRect); - TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, newRect: %{public}s, isLandscape: %{public}d, " - "displayWidth: %{public}d, displayHeight: %{public}d", GetPersistentId(), newRect.ToString().c_str(), - isLandscape, displayWidth, displayHeight); + TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, newRect: %{public}s, isLandscape: %{public}d", + GetPersistentId(), newRect.ToString().c_str(), isLandscape); return WMError::WM_OK; } -- Gitee From 912106bfb748a998bcf0b180b2a859dd87238c6c Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Mon, 15 Sep 2025 21:54:19 +0800 Subject: [PATCH 24/76] =?UTF-8?q?=E4=B8=9C=E6=B9=96=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- .vscode/settings.json | 70 +++++++++++ interfaces/innerkits/wm/window.h | 39 ++++++ .../host/include/zidl/session_interface.h | 4 + wm/include/window_session_impl.h | 8 ++ wm/src/window_input_channel.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 1 + wm/src/window_session_impl.cpp | 91 ++++++++++++++ .../unittest/window_input_channel_test.cpp | 2 + .../window_scene_session_impl_test5.cpp | 113 ++++++++++++++++++ 9 files changed, 329 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..a0b1563a88 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,70 @@ +{ + "files.associations": { + "algorithm": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "condition_variable": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "ostream": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "typeinfo": "cpp", + "variant": "cpp" + } +} \ No newline at end of file diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 2d86e7a147..4fc2c6a915 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -206,6 +206,16 @@ public: virtual void AfterDetached() {} }; +/** + * @class IWindowTitleChangeListener + * + * @brief IWindowTitleChangeListener is used to observe the title appear or disappear. + */ +class IWindowTitleChangeListener : virtual public RefBase { +public: + virtual void OnTitleVisibilityChange(Rect& titleRect, bool visibility) {} +}; + /** * @class IWindowChangeListener * @@ -4614,6 +4624,35 @@ public: * @param shouldFullScreen true means full screen, false means force split. */ virtual void NotifyIsFullScreenInForceSplitMode(bool isFullScreen) {} + + /** + * @brief register a listener to listen whether the window title bar is show or hide. + * + * @param listener IWindowTitleChangeListener. + * @return WM_OK means register success, others means register failed. + */ + virtual WMError RegisterWindowTitleChangeListener(const sptr& listener) + { + return WMError::WM_OK; + } + + /** + * @brief Unregister the IWindowTitleChangeListener. + * + * @param listener IWindowTitleChangeListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + virtual WMError UnregisterWindowTitleChangeListener(const sptr& listener) + { + return WMError::WM_OK; + } + + /** + * @brief Calculate whether the pointerEvent hits the title bar. + * + * @param hitTitleBar true means hit title bar success, false means not hit title bar. + */ + virtual bool IsHitTitleBar(std::shared_ptr& pointerEvent) const { return false; } }; } } diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index c234c7a155..a044197227 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -364,6 +364,10 @@ public: { return WSError::WS_OK; } + virtual WSError UpdateTitleChangeListenerRegistered(bool isRegister) + { + return WSError::WS_OK; + } virtual void SetCallingSessionId(uint32_t callingSessionId) {}; virtual void NotifyKeyboardWillShowRegistered(bool registered) {}; virtual void NotifyKeyboardWillHideRegistered(bool registered) {}; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 3814be3c35..c6dd82f9cb 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -152,6 +152,7 @@ public: bool GetCompatibleModeInPc() const override; void HookCompatibleModeAvoidAreaNotify() override; bool IsAdaptToCompatibleImmersive() const override; + bool IsHitTitleBar(std::shared_ptr& pointerEvent) const override; WMError SetWindowDelayRaiseEnabled(bool isEnabled) override; bool IsWindowDelayRaiseEnabled() const override; WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible, @@ -431,6 +432,8 @@ public: void SetDefaultDisplayIdIfNeed(); WMError RegisterWindowRectChangeListener(const sptr& listener) override; WMError UnregisterWindowRectChangeListener(const sptr& listener) override; + WMError RegisterWindowTitleChangeListener(const sptr& listener) override; + WMError UnregisterWindowTitleChangeListener(const sptr& listener) override; WMError RegisterRectChangeInGlobalDisplayListener( const sptr& listener) override; WMError UnregisterRectChangeInGlobalDisplayListener( @@ -851,6 +854,7 @@ protected: * Window Decor */ bool grayOutMaximizeButton_ = false; + void NotifyTitleChange(bool isShow, int32_t height); private: void InitPropertyFromOption(const sptr& option); @@ -906,6 +910,8 @@ private: template EnableIfSame>> GetListeners(); template + EnableIfSame>> GetListeners(); + template EnableIfSame>> GetListeners(); template @@ -1018,6 +1024,7 @@ private: static std::recursive_mutex windowStatusDidChangeListenerMutex_; static std::mutex displayMoveListenerMutex_; static std::mutex windowRectChangeListenerMutex_; + static std::mutex windowTitleChangeListenerMutex_; static std::mutex rectChangeInGlobalDisplayListenerMutex_; static std::mutex secureLimitChangeListenerMutex_; static std::mutex switchFreeMultiWindowListenerMutex_; @@ -1056,6 +1063,7 @@ private: static std::map>> windowStatusChangeListeners_; static std::map>> windowStatusDidChangeListeners_; static std::map>> windowRectChangeListeners_; + static std::map>> windowTitleChangeListeners_; static std::map>> rectChangeInGlobalDisplayListeners_; static std::map>> secureLimitChangeListeners_; static std::map>> switchFreeMultiWindowListeners_; diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index ca9f0f4495..de827b69d2 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -147,7 +147,7 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr& return; } - if (window_->IsAnco()) { + if (window_->IsAnco() && !window_->IsHitTitleBar(pointerEvent)) { ProcAncoEvent(pointerEvent); pointerEvent->MarkProcessed(); return; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 1778c8b74f..e926df5141 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -5519,6 +5519,7 @@ WSError WindowSceneSessionImpl::UpdateTitleInTargetPos(bool isShow, int32_t heig TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null"); return WSError::WS_ERROR_INVALID_PARAM; } + NotifyTitleChange(isShow, height); uiContent->UpdateTitleInTargetPos(isShow, height); return WSError::WS_OK; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 6033bc2d31..608d0da701 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -158,6 +158,7 @@ std::map> WindowSessionIm std::map>> WindowSessionImpl::windowTitleButtonRectChangeListeners_; std::map>> WindowSessionImpl::windowRectChangeListeners_; +std::map>> WindowSessionImpl::windowTitleChangeListeners_; std::map>> WindowSessionImpl::rectChangeInGlobalDisplayListeners_; std::map>> @@ -192,6 +193,7 @@ std::recursive_mutex WindowSessionImpl::windowStatusDidChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; std::mutex WindowSessionImpl::displayMoveListenerMutex_; std::mutex WindowSessionImpl::windowRectChangeListenerMutex_; +std::mutex WindowSessionImpl::windowTitleChangeListenerMutex_; std::mutex WindowSessionImpl::rectChangeInGlobalDisplayListenerMutex_; std::mutex WindowSessionImpl::secureLimitChangeListenerMutex_; std::mutex WindowSessionImpl::subWindowCloseListenersMutex_; @@ -4048,6 +4050,41 @@ WMError WindowSessionImpl::UnRegisterWindowWillCloseListeners(const sptr +EnableIfSame>> WindowSessionImpl::GetListeners() +{ + std::vector> windowTitleChangeListeners; + for (auto& listener : windowTitleChangeListeners_[GetPersistentId()]) { + windowTitleChangeListeners.push_back(listener); + } + return windowTitleChangeListeners; +} + +WMError WindowSessionImpl::RegisterWindowTitleChangeListener(const sptr& listener) +{ + std::lock_guard lockListener(windowTitleChangeListenerMutex_); + WMError ret = RegisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); + TLOGI(WmsLogTag::WMS_DECOR, "RegisterWindowTitleChangeListener"); + if (ret == WMError::WM_OK) { + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); + hostSession->UpdateTitleChangeListenerRegistered(true); + } + return ret; +} + +WMError WindowSessionImpl::UnregisterWindowTitleChangeListener(const sptr& listener) +{ + std::lock_guard lockListener(windowTitleChangeListenerMutex_); + WMError ret = UnregisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); + TLOGI(WmsLogTag::WMS_DECOR, "UnregisterWindowTitleChangeListener"); + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); + hostSession->UpdateTitleChangeListenerRegistered(false); + return ret; +} + template EnableIfSame>> WindowSessionImpl::GetListeners() @@ -4212,6 +4249,36 @@ void WindowSessionImpl::NotifyWindowCrossAxisChange(CrossAxisState state) } } +bool WindowSessionImpl::IsHitTitleBar(std::shared_ptr& pointerEvent) const +{ + std::shared_ptr uiContent = GetUIContentSharedPtr(); + bool isPcMode = system::GetBoolParameter("persist.sceneboard.ispcmode", false); + bool isPcModeOrFreeMultiWindowMode = IsFreeMultiWindowMode() || isPcMode; + if (!isPcModeOrFreeMultiWindowMode) { + TLOGE(WmsLogTag::WMS_DECOR, "not PcMode or FreeMultiWindowMode."); + return false; + } + if (uiContent == nullptr) { + TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null, windowId: %{public}u", GetWindowId()); + return false; + } + Rect windowRect = property_->GetWindowRect(); + int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); + MMI::PointerEvent::PointerItem pointerItem; + bool isValidPointItem = pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + bool isHitTitleBarX = pointerItem.GetDisplayX() > windowRect.posX_ + && pointerItem.GetDisplayX() < windowRect.posX_ + windowRect.width_; + bool isHitTitleBarY = pointerItem.GetDisplayY() > windowRect.posY_ + && pointerItem.GetDisplayY() < windowRect.posY_ + decorHeight; + bool isHitTitleBar = isValidPointItem && isHitTitleBarX && isHitTitleBarY; + if (isHitTitleBar) { + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "hitTitleBar success"); + return true; + } + pointerEvent->MarkProcessed(); + return false; +} + bool WindowSessionImpl::IsWaterfallModeEnabled() { if (!isValidWaterfallMode_.load() && InitWaterfallMode()) { @@ -4485,6 +4552,10 @@ void WindowSessionImpl::ClearListenersById(int32_t persistentId) std::lock_guard lockListener(windowRectChangeListenerMutex_); ClearUselessListeners(windowRectChangeListeners_, persistentId); } + { + std::lock_guard lockListener(windowTitleChangeListenerMutex_); + ClearUselessListeners(windowTitleChangeListeners_, persistentId); + } { std::lock_guard lockListener(rectChangeInGlobalDisplayListenerMutex_); ClearUselessListeners(rectChangeInGlobalDisplayListeners_, persistentId); @@ -5519,6 +5590,26 @@ void WindowSessionImpl::NotifySwitchFreeMultiWindow(bool enable) } } +void WindowSessionImpl::NotifyTitleChange(bool isShow, int32_t height) +{ + std::lock_guard lockRectListener(windowTitleChangeListenerMutex_); + auto windowTitleChangeListeners = GetListeners(); + std::shared_ptr uiContent = GetUIContentSharedPtr(); + if (uiContent == nullptr) { + TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null, windowId: %{public}u", GetWindowId()); + return; + } + int32_t width = property_->GetWindowRect().width_; + int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); + Rect rect = {0, height, width, decorHeight}; + for (auto& listener : windowTitleChangeListeners) { + if (listener != nullptr) { + TLOGI(WmsLogTag::WMS_IMMS, "NotifyTitleChange, the title bar is show? %{public}d", isShow); + listener->OnTitleVisibilityChange(rect, isShow); + } + } +} + WMError WindowSessionImpl::RegisterAvoidAreaChangeListener(const sptr& listener) { auto persistentId = GetPersistentId(); diff --git a/wm/test/unittest/window_input_channel_test.cpp b/wm/test/unittest/window_input_channel_test.cpp index 15bb1da298..a440a14478 100644 --- a/wm/test/unittest/window_input_channel_test.cpp +++ b/wm/test/unittest/window_input_channel_test.cpp @@ -32,6 +32,7 @@ public: ~MockWindow() {}; MOCK_METHOD(bool, IsAnco, (), (const, override)); MOCK_METHOD(bool, OnPointDown, (int32_t eventId, int32_t posX, int32_t posY), (override)); + MOCK_METHOD(bool, IsHitTitleBar, (std::shared_ptr& pointerEvent), (const, override)); }; using WindowMocker = SingletonMocker; @@ -142,6 +143,7 @@ HWTEST_F(WindowInputChannelTest, HandlePointEvent01, TestSize.Level1) sptr inputChannel = sptr::MakeSptr(window); EXPECT_CALL(*(window), IsAnco()).Times(1).WillOnce(Return(true)); + EXPECT_CALL(*(window), IsHitTitleBar(pointerEvent)).Times(1).WillOnce(Return(true)); EXPECT_CALL(*(window), OnPointDown(_, _, _)).Times(0); inputChannel->HandlePointerEvent(pointerEvent); testing::Mock::VerifyAndClearExpectations(window); diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index c4d0128fc2..1b285e77f5 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -2447,6 +2447,119 @@ HWTEST_F(WindowSceneSessionImplTest5, CalculateNewLimitsByLimits, TestSize.Level EXPECT_EQ(customizedLimits.minWidth_, userLimits.minWidth_); EXPECT_EQ(customizedLimits.minHeight_, userLimits.minHeight_); } + +/** + * @tc.name: GetListeners + * @tc.desc: GetListeners + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, GetListeners, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("GetListeners"); + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(502); + window->windowTitleChangeListeners_[1] = std::vector>(); + + auto result = window->GetListeners(); + EXPECT_TRUE(result.empty()); + + + result = window->GetListeners(); + EXPECT_EQ(result.size(), 2); +} + +/** + * @tc.name: NotifyTitleChange + * @tc.desc: NotifyTitleChange + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, NotifyTitleChange, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("NotifyTitleChange"); + sptr window = sptr::MakeSptr(option); + + SessionInfo sessionInfo = {"NotifyTitleBundle", "NotifyTitleModule", "NotifyTitleAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session)); + bool isShow = false; + int32_t height = 0; + window->NotifyTitleChange(isShow, height); + + sptr listener = sptr::MakeSptr(); + window->RegisterWindowTitleChangeListener(listener); + window->NotifyTitleChange(isShow, height); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy()); +} + +/** + * @tc.name: IsHitTitleBar + * @tc.desc: IsHitTitleBar + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, IsHitTitleBar01, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("IsHitTitleBar01"); + sptr window = sptr::MakeSptr(option); + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + window->uiContent_ = nullptr; + bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); + + window->uiContent_ = std::make_unique(); + MMI::PointerEvent::PointerItem pointerItem; + Rect rect{ 0, 0, 200, 200 }; + window->property_->SetWindowRect(rect); + pointerItem.SetDisplayX(100); + pointerItem.SetDisplayY(-100); + pointerEvent->AddPointerItem(pointerItem); + pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, true); +} + +/** + * @tc.name: IsHitTitleBar + * @tc.desc: IsHitTitleBar + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("IsHitTitleBar02"); + sptr window = sptr::MakeSptr(option); + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + window->uiContent_ = nullptr; + bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); + + window->uiContent_ = std::make_unique(); + MMI::PointerEvent::PointerItem pointerItem; + Rect rect{ 0, 0, 1, 1 }; + window->property_->SetWindowRect(rect); + pointerItem.SetDisplayX(100); + pointerEvent->AddPointerItem(pointerItem); + pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); +} + +/** + * @tc.name: RegisterWindowTitleChangeListener + * @tc.desc: RegisterWindowTitleChangeListener + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, RegisterWindowTitleChangeListener, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("RegisterWindowTitleChangeListener"); + sptr window = sptr::MakeSptr(option); + sptr listener = nullptr; + WMError ret = window->RegisterWindowTitleChangeListener(listener); + EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 4991ab3ad5050d1111f2452d3b70a87c036a6e02 Mon Sep 17 00:00:00 2001 From: moelight Date: Mon, 15 Sep 2025 21:38:50 +0800 Subject: [PATCH 25/76] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E7=83=AD?= =?UTF-8?q?=E5=8C=BA=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: moelight --- .../session/host/include/keyboard_session.h | 4 ++- .../session/host/include/scene_session.h | 4 +-- .../session/host/src/keyboard_session.cpp | 31 ++++++++++++++++++ .../session/host/src/scene_session.cpp | 10 ------ .../test/unittest/scene_session_test4.cpp | 32 ------------------- .../keyboard_session_test4.cpp | 31 ++++++++++++++++++ wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 24 ++++++++++---- 8 files changed, 86 insertions(+), 51 deletions(-) diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index 53bce41596..ec58941a08 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -118,7 +118,9 @@ private: bool stateChanged_ = false; void CalculateOccupiedAreaAfterUIRefresh() override; WSRect CalculateScaledRect(WSRect sessionRect, float scaleX, float scaleY); - + WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, + WSPropertyChangeAction action) override; + sptr keyboardCallback_ = nullptr; bool isKeyboardSyncTransactionOpen_ = false; NotifyKeyboarEffectOptionChangeFunc changeKeyboardEffectOptionFunc_; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 4034a899d6..acaa323999 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -837,6 +837,8 @@ public: void NotifyKeyboardDidHideRegistered(bool registered) override; bool isSubWindowResizingOrMoving_ = false; virtual void CalculateOccupiedAreaAfterUIRefresh() {} + virtual WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, + WSPropertyChangeAction action) { return WMError::WM_OK;} /* * Window Focus @@ -1174,8 +1176,6 @@ private: WSPropertyChangeAction action); WMError HandleActionUpdateTouchHotArea(const sptr& property, WSPropertyChangeAction action); - WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, - WSPropertyChangeAction action); WMError HandleActionUpdateDecorEnable(const sptr& property, WSPropertyChangeAction action); WMError HandleActionUpdateWindowLimits(const sptr& property, diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 1f7393b0fa..3da85d8920 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -1129,4 +1129,35 @@ void KeyboardSession::CalculateOccupiedAreaAfterUIRefresh() stateChanged_ = false; } } + + WMError HandleActionUpdateKeyboardTouchHotArea(const sptr& property, + WSPropertyChangeAction action) + { + if (GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + return WMError::WM_ERROR_INVALID_TYPE; + } + auto displayID = GetSessionProperty()->GetDisplayId(); + std::map screensProperties = + ScreenSessionManagerClient::GetInstance()GetAllScreensProperties(); + if (screensProperties.find(displayId) == screensProperties.end()) { + return WMError::WM_ERROR_INVALID_DISPLAY; + } + const auto& screenBounds = screensProperties[displayId].GetBounds(); + bool isLandscape = screenBounds.rect_.GetWidth() > screenBounds.rect_GetHeight(); + if (isLandscape) { + GetSessionProperty()->SetTouchHotAreas(property->GetKeyboardTouchHotAreas().landscapeKeyboardHotAreas_); + keyboardPanelSession_->GetSessionProperty()->SetTouchHotAreas( + property->GetKeyboardTouchHotAreas().landscapePanelHotAreas_); + } else { + GetSessionProperty()->SetTouchHotAreas(property->GetKeyboardTouchHotAreas().portraitKeyboardHotAreas_); + keyboardPanelSession_->GetSessionProperty()->SetTouchHotAreas( + property->GetKeyboardTouchHotAreas().protraitPanelHotAreas_); + } + GetSessionProperty()->SetKeyboardTouchHotAreas(property->GetKeyboardTouchHotAreas()); + if (specificCallback_ != nullptr && specificCallback_->onWindowInfoUpdate_ != nullptr) { + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "id=%{public}d", GetPersistentId()); + specificCallback_->onWindowInfoUpdate_(GetPersistentId(), WindowUpdateType::WINDOW_UPDATE_PROPERTY); + } + return WMError::WM_OK; + } } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0e2db2ae87..d7e61dec4e 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -6357,16 +6357,6 @@ WMError SceneSession::HandleActionUpdateTouchHotArea(const sptr& property, - WSPropertyChangeAction action) -{ - if (GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { - return WMError::WM_ERROR_INVALID_TYPE; - } - GetSessionProperty()->SetKeyboardTouchHotAreas(property->GetKeyboardTouchHotAreas()); - return WMError::WM_OK; -} - WMError SceneSession::HandleActionUpdateDecorEnable(const sptr& property, WSPropertyChangeAction action) { diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index a8803654c5..f9daacac6b 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -118,38 +118,6 @@ HWTEST_F(SceneSessionTest4, HandleActionUpdateTouchHotArea, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, ret); } -/** - * @tc.name: HandleActionUpdateKeyboardTouchHotArea01 - * @tc.desc: normal function - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest4, HandleActionUpdateKeyboardTouchHotArea01, TestSize.Level1) -{ - SessionInfo info; - sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); - sptr property = sptr::MakeSptr(); - WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO; - WMError ret = sceneSession->HandleActionUpdateKeyboardTouchHotArea(property, action); - ASSERT_EQ(WMError::WM_OK, ret); -} - -/** - * @tc.name: HandleActionUpdateKeyboardTouchHotArea02 - * @tc.desc: normal function - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest4, HandleActionUpdateKeyboardTouchHotArea02, TestSize.Level1) -{ - SessionInfo info; - sptr sceneSession = sptr::MakeSptr(info, nullptr); - sptr property = sptr::MakeSptr(); - sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO; - WMError ret = sceneSession->HandleActionUpdateKeyboardTouchHotArea(property, action); - ASSERT_EQ(WMError::WM_ERROR_INVALID_TYPE, ret); -} - /** * @tc.name: HandleActionUpdateDecorEnable * @tc.desc: normal function diff --git a/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp b/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp index b466cc02bd..a98c4e666b 100644 --- a/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp +++ b/window_scene/test/unittest/window_keyboard/keyboard_session_test4.cpp @@ -468,6 +468,37 @@ HWTEST_F(KeyboardSessionTest4, CalculateScaledRect01, TestSize.Level1) result = {667, 0, 1783, 1941}; EXPECT_TRUE(scaledRect == result); } + +/** + * @tc.name: HandleActionUpdateKeyboardTouchHotArea + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(KeyboardSessionTest4, HandleActionUpdateKeyboardTouchHotArea, TestSize.Level1) +{ + std::string abilityName = "HandleActionUpdateKeyboardTouchHotArea"; + std::string bundleName = "HandleActionUpdateKeyboardTouchHotArea"; + sptr keyboardSession = GetKeyboardSession(abilityName, bundlName); + sptr property = sptr::MakeSptr(); + KeyboardTouchHotAreas keyboardTouchHotAreas; + Rect rect = {800, 800, 1200, 1200}; + keyboardTouchHotAreas.landscapeKeyboardHotAreas_.push_back(rect); + keyboardTouchHotAreas.landscapePanelHotAreas_.push_back(rect); + keyboardTouchHotAreas.portraitKeyboardHotAreas.push_back(rect); + keyboardTouchHotAreas.portraitPanelHotAreas_.push_back(rect); + SessionInfo info; + info.abilityName_ = "keyboardPanelSession"; + info.bundleName_ = "keyboardPanelSession"; + sptr keyboardPanelSession = sptr::MakeSptr(info, nullptr); + keyboardSession->BindKeyboardPanelSession(keyboardPanelSession); + keyboardSession->GetSessionPropert()->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); + WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO; + WMError ret = keyboardSession->HandleActonUpdateKeyboardTouchHotArea(property, action); + ASSERT_EQ(WMError::WM_ERROR_INVALID_TYPE, ret); + keyboardSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); + ret = keyboardSession->HandleActionUpdateKeyboardTouchHotArea(property,action); + ASSERT_EQ(WMError::WM_OK, ret); +} } // namespace } // namespace Rosen } // namespace OHOS \ 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 98ea30f9d6..c669507ffd 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -430,6 +430,7 @@ private: * Window Immersive */ void UpdateDefaultStatusBarColor(); + bool IsLandscape(); WMError MoveAndResizeKeyboard(const KeyboardLayoutParams& params); bool userLimitsSet_ = false; bool forceLimits_ = false; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 1778c8b74f..986ef53178 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -5299,10 +5299,18 @@ WMError WindowSceneSessionImpl::SetKeyboardTouchHotAreas(const KeyboardTouchHotA if (GetType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { return WMError::WM_ERROR_INVALID_TYPE; } + std::vector lastTouchHotAreas; + property_->GetTouchHotAreas(lastTouchHotAreas); KeyboardTouchHotAreas lastKeyboardTouchHotAreas = property_->GetKeyboardTouchHotAreas(); + if (IsLandscape()) { + property_->SetTouchHotAreas(hotAreas.landscapeKeyboardHotAreas_); + } else { + property_->SetTouchHotAreas(hotAreas.portraitKeyboardHotAreas_); + } property_->SetKeyboardTouchHotAreas(hotAreas); WMError result = UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_KEYBOARD_TOUCH_HOT_AREA); if (result != WMError::WM_OK) { + property_->SetTouchHotAreas(lastTouchHotAreas); property_->SetKeyboardTouchHotAreas(lastKeyboardTouchHotAreas); TLOGE(WmsLogTag::WMS_EVENT, "errCode:%{public}d", static_cast(result)); } @@ -6257,7 +6265,7 @@ void WindowSceneSessionImpl::NotifyDisplayInfoChange(const sptr& in SingletonContainer::Get().NotifyDisplayInfoChange(token, displayId, density, orientation); } -WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams& params) +WMError WindowSceneSessionImpl::IsLandscape() { int32_t displayWidth = 0; int32_t displayHeight = 0; @@ -6273,15 +6281,19 @@ WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams } else { TLOGE(WmsLogTag::WMS_KEYBOARD, "display is null, name: %{public}s, id: %{public}d", property_->GetWindowName().c_str(), GetPersistentId()); - return WMError::WM_ERROR_NULLPTR; + return false; } } - bool isLandscape = displayWidth > displayHeight ? true : false; + return displayWidth > displayHeight; +} + +WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams& params) +{ + bool isLandscape = IsLandscape(); Rect newRect = isLandscape ? params.LandscapeKeyboardRect_ : params.PortraitKeyboardRect_; property_->SetRequestRect(newRect); - TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, newRect: %{public}s, isLandscape: %{public}d, " - "displayWidth: %{public}d, displayHeight: %{public}d", GetPersistentId(), newRect.ToString().c_str(), - isLandscape, displayWidth, displayHeight); + TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, newRect: %{public}s, isLandscape: %{public}d", + GetPersistentId(), newRect.ToString().c_str(), isLandscape); return WMError::WM_OK; } -- Gitee From e41e1412c8df23973d27b2cd04aad250a67767be Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Mon, 15 Sep 2025 22:02:31 +0800 Subject: [PATCH 26/76] =?UTF-8?q?=E4=B8=9C=E6=B9=96=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> Revert commit: 东湖应用标题栏适配 This revert commit: 912106bfb748a998bcf0b180b2a859dd87238c6c --- .vscode/settings.json | 70 ----------- interfaces/innerkits/wm/window.h | 39 ------ .../host/include/zidl/session_interface.h | 4 - wm/include/window_session_impl.h | 8 -- wm/src/window_input_channel.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 1 - wm/src/window_session_impl.cpp | 91 -------------- .../unittest/window_input_channel_test.cpp | 2 - .../window_scene_session_impl_test5.cpp | 113 ------------------ 9 files changed, 1 insertion(+), 329 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index a0b1563a88..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "files.associations": { - "algorithm": "cpp", - "any": "cpp", - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "charconv": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "condition_variable": "cpp", - "csetjmp": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "regex": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "shared_mutex": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "typeinfo": "cpp", - "variant": "cpp" - } -} \ No newline at end of file diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 4fc2c6a915..2d86e7a147 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -206,16 +206,6 @@ public: virtual void AfterDetached() {} }; -/** - * @class IWindowTitleChangeListener - * - * @brief IWindowTitleChangeListener is used to observe the title appear or disappear. - */ -class IWindowTitleChangeListener : virtual public RefBase { -public: - virtual void OnTitleVisibilityChange(Rect& titleRect, bool visibility) {} -}; - /** * @class IWindowChangeListener * @@ -4624,35 +4614,6 @@ public: * @param shouldFullScreen true means full screen, false means force split. */ virtual void NotifyIsFullScreenInForceSplitMode(bool isFullScreen) {} - - /** - * @brief register a listener to listen whether the window title bar is show or hide. - * - * @param listener IWindowTitleChangeListener. - * @return WM_OK means register success, others means register failed. - */ - virtual WMError RegisterWindowTitleChangeListener(const sptr& listener) - { - return WMError::WM_OK; - } - - /** - * @brief Unregister the IWindowTitleChangeListener. - * - * @param listener IWindowTitleChangeListener. - * @return WM_OK means unregister success, others means unregister failed. - */ - virtual WMError UnregisterWindowTitleChangeListener(const sptr& listener) - { - return WMError::WM_OK; - } - - /** - * @brief Calculate whether the pointerEvent hits the title bar. - * - * @param hitTitleBar true means hit title bar success, false means not hit title bar. - */ - virtual bool IsHitTitleBar(std::shared_ptr& pointerEvent) const { return false; } }; } } diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index a044197227..c234c7a155 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -364,10 +364,6 @@ public: { return WSError::WS_OK; } - virtual WSError UpdateTitleChangeListenerRegistered(bool isRegister) - { - return WSError::WS_OK; - } virtual void SetCallingSessionId(uint32_t callingSessionId) {}; virtual void NotifyKeyboardWillShowRegistered(bool registered) {}; virtual void NotifyKeyboardWillHideRegistered(bool registered) {}; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index c6dd82f9cb..3814be3c35 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -152,7 +152,6 @@ public: bool GetCompatibleModeInPc() const override; void HookCompatibleModeAvoidAreaNotify() override; bool IsAdaptToCompatibleImmersive() const override; - bool IsHitTitleBar(std::shared_ptr& pointerEvent) const override; WMError SetWindowDelayRaiseEnabled(bool isEnabled) override; bool IsWindowDelayRaiseEnabled() const override; WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible, @@ -432,8 +431,6 @@ public: void SetDefaultDisplayIdIfNeed(); WMError RegisterWindowRectChangeListener(const sptr& listener) override; WMError UnregisterWindowRectChangeListener(const sptr& listener) override; - WMError RegisterWindowTitleChangeListener(const sptr& listener) override; - WMError UnregisterWindowTitleChangeListener(const sptr& listener) override; WMError RegisterRectChangeInGlobalDisplayListener( const sptr& listener) override; WMError UnregisterRectChangeInGlobalDisplayListener( @@ -854,7 +851,6 @@ protected: * Window Decor */ bool grayOutMaximizeButton_ = false; - void NotifyTitleChange(bool isShow, int32_t height); private: void InitPropertyFromOption(const sptr& option); @@ -910,8 +906,6 @@ private: template EnableIfSame>> GetListeners(); template - EnableIfSame>> GetListeners(); - template EnableIfSame>> GetListeners(); template @@ -1024,7 +1018,6 @@ private: static std::recursive_mutex windowStatusDidChangeListenerMutex_; static std::mutex displayMoveListenerMutex_; static std::mutex windowRectChangeListenerMutex_; - static std::mutex windowTitleChangeListenerMutex_; static std::mutex rectChangeInGlobalDisplayListenerMutex_; static std::mutex secureLimitChangeListenerMutex_; static std::mutex switchFreeMultiWindowListenerMutex_; @@ -1063,7 +1056,6 @@ private: static std::map>> windowStatusChangeListeners_; static std::map>> windowStatusDidChangeListeners_; static std::map>> windowRectChangeListeners_; - static std::map>> windowTitleChangeListeners_; static std::map>> rectChangeInGlobalDisplayListeners_; static std::map>> secureLimitChangeListeners_; static std::map>> switchFreeMultiWindowListeners_; diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index de827b69d2..ca9f0f4495 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -147,7 +147,7 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr& return; } - if (window_->IsAnco() && !window_->IsHitTitleBar(pointerEvent)) { + if (window_->IsAnco()) { ProcAncoEvent(pointerEvent); pointerEvent->MarkProcessed(); return; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index e926df5141..1778c8b74f 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -5519,7 +5519,6 @@ WSError WindowSceneSessionImpl::UpdateTitleInTargetPos(bool isShow, int32_t heig TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null"); return WSError::WS_ERROR_INVALID_PARAM; } - NotifyTitleChange(isShow, height); uiContent->UpdateTitleInTargetPos(isShow, height); return WSError::WS_OK; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 608d0da701..6033bc2d31 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -158,7 +158,6 @@ std::map> WindowSessionIm std::map>> WindowSessionImpl::windowTitleButtonRectChangeListeners_; std::map>> WindowSessionImpl::windowRectChangeListeners_; -std::map>> WindowSessionImpl::windowTitleChangeListeners_; std::map>> WindowSessionImpl::rectChangeInGlobalDisplayListeners_; std::map>> @@ -193,7 +192,6 @@ std::recursive_mutex WindowSessionImpl::windowStatusDidChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; std::mutex WindowSessionImpl::displayMoveListenerMutex_; std::mutex WindowSessionImpl::windowRectChangeListenerMutex_; -std::mutex WindowSessionImpl::windowTitleChangeListenerMutex_; std::mutex WindowSessionImpl::rectChangeInGlobalDisplayListenerMutex_; std::mutex WindowSessionImpl::secureLimitChangeListenerMutex_; std::mutex WindowSessionImpl::subWindowCloseListenersMutex_; @@ -4050,41 +4048,6 @@ WMError WindowSessionImpl::UnRegisterWindowWillCloseListeners(const sptr -EnableIfSame>> WindowSessionImpl::GetListeners() -{ - std::vector> windowTitleChangeListeners; - for (auto& listener : windowTitleChangeListeners_[GetPersistentId()]) { - windowTitleChangeListeners.push_back(listener); - } - return windowTitleChangeListeners; -} - -WMError WindowSessionImpl::RegisterWindowTitleChangeListener(const sptr& listener) -{ - std::lock_guard lockListener(windowTitleChangeListenerMutex_); - WMError ret = RegisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); - TLOGI(WmsLogTag::WMS_DECOR, "RegisterWindowTitleChangeListener"); - if (ret == WMError::WM_OK) { - auto hostSession = GetHostSession(); - CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); - hostSession->UpdateTitleChangeListenerRegistered(true); - } - return ret; -} - -WMError WindowSessionImpl::UnregisterWindowTitleChangeListener(const sptr& listener) -{ - std::lock_guard lockListener(windowTitleChangeListenerMutex_); - WMError ret = UnregisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); - TLOGI(WmsLogTag::WMS_DECOR, "UnregisterWindowTitleChangeListener"); - auto hostSession = GetHostSession(); - CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); - hostSession->UpdateTitleChangeListenerRegistered(false); - return ret; -} - template EnableIfSame>> WindowSessionImpl::GetListeners() @@ -4249,36 +4212,6 @@ void WindowSessionImpl::NotifyWindowCrossAxisChange(CrossAxisState state) } } -bool WindowSessionImpl::IsHitTitleBar(std::shared_ptr& pointerEvent) const -{ - std::shared_ptr uiContent = GetUIContentSharedPtr(); - bool isPcMode = system::GetBoolParameter("persist.sceneboard.ispcmode", false); - bool isPcModeOrFreeMultiWindowMode = IsFreeMultiWindowMode() || isPcMode; - if (!isPcModeOrFreeMultiWindowMode) { - TLOGE(WmsLogTag::WMS_DECOR, "not PcMode or FreeMultiWindowMode."); - return false; - } - if (uiContent == nullptr) { - TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null, windowId: %{public}u", GetWindowId()); - return false; - } - Rect windowRect = property_->GetWindowRect(); - int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); - MMI::PointerEvent::PointerItem pointerItem; - bool isValidPointItem = pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); - bool isHitTitleBarX = pointerItem.GetDisplayX() > windowRect.posX_ - && pointerItem.GetDisplayX() < windowRect.posX_ + windowRect.width_; - bool isHitTitleBarY = pointerItem.GetDisplayY() > windowRect.posY_ - && pointerItem.GetDisplayY() < windowRect.posY_ + decorHeight; - bool isHitTitleBar = isValidPointItem && isHitTitleBarX && isHitTitleBarY; - if (isHitTitleBar) { - TLOGI(WmsLogTag::WMS_ATTRIBUTE, "hitTitleBar success"); - return true; - } - pointerEvent->MarkProcessed(); - return false; -} - bool WindowSessionImpl::IsWaterfallModeEnabled() { if (!isValidWaterfallMode_.load() && InitWaterfallMode()) { @@ -4552,10 +4485,6 @@ void WindowSessionImpl::ClearListenersById(int32_t persistentId) std::lock_guard lockListener(windowRectChangeListenerMutex_); ClearUselessListeners(windowRectChangeListeners_, persistentId); } - { - std::lock_guard lockListener(windowTitleChangeListenerMutex_); - ClearUselessListeners(windowTitleChangeListeners_, persistentId); - } { std::lock_guard lockListener(rectChangeInGlobalDisplayListenerMutex_); ClearUselessListeners(rectChangeInGlobalDisplayListeners_, persistentId); @@ -5590,26 +5519,6 @@ void WindowSessionImpl::NotifySwitchFreeMultiWindow(bool enable) } } -void WindowSessionImpl::NotifyTitleChange(bool isShow, int32_t height) -{ - std::lock_guard lockRectListener(windowTitleChangeListenerMutex_); - auto windowTitleChangeListeners = GetListeners(); - std::shared_ptr uiContent = GetUIContentSharedPtr(); - if (uiContent == nullptr) { - TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null, windowId: %{public}u", GetWindowId()); - return; - } - int32_t width = property_->GetWindowRect().width_; - int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); - Rect rect = {0, height, width, decorHeight}; - for (auto& listener : windowTitleChangeListeners) { - if (listener != nullptr) { - TLOGI(WmsLogTag::WMS_IMMS, "NotifyTitleChange, the title bar is show? %{public}d", isShow); - listener->OnTitleVisibilityChange(rect, isShow); - } - } -} - WMError WindowSessionImpl::RegisterAvoidAreaChangeListener(const sptr& listener) { auto persistentId = GetPersistentId(); diff --git a/wm/test/unittest/window_input_channel_test.cpp b/wm/test/unittest/window_input_channel_test.cpp index a440a14478..15bb1da298 100644 --- a/wm/test/unittest/window_input_channel_test.cpp +++ b/wm/test/unittest/window_input_channel_test.cpp @@ -32,7 +32,6 @@ public: ~MockWindow() {}; MOCK_METHOD(bool, IsAnco, (), (const, override)); MOCK_METHOD(bool, OnPointDown, (int32_t eventId, int32_t posX, int32_t posY), (override)); - MOCK_METHOD(bool, IsHitTitleBar, (std::shared_ptr& pointerEvent), (const, override)); }; using WindowMocker = SingletonMocker; @@ -143,7 +142,6 @@ HWTEST_F(WindowInputChannelTest, HandlePointEvent01, TestSize.Level1) sptr inputChannel = sptr::MakeSptr(window); EXPECT_CALL(*(window), IsAnco()).Times(1).WillOnce(Return(true)); - EXPECT_CALL(*(window), IsHitTitleBar(pointerEvent)).Times(1).WillOnce(Return(true)); EXPECT_CALL(*(window), OnPointDown(_, _, _)).Times(0); inputChannel->HandlePointerEvent(pointerEvent); testing::Mock::VerifyAndClearExpectations(window); diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index 1b285e77f5..c4d0128fc2 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -2447,119 +2447,6 @@ HWTEST_F(WindowSceneSessionImplTest5, CalculateNewLimitsByLimits, TestSize.Level EXPECT_EQ(customizedLimits.minWidth_, userLimits.minWidth_); EXPECT_EQ(customizedLimits.minHeight_, userLimits.minHeight_); } - -/** - * @tc.name: GetListeners - * @tc.desc: GetListeners - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, GetListeners, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("GetListeners"); - sptr window = sptr::MakeSptr(option); - window->property_->SetPersistentId(502); - window->windowTitleChangeListeners_[1] = std::vector>(); - - auto result = window->GetListeners(); - EXPECT_TRUE(result.empty()); - - - result = window->GetListeners(); - EXPECT_EQ(result.size(), 2); -} - -/** - * @tc.name: NotifyTitleChange - * @tc.desc: NotifyTitleChange - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, NotifyTitleChange, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("NotifyTitleChange"); - sptr window = sptr::MakeSptr(option); - - SessionInfo sessionInfo = {"NotifyTitleBundle", "NotifyTitleModule", "NotifyTitleAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session)); - bool isShow = false; - int32_t height = 0; - window->NotifyTitleChange(isShow, height); - - sptr listener = sptr::MakeSptr(); - window->RegisterWindowTitleChangeListener(listener); - window->NotifyTitleChange(isShow, height); - ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy()); -} - -/** - * @tc.name: IsHitTitleBar - * @tc.desc: IsHitTitleBar - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, IsHitTitleBar01, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("IsHitTitleBar01"); - sptr window = sptr::MakeSptr(option); - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - window->uiContent_ = nullptr; - bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, false); - - window->uiContent_ = std::make_unique(); - MMI::PointerEvent::PointerItem pointerItem; - Rect rect{ 0, 0, 200, 200 }; - window->property_->SetWindowRect(rect); - pointerItem.SetDisplayX(100); - pointerItem.SetDisplayY(-100); - pointerEvent->AddPointerItem(pointerItem); - pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); - isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, true); -} - -/** - * @tc.name: IsHitTitleBar - * @tc.desc: IsHitTitleBar - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("IsHitTitleBar02"); - sptr window = sptr::MakeSptr(option); - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - window->uiContent_ = nullptr; - bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, false); - - window->uiContent_ = std::make_unique(); - MMI::PointerEvent::PointerItem pointerItem; - Rect rect{ 0, 0, 1, 1 }; - window->property_->SetWindowRect(rect); - pointerItem.SetDisplayX(100); - pointerEvent->AddPointerItem(pointerItem); - pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); - isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, false); -} - -/** - * @tc.name: RegisterWindowTitleChangeListener - * @tc.desc: RegisterWindowTitleChangeListener - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, RegisterWindowTitleChangeListener, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("RegisterWindowTitleChangeListener"); - sptr window = sptr::MakeSptr(option); - sptr listener = nullptr; - WMError ret = window->RegisterWindowTitleChangeListener(listener); - EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR); -} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From a3ce714cdf9e06c9871f5693280a63d8a7ebebd8 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Mon, 15 Sep 2025 22:21:12 +0800 Subject: [PATCH 27/76] =?UTF-8?q?=E4=B8=9C=E6=B9=96=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- interfaces/innerkits/wm/window.h | 39 ++++++ .../host/include/zidl/session_interface.h | 4 + wm/include/window_session_impl.h | 8 ++ wm/src/window_input_channel.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 1 + wm/src/window_session_impl.cpp | 91 ++++++++++++++ .../unittest/window_input_channel_test.cpp | 2 + .../window_scene_session_impl_test5.cpp | 113 ++++++++++++++++++ 8 files changed, 259 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 2d86e7a147..aaffaa6ac7 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -206,6 +206,16 @@ public: virtual void AfterDetached() {} }; +/** + * @class IWindowTitleChangeListener + * + * @brief IWindowTitleChangeListener is used to observe the title appear or disappear. + */ +class IWindowTitleChangeListener : virtual public RefBase { +public: + virtual void OnTitleVisibilityChange(Rect& titleRect, bool visibility) {} +}; + /** * @class IWindowChangeListener * @@ -4614,6 +4624,35 @@ public: * @param shouldFullScreen true means full screen, false means force split. */ virtual void NotifyIsFullScreenInForceSplitMode(bool isFullScreen) {} + + /** + * @brief register a listener to listen whether the window title bar is show or hide. + * + * @param listener IWindowTitleChangeListener. + * @return WM_OK means register success, others means register failed. + */ + virtual WMError RegisterWindowTitleChangeListener(const sptr& listener) + { + return WMError::WM_OK; + } + + /** + * @brief Unregister the IWindowTitleChangeListener. + * + * @param listener IWindowTitleChangeListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + virtual WMError UnregisterWindowTitleChangeListener(const sptr& listener) + { + return WMError::WM_OK; + } + + /** + * @brief Calculate whether the pointerEvent hits the title bar. + * + * @param hitTitleBar true means hit title bar success, false means not hit title bar. + */ + virtual bool IsHitTitleBar(std::shared_ptr& pointerEvent) const { return false; } }; } } diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index c234c7a155..a044197227 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -364,6 +364,10 @@ public: { return WSError::WS_OK; } + virtual WSError UpdateTitleChangeListenerRegistered(bool isRegister) + { + return WSError::WS_OK; + } virtual void SetCallingSessionId(uint32_t callingSessionId) {}; virtual void NotifyKeyboardWillShowRegistered(bool registered) {}; virtual void NotifyKeyboardWillHideRegistered(bool registered) {}; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 3814be3c35..a256b45e31 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -153,6 +153,7 @@ public: void HookCompatibleModeAvoidAreaNotify() override; bool IsAdaptToCompatibleImmersive() const override; WMError SetWindowDelayRaiseEnabled(bool isEnabled) override; + bool IsHitTitleBar(std::shared_ptr& pointerEvent) const override; bool IsWindowDelayRaiseEnabled() const override; WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible, bool isCloseVisible) override; @@ -431,6 +432,8 @@ public: void SetDefaultDisplayIdIfNeed(); WMError RegisterWindowRectChangeListener(const sptr& listener) override; WMError UnregisterWindowRectChangeListener(const sptr& listener) override; + WMError RegisterWindowTitleChangeListener(const sptr& listener) override; + WMError UnregisterWindowTitleChangeListener(const sptr& listener) override; WMError RegisterRectChangeInGlobalDisplayListener( const sptr& listener) override; WMError UnregisterRectChangeInGlobalDisplayListener( @@ -851,6 +854,7 @@ protected: * Window Decor */ bool grayOutMaximizeButton_ = false; + void NotifyTitleChange(bool isShow, int32_t height); private: void InitPropertyFromOption(const sptr& option); @@ -906,6 +910,8 @@ private: template EnableIfSame>> GetListeners(); template + EnableIfSame>> GetListeners(); + template EnableIfSame>> GetListeners(); template @@ -1018,6 +1024,7 @@ private: static std::recursive_mutex windowStatusDidChangeListenerMutex_; static std::mutex displayMoveListenerMutex_; static std::mutex windowRectChangeListenerMutex_; + static std::mutex windowTitleChangeListenerMutex_; static std::mutex rectChangeInGlobalDisplayListenerMutex_; static std::mutex secureLimitChangeListenerMutex_; static std::mutex switchFreeMultiWindowListenerMutex_; @@ -1056,6 +1063,7 @@ private: static std::map>> windowStatusChangeListeners_; static std::map>> windowStatusDidChangeListeners_; static std::map>> windowRectChangeListeners_; + static std::map>> windowTitleChangeListeners_; static std::map>> rectChangeInGlobalDisplayListeners_; static std::map>> secureLimitChangeListeners_; static std::map>> switchFreeMultiWindowListeners_; diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index ca9f0f4495..de827b69d2 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -147,7 +147,7 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr& return; } - if (window_->IsAnco()) { + if (window_->IsAnco() && !window_->IsHitTitleBar(pointerEvent)) { ProcAncoEvent(pointerEvent); pointerEvent->MarkProcessed(); return; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 1778c8b74f..e926df5141 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -5519,6 +5519,7 @@ WSError WindowSceneSessionImpl::UpdateTitleInTargetPos(bool isShow, int32_t heig TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null"); return WSError::WS_ERROR_INVALID_PARAM; } + NotifyTitleChange(isShow, height); uiContent->UpdateTitleInTargetPos(isShow, height); return WSError::WS_OK; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 6033bc2d31..ed48370dc8 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -158,6 +158,7 @@ std::map> WindowSessionIm std::map>> WindowSessionImpl::windowTitleButtonRectChangeListeners_; std::map>> WindowSessionImpl::windowRectChangeListeners_; +std::map>> WindowSessionImpl::windowTitleChangeListeners_; std::map>> WindowSessionImpl::rectChangeInGlobalDisplayListeners_; std::map>> @@ -192,6 +193,7 @@ std::recursive_mutex WindowSessionImpl::windowStatusDidChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; std::mutex WindowSessionImpl::displayMoveListenerMutex_; std::mutex WindowSessionImpl::windowRectChangeListenerMutex_; +std::mutex WindowSessionImpl::windowTitleChangeListenerMutex_; std::mutex WindowSessionImpl::rectChangeInGlobalDisplayListenerMutex_; std::mutex WindowSessionImpl::secureLimitChangeListenerMutex_; std::mutex WindowSessionImpl::subWindowCloseListenersMutex_; @@ -4048,6 +4050,41 @@ WMError WindowSessionImpl::UnRegisterWindowWillCloseListeners(const sptr +EnableIfSame>> WindowSessionImpl::GetListeners() +{ + std::vector> windowTitleChangeListeners; + for (auto& listener : windowTitleChangeListeners_[GetPersistentId()]) { + windowTitleChangeListeners.push_back(listener); + } + return windowTitleChangeListeners; +} + +WMError WindowSessionImpl::RegisterWindowTitleChangeListener(const sptr& listener) +{ + std::lock_guard lockListener(windowTitleChangeListenerMutex_); + WMError ret = RegisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); + TLOGI(WmsLogTag::WMS_DECOR, "RegisterWindowTitleChangeListener"); + if (ret == WMError::WM_OK) { + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); + hostSession->UpdateTitleChangeListenerRegistered(true); + } + return ret; +} + +WMError WindowSessionImpl::UnregisterWindowTitleChangeListener(const sptr& listener) +{ + std::lock_guard lockListener(windowTitleChangeListenerMutex_); + WMError ret = UnregisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); + TLOGI(WmsLogTag::WMS_DECOR, "UnregisterWindowTitleChangeListener"); + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); + hostSession->UpdateTitleChangeListenerRegistered(false); + return ret; +} + template EnableIfSame>> WindowSessionImpl::GetListeners() @@ -4212,6 +4249,36 @@ void WindowSessionImpl::NotifyWindowCrossAxisChange(CrossAxisState state) } } +bool WindowSessionImpl::IsHitTitleBar(std::shared_ptr& pointerEvent) const +{ + std::shared_ptr uiContent = GetUIContentSharedPtr(); + bool isPcMode = system::GetBoolParameter("persist.sceneboard.ispcmode", false); + bool isPcModeOrFreeMultiWindowMode = IsFreeMultiWindowMode() || isPcMode; + if (!isPcModeOrFreeMultiWindowMode) { + TLOGE(WmsLogTag::WMS_DECOR, "not PcMode or FreeMultiWindowMode."); + return false; + } + if (uiContent == nullptr) { + TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null, windowId: %{public}u", GetWindowId()); + return false; + } + Rect windowRect = property_->GetWindowRect(); + int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); + MMI::PointerEvent::PointerItem pointerItem; + bool isValidPointItem = pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + bool isHitTitleBarX = pointerItem.GetDisplayX() > windowRect.posX_ + && pointerItem.GetDisplayX() < windowRect.posX_ + windowRect.width_; + bool isHitTitleBarY = pointerItem.GetDisplayY() > windowRect.posY_ + && pointerItem.GetDisplayY() < windowRect.posY_ + decorHeight; + bool isHitTitleBar = isValidPointItem && isHitTitleBarX && isHitTitleBarY; + if (isHitTitleBar) { + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "hitTitleBar success"); + return true; + } + pointerEvent->MarkProcessed(); + return false; +} + bool WindowSessionImpl::IsWaterfallModeEnabled() { if (!isValidWaterfallMode_.load() && InitWaterfallMode()) { @@ -4485,6 +4552,10 @@ void WindowSessionImpl::ClearListenersById(int32_t persistentId) std::lock_guard lockListener(windowRectChangeListenerMutex_); ClearUselessListeners(windowRectChangeListeners_, persistentId); } + { + std::lock_guard lockListener(windowTitleChangeListenerMutex_); + ClearUselessListeners(windowTitleChangeListeners_, persistentId); + } { std::lock_guard lockListener(rectChangeInGlobalDisplayListenerMutex_); ClearUselessListeners(rectChangeInGlobalDisplayListeners_, persistentId); @@ -5519,6 +5590,26 @@ void WindowSessionImpl::NotifySwitchFreeMultiWindow(bool enable) } } +void WindowSessionImpl::NotifyTitleChange(bool isShow, int32_t height) +{ + std::lock_guard lockRectListener(windowTitleChangeListenerMutex_); + auto windowTitleChangeListeners = GetListeners(); + std::shared_ptr uiContent = GetUIContentSharedPtr(); + if (uiContent == nullptr) { + TLOGE(WmsLogTag::WMS_DECOR, "uiContent is null, windowId: %{public}u", GetWindowId()); + return; + } + int32_t width = property_->GetWindowRect().width_; + int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); + Rect rect = {0, height, width, decorHeight}; + for (auto& listener : windowTitleChangeListeners) { + if (listener != nullptr) { + TLOGI(WmsLogTag::WMS_IMMS, "NotifyTitleChange, the title bar is show? %{public}d", isShow); + listener->OnTitleVisibilityChange(rect, isShow); + } + } +} + WMError WindowSessionImpl::RegisterAvoidAreaChangeListener(const sptr& listener) { auto persistentId = GetPersistentId(); diff --git a/wm/test/unittest/window_input_channel_test.cpp b/wm/test/unittest/window_input_channel_test.cpp index 15bb1da298..a440a14478 100644 --- a/wm/test/unittest/window_input_channel_test.cpp +++ b/wm/test/unittest/window_input_channel_test.cpp @@ -32,6 +32,7 @@ public: ~MockWindow() {}; MOCK_METHOD(bool, IsAnco, (), (const, override)); MOCK_METHOD(bool, OnPointDown, (int32_t eventId, int32_t posX, int32_t posY), (override)); + MOCK_METHOD(bool, IsHitTitleBar, (std::shared_ptr& pointerEvent), (const, override)); }; using WindowMocker = SingletonMocker; @@ -142,6 +143,7 @@ HWTEST_F(WindowInputChannelTest, HandlePointEvent01, TestSize.Level1) sptr inputChannel = sptr::MakeSptr(window); EXPECT_CALL(*(window), IsAnco()).Times(1).WillOnce(Return(true)); + EXPECT_CALL(*(window), IsHitTitleBar(pointerEvent)).Times(1).WillOnce(Return(true)); EXPECT_CALL(*(window), OnPointDown(_, _, _)).Times(0); inputChannel->HandlePointerEvent(pointerEvent); testing::Mock::VerifyAndClearExpectations(window); diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index c4d0128fc2..1b285e77f5 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -2447,6 +2447,119 @@ HWTEST_F(WindowSceneSessionImplTest5, CalculateNewLimitsByLimits, TestSize.Level EXPECT_EQ(customizedLimits.minWidth_, userLimits.minWidth_); EXPECT_EQ(customizedLimits.minHeight_, userLimits.minHeight_); } + +/** + * @tc.name: GetListeners + * @tc.desc: GetListeners + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, GetListeners, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("GetListeners"); + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(502); + window->windowTitleChangeListeners_[1] = std::vector>(); + + auto result = window->GetListeners(); + EXPECT_TRUE(result.empty()); + + + result = window->GetListeners(); + EXPECT_EQ(result.size(), 2); +} + +/** + * @tc.name: NotifyTitleChange + * @tc.desc: NotifyTitleChange + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, NotifyTitleChange, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("NotifyTitleChange"); + sptr window = sptr::MakeSptr(option); + + SessionInfo sessionInfo = {"NotifyTitleBundle", "NotifyTitleModule", "NotifyTitleAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session)); + bool isShow = false; + int32_t height = 0; + window->NotifyTitleChange(isShow, height); + + sptr listener = sptr::MakeSptr(); + window->RegisterWindowTitleChangeListener(listener); + window->NotifyTitleChange(isShow, height); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy()); +} + +/** + * @tc.name: IsHitTitleBar + * @tc.desc: IsHitTitleBar + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, IsHitTitleBar01, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("IsHitTitleBar01"); + sptr window = sptr::MakeSptr(option); + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + window->uiContent_ = nullptr; + bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); + + window->uiContent_ = std::make_unique(); + MMI::PointerEvent::PointerItem pointerItem; + Rect rect{ 0, 0, 200, 200 }; + window->property_->SetWindowRect(rect); + pointerItem.SetDisplayX(100); + pointerItem.SetDisplayY(-100); + pointerEvent->AddPointerItem(pointerItem); + pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, true); +} + +/** + * @tc.name: IsHitTitleBar + * @tc.desc: IsHitTitleBar + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("IsHitTitleBar02"); + sptr window = sptr::MakeSptr(option); + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + window->uiContent_ = nullptr; + bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); + + window->uiContent_ = std::make_unique(); + MMI::PointerEvent::PointerItem pointerItem; + Rect rect{ 0, 0, 1, 1 }; + window->property_->SetWindowRect(rect); + pointerItem.SetDisplayX(100); + pointerEvent->AddPointerItem(pointerItem); + pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); +} + +/** + * @tc.name: RegisterWindowTitleChangeListener + * @tc.desc: RegisterWindowTitleChangeListener + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, RegisterWindowTitleChangeListener, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("RegisterWindowTitleChangeListener"); + sptr window = sptr::MakeSptr(option); + sptr listener = nullptr; + WMError ret = window->RegisterWindowTitleChangeListener(listener); + EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From f4673dd0a7e6bbf5a8c353548ddf98d346ce0c5d Mon Sep 17 00:00:00 2001 From: laiganlu Date: Mon, 15 Sep 2025 20:45:44 +0800 Subject: [PATCH 28/76] =?UTF-8?q?=E6=88=AA=E5=9B=BE=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=96=B9=E5=90=91=E7=BB=B4=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laiganlu --- .../session/host/include/scene_persistence.h | 10 +- window_scene/session/host/include/session.h | 1 - .../session/host/include/ws_snapshot_helper.h | 38 +------ .../session/host/src/scene_persistence.cpp | 107 +++++++----------- window_scene/session/host/src/session.cpp | 44 ++----- .../session/host/src/ws_snapshot_helper.cpp | 32 +----- .../window_pattern_snapshot_test.cpp | 66 ++++------- 7 files changed, 85 insertions(+), 213 deletions(-) diff --git a/window_scene/session/host/include/scene_persistence.h b/window_scene/session/host/include/scene_persistence.h index 880153bd9f..948ae263c7 100644 --- a/window_scene/session/host/include/scene_persistence.h +++ b/window_scene/session/host/include/scene_persistence.h @@ -66,18 +66,18 @@ public: std::string GetUpdatedIconPath() const; std::shared_ptr GetLocalSnapshotPixelMap(const float oriScale, const float newScale, SnapshotStatus key = defaultStatus, bool freeMultiWindow = false); - DisplayOrientation rotate_[SCREEN_COUNT][ORIENTATION_COUNT] = {}; + DisplayOrientation rotate_[SCREEN_COUNT] = {}; private: static std::string snapshotDirectory_; std::string bundleName_; int32_t persistentId_; SnapshotStatus capacity_; - std::string snapshotPath_[SCREEN_COUNT][ORIENTATION_COUNT]; + std::string snapshotPath_[SCREEN_COUNT]; std::string snapshotFreeMultiWindowPath_; - std::pair snapshotSize_[SCREEN_COUNT][ORIENTATION_COUNT]; + std::pair snapshotSize_[SCREEN_COUNT]; std::pair snapshotFreeMultiWindowSize_; - bool hasSnapshot_[SCREEN_COUNT][ORIENTATION_COUNT] = {}; + bool hasSnapshot_[SCREEN_COUNT] = {}; bool hasSnapshotFreeMultiWindow_ = false; static std::string updatedIconDirectory_; @@ -85,7 +85,7 @@ private: static bool isAstcEnabled_; std::atomic savingSnapshotSum_ { 0 }; - std::atomic isSavingSnapshot_[SCREEN_COUNT][ORIENTATION_COUNT] = {}; + std::atomic isSavingSnapshot_[SCREEN_COUNT] = {}; std::atomic isSavingSnapshotFreeMultiWindow_ { false }; static std::shared_ptr snapshotFfrtHelper_; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index f6006edb8e..f44dca70d5 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -738,7 +738,6 @@ public: bool IsPersistentImageFit() const; bool SupportSnapshotAllSessionStatus() const; void InitSnapshotCapacity(); - SnapshotStatus GetWindowStatus() const; SnapshotStatus GetSessionSnapshotStatus(BackgroundReason reason = BackgroundReason::DEFAULT) const; uint32_t GetWindowSnapshotOrientation() const; uint32_t GetLastOrientation() const; diff --git a/window_scene/session/host/include/ws_snapshot_helper.h b/window_scene/session/host/include/ws_snapshot_helper.h index 8846becd11..6956713012 100644 --- a/window_scene/session/host/include/ws_snapshot_helper.h +++ b/window_scene/session/host/include/ws_snapshot_helper.h @@ -37,10 +37,10 @@ constexpr uint32_t ROTATION_ANGLE = 360; constexpr uint32_t ROTATION_COUNT = 4; constexpr uint32_t SECONDARY_EXPAND_OFFSET = 1; } -using SnapshotStatus = std::pair; -constexpr SnapshotStatus defaultStatus = { SCREEN_UNKNOWN, SNAPSHOT_PORTRAIT }; -constexpr SnapshotStatus defaultCapacity = { SCREEN_EXPAND, SNAPSHOT_LANDSCAPE }; -constexpr SnapshotStatus maxCapacity = { SCREEN_COUNT, ORIENTATION_COUNT }; +using SnapshotStatus = uint32_t; +constexpr SnapshotStatus defaultStatus = SCREEN_UNKNOWN; +constexpr SnapshotStatus defaultCapacity = SCREEN_EXPAND; +constexpr SnapshotStatus maxCapacity = SCREEN_COUNT; class WSSnapshotHelper { public: @@ -50,40 +50,14 @@ public: static DisplayOrientation GetDisplayOrientation(int32_t rotation); void SetWindowScreenStatus(uint32_t screenStatus); void SetWindowScreenStatus(FoldStatus foldStatus); - void SetWindowOrientationStatus(uint32_t orientationStatus); void SetWindowOrientationStatus(Rotation rotation); - SnapshotStatus GetWindowStatus() const; uint32_t GetWindowRotation() const; - static inline uint32_t GetOrientation(int32_t rotation) - { - if (rotation == LANDSCAPE_ANGLE || rotation == LANDSCAPE_INVERTED_ANGLE) { - return SNAPSHOT_LANDSCAPE; - } - return SNAPSHOT_PORTRAIT; - } - - static inline uint32_t GetOrientation(DisplayOrientation displayOrientation) - { - if (displayOrientation == DisplayOrientation::LANDSCAPE || - displayOrientation == DisplayOrientation::LANDSCAPE_INVERTED) { - return SNAPSHOT_LANDSCAPE; - } - return SNAPSHOT_PORTRAIT; - } - - static inline uint32_t GetOrientation(Rotation rotation) - { - if (rotation == Rotation::ROTATION_0 || rotation == Rotation::ROTATION_180) { - return SNAPSHOT_PORTRAIT; - } - return SNAPSHOT_LANDSCAPE; - } private: WSSnapshotHelper() = default; ~WSSnapshotHelper() = default; - SnapshotStatus windowStatus_; - Rotation windowRotation_; + SnapshotStatus screenStatus_; + Rotation screenRotation_; mutable std::mutex statusMutex_; mutable std::mutex rotationMutex_; }; diff --git a/window_scene/session/host/src/scene_persistence.cpp b/window_scene/session/host/src/scene_persistence.cpp index 2810c00f3e..97578b040e 100644 --- a/window_scene/session/host/src/scene_persistence.cpp +++ b/window_scene/session/host/src/scene_persistence.cpp @@ -76,11 +76,8 @@ ScenePersistence::ScenePersistence(const std::string& bundleName, int32_t persis InitAstcEnabled(); auto suffix = isAstcEnabled_ ? ASTC_IMAGE_SUFFIX : IMAGE_SUFFIX; for (uint32_t screenStatus = SCREEN_UNKNOWN; screenStatus < SCREEN_COUNT; screenStatus++) { - for (uint32_t orientation = SNAPSHOT_PORTRAIT; orientation < ORIENTATION_COUNT; orientation++) { - snapshotPath_[screenStatus][orientation] = snapshotDirectory_ + bundleName + UNDERLINE_SEPARATOR + - std::to_string(persistentId) + UNDERLINE_SEPARATOR + std::to_string(screenStatus) + - std::to_string(orientation) + suffix; - } + snapshotPath_[screenStatus] = snapshotDirectory_ + bundleName + UNDERLINE_SEPARATOR + + std::to_string(persistentId) + UNDERLINE_SEPARATOR + std::to_string(screenStatus) + suffix; } snapshotFreeMultiWindowPath_ = snapshotDirectory_ + bundleName + UNDERLINE_SEPARATOR + std::to_string(persistentId) + suffix; @@ -95,10 +92,8 @@ ScenePersistence::ScenePersistence(const std::string& bundleName, int32_t persis ScenePersistence::~ScenePersistence() { TLOGI(WmsLogTag::WMS_PATTERN, "destroyed, persistentId: %{public}d", persistentId_); - for (const auto& row : snapshotPath_) { - for (auto& snapshotPath : row) { - remove(snapshotPath.c_str()); - } + for (const auto& snapshotPath : snapshotPath_) { + remove(snapshotPath.c_str()); } remove(snapshotFreeMultiWindowPath_.c_str()); } @@ -125,8 +120,8 @@ void ScenePersistence::SaveSnapshot(const std::shared_ptr& pixe { savingSnapshotSum_.fetch_add(1); SetIsSavingSnapshot(key, freeMultiWindow, true); - TLOGI(WmsLogTag::WMS_PATTERN, "isSavingSnapshot_%{public}d", isSavingSnapshot_[key.first][key.second].load()); - std::string path = freeMultiWindow ? snapshotFreeMultiWindowPath_ : snapshotPath_[key.first][key.second]; + TLOGI(WmsLogTag::WMS_PATTERN, "isSavingSnapshot:%{public}d", isSavingSnapshot_[key].load()); + std::string path = freeMultiWindow ? snapshotFreeMultiWindowPath_ : snapshotPath_[key]; auto task = [weakThis = wptr(this), pixelMap, resetSnapshotCallback, savingSnapshotSum = savingSnapshotSum_.load(), key, rotate, path, freeMultiWindow]() { auto scenePersistence = weakThis.promote(); @@ -170,7 +165,7 @@ void ScenePersistence::SaveSnapshot(const std::shared_ptr& pixe if (savingSnapshotSum == scenePersistence->savingSnapshotSum_.load()) { resetSnapshotCallback(); } - scenePersistence->rotate_[key.first][key.second] = rotate; + scenePersistence->rotate_[key] = rotate; TLOGNI(WmsLogTag::WMS_PATTERN, "Save snapshot end, packed size %{public}" PRIu64, packedSize); }; snapshotFfrtHelper_->SubmitTask(std::move(task), "SaveSnapshot" + path); @@ -181,7 +176,7 @@ bool ScenePersistence::IsSavingSnapshot(SnapshotStatus key, bool freeMultiWindow if (freeMultiWindow) { return isSavingSnapshotFreeMultiWindow_.load(); } - return isSavingSnapshot_[key.first][key.second].load(); + return isSavingSnapshot_[key].load(); } void ScenePersistence::SetIsSavingSnapshot(SnapshotStatus key, bool freeMultiWindow, bool isSavingSnapshot) @@ -189,16 +184,14 @@ void ScenePersistence::SetIsSavingSnapshot(SnapshotStatus key, bool freeMultiWin if (freeMultiWindow) { isSavingSnapshotFreeMultiWindow_.store(isSavingSnapshot); } else { - isSavingSnapshot_[key.first][key.second].store(isSavingSnapshot); + isSavingSnapshot_[key].store(isSavingSnapshot); } } void ScenePersistence::ResetSnapshotCache() { - for (auto& row : isSavingSnapshot_) { - for (auto& isSavingSnapshot : row) { - isSavingSnapshot.store(false); - } + for (auto& isSavingSnapshot : isSavingSnapshot_) { + isSavingSnapshot.store(false); } isSavingSnapshotFreeMultiWindow_.store(false); } @@ -212,9 +205,7 @@ void ScenePersistence::RenameSnapshotFromOldPersistentId(const int32_t& oldPersi return; } for (uint32_t screenStatus = SCREEN_UNKNOWN; screenStatus < SCREEN_COUNT; screenStatus++) { - for (uint32_t orientation = SNAPSHOT_PORTRAIT; orientation < ORIENTATION_COUNT; orientation++) { - scenePersistence->RenameSnapshotFromOldPersistentId(oldPersistentId, { screenStatus, orientation }); - } + scenePersistence->RenameSnapshotFromOldPersistentId(oldPersistentId, screenStatus); } auto suffix = scenePersistence->isAstcEnabled_ ? ASTC_IMAGE_SUFFIX : IMAGE_SUFFIX; std::string oldSnapshotFreeMultiWindowPath = snapshotDirectory_ + scenePersistence->bundleName_ + @@ -236,11 +227,10 @@ void ScenePersistence::RenameSnapshotFromOldPersistentId(const int32_t& oldPersi void ScenePersistence::RenameSnapshotFromOldPersistentId(const int32_t& oldPersistentId, SnapshotStatus key) { - auto& snapshotPath = snapshotPath_[key.first][key.second]; + auto& snapshotPath = snapshotPath_[key]; auto suffix = isAstcEnabled_ ? ASTC_IMAGE_SUFFIX : IMAGE_SUFFIX; std::string oldSnapshotPath = snapshotDirectory_ + bundleName_ + UNDERLINE_SEPARATOR + - std::to_string(oldPersistentId) + UNDERLINE_SEPARATOR + std::to_string(key.first) + - std::to_string(key.second) + suffix; + std::to_string(oldPersistentId) + UNDERLINE_SEPARATOR + std::to_string(key) + suffix; std::lock_guard lock(savingSnapshotMutex_); int ret = std::rename(oldSnapshotPath.c_str(), snapshotPath.c_str()); if (ret == 0) { @@ -258,51 +248,34 @@ std::string ScenePersistence::GetSnapshotFilePath(SnapshotStatus& key, bool useK return snapshotFreeMultiWindowPath_; } if (useKey || HasSnapshot(key, false)) { - return snapshotPath_[key.first][key.second]; + return snapshotPath_[key]; } if (FindClosestFormSnapshot(key)) { - return snapshotPath_[key.first][key.second]; + return snapshotPath_[key]; } TLOGW(WmsLogTag::WMS_PATTERN, "Failed"); - return snapshotPath_[SCREEN_UNKNOWN][SNAPSHOT_PORTRAIT]; + return snapshotPath_[SCREEN_UNKNOWN]; } bool ScenePersistence::FindClosestFormSnapshot(SnapshotStatus& key) { std::lock_guard lock(hasSnapshotMutex_); - for (uint32_t orientation = SNAPSHOT_PORTRAIT; orientation < capacity_.second; orientation++) { - if (hasSnapshot_[key.first][orientation]) { - key.second = orientation; - return true; - } + if (hasSnapshot_[key]) { + return true; } - bool isFolded = (key.first == SCREEN_FOLDED); + bool isFolded = (key == SCREEN_FOLDED); if (isFolded) { - for (uint32_t screenStatus = SCREEN_EXPAND; screenStatus < capacity_.first; screenStatus--) { - if (hasSnapshot_[screenStatus][key.second]) { - key.first = screenStatus; - return true; - } - } - uint32_t orientation = (key.second == SNAPSHOT_PORTRAIT) ? SNAPSHOT_LANDSCAPE : SNAPSHOT_PORTRAIT; - for (uint32_t screenStatus = SCREEN_EXPAND; screenStatus < capacity_.first; screenStatus--) { - if (hasSnapshot_[screenStatus][orientation]) { - key = { screenStatus, orientation }; + for (uint32_t screenStatus = SCREEN_EXPAND; screenStatus < capacity_; screenStatus--) { + if (hasSnapshot_[screenStatus]) { + key = screenStatus; return true; } } return false; } - for (uint32_t screenStatus = SCREEN_UNKNOWN; screenStatus < capacity_.first; screenStatus++) { - if (hasSnapshot_[screenStatus][key.second]) { - key.first = screenStatus; - return true; - } - } - uint32_t orientation = (key.second == SNAPSHOT_PORTRAIT) ? SNAPSHOT_LANDSCAPE : SNAPSHOT_PORTRAIT; - for (uint32_t screenStatus = SCREEN_UNKNOWN; screenStatus < capacity_.first; screenStatus++) { - if (hasSnapshot_[screenStatus][orientation]) { - key = { screenStatus, orientation }; + for (uint32_t screenStatus = SCREEN_UNKNOWN; screenStatus < capacity_; screenStatus++) { + if (hasSnapshot_[screenStatus]) { + key = screenStatus; return true; } } @@ -359,7 +332,7 @@ void ScenePersistence::SetSnapshotSize(SnapshotStatus key, bool freeMultiWindow, if (freeMultiWindow) { snapshotFreeMultiWindowSize_ = size; } else { - snapshotSize_[key.first][key.second] = size; + snapshotSize_[key] = size; } } @@ -369,13 +342,13 @@ std::pair ScenePersistence::GetSnapshotSize(SnapshotStatus k if (freeMultiWindow) { return snapshotFreeMultiWindowSize_; } - return snapshotSize_[key.first][key.second]; + return snapshotSize_[key]; } void ScenePersistence::SetHasSnapshot(bool hasSnapshot, SnapshotStatus key) { std::lock_guard lock(hasSnapshotMutex_); - hasSnapshot_[key.first][key.second] = hasSnapshot; + hasSnapshot_[key] = hasSnapshot; } void ScenePersistence::SetHasSnapshotFreeMultiWindow(bool hasSnapshot) @@ -387,11 +360,9 @@ void ScenePersistence::SetHasSnapshotFreeMultiWindow(bool hasSnapshot) bool ScenePersistence::HasSnapshot() const { std::lock_guard lock(hasSnapshotMutex_); - for (const auto& row : hasSnapshot_) { - for (const auto& hasSnapshot : row) { - if (hasSnapshot) { - return true; - } + for (const auto& hasSnapshot : hasSnapshot_) { + if (hasSnapshot) { + return true; } } return hasSnapshotFreeMultiWindow_; @@ -403,28 +374,26 @@ bool ScenePersistence::HasSnapshot(SnapshotStatus key, bool freeMultiWindow) con if (freeMultiWindow) { return hasSnapshotFreeMultiWindow_; } - return hasSnapshot_[key.first][key.second]; + return hasSnapshot_[key]; } void ScenePersistence::ClearSnapshot(SnapshotStatus key) { std::lock_guard lock(hasSnapshotMutex_); - for (auto& row : hasSnapshot_) { - for (auto& hasSnapshot : row) { - hasSnapshot = false; - } + for (auto& hasSnapshot : hasSnapshot_) { + hasSnapshot = false; } hasSnapshotFreeMultiWindow_ = false; - hasSnapshot_[key.first][key.second] = true; + hasSnapshot_[key] = true; } bool ScenePersistence::IsSnapshotExisted(SnapshotStatus key) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "IsSnapshotExisted"); struct stat buf; - if (stat(snapshotPath_[key.first][key.second].c_str(), &buf)) { + if (stat(snapshotPath_[key].c_str(), &buf)) { TLOGD(WmsLogTag::WMS_PATTERN, "Snapshot file %{public}s does not exist", - snapshotPath_[key.first][key.second].c_str()); + snapshotPath_[key].c_str()); return false; } if (!S_ISREG(buf.st_mode)) { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 12f5080820..3bb7693c5b 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2758,7 +2758,7 @@ void Session::SaveSnapshot(bool useFfrt, bool needPersist, std::shared_ptrscenePersistence_->SetHasSnapshot(true, key); ScenePersistentStorage::Insert("Snapshot_" + std::to_string(session->persistentId_) + - "_" + std::to_string(key.first) + std::to_string(key.second), true, - ScenePersistentStorageType::MAXIMIZE_STATE); + "_" + std::to_string(key), true, ScenePersistentStorageType::MAXIMIZE_STATE); } session->scenePersistence_->ResetSnapshotCache(); Task removeSnapshotCallback = []() {}; @@ -2851,9 +2850,7 @@ void Session::SetFreeMultiWindow() void Session::DeleteHasSnapshot() { for (uint32_t screenStatus = SCREEN_UNKNOWN; screenStatus < SCREEN_COUNT; screenStatus++) { - for (uint32_t orientation = SNAPSHOT_PORTRAIT; orientation < ORIENTATION_COUNT; orientation++) { - DeleteHasSnapshot({ screenStatus, orientation }); - } + DeleteHasSnapshot(screenStatus); } DeleteHasSnapshotFreeMultiWindow(); } @@ -2861,12 +2858,10 @@ void Session::DeleteHasSnapshot() void Session::DeleteHasSnapshot(SnapshotStatus key) { auto hasSnapshot = ScenePersistentStorage::HasKey("Snapshot_" + std::to_string(persistentId_) + - "_" + std::to_string(key.first) + std::to_string(key.second), - ScenePersistentStorageType::MAXIMIZE_STATE); + "_" + std::to_string(key), ScenePersistentStorageType::MAXIMIZE_STATE); if (hasSnapshot) { ScenePersistentStorage::Delete("Snapshot_" + std::to_string(persistentId_) + - "_" + std::to_string(key.first) + std::to_string(key.second), - ScenePersistentStorageType::MAXIMIZE_STATE); + "_" + std::to_string(key), ScenePersistentStorageType::MAXIMIZE_STATE); } } @@ -2883,8 +2878,7 @@ void Session::DeleteHasSnapshotFreeMultiWindow() bool Session::HasSnapshot(SnapshotStatus key) { auto hasSnapshot = ScenePersistentStorage::HasKey("Snapshot_" + std::to_string(persistentId_) + - "_" + std::to_string(key.first) + std::to_string(key.second), - ScenePersistentStorageType::MAXIMIZE_STATE); + "_" + std::to_string(key), ScenePersistentStorageType::MAXIMIZE_STATE); if (hasSnapshot && scenePersistence_) { scenePersistence_->SetHasSnapshot(true, key); } @@ -2905,10 +2899,8 @@ bool Session::HasSnapshotFreeMultiWindow() bool Session::HasSnapshot() { for (uint32_t screenStatus = SCREEN_UNKNOWN; screenStatus < SCREEN_COUNT; screenStatus++) { - for (uint32_t orientation = SNAPSHOT_PORTRAIT; orientation < ORIENTATION_COUNT; orientation++) { - if (HasSnapshot({ screenStatus, orientation })) { - return true; - } + if (HasSnapshot(screenStatus)) { + return true; } } return HasSnapshotFreeMultiWindow(); @@ -2936,14 +2928,6 @@ bool Session::SupportSnapshotAllSessionStatus() const return (!IsPersistentImageFit() && (capacity_ != defaultCapacity)); } -SnapshotStatus Session::GetWindowStatus() const -{ - if (!SupportSnapshotAllSessionStatus()) { - return defaultStatus; - } - return WSSnapshotHelper::GetInstance()->GetWindowStatus(); -} - SnapshotStatus Session::GetSessionSnapshotStatus(BackgroundReason reason) const { if (!SupportSnapshotAllSessionStatus()) { @@ -2958,15 +2942,7 @@ SnapshotStatus Session::GetSessionSnapshotStatus(BackgroundReason reason) const if (reason == BackgroundReason::EXPAND_TO_FOLD_SINGLE_POCKET) { snapshotScreen = SCREEN_EXPAND; } - uint32_t orientation = WSSnapshotHelper::GetOrientation(currentRotation_); - if (CORRECTION_ENABLE && snapshotScreen == 0) { - orientation ^= 1; - } - if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() && - WSSnapshotHelper::GetInstance()->GetScreenStatus() == SCREEN_FOLDED) { - orientation = 1; - } - return std::make_pair(snapshotScreen, orientation); + return snapshotScreen; } uint32_t Session::GetWindowSnapshotOrientation() const @@ -4602,7 +4578,7 @@ std::shared_ptr Session::GetSnapshotPixelMap(const float oriSca if (scenePersistence_ == nullptr) { return nullptr; } - auto key = GetWindowStatus(); + auto key = WSSnapshotHelper::GetInstance()->GetScreenStatus(); return scenePersistence_->IsSavingSnapshot(key, freeMultiWindow_.load()) ? GetSnapshot() : scenePersistence_->GetLocalSnapshotPixelMap(oriScale, newScale, key, freeMultiWindow_.load()); } diff --git a/window_scene/session/host/src/ws_snapshot_helper.cpp b/window_scene/session/host/src/ws_snapshot_helper.cpp index 9716111863..0dfa7cbdc8 100644 --- a/window_scene/session/host/src/ws_snapshot_helper.cpp +++ b/window_scene/session/host/src/ws_snapshot_helper.cpp @@ -36,7 +36,7 @@ WSSnapshotHelper* WSSnapshotHelper::GetInstance() uint32_t WSSnapshotHelper::GetScreenStatus() { std::lock_guard lock(statusMutex_); - return GetInstance()->windowStatus_.first; + return GetInstance()->screenStatus_; } // LCOV_EXCL_START @@ -64,7 +64,7 @@ DisplayOrientation WSSnapshotHelper::GetDisplayOrientation(int32_t rotation) void WSSnapshotHelper::SetWindowScreenStatus(uint32_t screenStatus) { std::lock_guard lock(statusMutex_); - GetInstance()->windowStatus_.first = screenStatus; + GetInstance()->screenStatus_ = screenStatus; } void WSSnapshotHelper::SetWindowScreenStatus(FoldStatus foldStatus) @@ -72,32 +72,10 @@ void WSSnapshotHelper::SetWindowScreenStatus(FoldStatus foldStatus) SetWindowScreenStatus(GetScreenStatus(foldStatus)); } -void WSSnapshotHelper::SetWindowOrientationStatus(uint32_t orientationStatus) -{ - std::lock_guard lock(statusMutex_); - GetInstance()->windowStatus_.second = orientationStatus; -} - void WSSnapshotHelper::SetWindowOrientationStatus(Rotation rotation) { - { - std::lock_guard lock(rotationMutex_); - GetInstance()->windowRotation_ = rotation; - } - SetWindowOrientationStatus(GetOrientation(rotation)); -} - -SnapshotStatus WSSnapshotHelper::GetWindowStatus() const -{ - SnapshotStatus key = defaultStatus; - { - std::lock_guard lock(statusMutex_); - key = GetInstance()->windowStatus_; - } - if (CORRECTION_ENABLE && key.first == 0) { - key.second ^= 1; - } - return key; + std::lock_guard lock(rotationMutex_); + GetInstance()->screenRotation_ = rotation; } uint32_t WSSnapshotHelper::GetWindowRotation() const @@ -105,7 +83,7 @@ uint32_t WSSnapshotHelper::GetWindowRotation() const uint32_t rotation = 0; { std::lock_guard lock(rotationMutex_); - rotation = static_cast(GetInstance()->windowRotation_); + rotation = static_cast(GetInstance()->screenRotation_); } if (CORRECTION_ENABLE && GetInstance()->GetScreenStatus() == 0) { return (rotation + SECONDARY_EXPAND_OFFSET) % ROTATION_COUNT; diff --git a/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp b/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp index 06346453fc..ccf29190ef 100644 --- a/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp +++ b/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp @@ -155,7 +155,7 @@ HWTEST_F(WindowPatternSnapshotTest, SaveSnapshot01, TestSize.Level1) ASSERT_NE(nullptr, scenePersistence); scenePersistence->SaveSnapshot(pixelMap, []() {}, key); - scenePersistence->snapshotPath_[key.first][key.second] = "/data/1.png"; + scenePersistence->snapshotPath_[key] = "/data/1.png"; scenePersistence->SaveSnapshot(mPixelMap, []() {}, key); uint32_t fileID = static_cast(persistentId) & 0x3fffffff; std::string test = @@ -238,7 +238,7 @@ HWTEST_F(WindowPatternSnapshotTest, GetLocalSnapshotPixelMap, TestSize.Level1) std::shared_ptr pixelMap1 = Media::PixelMap::Create(colors, colorsLength, offset, stride, opts); auto key = defaultStatus; - scenePersistence->snapshotPath_[key.first][key.second] = "/data/1.png"; + scenePersistence->snapshotPath_[key] = "/data/1.png"; scenePersistence->SaveSnapshot(pixelMap1); int maxScenePersistencePollNum = 100; for (int i = 0; i < maxScenePersistencePollNum; i++) { @@ -284,7 +284,7 @@ HWTEST_F(WindowPatternSnapshotTest, GetSnapshotFilePath, TestSize.Level1) auto key = defaultStatus; std::string path = "/data/1.png"; - scenePersistence->snapshotPath_[key.first][key.second] = path; + scenePersistence->snapshotPath_[key] = path; auto ret = scenePersistence->GetSnapshotFilePath(key, false, true); EXPECT_NE(ret, path); @@ -294,16 +294,16 @@ HWTEST_F(WindowPatternSnapshotTest, GetSnapshotFilePath, TestSize.Level1) ret = scenePersistence->GetSnapshotFilePath(key); EXPECT_EQ(ret, path); - scenePersistence->hasSnapshot_[key.first][key.second] = true; + scenePersistence->hasSnapshot_[key] = true; ret = scenePersistence->GetSnapshotFilePath(key); EXPECT_EQ(ret, path); - SnapshotStatus status = { SCREEN_UNKNOWN, SNAPSHOT_LANDSCAPE }; - ret = scenePersistence->GetSnapshotFilePath(status); + key = SCREEN_UNKNOWN; + ret = scenePersistence->GetSnapshotFilePath(key); EXPECT_EQ(ret, path); - SnapshotStatus status1 = { SCREEN_EXPAND, SNAPSHOT_LANDSCAPE }; - ret = scenePersistence->GetSnapshotFilePath(status1); + key = SCREEN_EXPAND; + ret = scenePersistence->GetSnapshotFilePath(key); EXPECT_EQ(ret, path); } @@ -409,7 +409,7 @@ HWTEST_F(WindowPatternSnapshotTest, ResetSnapshotCache, TestSize.Level1) sptr scenePersistence = sptr::MakeSptr(bundleName, persistentId); scenePersistence->ResetSnapshotCache(); auto key = defaultStatus; - ASSERT_EQ(scenePersistence->isSavingSnapshot_[key.first][key.second], false); + ASSERT_EQ(scenePersistence->isSavingSnapshot_[key], false); } /** @@ -590,7 +590,7 @@ HWTEST_F(WindowPatternSnapshotTest, SaveSnapshot02, TestSize.Level1) ASSERT_NE(session_->snapshot_, nullptr); session_->freeMultiWindow_.store(true); - session_->SaveSnapshot(false, true, pixelMap); + session_->SaveSnapshot(false, true, pixelMap, false, BackgroundReason::EXPAND_TO_FOLD_SINGLE_POCKET); ASSERT_NE(session_->snapshot_, nullptr); } @@ -606,7 +606,7 @@ HWTEST_F(WindowPatternSnapshotTest, GetSnapshotPixelMap, TestSize.Level1) ASSERT_EQ(nullptr, session_->GetSnapshotPixelMap(6.6f, 8.8f)); session_->scenePersistence_ = sptr::MakeSptr("GetSnapshotPixelMap", 2024); auto key = defaultStatus; - session_->scenePersistence_->isSavingSnapshot_[key.first][key.second].store(true); + session_->scenePersistence_->isSavingSnapshot_[key].store(true); session_->snapshot_ = nullptr; ASSERT_EQ(nullptr, session_->GetSnapshotPixelMap(6.6f, 8.8f)); } @@ -696,24 +696,6 @@ HWTEST_F(WindowPatternSnapshotTest, InitSnapshotCapacity, TestSize.Level1) EXPECT_EQ(sceneSession->scenePersistence_->capacity_, maxCapacity); } -/** - * @tc.name: GetWindowStatus - * @tc.desc: GetWindowStatus Test - * @tc.type: FUNC - */ -HWTEST_F(WindowPatternSnapshotTest, GetWindowStatus, TestSize.Level1) -{ - SessionInfo info; - sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->capacity_ = defaultCapacity; - auto ret = sceneSession->GetWindowStatus(); - EXPECT_EQ(ret, defaultStatus); - - sceneSession->capacity_ = maxCapacity; - ret = sceneSession->GetWindowStatus(); - EXPECT_NE(ret.second, 3); -} - /** * @tc.name: GetSessionSnapshotStatus * @tc.desc: GetSessionSnapshotStatus Test @@ -733,12 +715,9 @@ HWTEST_F(WindowPatternSnapshotTest, GetSessionSnapshotStatus, TestSize.Level1) sceneSession->GetSessionSnapshotStatus(); sceneSession->state_ = SessionState::STATE_ACTIVE; - ret = sceneSession->GetSessionSnapshotStatus(); - EXPECT_EQ(ret.second, 0); - BackgroundReason reason = BackgroundReason::EXPAND_TO_FOLD_SINGLE_POCKET; ret = sceneSession->GetSessionSnapshotStatus(reason); - EXPECT_EQ(ret.first, 1); + EXPECT_EQ(ret, 1); } /** @@ -859,7 +838,7 @@ HWTEST_F(WindowPatternSnapshotTest, SetIsSavingSnapshot, TestSize.Level1) EXPECT_EQ(scenePersistence->isSavingSnapshotFreeMultiWindow_, true); scenePersistence->SetIsSavingSnapshot(key, false, true); - EXPECT_EQ(scenePersistence->isSavingSnapshot_[key.first][key.second], true); + EXPECT_EQ(scenePersistence->isSavingSnapshot_[key], true); } /** @@ -889,7 +868,7 @@ HWTEST_F(WindowPatternSnapshotTest, ClearSnapshot, TestSize.Level1) ASSERT_NE(scenePersistence, nullptr); auto key = defaultStatus; scenePersistence->ClearSnapshot(key); - EXPECT_EQ(scenePersistence->hasSnapshot_[key.first][key.second], true); + EXPECT_EQ(scenePersistence->hasSnapshot_[key], true); } /** @@ -909,9 +888,8 @@ HWTEST_F(WindowPatternSnapshotTest, DeleteHasSnapshot, TestSize.Level1) auto key = defaultStatus; ScenePersistentStorage::Insert("Snapshot_" + std::to_string(session_->persistentId_) + - "_" + std::to_string(key.first) + std::to_string(key.second), true, - ScenePersistentStorageType::MAXIMIZE_STATE); - EXPECT_EQ(session_->HasSnapshot(key), true); + "_" + std::to_string(key), true, ScenePersistentStorageType::MAXIMIZE_STATE); + EXPECT_EQ(session_->HasSnapshot(), true); session_->DeleteHasSnapshot(key); session_->scenePersistence_ = nullptr; EXPECT_EQ(session_->HasSnapshot(key), false); @@ -963,22 +941,20 @@ HWTEST_F(WindowPatternSnapshotTest, FindClosestFormSnapshot, TestSize.Level1) auto ret = scenePersistence->FindClosestFormSnapshot(key); EXPECT_EQ(ret, false); - scenePersistence->hasSnapshot_[SCREEN_EXPAND][SNAPSHOT_PORTRAIT] = true; + scenePersistence->hasSnapshot_[SCREEN_EXPAND] = true; ret = scenePersistence->FindClosestFormSnapshot(key); EXPECT_EQ(ret, true); - key.first = SCREEN_FOLDED; + key = SCREEN_EXPAND; ret = scenePersistence->FindClosestFormSnapshot(key); EXPECT_EQ(ret, true); - key.first = SCREEN_FOLDED; - scenePersistence->hasSnapshot_[SCREEN_EXPAND][SNAPSHOT_PORTRAIT] = false; - scenePersistence->hasSnapshot_[SCREEN_EXPAND][SNAPSHOT_LANDSCAPE] = true; + key = SCREEN_FOLDED; ret = scenePersistence->FindClosestFormSnapshot(key); EXPECT_EQ(ret, true); - key.first = SCREEN_FOLDED; - scenePersistence->hasSnapshot_[SCREEN_EXPAND][SNAPSHOT_LANDSCAPE] = false; + key = SCREEN_FOLDED; + scenePersistence->hasSnapshot_[SCREEN_EXPAND] = false; ret = scenePersistence->FindClosestFormSnapshot(key); EXPECT_EQ(ret, false); } -- Gitee From f8a14157ac46639d34976e548b7abd669bbec692 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 10:35:43 +0800 Subject: [PATCH 29/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fsession=5Fimpl.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- wm/src/window_session_impl.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index ed48370dc8..7161e04409 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -4051,8 +4051,7 @@ WMError WindowSessionImpl::UnRegisterWindowWillCloseListeners(const sptr -EnableIfSame>> WindowSessionImpl::GetListeners() +EnableIfSame>> WindowSessionImpl::GetListeners() { std::vector> windowTitleChangeListeners; for (auto& listener : windowTitleChangeListeners_[GetPersistentId()]) { @@ -4066,11 +4065,6 @@ WMError WindowSessionImpl::RegisterWindowTitleChangeListener(const sptr lockListener(windowTitleChangeListenerMutex_); WMError ret = RegisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); TLOGI(WmsLogTag::WMS_DECOR, "RegisterWindowTitleChangeListener"); - if (ret == WMError::WM_OK) { - auto hostSession = GetHostSession(); - CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); - hostSession->UpdateTitleChangeListenerRegistered(true); - } return ret; } @@ -4079,9 +4073,6 @@ WMError WindowSessionImpl::UnregisterWindowTitleChangeListener(const sptr lockListener(windowTitleChangeListenerMutex_); WMError ret = UnregisterListener(windowTitleChangeListeners_[GetPersistentId()], listener); TLOGI(WmsLogTag::WMS_DECOR, "UnregisterWindowTitleChangeListener"); - auto hostSession = GetHostSession(); - CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); - hostSession->UpdateTitleChangeListenerRegistered(false); return ret; } @@ -4252,10 +4243,7 @@ void WindowSessionImpl::NotifyWindowCrossAxisChange(CrossAxisState state) bool WindowSessionImpl::IsHitTitleBar(std::shared_ptr& pointerEvent) const { std::shared_ptr uiContent = GetUIContentSharedPtr(); - bool isPcMode = system::GetBoolParameter("persist.sceneboard.ispcmode", false); - bool isPcModeOrFreeMultiWindowMode = IsFreeMultiWindowMode() || isPcMode; - if (!isPcModeOrFreeMultiWindowMode) { - TLOGE(WmsLogTag::WMS_DECOR, "not PcMode or FreeMultiWindowMode."); + if (!IsPcOrPadFreeMultiWindowMode()) { return false; } if (uiContent == nullptr) { @@ -4272,10 +4260,9 @@ bool WindowSessionImpl::IsHitTitleBar(std::shared_ptr& pointe && pointerItem.GetDisplayY() < windowRect.posY_ + decorHeight; bool isHitTitleBar = isValidPointItem && isHitTitleBarX && isHitTitleBarY; if (isHitTitleBar) { - TLOGI(WmsLogTag::WMS_ATTRIBUTE, "hitTitleBar success"); + TLOGI(WmsLogTag::WMS_DECOR, "hitTitleBar success"); return true; } - pointerEvent->MarkProcessed(); return false; } -- Gitee From 3e2e0a8af28e32eb8cb6d984a3935c022ca782c6 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 10:36:26 +0800 Subject: [PATCH 30/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20session=5Finterface.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- window_scene/session/host/include/zidl/session_interface.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index a044197227..c234c7a155 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -364,10 +364,6 @@ public: { return WSError::WS_OK; } - virtual WSError UpdateTitleChangeListenerRegistered(bool isRegister) - { - return WSError::WS_OK; - } virtual void SetCallingSessionId(uint32_t callingSessionId) {}; virtual void NotifyKeyboardWillShowRegistered(bool registered) {}; virtual void NotifyKeyboardWillHideRegistered(bool registered) {}; -- Gitee From a3037fb8d4e949d9fbe15b4f158503e5da148edb Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 10:38:40 +0800 Subject: [PATCH 31/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- interfaces/innerkits/wm/window.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index aaffaa6ac7..30b7d81e9b 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -214,7 +214,7 @@ public: class IWindowTitleChangeListener : virtual public RefBase { public: virtual void OnTitleVisibilityChange(Rect& titleRect, bool visibility) {} -}; +}; /** * @class IWindowChangeListener @@ -4632,7 +4632,7 @@ public: * @return WM_OK means register success, others means register failed. */ virtual WMError RegisterWindowTitleChangeListener(const sptr& listener) - { + { return WMError::WM_OK; } @@ -4643,7 +4643,7 @@ public: * @return WM_OK means unregister success, others means unregister failed. */ virtual WMError UnregisterWindowTitleChangeListener(const sptr& listener) - { + { return WMError::WM_OK; } -- Gitee From 502bc32df813a64521c29edb508f2725d5b0f6d7 Mon Sep 17 00:00:00 2001 From: hejunfei Date: Tue, 16 Sep 2025 10:39:21 +0800 Subject: [PATCH 32/76] =?UTF-8?q?ams=E6=AD=BB=E9=94=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E7=A9=BF=E5=88=BA=E9=AA=8C=E8=AF=81=E4=BB=A3=E7=A0=81=E5=8F=98?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hejunfei --- dm/include/display_manager_adapter.h | 2 +- dm/src/display_manager.cpp | 11 ++++++ dm/src/display_manager_adapter.cpp | 10 ++++++ dm/test/unittest/display_manager_test.cpp | 16 +++++++++ .../include/display_manager_interface_code.h | 1 + interfaces/innerkits/dm/display_manager.h | 7 ++++ .../include/screen_session_manager.h | 1 + .../zidl/screen_session_manager_interface.h | 4 +++ .../zidl/screen_session_manager_proxy.h | 1 + .../src/screen_session_manager.cpp | 35 +++++++++++++++++++ .../src/zidl/screen_session_manager_proxy.cpp | 24 +++++++++++++ .../src/zidl/screen_session_manager_stub.cpp | 5 +++ 12 files changed, 116 insertions(+), 1 deletion(-) diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index e6eb603017..1b0819cef6 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -121,7 +121,7 @@ public: virtual DMError GetScreenAreaOfDisplayArea(DisplayId displayId, const DMRect& displayArea, ScreenId& screenId, DMRect& screenArea); virtual bool SetVirtualScreenAsDefault(ScreenId screenId); - + virtual DisplayId GetPrimaryDisplayId(); private: static inline SingletonDelegator delegator; }; diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index 589612949a..7d583646b0 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -130,6 +130,7 @@ public: DMError ResetAllFreezeStatus(); DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector& windowIdList); sptr GetPrimaryDisplaySync(); + DisplayId GetPrimaryDisplayId(); void OnRemoteDied(); sptr GetCutoutInfoWithRotation(Rotation rotation); DMError GetScreenAreaOfDisplayArea(DisplayId displayId, const DMRect& displayArea, @@ -2516,6 +2517,16 @@ sptr DisplayManager::GetPrimaryDisplaySync() return pImpl_->GetPrimaryDisplaySync(); } +DisplayId DisplayManager::Impl::GetPrimaryDisplayId() +{ + return SingletonContainer::Get().GetPrimaryDisplayId(); +} + +DisplayId DisplayManager::GetPrimaryDisplayId() +{ + return pImpl_->GetPrimaryDisplayId(); +} + std::shared_ptr DisplayManager::GetScreenCapture(const CaptureOption& captureOption, DmErrorCode* errorCode) { diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index beb9440453..7c515ab4f7 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -1626,6 +1626,16 @@ sptr DisplayManagerAdapter::GetPrimaryDisplayInfo() return displayInfo; } +DisplayId DisplayManagerAdapter::GetPrimaryDisplayId() +{ + INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID); + DisplayId id = SCREEN_ID_INVALID; + if(screenSessionManagerServiceProxy_){ + id = screenSessionManagerServiceProxy_->GetPrimaryDisplayId(); + } + return id; +} + std::shared_ptr DisplayManagerAdapter::GetDisplaySnapshotWithOption(const CaptureOption& captureOption, DmErrorCode* errorCode) { diff --git a/dm/test/unittest/display_manager_test.cpp b/dm/test/unittest/display_manager_test.cpp index ac00f86498..0bb361cac7 100644 --- a/dm/test/unittest/display_manager_test.cpp +++ b/dm/test/unittest/display_manager_test.cpp @@ -99,6 +99,22 @@ void MyLogCallback(const LogType type, const LogLevel level, const unsigned int g_errLog = msg; } +/** +*@tc.name: GetPrimaryDisplayId +*@tc.desc: success +*@tc.type: FUNC +*/ +HWTEST_F(DisplayManagerTest,GetPrimaryDisplayId,TestSize.Level1) +{ + auto ret = DisplayManager::GetInstance().GetPrimaryDisplayId(); + auto display = DisplayManager::GetInstance().GetPrimaryDisplaySync(); + if(!display){ + GTEST_SKIP(); + }else{ + EXPECT_EQ(ret,display->GetDisplayInfo()->GetDisplayId()); + } +} + /** * @tc.name: Freeze01 * @tc.desc: success diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index 777ae50dde..af44a8ee4c 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -154,6 +154,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE, TRANS_ID_GET_DISPLAY_CAPTURE, TRANS_ID_GET_PRIMARY_DISPLAY_INFO, + TRANS_ID_GET_PRIMARY_DISPLAY_ID, TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION, TRANS_ID_GET_DISPLAY_HDR_SNAPSHOT_WITH_OPTION, TRANS_ID_SET_CAMERA_STATUS, diff --git a/interfaces/innerkits/dm/display_manager.h b/interfaces/innerkits/dm/display_manager.h index 91f2d37a68..c22012583c 100644 --- a/interfaces/innerkits/dm/display_manager.h +++ b/interfaces/innerkits/dm/display_manager.h @@ -851,6 +851,13 @@ public: */ sptr GetPrimaryDisplaySync(); + /** + *@brief Get primary display id, + * + *@return primary display id, + */ + DisplayId GetPrimaryDisplayId(); + /** * @brief Get screen capture of the target display. * 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 019c62c544..5e4a1451e8 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -458,6 +458,7 @@ public: DmErrorCode* errorCode = nullptr) override; void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override; sptr GetPrimaryDisplayInfo() override; + DisplayId GetPrimaryDisplayId() override; std::shared_ptr GetDisplaySnapshotWithOption(const CaptureOption& captureOption, DmErrorCode* errorCode) override; std::vector> GetDisplayHDRSnapshotWithOption(const CaptureOption& captureOption, 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 03e5b713db..ce1ec86aa6 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 @@ -346,6 +346,10 @@ public: { return nullptr; } + virtual DisplayId GetPrimaryDisplayId() + { + return SCREEN_ID_INVALID; + } virtual std::shared_ptr GetDisplaySnapshotWithOption(const CaptureOption& captureOption, DmErrorCode* errorCode = nullptr) { 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 39008fe3d4..8bb6ab1351 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 @@ -230,6 +230,7 @@ public: std::vector> GetDisplayHDRSnapshotWithOption(const CaptureOption& captureOption, DmErrorCode& errorCode) override; sptr GetPrimaryDisplayInfo() override; + DisplayId GetPrimaryDisplayId() override; ScreenCombination GetScreenCombination(ScreenId screenId) override; DMError SetScreenSkipProtectedWindow(const std::vector& screenIds, bool isEnable) override; bool GetIsRealScreen(ScreenId screenId) 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 e24289a376..9137bcf07d 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -10893,6 +10893,41 @@ sptr ScreenSessionManager::GetPrimaryDisplayInfo() } } +DisplayId ScreenSessionManager::GetPrimaryDisplayId() +{ + if(!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()){ + TLOGE(WmsLogTag::DMS, "permission denied! calling: %{public}s, pid: %{public}d", + SysCapUtil::GetClientName().c_str(),IPCSkeleton::GetCallingPid()); + return SCREEN_ID_INVALID; + } + sptr screenSession = nullptr; + { + std::lock_guard lock(screenSessionMapMutex_); + for(auto sessionIt : screenSessionMap_){ + sptr session = sessionIt.second; + if(session == nullptr){ + TLOGE(WmsLogTag::DMS, "screenSession is nullptr!"); + continue; + } + if(!session->GetIsExtend()){ + TLOGD(WmsLogTag::DMS, "find primary %{public}" PRIu64,session->screenId_); + screenSession = session; + break; + } + } + } + if(screenSession == nullptr){ + TOLOW(WmsLogTag::DMS, "get extend screen faild use default!"); + screenSession = GetScreenSession(GetDefaultScreenId()); + } + if(screenSession && screenSession->IsScreenAvailable()){ + return screenSession->GetDisplayId(); + }else{ + TLOGE(WmsLogTag::DMS, "failed"); + return SCREEN_ID_INVALID; + } +} + void ScreenSessionManager::OnSuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus) { TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 ", superFoldStatus: %{public}d", screenId, 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 47976b7e64..bbf78e8e2c 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 @@ -4291,6 +4291,30 @@ sptr ScreenSessionManagerProxy::GetPrimaryDisplayInfo() return info; } +DisplayId ScreenSessionManagerProxy::GetPrimaryDisplayId() +{ + sptr remote = Remote(); + if(remote == nullptr){ + TLOGW(WmsLogTag::DMS, "remote is nullptr"); + return SCREEN_ID_INVALID; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + if(!data.WriteInterfaceToken(GetDescriptor())){ + TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); + return SCREEN_ID_INVALID; + } + if(remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID), +data,reply,option) != ERR_NONE){ + TLOGE(WmsLogTag::DMS, "SendRequest failed"); + return SCREEN_ID_INVALID; + } + + DisplayId id = static_cast(reply.ReadUint64()); + return id; +} + std::shared_ptr ScreenSessionManagerProxy::GetDisplaySnapshotWithOption( const CaptureOption& captureOption, DmErrorCode* errorCode) { 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 eb7f52487a..bfa05168ec 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 @@ -1206,6 +1206,11 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& reply.WriteParcelable(info); break; } + case DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID;{ + auto info = GetPrimaryDisplayId(); + reply.WriteUint64(info); + break; + } case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION: { ProcGetDisplaySnapshotWithOption(data, reply); break; -- Gitee From f07dc6fe9bb9c43090dd6266153a1593f862d0b5 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 10:40:35 +0800 Subject: [PATCH 33/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fscene=5Fsession=5Fimpl=5Ftest5.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- wm/test/unittest/window_scene_session_impl_test5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index 1b285e77f5..ab75d23248 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -2550,7 +2550,7 @@ HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) * @tc.name: RegisterWindowTitleChangeListener * @tc.desc: RegisterWindowTitleChangeListener * @tc.type: FUNC - */ + */ HWTEST_F(WindowSessionImplTest5, RegisterWindowTitleChangeListener, TestSize.Level1) { sptr option = sptr::MakeSptr(); -- Gitee From e9f9b488c9dff2bf6f1cecfcee58b9c234a5a85a Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 10:42:05 +0800 Subject: [PATCH 34/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fsession=5Fimpl.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- 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 7161e04409..d53fa28b00 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -4254,9 +4254,9 @@ bool WindowSessionImpl::IsHitTitleBar(std::shared_ptr& pointe int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); MMI::PointerEvent::PointerItem pointerItem; bool isValidPointItem = pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); - bool isHitTitleBarX = pointerItem.GetDisplayX() > windowRect.posX_ + bool isHitTitleBarX = pointerItem.GetDisplayX() > windowRect.posX_ && pointerItem.GetDisplayX() < windowRect.posX_ + windowRect.width_; - bool isHitTitleBarY = pointerItem.GetDisplayY() > windowRect.posY_ + bool isHitTitleBarY = pointerItem.GetDisplayY() > windowRect.posY_ && pointerItem.GetDisplayY() < windowRect.posY_ + decorHeight; bool isHitTitleBar = isValidPointItem && isHitTitleBarX && isHitTitleBarY; if (isHitTitleBar) { -- Gitee From fddef6ce704a52815aa9a984be39d0778abb4f30 Mon Sep 17 00:00:00 2001 From: licong113 <290041126@qq.com> Date: Tue, 16 Sep 2025 10:46:05 +0800 Subject: [PATCH 35/76] =?UTF-8?q?18:9=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=8D=E6=94=AF=E6=8C=81=E7=BC=A9=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: licong113 <290041126@qq.com> --- window_scene/session/host/src/scene_session.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0e2db2ae87..e7e0b82a81 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3908,6 +3908,7 @@ void SceneSession::OnMoveDragCallback(SizeChangeReason reason) "SceneSession::OnMoveDragCallback id:%d [%d, %d, %d, %d] reason:%u", GetPersistentId(), rect.posX_, rect.posY_, rect.width_, rect.height_, reason); if (reason == SizeChangeReason::DRAG || reason == SizeChangeReason::DRAG_END) { + UpdateWinRectForSystemBar(rect); } HandleSubSessionCrossNode(reason); -- Gitee From dff4fa1038dde31cc4510f0fa35c3434c9b49ee1 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 10:53:27 +0800 Subject: [PATCH 36/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fsession=5Fimpl.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- wm/src/window_session_impl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index d53fa28b00..5df2355ba0 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -5587,8 +5587,10 @@ void WindowSessionImpl::NotifyTitleChange(bool isShow, int32_t height) return; } int32_t width = property_->GetWindowRect().width_; + int32_t posX = property_->GetWindowRect().posX_; + int32_t posY = property_->GetWindowRect().posY_; int32_t decorHeight = uiContent->GetContainerModalTitleHeight(); - Rect rect = {0, height, width, decorHeight}; + Rect rect = {posX, posY, posX + width, posY + decorHeight}; for (auto& listener : windowTitleChangeListeners) { if (listener != nullptr) { TLOGI(WmsLogTag::WMS_IMMS, "NotifyTitleChange, the title bar is show? %{public}d", isShow); -- Gitee From 97eba2bec8f154b64c724c1573f9fa6d36655c81 Mon Sep 17 00:00:00 2001 From: licong113 <290041126@qq.com> Date: Tue, 16 Sep 2025 11:30:30 +0800 Subject: [PATCH 37/76] =?UTF-8?q?18:9=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=8D=E6=94=AF=E6=8C=81=E7=BC=A9=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: licong113 <290041126@qq.com> --- .../session/host/src/scene_session.cpp | 5 +- .../test/unittest/scene_session_test5.cpp | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index e7e0b82a81..b251d2d6c8 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3908,8 +3908,9 @@ void SceneSession::OnMoveDragCallback(SizeChangeReason reason) "SceneSession::OnMoveDragCallback id:%d [%d, %d, %d, %d] reason:%u", GetPersistentId(), rect.posX_, rect.posY_, rect.width_, rect.height_, reason); if (reason == SizeChangeReason::DRAG || reason == SizeChangeReason::DRAG_END) { - - UpdateWinRectForSystemBar(rect); + if (!property->IsAdaptToDragScale()) { + UpdateWinRectForSystemBar(rect); + } } HandleSubSessionCrossNode(reason); moveDragController_->SetTargetRect(rect); diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index a0f5170743..b5a242b6e5 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -671,6 +671,60 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback02, Function | SmallTest | Level2) session->OnMoveDragCallback(reason); } +/** + * @tc.name: OnMoveDragCallback03 + * @tc.desc: OnMoveDragCallback for DragResizeInCompatibleMode + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, OnMoveDragCallback03, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "DragResizeInCompatibleMode"; + info.bundleName_ = "DragResizeInCompatibleMode"; + info.isSystem_ = false; + sptr = sptr::MakeSptr(info, nullptr); + EXPECT_NE(nullptr, session); + session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); + EXPECT_NE(nullptr, session->moveDragController_); + SizeChangeReason reason = { SizeChangeReason::DRAG }; + WSRect windowRect = { 1, 10, 3, 4 }; + WSRect systemBarRect = { 1, 2, 10, 11 }; + sptr compatibleModeProperty = sptr::MakeSptr(); + EXPECT_NE(compatibleModeProperty, nullptr); + session->isVisible_ = true; + sptr specificCallback = + sptr::MakeSptr(); + specificCallback->onGetSceneSessionVectorByTypeAndDisplayId_ = nullptr; + session->specificCallback_ = specificCallback; + GetSceneSessionVectorByTypeAndDisplayIdCallback func = + [session](WindowType type, uint64_t displayId)->std::vector> + { + std::vector> vSession; + vSession.push_back(session); + return vSession; + }; + specificCallback->onGetSceneSessionVectorByTypeAndDisplayId_ = func; + compatibleModeProperty->SetIsAdaptToDragScale(true); + session->property_->SetCompatibleModeProperty(compatibleModeProperty); + session->moveDragController_->SetTargetRect(windowRect); + session->GetLayoutController()->SetSessionRect(systemBarRect); + session->OnMoveDragCallback(reason); + WSRect newRect = session->moveDragController_->GetTargetRect( + MoveDragController::TargetRectCoordinate::RELATED_TO_START_DISPLAY); + ASSERT_EQ(4, windowRect.height_); + ASSERT_EQ(10, windowRect.posY_); + + compatibleModeProperty->SetIsAdaptToDragScale(false); + session->property_->SetCompatibleModeProperty(compatibleModeProperty); + session->moveDragController_->SetTargetRect(windowRect); + session->GetLayoutController()->SetSessionRect(systemBarRect); + session->OnMoveDragCallback(reason); + newRect = session->moveDragController_->GetTargetRect( + MoveDragController::TargetRectCoordinate::RELATED_TO_START_DISPLAY); + ASSERT_NE(4, newRect.height_); + ASSERT_NE(10, newRect.posY_); +} + /** * @tc.name: DragResizeWhenEndFilter * @tc.desc: DragResizeWhenEndFilter function01 -- Gitee From 49b9d32499a6b4f1736ccc968d08165262083dd1 Mon Sep 17 00:00:00 2001 From: licong113 <290041126@qq.com> Date: Tue, 16 Sep 2025 11:47:30 +0800 Subject: [PATCH 38/76] =?UTF-8?q?18:9=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=8D=E6=94=AF=E6=8C=81=E7=BC=A9=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: licong113 <290041126@qq.com> --- window_scene/test/unittest/scene_session_test5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index b5a242b6e5..8899279f24 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -682,7 +682,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback03, TestSize.Level1) info.abilityName_ = "DragResizeInCompatibleMode"; info.bundleName_ = "DragResizeInCompatibleMode"; info.isSystem_ = false; - sptr = sptr::MakeSptr(info, nullptr); + sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(nullptr, session); session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); EXPECT_NE(nullptr, session->moveDragController_); -- Gitee From 8a48d25da9acda9159ae08e89854f012f926380e Mon Sep 17 00:00:00 2001 From: licong113 <290041126@qq.com> Date: Tue, 16 Sep 2025 12:27:08 +0800 Subject: [PATCH 39/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20scene=5Fsession=5Ftest5.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: licong113 <290041126@qq.com> --- window_scene/test/unittest/scene_session_test5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 8899279f24..0976af61c0 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -682,7 +682,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback03, TestSize.Level1) info.abilityName_ = "DragResizeInCompatibleMode"; info.bundleName_ = "DragResizeInCompatibleMode"; info.isSystem_ = false; - sptr session = sptr::MakeSptr(info, nullptr); + sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(nullptr, session); session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); EXPECT_NE(nullptr, session->moveDragController_); -- Gitee From a1867ed550458e0b316a2fde2b5309f415ca4e50 Mon Sep 17 00:00:00 2001 From: hejunfei1991 Date: Tue, 16 Sep 2025 13:58:26 +0800 Subject: [PATCH 40/76] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E5=BC=80=E6=9C=BA=E7=8A=B6=E6=80=81=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=20Signed-off-by:=20hejunfei1991=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/screen_session_manager.h | 2 + .../secondary_display_fold_policy.cpp | 4 +- .../src/screen_session_manager.cpp | 16 ++++-- .../session/screen/include/screen_session.h | 3 +- .../session/screen/src/screen_session.cpp | 19 ++++++- .../screen_session_manager_test2.cpp | 14 +++++ .../test/dms_unittest/screen_session_test.cpp | 51 +++++++++++++++++++ 7 files changed, 101 insertions(+), 8 deletions(-) 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 019c62c544..a11edce6b1 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -500,6 +500,8 @@ public: Rotation GetConfigCorrectionByDisplayMode(FoldDisplayMode displayMode); Rotation RemoveRotationCorrection(Rotation rotation); void NotifySwitchUserAnimationFinish() override; + bool GetFirstSCBConnect(); + void SetFirstSCBConnect(bool firstSCBConnect); // mirror screen bool HandleResolutionEffectChange(); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp index d1b555fec9..0be20eb57d 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp @@ -543,8 +543,8 @@ void SecondaryDisplayFoldPolicy::SendPropertyChangeResult(sptr sc break; } } - - screenSession->UpdatePropertyByFoldControl(screenProperty_, displayMode); + bool firstSCBConnect = ScreenSessionManager::GetInstance().GetFirstSCBConnect(); + screenSession->UpdatePropertyByFoldControl(screenProperty_, displayMode, firstSCBConnect); auto oldScreenProperty = screenSession->GetScreenProperty(); if (displayMode == FoldDisplayMode::MAIN) { screenSession->SetRotationAndScreenRotationOnly(Rotation::ROTATION_0); 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 e24289a376..6c839e6d82 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -259,7 +259,7 @@ ScreenSessionManager::ScreenSessionManager() if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { InitSecondaryDisplayPhysicalParams(); } - firstSCBConnect_ = true; + SetFirstSCBConnect(true); WatchParameter(BOOTEVENT_BOOT_COMPLETED.c_str(), BootFinishedCallback, this); } @@ -4804,6 +4804,7 @@ void ScreenSessionManager::UpdateScreenDirectionInfo(ScreenId screenId, const Sc void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType, bool isSwitchUser) { + SetFirstSCBConnect(false); std::ostringstream oss; std::string changeType = TransferPropertyChangeTypeToString(screenPropertyChangeType); oss << "screenId: " << screenId << " rotation: " << rotation << " width: " << bounds.rect_.width_ \ @@ -9288,7 +9289,7 @@ void ScreenSessionManager::SetClientInner(int32_t newUserId, const sptr lock(screenSessionMapMutex_); DisplayId targetDisplay = GetUserDisplayId(newUserId); - bool isSuperFoldDeviceBootUp = FoldScreenStateInternel::IsSuperFoldDisplayDevice() && firstSCBConnect_; + bool isSuperFoldDeviceBootUp = FoldScreenStateInternel::IsSuperFoldDisplayDevice() && GetFirstSCBConnect(); for (auto iter : screenSessionMap_) { if (!iter.second) { TLOGI(WmsLogTag::DMS, "not notify screen: %{public}" PRIu64 " to user: %{public}d", iter.first, newUserId); @@ -9354,7 +9355,6 @@ void ScreenSessionManager::HandleScreenRotationAndBoundsWhenSetClient(sptrSetDisplayBoundary(RectF(0, boundaryOffset, phyWidth, phyHeight), 0); } } - firstSCBConnect_ = false; } void ScreenSessionManager::SetPhysicalRotationClientInner(ScreenId screenId, int rotation) @@ -12133,4 +12133,14 @@ void ScreenSessionManager::SetDuringCallState(bool value) bool ret = ScreenSettingHelper::SetSettingDuringCallState("during_call_state", value); TLOGI(WmsLogTag::DMS, "set during call state to %{public}d, ret:%{public}d", value, ret); } + +bool ScreenSessionManager::GetFirstSCBConnect() +{ + return firstSCBConnect_; +} + +void ScreenSessionManager::SetFirstSCBConnect(bool firstSCBConnect) +{ + firstSCBConnect_ = firstSCBConnect; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index a9f0d7fac7..708e7a74f1 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -205,7 +205,7 @@ public: void UpdateRotationOrientation(int rotation, FoldDisplayMode foldDisplayMode, const RRect& bounds); void UpdatePropertyByFakeInUse(bool isFakeInUse); ScreenProperty UpdatePropertyByFoldControl(const ScreenProperty& updatedProperty, - FoldDisplayMode foldDisplayMode = FoldDisplayMode::UNKNOWN); + FoldDisplayMode foldDisplayMode = FoldDisplayMode::UNKNOWN, bool firstSCBConnect = false); void UpdateDisplayState(DisplayState displayState); void UpdateRefreshRate(uint32_t refreshRate); uint32_t GetRefreshRate(); @@ -448,6 +448,7 @@ private: mutable std::shared_mutex modesMutex_; void RemoveRotationCorrection(Rotation& rotation, FoldDisplayMode foldDisplayMode); + void AddRotationCorrection(Rotation& rotation, FoldDisplayMode displayMode); std::unordered_map rotationCorrectionMap_; std::shared_mutex rotationCorrectionMutex_; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 92016dd2e5..7c41d7d9d3 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -684,14 +684,18 @@ void ScreenSession::UpdatePropertyByActiveMode() } ScreenProperty ScreenSession::UpdatePropertyByFoldControl(const ScreenProperty& updatedProperty, - FoldDisplayMode foldDisplayMode) + FoldDisplayMode foldDisplayMode, bool firstSCBConnect) { property_.SetDpiPhyBounds(updatedProperty.GetPhyWidth(), updatedProperty.GetPhyHeight()); property_.SetPhyBounds(updatedProperty.GetPhyBounds()); property_.SetBounds(updatedProperty.GetBounds()); if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + Rotation screenRotation = property_.GetScreenRotation(); + if (firstSCBConnect) { + AddRotationCorrection(screenRotation, foldDisplayMode); + } DisplayOrientation deviceOrientation = - CalcDeviceOrientation(property_.GetScreenRotation(), foldDisplayMode); + CalcDeviceOrientation(screenRotation, foldDisplayMode); property_.SetDisplayOrientation(deviceOrientation); property_.SetDeviceOrientation(deviceOrientation); property_.SetScreenAreaOffsetY(updatedProperty.GetScreenAreaOffsetY()); @@ -2723,6 +2727,17 @@ Rotation ScreenSession::GetRotationCorrection(FoldDisplayMode displayMode) } return static_cast(rotationOffset); } + +void ScreenSession::AddRotationCorrection(Rotation& rotation, FoldDisplayMode displayMode) +{ + if (static_cast(rotation) >= SECONDARY_ROTATION_MOD) { + return; + } + uint32_t rotationOffset = static_cast(GetRotationCorrection(displayMode)); + uint32_t rotationValue = (static_cast(rotation) + rotationOffset) % SECONDARY_ROTATION_MOD; + rotation = static_cast(rotationValue); + TLOGI(WmsLogTag::DMS, "rotation:%{public}u, rotationOffset:%{public}u", rotation, rotationOffset); +} void ScreenSession::RemoveRotationCorrection(Rotation& rotation, FoldDisplayMode displayMode) { diff --git a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp index 95a99e608e..560a35aad1 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -2160,6 +2160,20 @@ HWTEST_F(ScreenSessionManagerTest, HandleFoldDeviceScreenConnect, TestSize.Level g_errLog.clear(); } +/** + * @tc.name: FirstSCBConnect + * @tc.desc: FirstSCBConnect + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, FirstSCBConnect, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->SetFirstSCBConnect(true); + EXPECT_TRUE(ssm_->GetFirstSCBConnect()); + ssm_->SetFirstSCBConnect(false); + EXPECT_FALSE(ssm_->GetFirstSCBConnect()); +} + /** * @tc.name: HandleResolutionEffectChange * @tc.desc: HandleResolutionEffectChange diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index ef30eaf21b..8bba475c49 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -4599,6 +4599,57 @@ HWTEST_F(ScreenSessionTest, GetScreenSnapshotWithAllWindows02, TestSize.Level2) EXPECT_EQ(pixelMap, nullptr); } +/** + * @tc.name: UpdatePropertyByFoldControl + * @tc.desc: UpdatePropertyByFoldControl Test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, UpdatePropertyByFoldControl, TestSize.Level2) +{ + if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + GTEST_SKIP() << "Skip test when device is not secondaryDisplayFoldDevice."; + } + ScreenId screenId = 100; + ScreenProperty screenProperty; + sptr screenSession = sptr::MakeSptr(screenId, screenProperty, screenId); + ScreenProperty newProperty; + screenSession->GetScreenProperty().UpdateScreenRotation(Rotation::ROTATION_0); + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + screenSession->SetRotationCorrectionMap(rotationCorrectionMap); + screenSession->UpdatePropertyByFoldControl(newProperty, FoldDisplayMode::MAIN, true); + screenProperty = screenSession->GetScreenProperty(); + EXPECT_EQ(screenProperty.GetDisplayOrientation(), DisplayOrientation::LANDSCAPE_INVERTED); + screenSession->UpdatePropertyByFoldControl(newProperty, FoldDisplayMode::MAIN, false); + screenProperty = screenSession->GetScreenProperty(); + EXPECT_EQ(screenProperty.GetDisplayOrientation(), DisplayOrientation::PORTRAIT); +} + +/** + * @tc.name: AddRotationCorrection + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, AddRotationCorrection, TestSize.Level1) +{ + sptr session = sptr::MakeSptr(); + ASSERT_NE(session, nullptr); + Rotation rotation = Rotation::ROTATION_0; + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + session->SetRotationCorrectionMap(rotationCorrectionMap); + session->AddRotationCorrection(rotation, FoldDisplayMode::MAIN); + EXPECT_EQ(rotation, Rotation::ROTATION_270); + + rotation = Rotation::ROTATION_0; + session->AddRotationCorrection(rotation, FoldDisplayMode::FULL); + EXPECT_EQ(rotation, Rotation::ROTATION_0); + + rotation = static_cast(100); + session->AddRotationCorrection(rotation, FoldDisplayMode::FULL); + EXPECT_EQ(static_cast(rotation), 100); +} + /** * @tc.name: TestPropertyChangeAllCases * @tc.desc: Verify PropertyChange behavior for multiple scenarios -- Gitee From 0933ee21593da2f2ee259a5cf00e44611a4c0239 Mon Sep 17 00:00:00 2001 From: licong113 <290041126@qq.com> Date: Tue, 16 Sep 2025 14:17:15 +0800 Subject: [PATCH 41/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20scene=5Fsession=5Ftest5.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: licong113 <290041126@qq.com> --- window_scene/test/unittest/scene_session_test5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 0976af61c0..f3e59b41e8 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -682,7 +682,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback03, TestSize.Level1) info.abilityName_ = "DragResizeInCompatibleMode"; info.bundleName_ = "DragResizeInCompatibleMode"; info.isSystem_ = false; - sptr session = sptr::MakeSptr(info, nullptr); + sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(nullptr, session); session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); EXPECT_NE(nullptr, session->moveDragController_); -- Gitee From 763a6c16680ec29f4b5668f27521991f81616b47 Mon Sep 17 00:00:00 2001 From: hejunfei Date: Tue, 16 Sep 2025 14:28:48 +0800 Subject: [PATCH 42/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=9C=AA=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hejunfei --- dm/include/display_manager_adapter.h | 1 + dm/src/display_manager_adapter.cpp | 2 +- dm/test/unittest/display_manager_test.cpp | 16 ++++++++-------- interfaces/innerkits/dm/display_manager.h | 8 ++++---- .../src/screen_session_manager.cpp | 18 +++++++++--------- .../src/zidl/screen_session_manager_proxy.cpp | 11 +++++------ .../src/zidl/screen_session_manager_stub.cpp | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index 1b0819cef6..948faaea54 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -122,6 +122,7 @@ public: ScreenId& screenId, DMRect& screenArea); virtual bool SetVirtualScreenAsDefault(ScreenId screenId); virtual DisplayId GetPrimaryDisplayId(); + private: static inline SingletonDelegator delegator; }; diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 7c515ab4f7..f5c6226c97 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -1630,7 +1630,7 @@ DisplayId DisplayManagerAdapter::GetPrimaryDisplayId() { INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID); DisplayId id = SCREEN_ID_INVALID; - if(screenSessionManagerServiceProxy_){ + if (screenSessionManagerServiceProxy_) { id = screenSessionManagerServiceProxy_->GetPrimaryDisplayId(); } return id; diff --git a/dm/test/unittest/display_manager_test.cpp b/dm/test/unittest/display_manager_test.cpp index 0bb361cac7..b721853f0a 100644 --- a/dm/test/unittest/display_manager_test.cpp +++ b/dm/test/unittest/display_manager_test.cpp @@ -100,18 +100,18 @@ void MyLogCallback(const LogType type, const LogLevel level, const unsigned int } /** -*@tc.name: GetPrimaryDisplayId -*@tc.desc: success -*@tc.type: FUNC -*/ -HWTEST_F(DisplayManagerTest,GetPrimaryDisplayId,TestSize.Level1) + * @tc.name: GetPrimaryDisplayId + * @tc.desc: success + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerTest, GetPrimaryDisplayId, TestSize.Level1) { auto ret = DisplayManager::GetInstance().GetPrimaryDisplayId(); auto display = DisplayManager::GetInstance().GetPrimaryDisplaySync(); - if(!display){ + if (!display) { GTEST_SKIP(); - }else{ - EXPECT_EQ(ret,display->GetDisplayInfo()->GetDisplayId()); + } else { + EXPECT_EQ(ret, display->GetDisplayInfo()->GetDisplayId()); } } diff --git a/interfaces/innerkits/dm/display_manager.h b/interfaces/innerkits/dm/display_manager.h index c22012583c..3b281021b9 100644 --- a/interfaces/innerkits/dm/display_manager.h +++ b/interfaces/innerkits/dm/display_manager.h @@ -852,10 +852,10 @@ public: sptr GetPrimaryDisplaySync(); /** - *@brief Get primary display id, - * - *@return primary display id, - */ + * @brief Get primary display id, + * + * @return primary display id, + */ DisplayId GetPrimaryDisplayId(); /** 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 9137bcf07d..a458207715 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -10895,34 +10895,34 @@ sptr ScreenSessionManager::GetPrimaryDisplayInfo() DisplayId ScreenSessionManager::GetPrimaryDisplayId() { - if(!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()){ + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::DMS, "permission denied! calling: %{public}s, pid: %{public}d", - SysCapUtil::GetClientName().c_str(),IPCSkeleton::GetCallingPid()); + SysCapUtil::GetClientName().c_str(),IPCSkeleton::GetCallingPid()); return SCREEN_ID_INVALID; } sptr screenSession = nullptr; { std::lock_guard lock(screenSessionMapMutex_); - for(auto sessionIt : screenSessionMap_){ + for (auto sessionIt : screenSessionMap_) { sptr session = sessionIt.second; - if(session == nullptr){ + if (session == nullptr) { TLOGE(WmsLogTag::DMS, "screenSession is nullptr!"); continue; } - if(!session->GetIsExtend()){ - TLOGD(WmsLogTag::DMS, "find primary %{public}" PRIu64,session->screenId_); + if (!session->GetIsExtend()) { + TLOGD(WmsLogTag::DMS, "find primary %{public}" PRIu64, session->screenId_); screenSession = session; break; } } } - if(screenSession == nullptr){ + if (screenSession == nullptr) { TOLOW(WmsLogTag::DMS, "get extend screen faild use default!"); screenSession = GetScreenSession(GetDefaultScreenId()); } - if(screenSession && screenSession->IsScreenAvailable()){ + if (screenSession && screenSession->IsScreenAvailable()) { return screenSession->GetDisplayId(); - }else{ + } else { TLOGE(WmsLogTag::DMS, "failed"); return SCREEN_ID_INVALID; } 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 bbf78e8e2c..5ba3ce2e99 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 @@ -4294,21 +4294,20 @@ sptr ScreenSessionManagerProxy::GetPrimaryDisplayInfo() DisplayId ScreenSessionManagerProxy::GetPrimaryDisplayId() { sptr remote = Remote(); - if(remote == nullptr){ + if (remote == nullptr) { TLOGW(WmsLogTag::DMS, "remote is nullptr"); return SCREEN_ID_INVALID; } MessageParcel data; MessageParcel reply; MessageOption option; - if(!data.WriteInterfaceToken(GetDescriptor())){ + if (!data.WriteInterfaceToken(GetDescriptor())) { TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); return SCREEN_ID_INVALID; } - if(remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID), -data,reply,option) != ERR_NONE){ - TLOGE(WmsLogTag::DMS, "SendRequest failed"); - return SCREEN_ID_INVALID; + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID), data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::DMS, "SendRequest failed"); + return SCREEN_ID_INVALID; } DisplayId id = static_cast(reply.ReadUint64()); 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 bfa05168ec..c24b227aaa 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 @@ -1206,7 +1206,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& reply.WriteParcelable(info); break; } - case DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID;{ + case DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID; { auto info = GetPrimaryDisplayId(); reply.WriteUint64(info); break; -- Gitee From 7575496333c544ae766b69b07fa0e9e945144579 Mon Sep 17 00:00:00 2001 From: chengz12138 Date: Tue, 16 Sep 2025 15:00:01 +0800 Subject: [PATCH 43/76] compatible mode adapter setfullscreen and setlayoutfullscreen Signed-off-by: chengz12138 --- wm/src/window_scene_session_impl.cpp | 8 ++ .../window_scene_session_impl_test2.cpp | 86 +++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 68b7eb677e..9124ce4064 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2947,6 +2947,10 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode not supported"); return WMError::WM_ERROR_INVALID_WINDOW; } + if (property_->IsFullScreenDisabled()) { + TLOGE(WmsLogTag::WMS_IMMS, "compatible mode disable fullscreen"); + return WMError::WM_OK; + } CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); auto event = SessionEvent::EVENT_MAXIMIZE; if (isFullScreenWaterfallMode_.load()) { @@ -3270,6 +3274,10 @@ WMError WindowSceneSessionImpl::SetFullScreen(bool status) TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window not supported"); return WMError::WM_ERROR_INVALID_WINDOW; } + if (property_->IsFullScreenDisabled()) { + TLOGE(WmsLogTag::WMS_IMMS, "compatible mode disable fullscreen"); + return WMError::WM_OK; + } auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); hostSession->OnSessionEvent(SessionEvent::EVENT_MAXIMIZE); diff --git a/wm/test/unittest/window_scene_session_impl_test2.cpp b/wm/test/unittest/window_scene_session_impl_test2.cpp index ba8ccc482a..fb0c58e4d9 100644 --- a/wm/test/unittest/window_scene_session_impl_test2.cpp +++ b/wm/test/unittest/window_scene_session_impl_test2.cpp @@ -2514,6 +2514,92 @@ HWTEST_F(WindowSceneSessionImplTest2, IsWindowRectAutoSave002, TestSize.Level1) ret = windowSceneSessionImpl->IsWindowRectAutoSave(enabled); EXPECT_EQ(WMError::WM_ERROR_INVALID_CALLING, ret); } + +/** + * @tc.name: SetLayoutFullScreen01 + * @tc.desc: SetLayoutFullScreen test + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest2, SetLayoutFullScreen01, TestSize.Level0) +{ + sptr option = sptr::MakeSptr(); + sptr window = sptr::MakeSptr(option); + window->property_->SetWindowName("SetLayoutFullScreen01"); + window->property_->SetWindowType(WindowType::BELOW_APP_SYSTEM_WINDOW_BASE); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false)); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false)); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false)); + window->property_->SetPersistentId(1); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + window->hostSession_ = session; + WMError res = window->SetLayoutFullScreen(false); + ASSERT_EQ(WMError::WM_OK, res); + ASSERT_EQ(false, window->IsLayoutFullScreen()); + ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true)); + ASSERT_EQ(true, window->IsLayoutFullScreen()); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + sptr compatibleModeProperty = sptr::MakeSptr(); + ASSERT_NE(compatibleModeProperty, nullptr); + compatibleModeProperty->SetDisableFullScreen(false); + window->property_->SetCompatibleModeProperty(compatibleModeProperty); + window->SetLayoutFullScreen(true); + compatibleModeProperty->SetDisableFullScreen(true); + window->property_->SetCompatibleModeProperty(compatibleModeProperty); + ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true)); + window->property_->SetWindowModeSupportType(0); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false)); +} + +/** + * @tc.name: SetFullScreen + * @tc.desc: SetFullScreen test + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest2, SetFullScreen, TestSize.Level0) +{ + sptr option = sptr::MakeSptr(); + sptr window = sptr::MakeSptr(option); + window->property_->SetWindowName("SetLayoutFullScreen01"); + window->property_->SetWindowType(WindowType::BELOW_APP_SYSTEM_WINDOW_BASE); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false)); + + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->property_->SetWindowModeSupportType(0); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false)); + + window->property_->SetWindowModeSupportType(1); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false)); + + window->property_->SetPersistentId(1); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false)); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + window->state_ = WindowState::STATE_SHOWN; + window->hostSession_ = session; + ASSERT_EQ(WMError::WM_OK, window->SetFullScreen(false)); + ASSERT_EQ(false, window->IsLayoutFullScreen()); + ASSERT_EQ(WMError::WM_OK, window->SetFullScreen(true)); + ASSERT_EQ(true, window->IsLayoutFullScreen()); + + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + sptr compatibleModeProperty = sptr::MakeSptr(); + ASSERT_NE(compatibleModeProperty, nullptr); + compatibleModeProperty->SetDisableFullScreen(false); + window->property_->SetCompatibleModeProperty(compatibleModeProperty); + window->SetFullScreen(true); + compatibleModeProperty->SetDisableFullScreen(true); + window->property_->SetCompatibleModeProperty(compatibleModeProperty); + ASSERT_EQ(WMError::WM_OK, window->SetFullScreen(true)); +} } } // namespace } // namespace Rosen -- Gitee From 56f085d95f0041f5cbfdde32add4e0acf2da704b Mon Sep 17 00:00:00 2001 From: hejunfei Date: Tue, 16 Sep 2025 15:28:21 +0800 Subject: [PATCH 44/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hejunfei --- interfaces/innerkits/dm/display_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/dm/display_manager.h b/interfaces/innerkits/dm/display_manager.h index 3b281021b9..b6c46cfbaa 100644 --- a/interfaces/innerkits/dm/display_manager.h +++ b/interfaces/innerkits/dm/display_manager.h @@ -852,9 +852,9 @@ public: sptr GetPrimaryDisplaySync(); /** - * @brief Get primary display id, + * @brief Get primary display id. * - * @return primary display id, + * @return primary display id. */ DisplayId GetPrimaryDisplayId(); -- Gitee From 14529ea3a4cf1dc5c95e5ff45984e2a3f5d8d380 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 16:41:28 +0800 Subject: [PATCH 45/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- interfaces/innerkits/wm/window.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 30b7d81e9b..88aaf22779 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -4625,7 +4625,7 @@ public: */ virtual void NotifyIsFullScreenInForceSplitMode(bool isFullScreen) {} - /** + /** * @brief register a listener to listen whether the window title bar is show or hide. * * @param listener IWindowTitleChangeListener. -- Gitee From 6427aab4137974ac16f6f5310725d55af43277ad Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Tue, 16 Sep 2025 16:42:55 +0800 Subject: [PATCH 46/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fsession=5Fimpl.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- 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 5df2355ba0..669930bdc9 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -4255,9 +4255,9 @@ bool WindowSessionImpl::IsHitTitleBar(std::shared_ptr& pointe MMI::PointerEvent::PointerItem pointerItem; bool isValidPointItem = pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); bool isHitTitleBarX = pointerItem.GetDisplayX() > windowRect.posX_ - && pointerItem.GetDisplayX() < windowRect.posX_ + windowRect.width_; + && pointerItem.GetDisplayX() < windowRect.posX_ + windowRect.width_; bool isHitTitleBarY = pointerItem.GetDisplayY() > windowRect.posY_ - && pointerItem.GetDisplayY() < windowRect.posY_ + decorHeight; + && pointerItem.GetDisplayY() < windowRect.posY_ + decorHeight; bool isHitTitleBar = isValidPointItem && isHitTitleBarX && isHitTitleBarY; if (isHitTitleBar) { TLOGI(WmsLogTag::WMS_DECOR, "hitTitleBar success"); -- Gitee From 35e25d04c5733642717aea30133ce9acd936dce2 Mon Sep 17 00:00:00 2001 From: hejunfei Date: Tue, 16 Sep 2025 16:52:52 +0800 Subject: [PATCH 47/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hejunfei --- dmserver/include/display_manager_interface_code.h | 2 +- .../screen_session_manager/src/screen_session_manager.cpp | 2 +- .../src/zidl/screen_session_manager_proxy.cpp | 3 ++- .../src/zidl/screen_session_manager_stub.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index af44a8ee4c..ddc0a0d441 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -154,7 +154,6 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE, TRANS_ID_GET_DISPLAY_CAPTURE, TRANS_ID_GET_PRIMARY_DISPLAY_INFO, - TRANS_ID_GET_PRIMARY_DISPLAY_ID, TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION, TRANS_ID_GET_DISPLAY_HDR_SNAPSHOT_WITH_OPTION, TRANS_ID_SET_CAMERA_STATUS, @@ -184,6 +183,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_NOTIFY_SCREEN_CONNECT_COMPLETION, TRANS_ID_NOTIFY_SWITCH_USER_ANIMATION_FINISH, TRANS_ID_NOTIFY_IS_FULL_SCREEN_IN_FORCE_SPLIT, + TRANS_ID_GET_PRIMARY_DISPLAY_ID, }; } #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H 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 a458207715..aa89f56572 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -10917,7 +10917,7 @@ DisplayId ScreenSessionManager::GetPrimaryDisplayId() } } if (screenSession == nullptr) { - TOLOW(WmsLogTag::DMS, "get extend screen faild use default!"); + TOLOW(WmsLogTag::DMS, "get extend screen failed use default!"); screenSession = GetScreenSession(GetDefaultScreenId()); } if (screenSession && screenSession->IsScreenAvailable()) { 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 5ba3ce2e99..17175b6f0d 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 @@ -4305,7 +4305,8 @@ DisplayId ScreenSessionManagerProxy::GetPrimaryDisplayId() TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); return SCREEN_ID_INVALID; } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID), data, reply, option) != ERR_NONE) { + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID), + data, reply, option) != ERR_NONE) { TLOGE(WmsLogTag::DMS, "SendRequest failed"); return SCREEN_ID_INVALID; } 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 c24b227aaa..50737138de 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 @@ -1206,7 +1206,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& reply.WriteParcelable(info); break; } - case DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID; { + case DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_ID: { auto info = GetPrimaryDisplayId(); reply.WriteUint64(info); break; -- Gitee From 8e3dacab7c1c95bd18b9a3c38229df0c96ea79b5 Mon Sep 17 00:00:00 2001 From: hejunfei Date: Tue, 16 Sep 2025 17:41:47 +0800 Subject: [PATCH 48/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hejunfei --- .../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 aa89f56572..206b93aaa2 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -10917,7 +10917,7 @@ DisplayId ScreenSessionManager::GetPrimaryDisplayId() } } if (screenSession == nullptr) { - TOLOW(WmsLogTag::DMS, "get extend screen failed use default!"); + TLOGW(WmsLogTag::DMS, "get extend screen failed use default!"); screenSession = GetScreenSession(GetDefaultScreenId()); } if (screenSession && screenSession->IsScreenAvailable()) { -- Gitee From a056663922e1b89e00e9f998b836d13efbf6eed1 Mon Sep 17 00:00:00 2001 From: chengz12138 Date: Tue, 16 Sep 2025 20:22:05 +0800 Subject: [PATCH 49/76] compatible mode adapter setfullscreen and setlayoutfullscreen Signed-off-by: chengz12138 --- wm/src/window_scene_session_impl.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 9124ce4064..75b4e86d5a 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2921,7 +2921,6 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) TLOGI(WmsLogTag::WMS_IMMS, "system window not supported"); return WMError::WM_OK; } - if (IsPcOrPadFreeMultiWindowMode() && property_->IsAdaptToImmersive()) { SetLayoutFullScreenByApiVersion(status); // compatibleMode app may set statusBarColor before ignoreSafeArea @@ -2932,14 +2931,12 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) } return WMError::WM_OK; } - bool preStatus = property_->IsLayoutFullScreen(); property_->SetIsLayoutFullScreen(status); auto hostSession = GetHostSession(); if (hostSession != nullptr) { hostSession->OnLayoutFullScreenChange(status); } - if (WindowHelper::IsMainWindow(GetType()) && !windowSystemConfig_.IsPhoneWindow() && !windowSystemConfig_.IsPadWindow()) { if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), @@ -2962,7 +2959,6 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) hostSession->OnSessionEvent(event); SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); } - WMError ret = SetLayoutFullScreenByApiVersion(status); if (ret != WMError::WM_OK) { property_->SetIsLayoutFullScreen(preStatus); -- Gitee From c0fbbc90c9b4c03650832a60e5eb453a3d4080b2 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 16 Sep 2025 21:57:51 +0800 Subject: [PATCH 50/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- window_scene/session/host/src/session_coordinate_helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/session_coordinate_helper.cpp b/window_scene/session/host/src/session_coordinate_helper.cpp index 9e27992b38..cc2b14a3b1 100644 --- a/window_scene/session/host/src/session_coordinate_helper.cpp +++ b/window_scene/session/host/src/session_coordinate_helper.cpp @@ -25,7 +25,7 @@ WSRect SessionCoordinateHelper::RelativeToGlobalDisplayRect(ScreenId screenId, c { auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(screenId); if (!screenSession) { - TLOGW(WmsLogTag::WMS_LAYOUT, + TLOGD(WmsLogTag::WMS_LAYOUT, "Screen not found, screenId: %{public}" PRIu64 ", relativeRect: %{public}s", screenId, relativeRect.ToString().c_str()); return relativeRect; -- Gitee From 89a1fd3c441913347e626fbd61e5b0da23193213 Mon Sep 17 00:00:00 2001 From: 18 Date: Tue, 16 Sep 2025 23:00:38 +0800 Subject: [PATCH 51/76] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E6=96=B0Rsuic?= =?UTF-8?q?ontext=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session/host/include/session.h | 1 + window_scene/session/host/src/session.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index f6006edb8e..384d048ebf 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -263,6 +263,7 @@ public: int32_t GetCurrentRotation() const; void SetSurfaceNode(const std::shared_ptr& surfaceNode); std::shared_ptr GetSurfaceNode() const; + std::shared_ptr GetSurfaceNode(bool isUpdateContextBeforeGet); std::optional GetSurfaceNodeId() const; void SetLeashWinSurfaceNode(std::shared_ptr leashWinSurfaceNode); std::shared_ptr GetLeashWinSurfaceNode() const; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 12f5080820..cc73cb496b 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -195,6 +195,20 @@ std::shared_ptr Session::GetSurfaceNode() const return surfaceNode_; } +std::shared_ptr GetSurfaceNode(bool isUpdateContextBeforeGet) +{ + std::lock_guard lock(surfaceNodeMutex_); + if (isUpdateContextBeforeGet) { + TLOGD(WmsLogTag::WMS_SCB, + "id: %{public}d, surfaceNode: %{public}s, original %{public}s", + GetPersistentId(), + RSAdapterUtil::RSNodeToStr(surfaceNode_).c_str(), + RSAdapterUtil::RSUIContextToStr(GetRSUIContext()).c_str()); + RSAdapterUtil::SetRSUIContext(surfaceNode_, GetRSUIContext(), true); + } + return surfaceNode_; +} + std::shared_ptr Session::GetShadowSurfaceNode() const { std::lock_guard lock(surfaceNodeMutex_); @@ -4920,6 +4934,11 @@ std::shared_ptr Session::GetRSUIContext(const char* caller) { RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(nullptr); auto screenId = GetScreenId(); + if (screenId == SCREEN_ID_INVALID) { + TLOGW(WmsLogTag::WMS_SCB, + "invalid screenId, %{public}s: %{public}s, sessionId: %{public}d, screenId:%{public}" PRIu64,ss + caller, RSAdapterUtil::RSUIContextToStr(rsUIContext_).c_str(), GetPersistentId(), screenId); + } if (screenIdOfRSUIContext_ != screenId) { // Note: For the window corresponding to UIExtAbility, RSUIContext cannot be obtained // directly here because its server side is not SceneBoard. The acquisition of RSUIContext -- Gitee From d9e21e84329e2dce32e4135532feccb2e951b97f Mon Sep 17 00:00:00 2001 From: nealchristmas Date: Wed, 17 Sep 2025 09:26:23 +0800 Subject: [PATCH 52/76] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E6=96=B0Rsuic?= =?UTF-8?q?ontext=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session/host/src/session.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index cc73cb496b..7198bed798 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -195,11 +195,11 @@ std::shared_ptr Session::GetSurfaceNode() const return surfaceNode_; } -std::shared_ptr GetSurfaceNode(bool isUpdateContextBeforeGet) +std::shared_ptr Session::GetSurfaceNode(bool isUpdateContextBeforeGet) { std::lock_guard lock(surfaceNodeMutex_); if (isUpdateContextBeforeGet) { - TLOGD(WmsLogTag::WMS_SCB, + TLOGI(WmsLogTag::WMS_SCB, "id: %{public}d, surfaceNode: %{public}s, original %{public}s", GetPersistentId(), RSAdapterUtil::RSNodeToStr(surfaceNode_).c_str(), @@ -4936,7 +4936,7 @@ std::shared_ptr Session::GetRSUIContext(const char* caller) auto screenId = GetScreenId(); if (screenId == SCREEN_ID_INVALID) { TLOGW(WmsLogTag::WMS_SCB, - "invalid screenId, %{public}s: %{public}s, sessionId: %{public}d, screenId:%{public}" PRIu64,ss + "invalid screenId, %{public}s: %{public}s, sessionId: %{public}d, screenId:%{public}" PRIu64, caller, RSAdapterUtil::RSUIContextToStr(rsUIContext_).c_str(), GetPersistentId(), screenId); } if (screenIdOfRSUIContext_ != screenId) { -- Gitee From 222cc757c3b3e4f20478b6809247a4c6f6306d5e Mon Sep 17 00:00:00 2001 From: nealchristmas Date: Wed, 17 Sep 2025 09:29:30 +0800 Subject: [PATCH 53/76] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E6=96=B0Rsuic?= =?UTF-8?q?ontext=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 7198bed798..9cae0853a0 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -4935,7 +4935,7 @@ std::shared_ptr Session::GetRSUIContext(const char* caller) RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(nullptr); auto screenId = GetScreenId(); if (screenId == SCREEN_ID_INVALID) { - TLOGW(WmsLogTag::WMS_SCB, + TLOGW(WmsLogTag::WMS_SCB, "invalid screenId, %{public}s: %{public}s, sessionId: %{public}d, screenId:%{public}" PRIu64, caller, RSAdapterUtil::RSUIContextToStr(rsUIContext_).c_str(), GetPersistentId(), screenId); } -- Gitee From c88ea5d2054842a7294da8bfe02db0fc0e0072bb Mon Sep 17 00:00:00 2001 From: hejunfei Date: Wed, 17 Sep 2025 10:30:49 +0800 Subject: [PATCH 54/76] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hejunfei --- .../screen_session_manager/src/screen_session_manager.cpp | 5 ----- 1 file changed, 5 deletions(-) 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 206b93aaa2..f69f3a3b26 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -10916,14 +10916,9 @@ DisplayId ScreenSessionManager::GetPrimaryDisplayId() } } } - if (screenSession == nullptr) { - TLOGW(WmsLogTag::DMS, "get extend screen failed use default!"); - screenSession = GetScreenSession(GetDefaultScreenId()); - } if (screenSession && screenSession->IsScreenAvailable()) { return screenSession->GetDisplayId(); } else { - TLOGE(WmsLogTag::DMS, "failed"); return SCREEN_ID_INVALID; } } -- Gitee From 518aa71bf98b0bb75b034038aec1a3acf52bb9d7 Mon Sep 17 00:00:00 2001 From: chengz12138 Date: Wed, 17 Sep 2025 11:03:48 +0800 Subject: [PATCH 55/76] compatible mode adapter setfullscreen and setlayoutfullscreen Signed-off-by: chengz12138 --- wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index e4477fd153..01ccef15ff 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -397,6 +397,7 @@ private: void NotifyDisplayInfoChange(const sptr& info = nullptr); void UpdateDensityInner(const sptr& info = nullptr); sptr GetDisplayInfo() const; + SessionEvent getSessionEvent(); /* * Window Input Event diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 75b4e86d5a..229668ad51 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2949,13 +2949,7 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) return WMError::WM_OK; } CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); - auto event = SessionEvent::EVENT_MAXIMIZE; - if (isFullScreenWaterfallMode_.load()) { - event = SessionEvent::EVENT_MAXIMIZE_WATERFALL; - } else if (isWaterfallToMaximize_.load()) { - event = SessionEvent::EVENT_WATERFALL_TO_MAXIMIZE; - isWaterfallToMaximize_.store(false); - } + auto event = getSessionEvent(); hostSession->OnSessionEvent(event); SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); } @@ -2969,6 +2963,18 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) return ret; } +SessionEvent WindowSceneSessionImpl::getSessionEvent() +{ + auto event = SessionEvent::EVENT_MAXIMIZE; + if (isFullScreenWaterfallMode_.load()) { + event = SessionEvent::EVENT_MAXIMIZE_WATERFALL; + } else if (isWaterfallToMaximize_.load()) { + event = SessionEvent::EVENT_WATERFALL_TO_MAXIMIZE; + isWaterfallToMaximize_.store(false); + } + return event; +} + WMError WindowSceneSessionImpl::SetTitleAndDockHoverShown( bool isTitleHoverShown, bool isDockHoverShown) { -- Gitee From 64f097cd981d483076c5df53d3a9d600fbfb2f95 Mon Sep 17 00:00:00 2001 From: nealchristmas Date: Wed, 17 Sep 2025 11:24:38 +0800 Subject: [PATCH 56/76] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E6=96=B0Rsuic?= =?UTF-8?q?ontext=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/test/unittest/session_test2.cpp | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index 30bd9b7411..745628dcc3 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -747,6 +747,30 @@ HWTEST_F(WindowSessionTest2, GetSurfaceNode, TestSize.Level1) ASSERT_EQ(res, nullptr); } +/** + * @tc.name: GetSurfaceNode + * @tc.desc: GetSurfaceNode Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest2, GetSurfaceNode02, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + session_->surfaceNode_ = nullptr; + std::shared_ptr res = session_->GetSurfaceNode(false); + ASSERT_EQ(res, nullptr); + res = session_->GetSurfaceNode(false); + ASSERT_EQ(res, nullptr); + + struct RSSurfaceNodeConfig config; + std::shared_ptr surfaceNode = RSSurfaceNode::Create(config); + session_->surfaceNode_ = surfaceNode; + res = session_->GetSurfaceNode(false); + ASSERT_EQ(res, surfaceNode); + res = session_->GetSurfaceNode(true); + ASSERT_EQ(res, surfaceNode); + session_->surfaceNode_ = nullptr; +} + /** * @tc.name: GetLeashWinSurfaceNode * @tc.desc: GetLeashWinSurfaceNode Test -- Gitee From 95764e79a54feef13cc1d58bda597c84c14584e7 Mon Sep 17 00:00:00 2001 From: nealchristmas Date: Wed, 17 Sep 2025 11:26:26 +0800 Subject: [PATCH 57/76] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E6=96=B0Rsuic?= =?UTF-8?q?ontext=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/test/unittest/session_test2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index 745628dcc3..dc47322122 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -758,7 +758,7 @@ HWTEST_F(WindowSessionTest2, GetSurfaceNode02, TestSize.Level1) session_->surfaceNode_ = nullptr; std::shared_ptr res = session_->GetSurfaceNode(false); ASSERT_EQ(res, nullptr); - res = session_->GetSurfaceNode(false); + res = session_->GetSurfaceNode(true); ASSERT_EQ(res, nullptr); struct RSSurfaceNodeConfig config; -- Gitee From dc47cc480a9a7cb54955929ec3202ed731910818 Mon Sep 17 00:00:00 2001 From: yangwenxin Date: Wed, 17 Sep 2025 11:54:42 +0800 Subject: [PATCH 58/76] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E8=B7=B3=E8=BD=AC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwenxin --- README_zh.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README_zh.md b/README_zh.md index 889d194333..6c70011969 100644 --- a/README_zh.md +++ b/README_zh.md @@ -97,11 +97,11 @@ foundation/window/window_manager/ ## 接口说明 -- [Window](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-window.md) -- [Display](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-display.md) +- [Window](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window.md) +- [Display](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-display.md) ## 相关仓 -- [graphic_graphic_2d](https://gitee.com/openharmony/graphic_graphic_2d) -- [arkui_ace_engine](https://gitee.com/openharmony/arkui_ace_engine) -- [ability_ability_runtime](https://gitee.com/openharmony/ability_ability_runtime) -- [multimodalinput_input](https://gitee.com/openharmony/multimodalinput_input) \ No newline at end of file +- [graphic_graphic_2d](https://gitcode.com/openharmony/graphic_graphic_2d) +- [arkui_ace_engine](https://gitcode.com/openharmony/arkui_ace_engine) +- [ability_ability_runtime](https://gitcode.com/openharmony/ability_ability_runtime) +- [multimodalinput_input](https://gitcode.com/openharmony/multimodalinput_input) \ No newline at end of file -- Gitee From aea39d1762117119faccdbc550e9bb75637835a7 Mon Sep 17 00:00:00 2001 From: f00520381 Date: Wed, 17 Sep 2025 00:26:33 +0800 Subject: [PATCH 59/76] =?UTF-8?q?=E5=AD=90=E7=AA=97=E8=B0=83=E7=94=A8minim?= =?UTF-8?q?ize=E6=96=B9=E6=B3=95=E5=85=88=E5=88=87=E5=88=B0=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=86=8D=E5=A4=B1=E7=84=A6=20Signed-off-by:=20fukun?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wm/include/window_scene_session_impl.h | 2 +- wm/include/window_session_impl.h | 3 +- wm/src/window_scene_session_impl.cpp | 9 +++--- wm/src/window_session_impl.cpp | 4 +-- .../window_scene_session_impl_test.cpp | 32 +++++++++++++++++++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index e4477fd153..f2dc352919 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -146,7 +146,7 @@ public: void NotifySessionForeground(uint32_t reason, bool withAnimation) override; void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError NotifyPrepareClosePiPWindow() override; - void UpdateSubWindowState(const WindowType& type, bool waitDetach = false); + void UpdateSubWindowState(const WindowType& type); WMError SetSystemBarProperties(const std::map& properties, const std::map& propertyFlags) override; WMError GetSystemBarProperties(std::map& properties) override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index a256b45e31..cc9376ca12 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -327,8 +327,7 @@ public: void NotifyAfterForeground(bool needNotifyListeners = true, bool needNotifyUiContent = true, bool waitAttach = false); void GetAttachStateSyncResult(bool waitAttachState, bool afterForeground) const; - void NotifyAfterBackground(bool needNotifyListeners = true, - bool needNotifyUiContent = true, bool waitDetach = false); + void NotifyAfterBackground(bool needNotifyListeners = true, bool needNotifyUiContent = true); void NotifyAfterDidForeground(uint32_t reason = static_cast(WindowStateChangeReason::NORMAL)); void NotifyAfterDidBackground(uint32_t reason = static_cast(WindowStateChangeReason::NORMAL)); void NotifyForegroundFailed(WMError ret); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 6b8b8d89ae..c44a6f2fde 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1780,7 +1780,8 @@ WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool i RecordLifeCycleExceptionEvent(LifeCycleEvent::HIDE_EVENT, res); if (res == WMError::WM_OK) { // update sub window state if this is main window - UpdateSubWindowState(type, waitDetach); + GetAttachStateSyncResult(waitDetach, false); + UpdateSubWindowState(type); NotifyAfterDidBackground(reason); state_ = WindowState::STATE_HIDDEN; requestState_ = WindowState::STATE_HIDDEN; @@ -1836,15 +1837,15 @@ WMError WindowSceneSessionImpl::NotifyRemoveStartingWindow() return res; } -void WindowSceneSessionImpl::UpdateSubWindowState(const WindowType& type, bool waitDetach) +void WindowSceneSessionImpl::UpdateSubWindowState(const WindowType& type) { UpdateSubWindowStateAndNotify(GetPersistentId(), WindowState::STATE_HIDDEN); if (WindowHelper::IsSubWindow(type)) { if (state_ == WindowState::STATE_SHOWN) { - NotifyAfterBackground(true, true, waitDetach); + NotifyAfterBackground(true, true); } } else { - NotifyAfterBackground(true, true, waitDetach); + NotifyAfterBackground(true, true); } } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 669930bdc9..a87395c6d9 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -4929,7 +4929,7 @@ void WindowSessionImpl::NotifyAfterDidForeground(uint32_t reason) }, where, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } -void WindowSessionImpl::NotifyAfterBackground(bool needNotifyListeners, bool needNotifyUiContent, bool waitDetach) +void WindowSessionImpl::NotifyAfterBackground(bool needNotifyListeners, bool needNotifyUiContent) { if (needNotifyListeners) { { @@ -4939,7 +4939,7 @@ void WindowSessionImpl::NotifyAfterBackground(bool needNotifyListeners, bool nee } NotifyAfterLifecycleBackground(); } - GetAttachStateSyncResult(waitDetach, false); + if (needNotifyUiContent) { CALL_UI_CONTENT(Background); } diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 9d6dfff5b2..43deb9af4d 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1401,6 +1401,38 @@ HWTEST_F(WindowSceneSessionImplTest, Hide03, TestSize.Level0) EXPECT_EQ(WMError::WM_OK, window->Destroy(false)); } +/** + * @tc.name: Hide04 + * @tc.desc: Hide session + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, Hide04, TestSize.Level0) +{ + g_logMsg.clear(); + LOG_SetCallback(LogCallback); + sptr option = sptr::MakeSptr(); + option->SetWindowName("Hide04"); + sptr window = sptr::MakeSptr(option); + + window->property_->SetPersistentId(1); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + window->hostSession_ = session; + + EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, false)); + EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos); + EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, false)); + + EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true)); + EXPECT_FALSE(g_logMsg.find("lifecycleCallback is null") == std::string::npos); + EXPECT_FALSE(g_logMsg.find("window attach state timeout, persistentId") == std::string::npos); + EXPECT_FALSE(g_logMsg.find("get attach state sync result, id") == std::string::npos); + EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true)); + + EXPECT_EQ(WMError::WM_OK, window->Destroy(false)); +} + /** * @tc.name: Show01 * @tc.desc: Show session -- Gitee From 2064e28d1286068337a3d2024244614926fe0bb7 Mon Sep 17 00:00:00 2001 From: chengz12138 Date: Wed, 17 Sep 2025 14:15:57 +0800 Subject: [PATCH 60/76] compatible mode adapter setfullscreen and setlayoutfullscreen Signed-off-by: chengz12138 --- wm/include/window_scene_session_impl.h | 2 +- wm/src/window_scene_session_impl.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 01ccef15ff..b355319151 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -397,7 +397,7 @@ private: void NotifyDisplayInfoChange(const sptr& info = nullptr); void UpdateDensityInner(const sptr& info = nullptr); sptr GetDisplayInfo() const; - SessionEvent getSessionEvent(); + SessionEvent GetSessionEvent(); /* * Window Input Event diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 229668ad51..9cb4605abb 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2949,7 +2949,7 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) return WMError::WM_OK; } CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); - auto event = getSessionEvent(); + auto event = GetSessionEvent(); hostSession->OnSessionEvent(event); SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); } @@ -2963,7 +2963,7 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) return ret; } -SessionEvent WindowSceneSessionImpl::getSessionEvent() +SessionEvent WindowSceneSessionImpl::GetSessionEvent() { auto event = SessionEvent::EVENT_MAXIMIZE; if (isFullScreenWaterfallMode_.load()) { -- Gitee From ad80dfa92db3daa6612a935c1be53cc99636b47e Mon Sep 17 00:00:00 2001 From: chenpeng Date: Wed, 17 Sep 2025 16:17:58 +0800 Subject: [PATCH 61/76] =?UTF-8?q?xts=E9=80=82=E9=85=8DTV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenpeng --- .../screen_session_manager/src/screen_session_manager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 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 6c839e6d82..5f7c6b3bbc 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -10120,8 +10120,13 @@ DMError ScreenSessionManager::GetDisplayCapability(std::string& capabilitInfo) return GetSuperFoldCapability(capabilitInfo); } + bool isWidthGreaterThanHeight = false; + auto displayInfo = GetDefaultDisplayInfo(); + if (displayInfo != nullptr && (displayInfo->GetWidth() > displayInfo->GetHeight())) { + isWidthGreaterThanHeight = true; + } std::vector orientation = ORIENTATION_DEFAULT; - if (g_isPcDevice && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + if ((g_isPcDevice && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) || isWidthGreaterThanHeight) { orientation = {"1", "0", "3", "2"}; } nlohmann::ordered_json jsonDisplayCapabilityList; -- Gitee From c1ba33a7fb5f058c379c503c00f7f58480b2b7e4 Mon Sep 17 00:00:00 2001 From: y_ddddd1 Date: Wed, 17 Sep 2025 18:16:10 +0800 Subject: [PATCH 62/76] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: y_ddddd1 --- .../js_extension_window_listener.cpp | 10 +++++-- kitsnapiembeddable_window_stage | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 kitsnapiembeddable_window_stage 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 76ef869961..6e86813031 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -91,8 +91,8 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r return; } napi_handle_scope scope = nullptr; - napi_open_handle_scope(eng, &scope); - if (scope == nullptr) { + napi_status != napi_open_handle_scope(eng, &scope); + if (status != napi_ok || scope == nullptr) { TLOGNE(WmsLogTag::WMS_UIEXT, "open handle scope failed"); return; } @@ -375,7 +375,11 @@ static void LifeCycleCallBack(LifeCycleEventType eventType, wptr(eventType))}; thisListener->CallJsMethod(LIFECYCLE_EVENT_CB.c_str(), argv, ArraySize(argv)); napi_close_handle_scope(eng, scope); diff --git a/kitsnapiembeddable_window_stage b/kitsnapiembeddable_window_stage new file mode 100644 index 0000000000..ffe5af67fe --- /dev/null +++ b/kitsnapiembeddable_window_stage @@ -0,0 +1,28 @@ +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 76ef869961..6e86813031 100644 +--- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp ++++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +@@ -91,8 +91,8 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r + return; + } + napi_handle_scope scope = nullptr; +- napi_open_handle_scope(eng, &scope); +- if (scope == nullptr) { ++ napi_status != napi_open_handle_scope(eng, &scope);  ++ if (status != napi_ok || scope == nullptr) {  + TLOGNE(WmsLogTag::WMS_UIEXT, "open handle scope failed"); + return; + } +@@ -375,7 +375,11 @@ static void LifeCycleCallBack(LifeCycleEventType eventType, wptr(eventType))}; + thisListener->CallJsMethod(LIFECYCLE_EVENT_CB.c_str(), argv, ArraySize(argv)); + napi_close_handle_scope(eng, scope); -- Gitee From 8ff5df24adbc8cc9cb9003dacd6e626f169f12e9 Mon Sep 17 00:00:00 2001 From: y_ddddd1 Date: Wed, 17 Sep 2025 19:02:17 +0800 Subject: [PATCH 63/76] =?UTF-8?q?delete:=20=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20kitsnapiembeddable=5Fwindow=5Fstage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: y_ddddd1 --- kitsnapiembeddable_window_stage | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 kitsnapiembeddable_window_stage diff --git a/kitsnapiembeddable_window_stage b/kitsnapiembeddable_window_stage deleted file mode 100644 index ffe5af67fe..0000000000 --- a/kitsnapiembeddable_window_stage +++ /dev/null @@ -1,28 +0,0 @@ -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 76ef869961..6e86813031 100644 ---- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp -+++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp -@@ -91,8 +91,8 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r - return; - } - napi_handle_scope scope = nullptr; -- napi_open_handle_scope(eng, &scope); -- if (scope == nullptr) { -+ napi_status != napi_open_handle_scope(eng, &scope);  -+ if (status != napi_ok || scope == nullptr) {  - TLOGNE(WmsLogTag::WMS_UIEXT, "open handle scope failed"); - return; - } -@@ -375,7 +375,11 @@ static void LifeCycleCallBack(LifeCycleEventType eventType, wptr(eventType))}; - thisListener->CallJsMethod(LIFECYCLE_EVENT_CB.c_str(), argv, ArraySize(argv)); - napi_close_handle_scope(eng, scope); -- Gitee From c983561ac54584de499e17a1c9b8c754196ac039 Mon Sep 17 00:00:00 2001 From: y_ddddd1 Date: Wed, 17 Sep 2025 19:10:55 +0800 Subject: [PATCH 64/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20js=5Fextension=5Fwindow=5Flistener.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: y_ddddd1 --- .../napi/extension_window/js_extension_window_listener.cpp | 4 ++-- 1 file 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 6e86813031..63da9685e5 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -376,8 +376,8 @@ static void LifeCycleCallBack(LifeCycleEventType eventType, wptr(eventType))}; -- Gitee From 47b722b3a0879814d547cdcb11d3aa78d19eb14a Mon Sep 17 00:00:00 2001 From: y_ddddd1 Date: Wed, 17 Sep 2025 19:18:14 +0800 Subject: [PATCH 65/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20js=5Fextension=5Fwindow=5Flistener.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: y_ddddd1 --- .../kits/napi/extension_window/js_extension_window_listener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 63da9685e5..e9695eab2e 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -91,7 +91,7 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r return; } napi_handle_scope scope = nullptr; - napi_status != napi_open_handle_scope(eng, &scope); + napi_status = napi_open_handle_scope(eng, &scope); if (status != napi_ok || scope == nullptr) { TLOGNE(WmsLogTag::WMS_UIEXT, "open handle scope failed"); return; -- Gitee From bfba1f06926b4ffae65b4ac648d4ef35af7f07f0 Mon Sep 17 00:00:00 2001 From: Jiayi Zhu Date: Wed, 17 Sep 2025 19:51:27 +0800 Subject: [PATCH 66/76] fix incorrect comments Signed-off-by: Jiayi Zhu --- interfaces/innerkits/dm/screen_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/dm/screen_manager.h b/interfaces/innerkits/dm/screen_manager.h index aea37a4bae..41ee78ee29 100644 --- a/interfaces/innerkits/dm/screen_manager.h +++ b/interfaces/innerkits/dm/screen_manager.h @@ -137,10 +137,10 @@ public: ScreenId& screenGroupId); /** - * @brief Make screen as mirror-screen for region of main screen. + * @brief Make screen as mirror-screen with rotation. * * @param mainScreenId Main screen id. - * @param mirrorScreenId Mirro screen id. + * @param mirrorScreenId Mirror screen ids. * @param screenGroupId Screen group id. * @param rotation Mirror screen rotation. * @return DM_OK means make mirror success, others means make mirror failed. -- Gitee From cc5922b5a6cae1eaabca2d432196b4cb7d68860e Mon Sep 17 00:00:00 2001 From: y_ddddd1 Date: Wed, 17 Sep 2025 19:52:22 +0800 Subject: [PATCH 67/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20js=5Fextension=5Fwindow=5Flistener.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: y_ddddd1 --- .../kits/napi/extension_window/js_extension_window_listener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e9695eab2e..462f411db0 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -91,7 +91,7 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r return; } napi_handle_scope scope = nullptr; - napi_status = napi_open_handle_scope(eng, &scope); + napi_status status = napi_open_handle_scope(eng, &scope); if (status != napi_ok || scope == nullptr) { TLOGNE(WmsLogTag::WMS_UIEXT, "open handle scope failed"); return; -- Gitee From fb22d7dab8bd27f3db98ae1d4950a61a474bab84 Mon Sep 17 00:00:00 2001 From: zhouwenbo7 Date: Wed, 17 Sep 2025 22:30:00 +0800 Subject: [PATCH 68/76] fix real screen connect for sync Signed-off-by: zhouwenbo7 --- window_scene/session/screen/src/screen_session.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 7c41d7d9d3..619c5ec332 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -97,6 +97,7 @@ ScreenSession::ScreenSession(const ScreenSessionConfig& config, ScreenSessionRea } case ScreenSessionReason::CREATE_SESSION_FOR_REAL: { rsConfig.screenId = rsId_; + rsConfig.isSync = true; break; } case ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE: { -- Gitee From cafe7055fc4de3c8ee4f8d22359850664a076203 Mon Sep 17 00:00:00 2001 From: laiganlu Date: Thu, 18 Sep 2025 10:40:45 +0800 Subject: [PATCH 69/76] =?UTF-8?q?mainSession=E6=B5=8B=E8=AF=95=E5=A5=97?= =?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: laiganlu --- window_scene/test/unittest/main_session_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/main_session_test.cpp b/window_scene/test/unittest/main_session_test.cpp index ae0a1add55..d5d29696d0 100644 --- a/window_scene/test/unittest/main_session_test.cpp +++ b/window_scene/test/unittest/main_session_test.cpp @@ -83,7 +83,7 @@ namespace { */ HWTEST_F(MainSessionTest, MainSession01, TestSize.Level1) { - MainSession* pMainSession = nullptr; + sptr pMainSession = nullptr; sptr pSpecificCallback = nullptr; SessionInfo info; @@ -118,7 +118,7 @@ HWTEST_F(MainSessionTest, MainSession01, TestSize.Level1) */ HWTEST_F(MainSessionTest, MainSession02, TestSize.Level1) { - MainSession* pMainSession = nullptr; + sptr pMainSession = nullptr; sptr pSpecificCallback = nullptr; SessionInfo info; -- Gitee From 1e90c862c63a56af5dfdcef901f62425103dcd6e Mon Sep 17 00:00:00 2001 From: f00520381 Date: Tue, 16 Sep 2025 23:52:49 +0800 Subject: [PATCH 70/76] =?UTF-8?q?=E4=BC=98=E5=8C=96RootSceneSession?= =?UTF-8?q?=E7=9A=84=E6=B3=A8=E5=86=8C=E6=97=B6=E6=9C=BA=20Signed-off-by:?= =?UTF-8?q?=20fukun=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index e3c8285d0d..5956d65f74 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -901,6 +901,7 @@ private: std::mutex requestTaskInfoMapMutex_; sptr GetSceneSessionBySessionInfo(const SessionInfo& sessionInfo); void CreateRootSceneSession(); + void RegisterRootSceneSession(); void InitSceneSession(sptr& sceneSession, const SessionInfo& sessionInfo, const sptr& property) REQUIRES(SCENE_GUARD); void InitFbWindow(const sptr& sceneSession, const sptr& property); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3dffef0dd7..9e250b44c5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1644,16 +1644,6 @@ void SceneSessionManager::CreateRootSceneSession() rootSceneSession_->isKeyboardPanelEnabled_ = isKeyboardPanelEnabled_; rootSceneSession_->SetEventHandler(taskScheduler_->GetEventHandler()); rootSceneSession_->SetSystemConfig(systemConfig_); - - AppExecFwk::RunningProcessInfo info; - DelayedSingleton::GetInstance()->GetRunningProcessInfoByPid(getpid(), info); - TLOGI(WmsLogTag::WMS_LIFE, "pid: %{public}d processName: %{public}s", getpid(), info.processName_.c_str()); - - if (SCENE_BOARD_BUNDLE_NAME == info.processName_) { - AAFwk::AbilityManagerClient::GetInstance()->SetRootSceneSession(rootSceneSession_->AsObject()); - TLOGI(WmsLogTag::WMS_LIFE, "SetRootSceneSession success."); - } - rootSceneSession_->RegisterGetStatusBarAvoidHeightFunc([this](DisplayId displayId, WSRect& barArea) { return this->GetStatusBarAvoidHeight(displayId, barArea); }); @@ -1662,6 +1652,22 @@ void SceneSessionManager::CreateRootSceneSession() }); } +void SceneSessionManager::RegisterRootSceneSession() +{ + if (rootSceneSession_ == nullptr) { + TLOGW(WmsLogTag::WMS_LIFE, "rootSceneSession is null"); + return; + } + AppExecFwk::RunningProcessInfo info; + DelayedSingleton::GetInstance()->GetRunningProcessInfoByPid(getpid(), info); + TLOGI(WmsLogTag::WMS_LIFE, "pid: %{public}d, processName: %{public}s, currentUserId: %{public}d", getpid(), + info.processName_.c_str(), currentUserId_.load()); + if (SCENE_BOARD_BUNDLE_NAME == info.processName_ && currentUserId_ != DEFAULT_USERID) { + AAFwk::AbilityManagerClient::GetInstance()->SetRootSceneSession(rootSceneSession_->AsObject()); + TLOGI(WmsLogTag::WMS_LIFE, "SetRootSceneSession success."); + } +} + sptr SceneSessionManager::GetRootSceneSession() { return rootSceneSession_; @@ -5152,6 +5158,7 @@ WSError SceneSessionManager::InitUserInfo(int32_t userId, std::string& fileDir) MultiInstanceManager::GetInstance().SetCurrentUserId(currentUserId_); } AbilityInfoManager::GetInstance().SetCurrentUserId(currentUserId_); + RegisterRootSceneSession(); RegisterSecSurfaceInfoListener(); RegisterConstrainedModalUIExtInfoListener(); return WSError::WS_OK; -- Gitee From ace3f0c93db95c1decbbd390817ecd2b9321d89e Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Thu, 18 Sep 2025 15:51:50 +0800 Subject: [PATCH 71/76] =?UTF-8?q?GetListener=E5=8A=A0=E9=94=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- wm/src/window_session_impl.cpp | 2 +- .../window_scene_session_impl_test5.cpp | 155 ------------------ .../unittest/window_session_impl_test5.cpp | 110 +++++++++++++ 3 files changed, 111 insertions(+), 156 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 669930bdc9..2291fe8985 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -4054,6 +4054,7 @@ template EnableIfSame>> WindowSessionImpl::GetListeners() { std::vector> windowTitleChangeListeners; + std::lock_guard lockRectListener(windowTitleChangeListenerMutex_); for (auto& listener : windowTitleChangeListeners_[GetPersistentId()]) { windowTitleChangeListeners.push_back(listener); } @@ -5579,7 +5580,6 @@ void WindowSessionImpl::NotifySwitchFreeMultiWindow(bool enable) void WindowSessionImpl::NotifyTitleChange(bool isShow, int32_t height) { - std::lock_guard lockRectListener(windowTitleChangeListenerMutex_); auto windowTitleChangeListeners = GetListeners(); std::shared_ptr uiContent = GetUIContentSharedPtr(); if (uiContent == nullptr) { diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index a04d8073d0..c4d0128fc2 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -995,48 +995,6 @@ HWTEST_F(WindowSceneSessionImplTest5, UpdateSystemBarProperties02, TestSize.Leve window->UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags)); } -/** - * @tc.name: MobileAppInPadLayoutFullScreenChange - * @tc.desc: MobileAppInPadLayoutFullScreenChange test - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest5, MobileAppInPadLayoutFullScreenChange, TestSize.Level0) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("MobileAppInPadLayoutFullScreenChange"); - option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); - option->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - - sptr window = sptr::MakeSptr(option); - window->hostSession_ = session; - window->property_->SetPersistentId(1); - window->state_ = WindowState::STATE_CREATED; - window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; - window->windowSystemConfig_.freeMultiWindowEnable_ = true; - window->windowSystemConfig_.freeMultiWindowSupport_ = true; - - window->property_->SetMobileAppInPadLayoutFullScreen(true); - window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - bool statusBarEnable = true; - bool navigationEnable = true; - window->enableImmersiveMode_ = true; - window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); - EXPECT_EQ(false, window->enableImmersiveMode_); - statusBarEnable = false; - navigationEnable = false; - window->enableImmersiveMode_ = false; - window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); - EXPECT_EQ(true, window->enableImmersiveMode_); - statusBarEnable = false; - navigationEnable = true; - window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); - statusBarEnable = true; - navigationEnable = false; - window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); -} - /** * @tc.name: NotifyAfterDidForeground * @tc.desc: NotifyAfterDidForeground @@ -2489,119 +2447,6 @@ HWTEST_F(WindowSceneSessionImplTest5, CalculateNewLimitsByLimits, TestSize.Level EXPECT_EQ(customizedLimits.minWidth_, userLimits.minWidth_); EXPECT_EQ(customizedLimits.minHeight_, userLimits.minHeight_); } - -/** - * @tc.name: GetListeners - * @tc.desc: GetListeners - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, GetListeners, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("GetListeners"); - sptr window = sptr::MakeSptr(option); - window->property_->SetPersistentId(502); - window->windowTitleChangeListeners_[1] = std::vector>(); - - auto result = window->GetListeners(); - EXPECT_TRUE(result.empty()); - - - result = window->GetListeners(); - EXPECT_EQ(result.size(), 2); -} - -/** - * @tc.name: NotifyTitleChange - * @tc.desc: NotifyTitleChange - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, NotifyTitleChange, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("NotifyTitleChange"); - sptr window = sptr::MakeSptr(option); - - SessionInfo sessionInfo = {"NotifyTitleBundle", "NotifyTitleModule", "NotifyTitleAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session)); - bool isShow = false; - int32_t height = 0; - window->NotifyTitleChange(isShow, height); - - sptr listener = sptr::MakeSptr(); - window->RegisterWindowTitleChangeListener(listener); - window->NotifyTitleChange(isShow, height); - ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy()); -} - -/** - * @tc.name: IsHitTitleBar - * @tc.desc: IsHitTitleBar - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, IsHitTitleBar01, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("IsHitTitleBar01"); - sptr window = sptr::MakeSptr(option); - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - window->uiContent_ = nullptr; - bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, false); - - window->uiContent_ = std::make_unique(); - MMI::PointerEvent::PointerItem pointerItem; - Rect rect{ 0, 0, 200, 200 }; - window->property_->SetWindowRect(rect); - pointerItem.SetDisplayX(100); - pointerItem.SetDisplayY(-100); - pointerEvent->AddPointerItem(pointerItem); - pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); - isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, true); -} - -/** - * @tc.name: IsHitTitleBar - * @tc.desc: IsHitTitleBar - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("IsHitTitleBar02"); - sptr window = sptr::MakeSptr(option); - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - window->uiContent_ = nullptr; - bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, false); - - window->uiContent_ = std::make_unique(); - MMI::PointerEvent::PointerItem pointerItem; - Rect rect{ 0, 0, 1, 1 }; - window->property_->SetWindowRect(rect); - pointerItem.SetDisplayX(100); - pointerEvent->AddPointerItem(pointerItem); - pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); - isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, false); -} - -/** - * @tc.name: RegisterWindowTitleChangeListener - * @tc.desc: RegisterWindowTitleChangeListener - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, RegisterWindowTitleChangeListener, TestSize.Level1) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("RegisterWindowTitleChangeListener"); - sptr window = sptr::MakeSptr(option); - sptr listener = nullptr; - WMError ret = window->RegisterWindowTitleChangeListener(listener); - EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR); -} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wm/test/unittest/window_session_impl_test5.cpp b/wm/test/unittest/window_session_impl_test5.cpp index fada4865da..1987073b52 100644 --- a/wm/test/unittest/window_session_impl_test5.cpp +++ b/wm/test/unittest/window_session_impl_test5.cpp @@ -1983,6 +1983,116 @@ HWTEST_F(WindowSessionImplTest5, UpdateIsShowDecorInFreeMultiWindow, Function | bool isShow = true; ASSERT_EQ(WSError::WS_OK, window->UpdateIsShowDecorInFreeMultiWindow(isShow)); } + +/** + * @tc.name: GetListeners + * @tc.desc: GetListeners + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, GetListeners, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("GetListeners"); + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(502); + window->windowTitleChangeListeners_[502] = std::vector>(); + + ASSERT_FALSE(window_->windowTitleChangeListeners_[window_->GetPersistentId()].empty()); +} + +/** + * @tc.name: NotifyTitleChange + * @tc.desc: NotifyTitleChange + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, NotifyTitleChange, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("NotifyTitleChange"); + sptr window = sptr::MakeSptr(option); + + SessionInfo sessionInfo = {"NotifyTitleBundle", "NotifyTitleModule", "NotifyTitleAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session)); + bool isShow = false; + int32_t height = 0; + window->NotifyTitleChange(isShow, height); + + sptr listener = sptr::MakeSptr(); + window->RegisterWindowTitleChangeListener(listener); + window->NotifyTitleChange(isShow, height); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy()); +} + +/** + * @tc.name: IsHitTitleBar + * @tc.desc: IsHitTitleBar + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, IsHitTitleBar01, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("IsHitTitleBar01"); + sptr window = sptr::MakeSptr(option); + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + window->uiContent_ = nullptr; + bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); + + window->uiContent_ = std::make_unique(); + MMI::PointerEvent::PointerItem pointerItem; + Rect rect{ 0, 0, 200, 200 }; + window->property_->SetWindowRect(rect); + pointerItem.SetDisplayX(100); + pointerItem.SetDisplayY(-100); + pointerEvent->AddPointerItem(pointerItem); + pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, true); +} + +/** + * @tc.name: IsHitTitleBar + * @tc.desc: IsHitTitleBar + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("IsHitTitleBar02"); + sptr window = sptr::MakeSptr(option); + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + window->uiContent_ = nullptr; + bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); + + + + window->uiContent_ = std::make_unique(); + MMI::PointerEvent::PointerItem pointerItem; + Rect rect{ 0, 0, 1, 1 }; + window->property_->SetWindowRect(rect); + pointerItem.SetDisplayX(100); + pointerEvent->AddPointerItem(pointerItem); + pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + isHitTitleBar = window->IsHitTitleBar(pointerEvent); + EXPECT_EQ(isHitTitleBar, false); +} + +/** + * @tc.name: RegisterWindowTitleChangeListener + * @tc.desc: RegisterWindowTitleChangeListener + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, RegisterWindowTitleChangeListener, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("RegisterWindowTitleChangeListener"); + sptr window = sptr::MakeSptr(option); + sptr listener = nullptr; + WMError ret = window->RegisterWindowTitleChangeListener(listener); + EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR); +} } // namespace } // namespace Rosen } // namespace OHOS -- Gitee From 7b8329e572b9a2779148d58dae48d3a44dc3c834 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Thu, 18 Sep 2025 16:00:57 +0800 Subject: [PATCH 72/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fscene=5Fsession=5Fimpl=5Ftest5.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- .../window_scene_session_impl_test5.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index c4d0128fc2..f3a2769e51 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -995,6 +995,48 @@ HWTEST_F(WindowSceneSessionImplTest5, UpdateSystemBarProperties02, TestSize.Leve window->UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags)); } +/** + * @tc.name: MobileAppInPadLayoutFullScreenChange + * @tc.desc: MobileAppInPadLayoutFullScreenChange test + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, MobileAppInPadLayoutFullScreenChange, TestSize.Level0) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("MobileAppInPadLayoutFullScreenChange"); + option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); + option->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + + sptr window = sptr::MakeSptr(option); + window->hostSession_ = session; + window->property_->SetPersistentId(1); + window->state_ = WindowState::STATE_CREATED; + window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; + window->windowSystemConfig_.freeMultiWindowEnable_ = true; + window->windowSystemConfig_.freeMultiWindowSupport_ = true; + + window->property_->SetMobileAppInPadLayoutFullScreen(true); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + bool statusBarEnable = true; + bool navigationEnable = true; + window->enableImmersiveMode_ = true; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + EXPECT_EQ(false, window->enableImmersiveMode_); + statusBarEnable = false; + navigationEnable = false; + window->enableImmersiveMode_ = false; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + EXPECT_EQ(true, window->enableImmersiveMode_); + statusBarEnable = false; + navigationEnable = true; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); + statusBarEnable = true; + navigationEnable = false; + window->MobileAppInPadLayoutFullScreenChange(statusBarEnable, navigationEnable); +} + /** * @tc.name: NotifyAfterDidForeground * @tc.desc: NotifyAfterDidForeground -- Gitee From 778b7d4d88d6333d2a30111492a5e8cd9bf18551 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Thu, 18 Sep 2025 16:12:05 +0800 Subject: [PATCH 73/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fsession=5Fimpl=5Ftest5.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- wm/test/unittest/window_session_impl_test5.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wm/test/unittest/window_session_impl_test5.cpp b/wm/test/unittest/window_session_impl_test5.cpp index 1987073b52..9c510e6030 100644 --- a/wm/test/unittest/window_session_impl_test5.cpp +++ b/wm/test/unittest/window_session_impl_test5.cpp @@ -2039,16 +2039,18 @@ HWTEST_F(WindowSessionImplTest5, IsHitTitleBar01, TestSize.Level1) bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); EXPECT_EQ(isHitTitleBar, false); + window->uiContent_ = std::make_unique(); + window->uiContent_->SetContainerModalTitleHeight(100); MMI::PointerEvent::PointerItem pointerItem; - Rect rect{ 0, 0, 200, 200 }; + Rect rect = { 0, 0, 200, 200 }; window->property_->SetWindowRect(rect); pointerItem.SetDisplayX(100); - pointerItem.SetDisplayY(-100); + pointerItem.SetDisplayY(50); pointerEvent->AddPointerItem(pointerItem); pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); isHitTitleBar = window->IsHitTitleBar(pointerEvent); - EXPECT_EQ(isHitTitleBar, true); + EXPECT_EQ(isHitTitleBar, false); } /** @@ -2066,8 +2068,6 @@ HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) bool isHitTitleBar = window->IsHitTitleBar(pointerEvent); EXPECT_EQ(isHitTitleBar, false); - - window->uiContent_ = std::make_unique(); MMI::PointerEvent::PointerItem pointerItem; Rect rect{ 0, 0, 1, 1 }; -- Gitee From 96fb8bd3ddbc899d3d487af7e5071625c79c1471 Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Thu, 18 Sep 2025 16:30:49 +0800 Subject: [PATCH 74/76] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20window=5Fsession=5Fimpl=5Ftest5.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- wm/test/unittest/window_session_impl_test5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/test/unittest/window_session_impl_test5.cpp b/wm/test/unittest/window_session_impl_test5.cpp index 9c510e6030..c6fcd529a3 100644 --- a/wm/test/unittest/window_session_impl_test5.cpp +++ b/wm/test/unittest/window_session_impl_test5.cpp @@ -2083,7 +2083,7 @@ HWTEST_F(WindowSessionImplTest5, IsHitTitleBar02, TestSize.Level1) * @tc.name: RegisterWindowTitleChangeListener * @tc.desc: RegisterWindowTitleChangeListener * @tc.type: FUNC - */ + */ HWTEST_F(WindowSessionImplTest5, RegisterWindowTitleChangeListener, TestSize.Level1) { sptr option = sptr::MakeSptr(); -- Gitee From ca48986c1319e986152082a69462ce9d0ac698af Mon Sep 17 00:00:00 2001 From: shuangshuangliu Date: Mon, 15 Sep 2025 15:07:15 +0800 Subject: [PATCH 75/76] =?UTF-8?q?TDD=E4=B8=8D=E8=A7=84=E8=8C=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shuangshuangliu Change-Id: Ifc0de9695ef7b3f5a602762e44056c618a03c193 --- .../test/unittest/anomaly_detection_test.cpp | 17 ++++++++++---- .../test/unittest/main_session_test.cpp | 16 ++----------- .../test/unittest/scb_system_session_test.cpp | 15 ++++++++++-- .../unittest/scene_session_manager_test10.cpp | 14 +++++++++-- .../unittest/scene_session_manager_test12.cpp | 23 ++++++++++++------- .../test/unittest/scene_session_test.cpp | 16 ++----------- .../test/unittest/scene_session_test2.cpp | 7 ------ .../unittest/session_specific_window_test.cpp | 2 -- .../test/unittest/session_stub_test.cpp | 1 - window_scene/test/unittest/session_test.cpp | 11 ++++++++- window_scene/test/unittest/session_test3.cpp | 14 +++++++---- window_scene/test/unittest/session_test4.cpp | 12 ++++++++-- .../unittest/ssmgr_specific_window_test.cpp | 1 - .../test/unittest/system_session_test.cpp | 15 +++++------- 14 files changed, 93 insertions(+), 71 deletions(-) diff --git a/window_scene/test/unittest/anomaly_detection_test.cpp b/window_scene/test/unittest/anomaly_detection_test.cpp index b7063000c2..681dc33cb2 100644 --- a/window_scene/test/unittest/anomaly_detection_test.cpp +++ b/window_scene/test/unittest/anomaly_detection_test.cpp @@ -20,13 +20,21 @@ #include "session/host/include/session.h" #include "session/host/include/scene_session.h" #include "common/include/window_session_property.h" - +#include "window_manager_hilog.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class AnomalyDetectionTest : public testing::Test { public: static void SetUpTestCase(); @@ -288,9 +296,10 @@ void WallPaperTest(sptr ssm_) HWTEST_F(AnomalyDetectionTest, SceneZOrderCheckProcess, TestSize.Level1) { GTEST_LOG_(INFO) << "AnomalyDetectionTest: SceneZOrderCheckProcess start"; - int ret = 0; + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); AnomalyDetection::SceneZOrderCheckProcess(); - + EXPECT_FALSE(g_errLog.find("ZOrderCheck err, zorder 0") != std::string::npos); SessionVisibleTest(ssm_); ZeroOrderTest(ssm_); EQOrderTest(ssm_); @@ -299,7 +308,7 @@ HWTEST_F(AnomalyDetectionTest, SceneZOrderCheckProcess, TestSize.Level1) KeyGUARDTest(ssm_); IsShowWhenLockedTest(ssm_); WallPaperTest(ssm_); - ASSERT_EQ(ret, 0); + LOG_SetCallback(nullptr); GTEST_LOG_(INFO) << "AnomalyDetectionTest: SceneZOrderCheckProcess end"; } diff --git a/window_scene/test/unittest/main_session_test.cpp b/window_scene/test/unittest/main_session_test.cpp index e7f7711a6c..b71277bf8a 100644 --- a/window_scene/test/unittest/main_session_test.cpp +++ b/window_scene/test/unittest/main_session_test.cpp @@ -118,7 +118,7 @@ HWTEST_F(MainSessionTest, MainSession01, TestSize.Level1) */ HWTEST_F(MainSessionTest, MainSession02, TestSize.Level1) { - MainSession* pMainSession = nullptr; + sptr pMainSession = nullptr; sptr pSpecificCallback = nullptr; SessionInfo info; @@ -391,18 +391,6 @@ HWTEST_F(MainSessionTest, NotifyClientToUpdateInteractive, TestSize.Level1) ASSERT_NE(testSession->isClientInteractive_, interactive); } -/** - * @tc.name: SetExitSplitOnBackground - * @tc.desc: check func SetExitSplitOnBackground - * @tc.type: FUNC - */ -HWTEST_F(MainSessionTest, SetExitSplitOnBackground, TestSize.Level1) -{ - bool isExitSplitOnBackground = true; - mainSession_->SetExitSplitOnBackground(isExitSplitOnBackground); - ASSERT_EQ(true, isExitSplitOnBackground); -} - /** * @tc.name: IsExitSplitOnBackground01 * @tc.desc: check func IsExitSplitOnBackground @@ -892,7 +880,7 @@ HWTEST_F(MainSessionTest, NotifySubAndDialogFollowRectChange01, TestSize.Level1) WSRect rect; subSession->isFollowParentLayout_ = false; mainSession->NotifySubAndDialogFollowRectChange(rect, false, false); - ASSERT_EQ(false, isCall); + ASSERT_NE(false, isCall); subSession->isFollowParentLayout_ = true; sptr callBack = sptr::MakeSptr(); diff --git a/window_scene/test/unittest/scb_system_session_test.cpp b/window_scene/test/unittest/scb_system_session_test.cpp index 13d787515b..f04ad5aba0 100644 --- a/window_scene/test/unittest/scb_system_session_test.cpp +++ b/window_scene/test/unittest/scb_system_session_test.cpp @@ -27,6 +27,14 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class SCBSystemSessionTest : public testing::Test { public: static void SetUpTestCase(); @@ -237,13 +245,16 @@ HWTEST_F(SCBSystemSessionTest, PresentFocusIfPointDown02, TestSize.Level1) */ HWTEST_F(SCBSystemSessionTest, PresentFocusIfNeed, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); int32_t pointerAction = 8; scbSystemSession_->PresentFocusIfNeed(pointerAction, 0); - ASSERT_EQ(pointerAction, 8); + EXPECT_FALSE(g_errLog.find("OnClick down, id:") != std::string::npos); pointerAction = 100; scbSystemSession_->PresentFocusIfNeed(pointerAction, 0); - ASSERT_EQ(pointerAction, 100); + EXPECT_FALSE(g_errLog.find("OnClick down, id:") != std::string::npos); + LOG_SetCallback(nullptr); } /** diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 8ddd07a2e5..69bec5441e 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -30,7 +30,14 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { - +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class SceneSessionManagerTest10 : public testing::Test { public: static void SetUpTestCase(); @@ -591,15 +598,18 @@ HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate05, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest10, ChangeWindowRectYInVirtualDisplay, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); DisplayId defaultDisplayId = 0; DisplayId displayId = 0; int32_t y = 100; ssm_->ChangeWindowRectYInVirtualDisplay(displayId, y); - EXPECT_EQ(displayId, 0); + EXPECT_TRUE(g_errLog.find("This is not VIRTUAL_DISPLAY_ID") != std::string::npos); EXPECT_EQ(y, 100); displayId = 999; ssm_->ChangeWindowRectYInVirtualDisplay(displayId, y); EXPECT_EQ(displayId, defaultDisplayId); + LOG_SetCallback(nullptr); } /** * @tc.name: ProcessFocusZOrderChange diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 3b50f371fa..c8bfb99d27 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -40,12 +40,21 @@ #include "session_manager/include/zidl/session_router_stack_listener_stub.h" #include "ui_effect_manager.h" #include "ui_effect_controller_client_proxy.h" +#include "window_manager_hilog.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class KeyboardTestData; class SceneSessionManagerTest12 : public testing::Test { public: @@ -1675,7 +1684,6 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground01, TestSize.Leve bool hasFloatWindowForeground = false; WMError result = ssm_->HasFloatingWindowForeground(nullptr, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); - EXPECT_EQ(hasFloatWindowForeground, false); } /** @@ -1708,7 +1716,7 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground02, TestSize.Leve sceneSession->SetSessionState(SessionState::STATE_ACTIVE); ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; sptr token2 = sptr::MakeSptr(); WMError result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); @@ -1790,12 +1798,12 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground04, TestSize.Leve ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; WMError result = ssm_->HasFloatingWindowForeground(token1, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); - hasFloatWindowForeground = false; + hasFloatWindowForeground = true; result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); @@ -1821,7 +1829,7 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground05, TestSize.Leve ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; WMError result = ssm_->HasFloatingWindowForeground(token, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); @@ -1859,7 +1867,7 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground06, TestSize.Leve ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; WMError result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); @@ -3011,7 +3019,7 @@ HWTEST_F(SceneSessionManagerTest12, GetPiPSettingSwitchStatus, Function | SmallT ssm_->SetPiPSettingSwitchStatus(false); ret = ssm_->GetPiPSettingSwitchStatus(switchStatus); - EXPECT_EQ(switchStatus, false); + EXPECT_NE(switchStatus, true); EXPECT_EQ(ret, WMError::WM_OK); } @@ -3064,7 +3072,6 @@ HWTEST_F(SceneSessionManagerTest12, IsFocusWindowParent, Function | SmallTest | sceneSession->SetAbilityToken(nullptr); EXPECT_EQ(WSError::WS_OK, ssm_->IsFocusWindowParent(token, isParent)); - EXPECT_EQ(false, isParent); } } // namespace } // namespace Rosen diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index c669ef21ee..5eb08e0c89 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -201,9 +201,6 @@ HWTEST_F(SceneSessionTest, SetZOrder01, TestSize.Level1) sceneSession->SetZOrder(zOrder); usleep(WAIT_ASYNC_US); ASSERT_EQ(zOrder, sceneSession->zOrder_); - sceneSession->SetZOrder(zOrder); - usleep(WAIT_ASYNC_US); - ASSERT_EQ(zOrder, sceneSession->zOrder_); } /** @@ -1173,9 +1170,7 @@ HWTEST_F(SceneSessionTest, GetCutoutAvoidArea, TestSize.Level1) EXPECT_NE(sceneSession, nullptr); WSRect overlapRect = { 0, 0, 0, 0 }; AvoidArea avoidArea; - int ret = 1; sceneSession->GetCutoutAvoidArea(overlapRect, avoidArea); - ASSERT_EQ(ret, 1); } /** @@ -1273,9 +1268,8 @@ HWTEST_F(SceneSessionTest, OnShowWhenLocked, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); - int ret = 0; - sceneSession->OnShowWhenLocked(false); - ASSERT_EQ(ret, 0); + auto res = sceneSession->OnShowWhenLocked(false); + ASSERT_EQ(res, WSError::WS_OK); } /** @@ -1492,7 +1486,6 @@ HWTEST_F(SceneSessionTest, CalculateAvoidAreaRect, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); - int ret = 0; WSRect overlapRect = { 0, 0, 0, 0 }; WSRect avoidRect = { 0, 0, 0, 0 }; AvoidArea avoidArea; @@ -1500,7 +1493,6 @@ HWTEST_F(SceneSessionTest, CalculateAvoidAreaRect, TestSize.Level1) WSRect overlapRect_ = { 1, 1, 1, 1 }; WSRect avoidRect_ = { 1, 1, 1, 1 }; sceneSession->CalculateAvoidAreaRect(overlapRect_, avoidRect_, avoidArea); - ASSERT_EQ(ret, 0); } /** @@ -1590,7 +1582,6 @@ HWTEST_F(SceneSessionTest, UpdateCameraWindowStatus, TestSize.Level1) sptr sysSession; sysSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sysSession, nullptr); - int ret = 1; specificCallback_->onCameraFloatSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {}; specificCallback_->onCameraSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {}; @@ -1611,7 +1602,6 @@ HWTEST_F(SceneSessionTest, UpdateCameraWindowStatus, TestSize.Level1) sysSession->SetPiPTemplateInfo(pipType); sysSession->property_ = property; sysSession->UpdateCameraWindowStatus(false); - ASSERT_EQ(ret, 1); } /** @@ -1664,7 +1654,6 @@ HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - int ret = 1; std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_; sceneSession = sptr::MakeSptr(info, specificCallback_); sceneSession->NotifyPropertyWhenConnect(); @@ -1672,7 +1661,6 @@ HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, TestSize.Level1) property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); sceneSession->property_ = property; sceneSession->NotifyPropertyWhenConnect(); - ASSERT_EQ(ret, 1); } /** diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index f3f0f21989..dc7871f3a1 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -169,14 +169,9 @@ HWTEST_F(SceneSessionTest2, NotifyPropertyWhenConnect1, TestSize.Level1) EXPECT_NE(specificCallback_, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - int ret = 1; std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_; sceneSession = sptr::MakeSptr(info, specificCallback_); sceneSession->NotifyPropertyWhenConnect(); - - sptr property = nullptr; - sceneSession->NotifyPropertyWhenConnect(); - ASSERT_EQ(ret, 1); } /** @@ -506,11 +501,9 @@ HWTEST_F(SceneSessionTest2, SetScale, TestSize.Level1) sptr specificCallback_ = sptr::MakeSptr(); EXPECT_NE(specificCallback_, nullptr); - int resultValue = 0; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->SetScale(1.0f, 1.0f, 0.0f, 0.0f); - ASSERT_EQ(0, resultValue); } /** diff --git a/window_scene/test/unittest/session_specific_window_test.cpp b/window_scene/test/unittest/session_specific_window_test.cpp index d9a1eab8c1..1e7e7fd8a3 100644 --- a/window_scene/test/unittest/session_specific_window_test.cpp +++ b/window_scene/test/unittest/session_specific_window_test.cpp @@ -183,11 +183,9 @@ HWTEST_F(SessionSpecificWindowTest, ClearSpecificSessionCbMap01, TestSize.Level1 info.bundleName_ = "ClearSpecificSessionCbMap01"; sptr sceneSession = sptr::MakeSptr(info, nullptr); sptr session = sptr::MakeSptr(info); - auto result = false; sceneSession->clearCallbackMapFunc_ = nullptr; sceneSession->ClearSpecificSessionCbMap(); usleep(WAIT_SYNC_IN_NS); - ASSERT_EQ(result, false); ASSERT_NE(sceneSession, nullptr); } diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 74ca78405e..9bbb648b93 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -1398,7 +1398,6 @@ HWTEST_F(SessionStubTest, HandleUpdateKeyFrameCloneNode, Function | SmallTest | ASSERT_EQ(result, ERR_NONE); int32_t ret = 0; ASSERT_EQ(reply.ReadInt32(ret), true); - ASSERT_EQ(ret, 0); } /** diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 89768221ad..3f2db830cc 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -40,6 +40,12 @@ namespace OHOS { namespace Rosen { namespace { const std::string UNDEFINED = "undefined"; +std::string g_errLog; +void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) +{ + g_errLog = msg; +} } class WindowSessionTest : public testing::Test { @@ -1667,9 +1673,12 @@ HWTEST_F(WindowSessionTest, GetAndSetSessionRequestRect, TestSize.Level1) */ HWTEST_F(WindowSessionTest, SetSessionRect01, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); WSRect rect = session_->GetSessionRect(); session_->SetSessionRect(rect); - ASSERT_EQ(rect, session_->GetSessionRect()); + EXPECT_TRUE(g_errLog.find("skip same rect") != std::string::npos); + LOG_SetCallback(nullptr); } /** diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index aa0ec8283b..e52f40755a 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -40,6 +40,12 @@ namespace OHOS { namespace Rosen { namespace { const std::string UNDEFINED = "undefined"; +std::string g_errLog; +void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) +{ + g_errLog = msg; +} } class WindowSessionTest3 : public testing::Test { @@ -644,7 +650,6 @@ HWTEST_F(WindowSessionTest3, NotifyClick, TestSize.Level1) }; session_->SetClickListener(func); session_->NotifyClick(false, false); - EXPECT_EQ(resultValue, 1); EXPECT_EQ(hasRequestFocus, false); EXPECT_EQ(hasIsClick, false); } @@ -1012,13 +1017,14 @@ HWTEST_F(WindowSessionTest3, NotifySessionInfoChange, TestSize.Level1) */ HWTEST_F(WindowSessionTest3, NotifySessionPropertyChange01, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); int resultValue = 0; NotifySessionPropertyChangeNotifyManagerFunc func = [&resultValue](int32_t persistentid, WindowInfoKey windowInfoKey) { resultValue = 1; }; session_->sessionPropertyChangeNotifyManagerFunc_ = nullptr; session_->NotifySessionPropertyChange(WindowInfoKey::WINDOW_RECT); - EXPECT_EQ(resultValue, 0); - + EXPECT_TRUE(g_errLog.find("Func is invalid") != std::string::npos); session_->SetSessionPropertyChangeNotifyManagerListener(func); session_->NotifySessionPropertyChange(WindowInfoKey::WINDOW_RECT); EXPECT_EQ(resultValue, 1); @@ -1171,7 +1177,7 @@ HWTEST_F(WindowSessionTest3, SetFreezeImmediately, TestSize.Level1) HWTEST_F(WindowSessionTest3, GetIsHighlighted, Function | SmallTest | Level2) { ASSERT_NE(session_, nullptr); - bool isHighlighted = false; + bool isHighlighted = true; ASSERT_EQ(session_->GetIsHighlighted(isHighlighted), WSError::WS_OK); ASSERT_EQ(isHighlighted, false); } diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index 1ec4a6f112..12ef0f99e1 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -41,6 +41,12 @@ namespace Rosen { namespace { const std::string UNDEFINED = "undefined"; constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest4" }; + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } } // namespace namespace { std::string g_logMsg; @@ -935,16 +941,18 @@ HWTEST_F(WindowSessionTest4, ShouldCreateDetectTaskInRecent, TestSize.Level1) */ HWTEST_F(WindowSessionTest4, CreateWindowStateDetectTask, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); session_->SetSessionState(SessionState::STATE_CONNECT); bool isAttach = true; session_->CreateWindowStateDetectTask(isAttach, WindowMode::WINDOW_MODE_UNDEFINED); - ASSERT_EQ(isAttach, true); + EXPECT_FALSE(g_errLog.find("Window attach state and session state mismatch, ") != std::string::npos); session_->handler_ = nullptr; session_->CreateWindowStateDetectTask(false, WindowMode::WINDOW_MODE_UNDEFINED); - ASSERT_EQ(session_->handler_, nullptr); + LOG_SetCallback(nullptr); } /** diff --git a/window_scene/test/unittest/ssmgr_specific_window_test.cpp b/window_scene/test/unittest/ssmgr_specific_window_test.cpp index 3f453a4a5a..ce2228d3c9 100644 --- a/window_scene/test/unittest/ssmgr_specific_window_test.cpp +++ b/window_scene/test/unittest/ssmgr_specific_window_test.cpp @@ -252,7 +252,6 @@ HWTEST_F(SSMgrSpecificWindowTest, IsKeyboardForeground, TestSize.Level1) ssm_->sceneSessionMap_.insert({ 0, sceneSession }); session->property_ = sptr::MakeSptr(); - ASSERT_NE(session->property_, nullptr); if (session->property_) { auto result1 = session->GetWindowType(); diff --git a/window_scene/test/unittest/system_session_test.cpp b/window_scene/test/unittest/system_session_test.cpp index a421e35164..5710f34387 100644 --- a/window_scene/test/unittest/system_session_test.cpp +++ b/window_scene/test/unittest/system_session_test.cpp @@ -318,15 +318,12 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus01, TestSize.Level1) bool result = false; systemSession_->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); systemSession_->specificCallback_ = specificCallback; systemSession_->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); systemSession_->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA); systemSession_->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); systemSession_->specificCallback_->onCameraFloatSessionChange_ = [&result](uint32_t accessTokenId, bool isShowing) { result = isShowing; @@ -353,7 +350,6 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus02, TestSize.Level1) sysSession->property_->SetWindowType(WindowType::WINDOW_TYPE_PIP); sysSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sysSession->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); sysSession->specificCallback_->onCameraSessionChange_ = [&result](uint32_t accessTokenId, bool isShowing) { result = isShowing; @@ -372,7 +368,6 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus02, TestSize.Level1) result = false; sysSession->pipTemplateInfo_.pipTemplateType = static_cast(PiPTemplateType::VIDEO_LIVE); sysSession->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); } /** @@ -706,7 +701,8 @@ HWTEST_F(SystemSessionTest, NotifyClientToUpdateRect03, TestSize.Level1) sysSession->dirtyFlags_ = 0; sysSession->isKeyboardPanelEnabled_ = true; - sysSession->Session::UpdateSizeChangeReason(SizeChangeReason::MAXIMIZE); + auto res = sysSession->Session::UpdateSizeChangeReason(SizeChangeReason::MAXIMIZE); + EXPECT_EQ(res, WSError::WS_OK); sptr specificCallback = sptr::MakeSptr(); @@ -714,17 +710,18 @@ HWTEST_F(SystemSessionTest, NotifyClientToUpdateRect03, TestSize.Level1) sysSession->specificCallback_ = specificCallback; sysSession->specificCallback_->onUpdateAvoidArea_ = nullptr; sysSession->GetLayoutController()->SetSessionRect({ 0, 0, 800, 800 }); - sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); + res = sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); usleep(WAIT_ASYNC_US); - EXPECT_EQ(sysSession->dirtyFlags_, 0); + EXPECT_EQ(res, WSError::WS_OK); sysSession->dirtyFlags_ = 0; sysSession->SetScbCoreEnabled(true); sysSession->Session::UpdateSizeChangeReason(SizeChangeReason::MAXIMIZE); sysSession->specificCallback_->onUpdateAvoidArea_ = [](const int32_t& persistentId) {}; - sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); + res = sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); usleep(WAIT_ASYNC_US); EXPECT_EQ(sysSession->dirtyFlags_, static_cast(SessionUIDirtyFlag::AVOID_AREA)); + EXPECT_EQ(res, WSError::WS_OK); } /** -- Gitee From 75c1251ccb0ef49847d26353b253670d7a4cf9b3 Mon Sep 17 00:00:00 2001 From: 17342015572 Date: Thu, 28 Aug 2025 08:30:19 +0000 Subject: [PATCH 76/76] UpdateOutline Signed-off-by: 17342015572 Change-Id: I3e2d3d83c4d0cb8b6c0e2cd75854e50f67dab880 Signed-off-by: 17342015572 --- interfaces/innerkits/wm/window_manager.h | 15 ++ interfaces/innerkits/wm/wm_common.h | 157 ++++++++++++++++++ test/demo/BUILD.gn | 24 +++ .../demo_outline_virtual_media_service.cpp | 140 ++++++++++++++++ .../systemtest/wms/window_animate_to_test.cpp | 26 +++ .../js_scene_session.cpp | 50 ++++++ .../scene_session_manager/js_scene_session.h | 3 + window_scene/session/host/include/session.h | 14 ++ window_scene/session/host/src/session.cpp | 42 +++++ .../include/scene_session_manager.h | 13 ++ .../zidl/scene_session_manager_interface.h | 5 + .../zidl/scene_session_manager_proxy.h | 1 + .../include/zidl/scene_session_manager_stub.h | 1 + .../src/scene_session_manager.cpp | 100 +++++++++++ .../src/zidl/scene_session_manager_proxy.cpp | 40 +++++ .../src/zidl/scene_session_manager_stub.cpp | 23 +++ .../scene_session_manager_proxy_test.cpp | 63 +++++++ .../scene_session_manager_stub_test2.cpp | 36 ++++ .../scene_session_manager_supplement_test.cpp | 15 ++ .../unittest/scene_session_manager_test12.cpp | 123 ++++++++++++++ window_scene/test/unittest/session_test2.cpp | 12 ++ window_scene/test/unittest/session_test4.cpp | 69 ++++++++ wm/include/window_adapter.h | 11 ++ wm/src/window_adapter.cpp | 32 ++++ wm/src/window_manager.cpp | 60 +++++++ wm/test/unittest/window_adapter_test.cpp | 32 ++++ wm/test/unittest/window_manager_test.cpp | 41 +++++ .../include/zidl/window_manager_interface.h | 8 + 28 files changed, 1156 insertions(+) create mode 100644 test/demo/demo_outline_virtual_media_service.cpp diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index ab2484ec00..dcc3cce3bc 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -1364,6 +1364,14 @@ public: WMError RemoveSessionBlackList( const std::unordered_set& bundleNames, const std::unordered_set& privacyWindowTags); + /** + * @brief Update outline to highlight some sharing areas. + * @param remoteObject Remote object who needs to update outline. + * @param outlineParams The outline params. + * @return WM_OK means update success, others means update failed. + */ + WMError UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams); + ~WindowManager() override; private: @@ -1383,6 +1391,13 @@ private: std::unordered_map interestInfoMap_; GetJSWindowObjFunc getJSWindowObjFunc_; + /** + * Update outline to highlight some sharing areas. + */ + sptr outlineRemoteObject_ = nullptr; + OutlineParams outlineParams_; + bool isOutlineRecoverRegistered_ = false; + void OnWMSConnectionChanged(int32_t userId, int32_t screenId, bool isConnected) const; void UpdateFocusStatus(uint32_t windowId, const sptr& abilityToken, WindowType windowType, DisplayId displayId, bool focused) const; diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 4ece6282c9..a01b563e78 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -90,6 +90,16 @@ constexpr uint32_t SIDEBAR_SNAPSHOT_MASKCOLOR_DARK = 0xff414141; */ constexpr float COMPACT_SIMULATION_SCALE_DPI = 3.25f; constexpr float COMPACT_NORMAL_SCALE = 1.0f; + +/* + * Window outline + */ +constexpr uint32_t OUTLINE_WIDTH_MIN = 1; // vp +constexpr uint32_t OUTLINE_WIDTH_DEFAULT = 4; // vp +constexpr uint32_t OUTLINE_WIDTH_MAX = 8; // vp +constexpr uint32_t OUTLINE_FOR_WINDOW_MAX_NUM = 10; +constexpr uint32_t OUTLIEN_COLOR_NO_ALPHA = 0x00ffffff; +constexpr uint32_t OUTLIEN_COLOR_ALPHA_OPAQUE = 0xff000000; } /** @@ -3040,6 +3050,153 @@ enum class RequestResultCode: uint32_t { SUCCESS = 1, FAIL, }; + +/** + * @brief The type of outline. + */ +enum class OutlineType: uint32_t { + OUTLINE_FOR_UNDEFINED = 0, // Invalid outline type + OUTLINE_FOR_SCREEN, // Add outline to highlight screen + OUTLINE_FOR_RECT, // Add outline to highlight a rect of screen + OUTLINE_FOR_WINDOW // Add outline to highlight windows +}; + +/** + * @brief The shape of outline. + */ +enum class OutlineShape: uint32_t { + OUTLINE_SHAPE_FOUR_CORNER, + OUTLINE_SHAPE_RECTANGLE, + OUTLINE_SHAPE_MAX +}; + +/** + * @brief Outline style params. + */ +struct OutlineStyleParams { + uint32_t outlineColor_ = 0; // Can not be transparent. + uint32_t outlineWidth_ = OUTLINE_WIDTH_DEFAULT; // Valid range: [1vp, 8vp]. + OutlineShape outlineShape_ = OutlineShape::OUTLINE_SHAPE_FOUR_CORNER; + + bool operator == (const OutlineStyleParams& a) const + { + return outlineColor_ == a.outlineColor_ && outlineWidth_ == a.outlineWidth_ && outlineShape_ == a.outlineShape_; + } + inline std::string ToString() const + { + std::ostringstream oss; + oss << "[ color: " << outlineColor_ << ", width: " << outlineWidth_ << "vp, shape: "; + oss << static_cast(outlineShape_) << " ]"; + return oss.str(); + } +}; + +/** + * @brief Outline params. + */ +struct OutlineParams : public Parcelable { + OutlineType type_ = OutlineType::OUTLINE_FOR_UNDEFINED; // Add outline to highlight what kind of area. + DisplayId displayId_ = DISPLAY_ID_INVALID; // Indicates the displayId of the screen that needs to be highlight. + Rect rect_; // Indicates the rect of one screen that needs to be highlight. + std::vector persistentIds_; // Indicates which windows need to be highlight. + OutlineStyleParams outlineStyleParams_; // Indicates the style of a outline. + + bool Marshalling(Parcel& parcel) const override + { + if (!parcel.WriteUint32(static_cast(type_))) { + return false; + } + + if (!parcel.WriteUint64(static_cast(displayId_))) { + return false; + } + + if (!parcel.WriteInt32(rect_.posX_) || !parcel.WriteInt32(rect_.posY_) || + !parcel.WriteUint32(rect_.width_) || !parcel.WriteUint32(rect_.height_)) { + return false; + } + + uint32_t size = static_cast(persistentIds_.size()); + if (size > OUTLINE_FOR_WINDOW_MAX_NUM || !parcel.WriteUint32(size)) { + return false; + } + + for (const auto id : persistentIds_) { + if (!parcel.WriteInt32(id)) { + return false; + } + } + + if (!parcel.WriteUint32(outlineStyleParams_.outlineColor_) || + !parcel.WriteUint32(outlineStyleParams_.outlineWidth_) || + !parcel.WriteUint32(static_cast(outlineStyleParams_.outlineShape_))) { + return false; + } + return true; + } + + static OutlineParams* Unmarshalling(Parcel& parcel) + { + std::unique_ptr params = std::make_unique(); + if (params == nullptr) { + return nullptr; + } + + uint32_t type; + if (!parcel.ReadUint32(type)) { + return nullptr; + } + params->type_ = static_cast(type); + + uint64_t displayId; + if (!parcel.ReadUint64(displayId)) { + return nullptr; + } + params->displayId_ = static_cast(displayId); + + if (!parcel.ReadInt32(params->rect_.posX_) || !parcel.ReadInt32(params->rect_.posY_) || + !parcel.ReadUint32(params->rect_.width_) || !parcel.ReadUint32(params->rect_.height_)) { + return nullptr; + } + + uint32_t size; + if (!parcel.ReadUint32(size) || size > OUTLINE_FOR_WINDOW_MAX_NUM) { + return nullptr; + } + for (uint32_t i = 0; i < size; i++) { + int32_t persistentId; + if (!parcel.ReadInt32(persistentId)) { + return nullptr; + } + params->persistentIds_.push_back(persistentId); + } + + if (!parcel.ReadUint32(params->outlineStyleParams_.outlineColor_) || + !parcel.ReadUint32(params->outlineStyleParams_.outlineWidth_)) { + return nullptr; + } + + uint32_t outlineShape; + if (!parcel.ReadUint32(outlineShape)) { + return nullptr; + } + params->outlineStyleParams_.outlineShape_ = static_cast(outlineShape); + return params.release(); + } + + inline std::string ToString() const + { + std::ostringstream oss; + oss << "Outline params: type=" << static_cast(type_) << ", displayId=" << displayId_ << ", "; + oss << "rect=[" << rect_.posX_ << ", " << rect_.posY_ << ", " << rect_.width_ << ", " << rect_.height_ << "], "; + oss << "windowIdList=[ "; + for (const auto id : persistentIds_) { + oss << id << ", "; + } + oss << "], outlineStyleParams="; + return oss.str() + outlineStyleParams_.ToString(); + } +}; } } #endif // OHOS_ROSEN_WM_COMMON_H diff --git a/test/demo/BUILD.gn b/test/demo/BUILD.gn index ccc7cff128..381c04550b 100644 --- a/test/demo/BUILD.gn +++ b/test/demo/BUILD.gn @@ -25,6 +25,7 @@ group("demo") { ":demo_system_sub_window", ":demo_visible_window_num_listener", ":demo_water_mark_listener", + ":demo_outline_virtual_media_service", ] } @@ -205,3 +206,26 @@ ohos_executable("demo_session_manager") { part_name = "window_manager" subsystem_name = "window" } + +ohos_executable("demo_outline_virtual_media_service") { + sources = [ "demo_outline_virtual_media_service.cpp" ] + + include_dirs = [ + "${window_base_path}/interfaces/innerkits/wm", + "${window_base_path}/test/common/utils/include", + ] + + deps = [ + "${window_base_path}/test/common/utils:libtestutil", + "${window_base_path}/wm:libwm", + ] + + external_deps = [ + "c_utils:utils", + "graphic_2d:librender_service_base", + "hilog:libhilog", + ] + + part_name = "window_manager" + subsystem_name = "window" +} \ No newline at end of file diff --git a/test/demo/demo_outline_virtual_media_service.cpp b/test/demo/demo_outline_virtual_media_service.cpp new file mode 100644 index 0000000000..b521edab64 --- /dev/null +++ b/test/demo/demo_outline_virtual_media_service.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include "common_test_utils.h" +#include "ipc_skeleton.h" +#include "window_manager.h" + +using namespace OHOS; +using namespace OHOS::Rosen; + +namespace OHOS { +namespace Rosen { +class DemoOutlineVirtualMediaService { +public: + void GetWindowIds() + { + windowInfos_.clear(); + WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos_); + std::cout << "Accessibility window infos length :" << windowInfos_.size() << std::endl; + std::cout << "windowId -- windowType -- windowName" << std::endl; + for (auto info : windowInfos_) { + std::cout << " " << info->wid_; + std::cout << " -- " << static_cast(info->type_); + std::cout << " -- " << info->bundleName_; + std::cout << std::endl; + } + } + void UpdateOutlines() + { + OutlineParams outlineParams; + outlineParams.type_ = OutlineType::OUTLINE_FOR_WINDOW; + std::cout << "Please input outline color:" << std::endl; + std::cin >> outlineParams.outlineStyleParams_.outlineColor_; + std::cout << "Please input outline width:" << std::endl; + std::cin >> outlineParams.outlineStyleParams_.outlineWidth_; + std::cout << "Please input outline shape:" << std::endl; + uint32_t shape = 0; + std::cin >> shape; + outlineParams.outlineStyleParams_.outlineShape_ = static_cast(shape); + std::cout << "Please input window id list:" << std::endl; + std::cin.ignore(std::numeric_limits::max(), '\n'); + std::string line; + std::getline(std::cin, line); + std::istringstream iss(line); + int32_t id; + outlineParams.persistentIds_.clear(); + while (iss >> id) { + outlineParams.persistentIds_.push_back(id); + } + if (remoteObject_ == nullptr) { + std::cout << "Remote object is nullptr, pid" << IPCSkeleton::GetCallingPid() << std::endl; + return; + } + std::cout << "Update outlines: curr pid: " << IPCSkeleton::GetCallingPid() << std::endl; + std::cout << "Update outlines: the outline params: " << outlineParams.ToString().c_str() << std::endl; + WMError ret = WindowManager::GetInstance().UpdateOutline(remoteObject_, outlineParams); + if (ret != WMError::WM_OK) { + std::cout << "Update outlines failed, ret:" << + std::to_string(static_cast(ret)).c_str() << std::endl; + return; + } + std::cout << "Update outlines succeed." << std::endl; + } + + void ClearOutlines() + { + OutlineParams outlineParams; + outlineParams.type_ = OutlineType::OUTLINE_FOR_WINDOW; + std::cout << "Clear outlines: curr pid: " << IPCSkeleton::GetCallingPid() << std::endl; + std::cout << "Clear outlines: the outline params: " << outlineParams.ToString().c_str() << std::endl; + WMError ret = WindowManager::GetInstance().UpdateOutline(remoteObject_, outlineParams); + if (ret != WMError::WM_OK) { + std::cout << "Clear outlines failed,ret:" << std::to_string(static_cast(ret)).c_str() << std::endl; + return; + } + std::cout << "Clear outlines succeed." << std::endl; + } +private: + std::vector> windowInfos_; + sptr remoteObject_ = IPCSkeleton::GetContextObject(); +}; +} +} + +int main(int argc, char* argv[]) +{ + std::cout << "===============Demo outline virtual media service start===============" << std::endl; + std::cout << "Please input: " << std::endl; + std::cout << " 1: Get the windows that can update outline;" << std::endl; + std::cout << " 2: Update outline for windows;" << std::endl; + std::cout << " 3: Clear all outline for windows;" << std::endl; + std::cout << " others: Exit this demo;" << std::endl; + CommonTestUtils::GuaranteeFloatWindowPermission("demo_outline_virtual_media_service"); + + uint32_t inputFlag = 0; + std::unique_ptr demo = std::make_unique(); + while (true) { + std::cout << "Please input flag: " << std::endl; + std::cin >> inputFlag; + bool needExit = false; + switch (inputFlag) { + case 1: { + demo->GetWindowIds(); + break; + } + case 2: { + demo->UpdateOutlines(); + break; + } + case 3: { + demo->ClearOutlines(); + break; + } + default: { + needExit = true; + } + } + if (needExit) { + break; + } + }; + std::cout << "===============Demo outline virtual media service end===============" << std::endl; + return 0; +} \ No newline at end of file diff --git a/test/systemtest/wms/window_animate_to_test.cpp b/test/systemtest/wms/window_animate_to_test.cpp index 9d54e49b33..fb51ef90ca 100644 --- a/test/systemtest/wms/window_animate_to_test.cpp +++ b/test/systemtest/wms/window_animate_to_test.cpp @@ -16,6 +16,7 @@ // gtest #include #include "common_test_utils.h" +#include "../../common/mock/iremote_object_mocker.h" #include "modifier_render_thread/rs_modifiers_draw_thread.h" #include "scene_board_judgement.h" #include "window.h" @@ -116,6 +117,31 @@ HWTEST_F(WindowAnimateToTest, AnimateTo02, TestSize.Level1) ASSERT_EQ(WMError::WM_DO_NOTHING, WindowManager::GetInstance().AnimateTo(MAX_WINDOW_ID, animationProperty, animationOption)); } + +/** + * @tc.name: UpdateOutline + * @tc.desc: test founction WindowManager::UpdateOutline. + * @tc.type: FUNC + */ +HWTEST_F(WindowAnimateToTest, UpdateOutline, TestSize.Level1) +{ + sptr remoteObject = sptr::MakeSptr(); + OutlineParams outlineParams; + outlineParams.type_ = OutlineType::OUTLINE_FOR_WINDOW; + WMError ret = WindowManager::GetInstance().UpdateOutline(remoteObject, outlineParams); + EXPECT_EQ(ret, WMError::WM_OK); + + bool outlineRecoverRegister = WindowManager::GetInstance().isOutlineRecoverRegistered_; + outlineParams.persistentIds_.push_back(1); // 1 persistentId + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, outlineParams); + EXPECT_EQ(ret, WMError::WM_OK); + + WindowManager::GetInstance().isOutlineRecoverRegistered_ = !outlineRecoverRegister; + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, outlineParams); + EXPECT_EQ(ret, WMError::WM_OK); + + WindowManager::GetInstance().isOutlineRecoverRegistered_ = outlineRecoverRegister; +} } // namespace } // namespace Rosen } // namespace OHOS 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 b0af1505a5..ca25fc8b00 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 @@ -112,6 +112,7 @@ const std::string SET_WINDOW_SHADOWS_CB = "setWindowShadows"; const std::string SET_SUB_WINDOW_SOURCE_CB = "setSubWindowSource"; const std::string ANIMATE_TO_CB = "animateToTargetProperty"; const std::string BATCH_PENDING_SCENE_ACTIVE_CB = "batchPendingSceneSessionsActivation"; +const std::string SCENE_OUTLINE_PARAMS_CHANGE_CB = "sceneOutlineParamsChange"; constexpr int ARG_COUNT_1 = 1; constexpr int ARG_COUNT_2 = 2; @@ -217,6 +218,7 @@ const std::map ListenerFuncMap { {FLOATING_BALL_UPDATE_CB, ListenerFuncType::FLOATING_BALL_UPDATE_CB}, {FLOATING_BALL_STOP_CB, ListenerFuncType::FLOATING_BALL_STOP_CB}, {FLOATING_BALL_RESTORE_MAIN_WINDOW_CB, ListenerFuncType::FLOATING_BALL_RESTORE_MAIN_WINDOW_CB}, + {SCENE_OUTLINE_PARAMS_CHANGE_CB, ListenerFuncType::SCENE_OUTLINE_PARAMS_CHANGE_CB}, }; const std::vector g_syncGlobalPositionPermission { @@ -3200,6 +3202,9 @@ void JsSceneSession::ProcessRegisterCallback(ListenerFuncType listenerFuncType) case static_cast(ListenerFuncType::FLOATING_BALL_RESTORE_MAIN_WINDOW_CB): ProcessFloatingBallRestoreMainWindowRegister(); break; + case static_cast(ListenerFuncType::SCENE_OUTLINE_PARAMS_CHANGE_CB): + ProcessSceneOutlineParamsChangeRegister(); + break; default: break; } @@ -8166,6 +8171,51 @@ void JsSceneSession::OnAnimateToTargetProperty(const WindowAnimationProperty& an }, __func__); } +void JsSceneSession::ProcessSceneOutlineParamsChangeRegister() +{ + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Session is nullptr, id: %{public}d", persistentId_); + return; + } + auto callback = [weakThis = wptr(this), where = __func__] (bool enabled, const OutlineStyleParams& params) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_ANIMATION, "%{public}s jsSceneSession is nullptr.", where); + return; + } + jsSceneSession->OnOutlineParamsChange(enabled, params); + }; + session->SetOutlineParamsChangeCallback(std::move(callback)); +} + +void JsSceneSession::OnOutlineParamsChange(bool isOutlineEnabled, const OutlineStyleParams& outlineStyleParams) +{ + auto task = [weakThis = wptr(this), where = __func__, env = env_, persistentId = persistentId_, isOutlineEnabled, + outlineStyleParams]() { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) { + TLOGNE(WmsLogTag::WMS_ANIMATION, "%{public}s: JsSceneSession is invalid, id: %{public}d", + where, persistentId); + return; + } + TLOGNI(WmsLogTag::WMS_ANIMATION, "%{public}s, id: %{public}d, enabled: %{public}d, params: %{public}s", + where, persistentId, isOutlineEnabled, outlineStyleParams.ToString().c_str()); + auto jsCallBack = jsSceneSession->GetJSCallback(SCENE_OUTLINE_PARAMS_CHANGE_CB); + if (!jsCallBack) { + TLOGNE(WmsLogTag::WMS_ANIMATION, "%{public}s: JsCallback is nullptr.", where); + return; + } + napi_value enabledObj = CreateJsValue(env, isOutlineEnabled); + napi_value colorObj = CreateJsValue(env, outlineStyleParams.outlineColor_); + napi_value widthObj = CreateJsValue(env, outlineStyleParams.outlineWidth_); + napi_value shapeObj = CreateJsValue(env, static_cast(outlineStyleParams.outlineShape_)); + napi_value argv[] = { enabledObj, colorObj, widthObj, shapeObj }; + napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); + + }; + taskScheduler_->PostMainThreadTask(task, __func__); +} void JsSceneSession::AddRequestTaskInfo(sptr sceneSession, SessionInfo& info, bool needAddRequestInfo) 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 b53a17976d..b7e35cfe8b 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 @@ -112,6 +112,7 @@ enum class ListenerFuncType : uint32_t { FLOATING_BALL_UPDATE_CB, FLOATING_BALL_STOP_CB, FLOATING_BALL_RESTORE_MAIN_WINDOW_CB, + SCENE_OUTLINE_PARAMS_CHANGE_CB, }; class SceneSession; @@ -425,6 +426,7 @@ private: void ProcessUseImplicitAnimationChangeRegister(); void ProcessSetSubWindowSourceRegister(); void ProcessAnimateToTargetPropertyRegister(); + void ProcessSceneOutlineParamsChangeRegister(); /* * Window Property @@ -516,6 +518,7 @@ private: void NotifySetSubWindowSource(SubWindowSource source); void OnAnimateToTargetProperty(const WindowAnimationProperty& animationProperty, const WindowAnimationOption& animationOption); + void OnOutlineParamsChange(bool isOutlineEnabled, const OutlineStyleParams& outlineStyleParams); /* * Window Property diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 66b7adb2f3..be5fa295a0 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -116,6 +116,7 @@ using NotifySurfaceBoundsChangeFunc = std::function; using RequestNextVsyncWhenModeChangeFunc = std::function& vsyncCallback)>; using NotifyClearSubSessionFunc = std::function; +using OutlineParamsChangeCallbackFunc = std::function; class ILifecycleListener { public: virtual void OnActivation() {} @@ -762,6 +763,12 @@ public: */ std::shared_ptr GetRSUIContext(const char* caller = ""); + /* + * Window highligt outline + */ + void UpdateSessionOutline(bool enabled, const OutlineStyleParams& params); + void SetOutlineParamsChangeCallback(OutlineParamsChangeCallbackFunc&& func); + WSError SetIsShowDecorInFreeMultiWindow(bool isShow); protected: @@ -1156,6 +1163,13 @@ private: */ uint64_t screenIdOfRSUIContext_ = SCREEN_ID_INVALID; std::shared_ptr rsUIContext_; + + /* + * Window highligt outline + */ + bool isOutlineEnabled_ = false; + OutlineStyleParams outlineStyleParams_; + OutlineParamsChangeCallbackFunc outlineParamsChangeCallback_; }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 256ef76d47..a157f001ca 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -676,6 +676,10 @@ void Session::SetSessionState(SessionState state) } state_ = state; SetMainSessionUIStateDirty(true); + if (state == SessionState::STATE_DISCONNECT) { + OutlineStyleParams defaultParams; + UpdateSessionOutline(false, defaultParams); + } } void Session::UpdateSessionState(SessionState state) @@ -689,6 +693,10 @@ void Session::UpdateSessionState(SessionState state) state_ = state; SetMainSessionUIStateDirty(true); NotifySessionStateChange(state); + if (state == SessionState::STATE_DISCONNECT) { + OutlineStyleParams defaultParams; + UpdateSessionOutline(false, defaultParams); + } } void Session::UpdateSessionTouchable(bool touchable) @@ -4915,6 +4923,40 @@ WSError Session::NotifyClientToUpdateGlobalDisplayRect(const WSRect& rect, SizeC return sessionStage_->UpdateGlobalDisplayRectFromServer(rect, reason); } +void Session::SetOutlineParamsChangeCallback(OutlineParamsChangeCallbackFunc&& func) +{ + PostTask([weakThis = wptr(this), where = __func__, func = std::move(func)] { + auto session = weakThis.promote(); + if (!session || !func) { + TLOGNE(WmsLogTag::WMS_ANIMATION, "session or onOutlineParamsChangeCallback is null."); + return; + } + session->outlineParamsChangeCallback_ = std::move(func); + session->outlineParamsChangeCallback_(session->isOutlineEnabled_, session->outlineStyleParams_); + }, __func__); +} + +void Session::UpdateSessionOutline(bool enabled, const OutlineStyleParams& params) +{ + if (enabled == isOutlineEnabled_ && params == outlineStyleParams_) { + TLOGD(WmsLogTag::WMS_ANIMATION, "Same outline params."); + return; + } + TLOGI(WmsLogTag::WMS_ANIMATION, "id: %{public}d, oldEnabled: %{public}d, oldParams: %{public}s, " + "newEnabled: %{public}d, newParams: %{public}s", GetPersistentId(), isOutlineEnabled_, + outlineStyleParams_.ToString().c_str(), enabled, params.ToString().c_str()); + isOutlineEnabled_ = enabled; + outlineStyleParams_.outlineColor_ = params.outlineColor_; + outlineStyleParams_.outlineWidth_ = params.outlineWidth_; + outlineStyleParams_.outlineShape_ = params.outlineShape_; + if (outlineParamsChangeCallback_) { + outlineParamsChangeCallback_(isOutlineEnabled_, outlineStyleParams_); + } else { + TLOGI(WmsLogTag::WMS_ANIMATION, "Outline params change callback is null."); + } + +} + std::shared_ptr Session::GetRSUIContext(const char* caller) { RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(nullptr); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 5956d65f74..df74b22024 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -820,6 +820,8 @@ public: std::vector> GetSceneSessions(ScreenId screenId); WMError UpdateScreenLockState(int32_t persistentId); + WMError UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) override; + protected: SceneSessionManager(); virtual ~SceneSessionManager(); @@ -1736,6 +1738,17 @@ private: WMError SetImageForRecent(uint32_t imgResourceId, ImageFit imageFit, int32_t persistentId) override; void UpdateAllStartingWindowRdb(); bool needUpdateRdb_ = true; + + OutlineParams recoverOutlineParams_; + bool needRecoverOutline_ = false; + sptr outlineRemoteObject_; + sptr outlineRemoteDeath_ = new AgentDeathRecipient( + [this](const sptr& remoteObject) { this->DeleteAllOutline(remoteObject); }); + void UpdateOutlineInner(const sptr& remoteObject, const OutlineParams& outlineParams); + bool NeedOutline(int32_t persistenId, const std::vector& persistentIdList); + void AddOutlineRemoteDeathRecipient(const sptr& remoteObject); + void DeleteAllOutline(const sptr& remoteObject); + std::string GetCallerSessionColorMode(const SessionInfo& sessionInfo); void NotifySessionScreenLockedChange(bool isScreenLocked); diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h index 8af9a8d0b3..8dc9e30143 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h @@ -156,6 +156,7 @@ public: TRANS_ID_REMOVE_SESSION_BLACK_LIST, TRANS_ID_GET_PIP_SWITCH_STATUS, TRANS_ID_RECOVER_WINDOW_PROPERTY_CHANGE_FLAG, + TRANS_ID_UPDATE_OUTLINE, }; virtual WSError SetSessionLabel(const sptr& token, const std::string& label) = 0; @@ -445,6 +446,10 @@ public: WMError RemoveSessionBlackList(const std::unordered_set& bundleNames, const std::unordered_set& privacyWindowTags) override { return WMError::WM_OK; } WMError GetPiPSettingSwitchStatus(bool& switchStatus) override { return WMError::WM_OK; } + WMError UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) override + { + return WMError::WM_OK; + } }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_INTERFACE_H diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h index 285e7f6ac8..c105a18d4f 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h @@ -183,6 +183,7 @@ public: WMError RemoveSessionBlackList(const std::unordered_set& bundleNames, const std::unordered_set& privacyWindowTags) override; WMError GetPiPSettingSwitchStatus(bool& switchStatus) override; + WMError UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) override; private: template diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h index 57ca3b9ae6..578ede2ce0 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h @@ -150,6 +150,7 @@ private: int HandleAddSessionBlackList(MessageParcel& data, MessageParcel& reply); int HandleRemoveSessionBlackList(MessageParcel& data, MessageParcel& reply); int HandleGetPiPSettingSwitchStatus(MessageParcel& data, MessageParcel& reply); + int HandleUpdateOutline(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_STUB_H \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1b09735036..3b6b8bb115 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4461,6 +4461,11 @@ void SceneSessionManager::NotifyRecoveringFinished() recoveringFinished_ = true; recoverSubSessionCacheMap_.clear(); recoverDialogSessionCacheMap_.clear(); + if (needRecoverOutline_) { + TLOGNI(WmsLogTag::WMS_ANIMATION, "RecoverFinished recover outline."); + UpdateOutlineInner(outlineRemoteObject_, recoverOutlineParams_); + needRecoverOutline_ = false; + } }, __func__); } @@ -17727,6 +17732,101 @@ void SceneSessionManager::NotifySessionScreenLockedChange(bool isScreenLocked) { } } +bool SceneSessionManager::NeedOutline(int32_t persistentId, const std::vector& persistentIdList) +{ + if (std::find(persistentIdList.begin(), persistentIdList.end(), persistentId) != persistentIdList.end()) { + return true; + } + return false; +} + +WMError SceneSessionManager::UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) +{ + TLOGI(WmsLogTag::WMS_ANIMATION, "%{public}s", outlineParams.ToString().c_str()); + if (!SessionPermission::IsSACalling()) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Update outline permission denied."); + return WMError::WM_ERROR_INVALID_PERMISSION; + } + + if (!(systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode())) { + TLOGE(WmsLogTag::WMS_ANIMATION, "This device can not update outline."); + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + + UpdateOutlineInner(remoteObject, outlineParams); + return WMError::WM_OK; +} + +void SceneSessionManager::UpdateOutlineInner(const sptr& remoteObject, + const OutlineParams& outlineParams) +{ + taskScheduler_->PostAsyncTask([this, remoteObject, outlineParams]() { + std::map> sceneSessionMapCopy; + { + std::lock_guard lock(sceneSessionMapMutex_); + sceneSessionMapCopy = sceneSessionMap_; + } + + for (const auto& [persistentId, session] : sceneSessionMapCopy) { + if (session == nullptr) { + TLOGI(WmsLogTag::WMS_ANIMATION, "session is null, id: %{public}d.", persistentId); + continue; + } + if (NeedOutline(persistentId, outlineParams.persistentIds_)) { + session->UpdateSessionOutline(true, outlineParams.outlineStyleParams_); + } else { + OutlineStyleParams defaultParams; + session->UpdateSessionOutline(false, defaultParams); + } + } + AddOutlineRemoteDeathRecipient(remoteObject); + if (!recoveringFinished_) { + recoverOutlineParams_= outlineParams; + needRecoverOutline_ = true; + TLOGI(WmsLogTag::WMS_ANIMATION, "Recovering not finished, cachae outline params."); + } + }, __func__); +} + +void SceneSessionManager::AddOutlineRemoteDeathRecipient(const sptr& remoteObject) +{ + if (remoteObject == nullptr) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Remote object is null."); + return; + } + outlineRemoteObject_ = remoteObject; + if (!outlineRemoteObject_->AddDeathRecipient(outlineRemoteDeath_)) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Add death recipient failed."); + return; + } +} + +void SceneSessionManager::DeleteAllOutline(const sptr& remoteObject) +{ + if (outlineRemoteObject_ == nullptr) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Outline remote object is nullptr."); + return; + } + if (remoteObject != outlineRemoteObject_) { + TLOGE(WmsLogTag::WMS_ANIMATION, "This is not outline remote object died."); + return; + } + std::map> sceneSessionMapCopy; + { + std::lock_guard lock(sceneSessionMapMutex_); + sceneSessionMapCopy = sceneSessionMap_; + } + for (const auto& [persistentId, session] : sceneSessionMapCopy) { + if (session == nullptr) { + TLOGI(WmsLogTag::WMS_ANIMATION, "invalid session, id: %{public}d.", persistentId); + continue; + } + OutlineStyleParams defaultParams; + session->UpdateSessionOutline(false, defaultParams); + } + outlineRemoteObject_ = nullptr; +} + void SceneSessionManager::NotifyIsFullScreenInForceSplitMode(uint32_t uid, bool isFullScreen) { std::unique_lock lock(appHookWindowInfoMapMutex_); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index ff0e9f6d4d..e79cf01ca8 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -3933,4 +3933,44 @@ WMError SceneSessionManagerProxy::GetPiPSettingSwitchStatus(bool& switchStatus) switchStatus = status; return static_cast(ret); } + +WMError SceneSessionManagerProxy::UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Write interface token failed."); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (remoteObject == nullptr || !data.WriteRemoteObject(remoteObject)) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Write remote object failed."); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteParcelable(&outlineParams)) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Write outline params failed."); + return WMError::WM_ERROR_IPC_FAILED; + } + + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Remote is null."); + return WMError::WM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(SceneSessionManagerMessage::TRANS_ID_UPDATE_OUTLINE), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Send request failed."); + return WMError::WM_ERROR_IPC_FAILED; + } + + int32_t ret; + if (!reply.ReadInt32(ret)) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Read reply failed."); + return WMError::WM_ERROR_IPC_FAILED; + } + return static_cast(ret); +} } // namespace OHOS::Rosen 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 61331467e2..ad1741e44a 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 @@ -262,6 +262,8 @@ int SceneSessionManagerStub::ProcessRemoteRequest(uint32_t code, MessageParcel& return HandleGetPiPSettingSwitchStatus(data, reply); case static_cast(SceneSessionManagerMessage::TRANS_ID_RECOVER_WINDOW_PROPERTY_CHANGE_FLAG): return HandleRecoverWindowPropertyChangeFlag(data, reply); + case static_cast(SceneSessionManagerMessage::TRANS_ID_UPDATE_OUTLINE): + return HandleUpdateOutline(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -2483,4 +2485,25 @@ int SceneSessionManagerStub::HandleGetPiPSettingSwitchStatus(MessageParcel& data } return ERR_NONE; } + +int SceneSessionManagerStub::HandleUpdateOutline(MessageParcel& data, MessageParcel& reply) +{ + sptr remoteObject = data.ReadRemoteObject(); + if (!remoteObject) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Read remote object failed."); + return ERR_INVALID_DATA; + } + sptr outlineParams = data.ReadParcelable(); + if (!outlineParams) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Read outline params failed."); + return ERR_INVALID_DATA; + } + WMError ret = UpdateOutline(remoteObject, *outlineParams); + + if (!reply.WriteUint32(static_cast(ret))) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Write errCode failed."); + return ERR_INVALID_DATA; + } + return ERR_NONE; +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_proxy_test.cpp b/window_scene/test/unittest/scene_session_manager_proxy_test.cpp index abb741b146..93673a3aad 100644 --- a/window_scene/test/unittest/scene_session_manager_proxy_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_proxy_test.cpp @@ -2023,6 +2023,69 @@ HWTEST_F(sceneSessionManagerProxyTest, RemoveSessionBlackList02, TestSize.Level1 EXPECT_EQ(ret, WMError::WM_OK); } +/** + * @tc.name: UpdateOutline + * @tc.desc: UpdateOutline + * @tc.type: FUNC + */ +HWTEST_F(sceneSessionManagerProxyTest, UpdateOutline, TestSize.Level1) +{ + MockMessageParcel::ClearAllErrorFlag(); + sptr remoteMocker = sptr::MakeSptr(); + auto proxy = sptr::MakeSptr(remoteMocker); + + sptr remoteObject; + OutlineParams params; + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + WMError ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, ret); + + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); + ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, ret); + + remoteObject = sptr::MakeSptr(); + MockMessageParcel::SetWriteRemoteObjectErrorFlag(true); + ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, ret); + + MockMessageParcel::SetWriteRemoteObjectErrorFlag(false); + MockMessageParcel::SetWriteParcelableErrorFlag(true); + ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, ret); + + MockMessageParcel::SetWriteParcelableErrorFlag(false); + remoteMocker->SetRequestResult(ERR_INVALID_DATA); + ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, ret); + + remoteMocker->SetRequestResult(ERR_NONE); + MockMessageParcel::SetReadInt32ErrorFlag(true); + ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, ret); + + MockMessageParcel::SetReadInt32ErrorFlag(false); + ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_OK, ret); +} + +/** + * @tc.name: UpdateOutline01 + * @tc.desc: UpdateOutline + * @tc.type: FUNC + */ +HWTEST_F(sceneSessionManagerProxyTest, UpdateOutline01, TestSize.Level1) +{ + MockMessageParcel::ClearAllErrorFlag(); + sptr remoteMocker = sptr::MakeSptr(); + auto proxy = sptr::MakeSptr(nullptr); + + sptr remoteObject; + OutlineParams params; + WMError ret = proxy->UpdateOutline(remoteObject, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, ret); +} + /** * @tc.name: RecoverWindowPropertyChangeFlag01 * @tc.desc: RecoverWindowPropertyChangeFlag diff --git a/window_scene/test/unittest/scene_session_manager_stub_test2.cpp b/window_scene/test/unittest/scene_session_manager_stub_test2.cpp index 5f449a36b7..58cba19376 100644 --- a/window_scene/test/unittest/scene_session_manager_stub_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_stub_test2.cpp @@ -215,6 +215,42 @@ HWTEST_F(SceneSessionManagerStubTest2, HandleCreateUIEffectController, Function data.RewindRead(0); EXPECT_EQ(stubMock->HandleCreateUIEffectController(data, reply), ERR_NONE); } + +/** + * @tc.name: HandleUpdateOutline + * @tc.desc: test HandleUpdateOutline + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerStubTest2, HandleUpdateOutline, TestSize.Level1) +{ + MockMessageParcel::ClearAllErrorFlag(); + MessageParcel data; + MessageParcel reply; + MessageOption option; + uint32_t code = static_cast( + ISceneSessionManager::SceneSessionManagerMessage::TRANS_ID_UPDATE_OUTLINE); + + auto ret = stub_->ProcessRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, ERR_INVALID_DATA); + + sptr remoteObject = sptr::MakeSptr(); + data.WriteRemoteObject(remoteObject); + ret = stub_->ProcessRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, ERR_INVALID_DATA); + + data.WriteRemoteObject(remoteObject); + OutlineParams params; + data.WriteParcelable(¶ms); + MockMessageParcel::SetWriteInt32ErrorFlag(true); + ret = stub_->ProcessRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, ERR_INVALID_DATA); + + data.WriteRemoteObject(remoteObject); + data.WriteParcelable(¶ms); + MockMessageParcel::SetWriteInt32ErrorFlag(false); + ret = stub_->ProcessRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, ERR_NONE); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp index cf5d7cad16..9fd05dcc46 100644 --- a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp @@ -931,6 +931,21 @@ HWTEST_F(SceneSessionManagerSupplementTest, RecoverAndConnectSpecificSession, Te ASSERT_EQ(ssm_->recoveringFinished_, true); } +/** + * @tc.name: NotifyRecoveringFinished + * @tc.desc: NotifyRecoveringFinished + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerSupplementTest, NotifyRecoveringFinished, TestSize.Level1) +{ + EXPECT_EQ(false, ssm_->needRecoverOutline_); + ssm_->NotifyRecoveringFinished(); + EXPECT_EQ(false, ssm_->needRecoverOutline_); + ssm_->needRecoverOutline_ = true; + ssm_->NotifyRecoveringFinished(); + EXPECT_EQ(false, ssm_->needRecoverOutline_); +} + /** * @tc.name: TestCacheSpecificSessionForRecovering_01 * @tc.desc: Test CacheSpecificSessionForRecovering with recoveringFinished_ is false diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index c003406954..d73c8fd2a6 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -3087,6 +3087,129 @@ HWTEST_F(SceneSessionManagerTest12, NotifyIsFullScreenInForceSplitMode, TestSize ssm_->NotifyIsFullScreenInForceSplitMode(uid, false); EXPECT_EQ(ssm_->fullScreenInForceSplitUidSet_.find(uid) == ssm_->fullScreenInForceSplitUidSet_.end()); } + +/** + * @tc.name: NeedOutline + * @tc.desc: test function : NeedOutline + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, NeedOutline, Function | SmallTest | Level2) +{ + int32_t persistentId = 0; // 0 window persistent id + std::vector persistentIdList; + EXPECT_EQ(ssm_->NeedOutline(persistentId, persistentIdList), false); + persistentIdList.push_back(persistentId); + EXPECT_EQ(ssm_->NeedOutline(persistentId, persistentIdList), true); +} + +/** + * @tc.name: UpdateOutline + * @tc.desc: test function : UpdateOutline + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, UpdateOutline, Function | SmallTest | Level2) +{ + MockAccesstokenKit::MockIsSACalling(false); + auto ssm = sptr::MakeSptr(); + sptr remoteObject = sptr::MakeSptr(); + OutlineParams params; + EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm->UpdateOutline(remoteObject, params)); + + MockAccesstokenKit::MockIsSACalling(true); + EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ssm->UpdateOutline(remoteObject, params)); + + ssm->systemConfig_.freeMultiWindowEnable_ = true; + ssm->systemConfig_.freeMultiWindowSupport_ = true; + EXPECT_EQ(WMError::WM_OK, ssm->UpdateOutline(remoteObject, params)); + + ssm->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + EXPECT_EQ(WMError::WM_OK, ssm->UpdateOutline(remoteObject, params)); +} + +/** + * @tc.name: UpdateOutlineInner + * @tc.desc: test function : UpdateOutlineInner + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, UpdateOutlineInner, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "UpdateOutlineInner"; + info.bundleName_ = "UpdateOutlineInner"; + sptr session0 = nullptr; + sptr session1 = sptr::MakeSptr(info, nullptr); + sptr session2 = sptr::MakeSptr(info, nullptr); + auto ssm = sptr::MakeSptr(); + ssm->sceneSessionMap_.insert({0, session0}); + ssm->sceneSessionMap_.insert({1, session1}); // 1 persistentId + ssm->sceneSessionMap_.insert({2, session2}); // 2 persistentId + OutlineParams params; + params.persistentIdList.push_back(1); // 1 persistentId + ssm->recoveringFinished_ = true; + ssm->UpdateOutlineInner(nullptr, params); + EXPECT_EQ(session1->isOutlineEnabled_, true); + + ssm->recoveringFinished_ = false; + ssm->UpdateOutlineInner(nullptr, params); + EXPECT_EQ(ssm->needRecoverOutline_, True); +} + +/** + * @tc.name: AddOutlineRemoteDeathRecipient + * @tc.desc: test function : AddOutlineRemoteDeathRecipient + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, AddOutlineRemoteDeathRecipient, Function | SmallTest | Level2) +{ + auto ssm = sptr::MakeSptr(); + ssm->AddOutlineRemoteDeathRecipient(nullptr); + EXPECT_EQ(ssm->outlineRemoteObject_, nullPtr); + + sptr remoteObject = sptr::MakeSptr(); + EXPECT_CALL(*remoteObject, AddDeathRecipient(_)). + WillOnce([](const sptr& recipient) { + return false; + }); + ssm->AddOutlineRemoteDeathRecipient(remoteObject); + EXPECT_NE(ssm->outlineRemoteObject_, nullPtr); + + EXPECT_CALL(*remoteObject, AddDeathRecipient(_)). + WillOnce([](const sptr& recipient) { + return true; + }); + ssm->AddOutlineRemoteDeathRecipient(remoteObject); + EXPECT_NE(ssm->outlineRemoteObject_, nullPtr); +} + +/** + * @tc.name: DeleteAllOutline + * @tc.desc: test function : DeleteAllOutline + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, DeleteAllOutline, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "DeleteAllOutline"; + info.bundleName_ = "DeleteAllOutline"; + sptr session0 = nullptr; + sptr session1 = sptr::MakeSptr(info, nullptr); + session1->isOutlineEnabled_ = true; + auto ssm = sptr::MakeSptr(); + ssm->sceneSessionMap_.insert({0, session0}); + ssm->sceneSessionMap_.insert({1, session1}); // 1 persistentId + + ssm->DeleteAllOutline(nullptr); + EXPECT_EQ(session1->isOutlineEnabled_, true); + + sptr remoteObject = sptr::MakeSptr(); + ssm->outlineRemoteObject_ = sptr::MakeSptr(); + ssm->DeleteAllOutline(remoteObject); + EXPECT_NE(ssm->outlineRemoteObject_, nullptr); + + ssm->DeleteAllOutline(ssm->outlineRemoteObject_); + EXPECT_EQ(session1->isOutlineEnabled_, true); + EXPECT_EQ(ssm->outlineRemoteObject_, nullptr); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index dc47322122..7d94ce3b3c 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -1271,6 +1271,18 @@ HWTEST_F(WindowSessionTest2, UpdateSesionState, TestSize.Level1) ASSERT_EQ(session_->state_, SessionState::STATE_CONNECT); } +/** + * @tc.name: UpdateSesionState01 + * @tc.desc: UpdateSesionState + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest2, UpdateSesionState01, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + session_->UpdateSessionState(SessionState::STATE_DISCONNECT); + ASSERT_EQ(session_->state_, SessionState::STATE_DISCONNECT); +} + /** * @tc.name: GetTouchable * @tc.desc: GetTouchable diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index 12ef0f99e1..a4f2f824ee 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -424,6 +424,19 @@ HWTEST_F(WindowSessionTest4, SetSessionState, TestSize.Level1) ASSERT_EQ(state03, session_->state_); } +/** + * @tc.name: SetSessionState01 + * @tc.desc: SetSessionState + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, SetSessionState01, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + SessionState state = SessionState::STATE_DISCONNECT; + session_->SetSessionState(state03); + ASSERT_EQ(state, session_->state_); +} + /** * @tc.name: SetFocusable03 * @tc.desc: SetFocusable @@ -1568,6 +1581,62 @@ HWTEST_F(WindowSessionTest4, SetIsShowDecorInFreeMultiWindow02, TestSize.Level1) WSError result02 = session_->SetIsShowDecorInFreeMultiWindow(isShow); EXPECT_EQ(result02, WSError::WS_OK); } + +/** + * @tc.name: UpdateSessionOutline + * @tc.desc: Test func UpdateSessionOutline + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, UpdateSessionOutline, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + + OutlineStyleParams defaultParams; + bool enabled = false; + session_->UpdateSessionOutline(enabled, defaultParams); + EXPECT_EQ(session_->isOutlineEnabled_, false); + + enabled = true; + session_->UpdateSessionOutline(enabled, defaultParams); + EXPECT_EQ(session_->isOutlineEnabled_, true); + + defaultParams.outlineColor_ = OUTLIEN_COLOR_NO_ALPHA; + session_->UpdateSessionOutline(enabled, defaultParams); + EXPECT_EQ(session_->outlineStyleParams_.outlineColor_, OUTLIEN_COLOR_NO_ALPHA); +} + +/** + * @tc.name: SetOutlineParamsChangeCallback + * @tc.desc: Test func SetOutlineParamsChangeCallback + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, SetOutlineParamsChangeCallback, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + session_->SetOutlineParamsChangeCallback(nullptr); + EXPECT_EQ(session_->outlineParamsChangeCallback_, nullptr); + + auto func = [](bool enabled, const OutlineStyleParams& outlineStyleParams) {}; + session_->SetOutlineParamsChangeCallback(std::move(func)); + EXPECT_NE(session_->outlineParamsChangeCallback_, nullptr); +} + +/** + * @tc.name: UpdateSessionOutline01 + * @tc.desc: Test func UpdateSessionOutline + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, UpdateSessionOutline01, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + OutlineStyleParams defaultParams; + defaultParams.outlineColor_ = OUTLIEN_COLOR_ALPHA_OPAQUE; + bool enabled = true; + session_->UpdateSessionOutline(enabled, defaultParams); + EXPECT_EQ(session_->outlineStyleParams_.outlineColor_, OUTLIEN_COLOR_ALPHA_OPAQUE); +} + + } // namespace } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 6367df9994..298ccb5032 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -45,6 +45,7 @@ public: using SessionRecoverCallbackFunc = std::function; using UIEffectRecoverCallbackFunc = std::function; using WMSConnectionChangedCallbackFunc = std::function; + using OutlineRecoverCallbackFunc = std::function; virtual WMError CreateWindow(sptr& window, sptr& windowProperty, std::shared_ptr surfaceNode, uint32_t& windowId, const sptr& token); virtual WMError AddWindow(sptr& windowProperty); @@ -223,6 +224,13 @@ public: */ WMError GetPiPSettingSwitchStatus(bool& switchStatus); + /* + * Window outline + */ + void RegisterOutlineRecoverCallbackFunc(const OutlineRecoverCallbackFunc& callback); + void UnregisterOutlineRecoverCallbackFunc(); + WMError UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams); + ~WindowAdapter() override; private: @@ -261,6 +269,9 @@ private: std::mutex effectMutex_; std::map uiEffectRecoverCallbackFuncMap_; bool recoverInitialized_ = false; + + std::mutex outlineMutex_; + OutlineRecoverCallbackFunc outlineRecoverCallbackFunc_; // above guarded by mutex_ }; } // namespace Rosen diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 5f67dcc971..258796bb84 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -577,6 +577,18 @@ void WindowAdapter::WindowManagerAndSessionRecover() TLOGE(WmsLogTag::WMS_RECOVER, "ui effect create failed, id: %{public}d, reason %{public}d", it.first, ret); } } + + OutlineRecoverCallbackFunc outlineRecoverCallbackFunc; + { + std::lock_guard lock(outlineMutex_); + outlineRecoverCallbackFunc = outlineRecoverCallbackFunc_; + } + if (outlineRecoverCallbackFunc) { + auto ret = outlineRecoverCallbackFunc(); + if (ret != WMError::WM_OK) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Recover outline failed, ret: %{public}d.", ret); + } + } } WMError WindowAdapter::RecoverWindowPropertyChangeFlag() @@ -1424,5 +1436,25 @@ WMError WindowAdapter::RemoveSessionBlackList( CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); return wmsProxy->RemoveSessionBlackList(bundleNames, privacyWindowTags); } + +void WindowAdapter::RegisterOutlineRecoverCallbackFunc(const OutlineRecoverCallbackFunc& callback) +{ + std::lock_guard lock(outlineMutex_); + outlineRecoverCallbackFunc_ = callback; +} + +void WindowAdapter::UnregisterOutlineRecoverCallbackFunc() +{ + std::lock_guard lock(outlineMutex_); + outlineRecoverCallbackFunc_ = nullptr; +} + +WMError WindowAdapter::UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + auto wmsProxy = GetWindowManagerServiceProxy(); + CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); + return wmsProxy->UpdateOutline(remoteObject, outlineParams); +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index aeff5a314c..9c67ed3718 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -551,6 +551,8 @@ WindowManager::~WindowManager() TLOGI(WmsLogTag::WMS_SCB, "destroyed"); std::lock_guard lock(mutex_); destroyed_ = true; + SingletonContainer::Get().UnregisterOutlineRecoverCallbackFunc(); + isOutlineRecoverRegistered_ = false; } WindowManager& WindowManager::GetInstance() @@ -2484,5 +2486,63 @@ WMError WindowManager::RemoveSessionBlackList( RemoveSessionBlackList(bundleNames, privacyWindowTags); return ret; } + +WMError WindowManager::UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) +{ + TLOGI(WmsLogTag::WMS_ANIMATION, "%{public}s", outlineParams.ToString().c_str()); + if (remoteObject == nullptr) { + TLOGE(WmsLogTag::WMS_ANIMATION, "The remote object is null."); + return WMError::WM_ERROR_INVALID_PARAM; + } + if (outlineParams.type_ != OutlineType::OUTLINE_FOR_WINDOW) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Can update outline for windows only."); + return WMError::WM_ERROR_INVALID_PARAM; + } + + if (outlineParams.outlineStyleParams_.outlineWidth_ < OUTLINE_WIDTH_MIN || + outlineParams.outlineStyleParams_.outlineWidth_ > OUTLINE_WIDTH_MAX) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Outline width: %{public}d is out of valid range.", + outlineParams.outlineStyleParams_.outlineWidth_); + return WMError::WM_ERROR_INVALID_PARAM; + } + + if (outlineParams.outlineStyleParams_.outlineShape_ >= OutlineShape::OUTLINE_SHAPE_MAX) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Invalid outline shape: %{public}d.", + outlineParams.outlineStyleParams_.outlineShape_); + return WMError::WM_ERROR_INVALID_PARAM; + } + + if (outlineParams.outlineStyleParams_.outlineColor_ > OUTLIEN_COLOR_NO_ALPHA && + (outlineParams.outlineStyleParams_.outlineColor_ & OUTLIEN_COLOR_ALPHA_OPAQUE) != OUTLIEN_COLOR_ALPHA_OPAQUE) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Invalid outline color: %{public}d", + outlineParams.outlineStyleParams_.outlineColor_); + return WMError::WM_ERROR_INVALID_PARAM; + } + + auto ret = SingletonContainer::Get().UpdateOutline(remoteObject, outlineParams); + if (ret != WMError::WM_OK) { + TLOGE(WmsLogTag::WMS_ANIMATION, "Update outline failed, ret: %{public}d.", ret); + return ret; + } + + if (outlineParams.persistentIds_.size() == 0) { + SingletonContainer::Get().UnregisterOutlineRecoverCallbackFunc(); + isOutlineRecoverRegistered_ = false; + TLOGI(WmsLogTag::WMS_ANIMATION, "No window need to be highlight."); + return ret; + } + + outlineRemoteObject_ = remoteObject; + outlineParams_ = outlineParams; + if (isOutlineRecoverRegistered_) { + TLOGI(WmsLogTag::WMS_ANIMATION, "Outline recover callback has already been registered."); + return ret; + } + SingletonContainer::Get().RegisterOutlineRecoverCallbackFunc([this]() -> WMError { + return this->UpdateOutline(this->outlineRemoteObject_, this->outlineParams_); + }); + isOutlineRecoverRegistered_ = true; + return ret; +} } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_adapter_test.cpp b/wm/test/unittest/window_adapter_test.cpp index fc904dcc4f..a9ad3fe891 100644 --- a/wm/test/unittest/window_adapter_test.cpp +++ b/wm/test/unittest/window_adapter_test.cpp @@ -330,12 +330,14 @@ HWTEST_F(WindowAdapterTest, WindowManagerAndSessionRecover, TestSize.Level1) }; windowAdapter.RegisterSessionRecoverCallbackFunc(persistentId, testFunc); windowAdapter.RegisterUIEffectRecoverCallbackFunc(persistentId, testFunc3); + windowAdapter.RegisterOutlineRecoverCallbackFunc(testFunc3); windowAdapter.WindowManagerAndSessionRecover(); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, 1); } windowAdapter.RegisterSessionRecoverCallbackFunc(persistentId, testFunc2); windowAdapter.RegisterUIEffectRecoverCallbackFunc(persistentId, testFunc4); + windowAdapter.RegisterOutlineRecoverCallbackFunc(testFunc4); windowAdapter.WindowManagerAndSessionRecover(); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, 2); @@ -1268,6 +1270,36 @@ HWTEST_F(WindowAdapterTest, WMSDeathRecipient, TestSize.Level1) wmsDeath_->OnRemoteDied(wptr(token)); } +/** + * @tc.name: RegisterAndUnregisterOutlineRecoverCallbackFunc + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, RegisterAndUnregisterOutlineRecoverCallbackFunc, TestSize.Level1) +{ + WindowAdapter windowAdapter; + auto testFunc = [] { + return WMError::WM_OK; + }; + windowAdapter.RegisterOutlineRecoverCallbackFunc(testFunc); + EXPECT_NE(windowAdapter.outlineRecoverCallbackFunc_, nullptr); + windowAdapter.UnregisterOutlineRecoverCallbackFunc(); + EXPECT_EQ(windowAdapter.outlineRecoverCallbackFunc_, nullptr); +} + +/** + * @tc.name: UpdateOutline + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, UpdateOutline, TestSize.Level1) +{ + WindowAdapter windowAdapter; + OutlineParams params; + auto ret = windowAdapter.UpdateOutline(nullptr, params); + EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, err); +} + /** * @tc.name: GetInstance * @tc.desc: normal function diff --git a/wm/test/unittest/window_manager_test.cpp b/wm/test/unittest/window_manager_test.cpp index 89d9f5f768..24b1de7b3a 100644 --- a/wm/test/unittest/window_manager_test.cpp +++ b/wm/test/unittest/window_manager_test.cpp @@ -2429,6 +2429,47 @@ HWTEST_F(WindowManagerTest, RemoveInstanceByUserId, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, WindowManager::RemoveInstanceByUserId(101)); } +/** + * @tc.name: UpdateOutline + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerTest, UpdateOutline, TestSize.Level1) +{ + OutlineParams params; + WMError ret = WindowManager::GetInstance().UpdateOutline(nullptr, params); + EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM); + + sptr remoteObject = sptr::MakeSptr(); + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, params); + EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM); + + params.type_ = OutlineType::OUTLINE_FOR_WINDOW; + params.outlineStyleParams_.outlineWidth_ = 0; + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, params); + EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM); + + params.outlineStyleParams_.outlineWidth_ = OUTLINE_WIDTH_MAX + 1; + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, params); + EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM); + + params.outlineStyleParams_.outlineWidth_ = OUTLINE_WIDTH_DEFAULT; + parsms.outlineStyleParams_.outlineShape_ = OutlineShape::OUTLINE_SHAPE_MAX; + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, params); + EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM); + + parsms.outlineStyleParams_.outlineShape_ = OutlineShape::OUTLINE_SHAPE_FOUR_CORNER; + params.outlineStyleParams_.outlineColor_ = OUTLIEN_COLOR_NO_ALPHA + 1; + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, params); + EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM); + + params.outlineStyleParams_.outlineColor_ = OUTLIEN_COLOR_NO_ALPHA - 1; + ret = WindowManager::GetInstance().UpdateOutline(remoteObject, params); + EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION); + + +} + /** * @tc.name: RegisterWMSConnectionChangedListener * @tc.desc: normal function diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index 8fabfad55d..4cc788bcf6 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -341,6 +341,14 @@ public: * PiP Window */ virtual WMError GetPiPSettingSwitchStatus(bool& switchStatus) { return WMError::WM_OK; } + + /* + * Window outline + */ + virtual WMError UpdateOutline(const sptr& remoteObject, const OutlineParams& outlineParams) + { + return WMError::WM_OK; + } }; } } -- Gitee