From 82163de86fdb477063727eedaec64cd017ab977b Mon Sep 17 00:00:00 2001 From: yangsanjin1 Date: Tue, 29 Jul 2025 14:54:44 +0800 Subject: [PATCH 001/241] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangsanjin1 --- .../unittest/scene_session_manager_test12.cpp | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index e5ec3d08d7..500f0ef3ef 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -1793,6 +1793,80 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground06, TestSize.Leve EXPECT_EQ(hasFloatWindowForeground, false); } +/** + * @tc.name: GetRouterStackInfo01 + * @tc.desc: test function : GetRouterStackInfo01 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetRouterStackInfo01, Function | SmallTest | Level2) +{ + class TestRouterListener : public SessionRouterStackListenerStub { + void SendRouterStackInfo(const sptr& routerStackInfo) override {} + }; + int32_t persistentId = -1; + auto listener = sptr::MakeSptr(); + MockAccesstokenKit::MockIsSystemApp(true); + MockAccesstokenKit::MockIsSACalling(true); + + auto result = ssm_->GetRouterStackInfo(persistentId, listener); + EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); + + result = ssm_->GetRouterStackInfo(persistentId, nullptr); + EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); +} + +/** + * @tc.name: GetRouterStackInfo02 + * @tc.desc: test function : GetRouterStackInfo02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetRouterStackInfo02, Function | SmallTest | Level2) +{ + class TestRouterListener : public SessionRouterStackListenerStub { + void SendRouterStackInfo(const sptr& routerStackInfo) override {} + }; + + SessionInfo info; + info.abilityName_ = "GetRouterStackInfo02"; + info.bundleName_ = "GetRouterStackInfo02"; + info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sptr scenesession = sptr::MakeSptr(info, nullptr); + ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), scneSession}); + + auto listener = sptr::MakeSptr(); + MockAccesstokenKit::MockIsSystemApp(true); + MockAccesstokenKit::MockIsSACalling(true); + + auto result = ssm_->GetRouterStackInfo(sceneSession->GetPersistentId(), listener); + EXPECT_EQ(result, WMError::WM_OK); +} + +/** + * @tc.name: GetRouterStackInfo03 + * @tc.desc: test function : GetRouterStackInfo03 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetRouterStackInfo03, Function | SmallTest | Level2) +{ + MockAccesstokenKit::MockIsSystemApp(false); + MockAccesstokenKit::MockIsSACalling(false); + auto result = ssm_->GetRouterStackInfo(1, nullptr); + EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PERMISSION); + + MockAccesstokenKit::MockIsSystemApp(false); + MockAccesstokenKit::MockIsSACalling(true); + auto result = ssm_->GetRouterStackInfo(1, nullptr); + EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); + + MockAccesstokenKit::MockIsSystemApp(true); + MockAccesstokenKit::MockIsSACalling(false); + auto result = ssm_->GetRouterStackInfo(1, nullptr); + EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); + + MockAccesstokenKit::MockIsSystemApp(true); + MockAccesstokenKit::MockIsSACalling(true); +} + /** * @tc.name: UpdateSessionWithFoldStateChange * @tc.desc: test function : UpdateSessionWithFoldStateChange @@ -1870,6 +1944,102 @@ HWTEST_F(SceneSessionManagerTest12, GetActiveSceneSessionCopy, Function | SmallT EXPECT_EQ(activeSession.empty(), false); } +/** + * @tc.name: GetHookedSessionByModuleName + * @tc.desc: test function : GetHookedSessionByModuleName + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetHookedSessionByModuleName, Function | SmallTest | Level2) +{ + SessionInfo info; + info.bundleName_ = "testBundleName1"; + info.moduleName_ = "testModuleName1"; + info.appIndex_ = 1; + info.appInstanceKey_ = ""; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + sceneSession->property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + auto res = ssm_->GetHookedSessionByModuleName(info); + ASSERT_EQ(res, nullptr); + + ssm_->sceneSessionMap_insert({101, sceneSession}); + res = ssm_->GetHookedSessionByModuleName(info); + ASSERT_EQ(res, sceneSession); + + info.appInstanceKey_ = "testAppInstanceKey1"; + res = ssm_->GetHookedSessionByModuleName(info); + ASSERT_EQ(res, nullptr); + + info.appIndex_ = 2; + res = ssm_->GetHookedSessionByModuleName(info); + ASSERT_EQ(res, nullptr); + + info.moduleName_ = "testModuleName2"; + res = ssm_->GetHookedSessionByModuleName(info); + ASSERT_EQ(res, nullptr); + + info.bundleName_ = "testBundleName2"; + res = ssm_->GetHookedSessionByModuleName(info); + ASSERT_EQ(res, nullptr); +} + +/** + * @tc.name: RequestSceneSession + * @tc.desc: test function : RequestSceneSession + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, RequestSceneSession, Function | SmallTest | Level2) +{ + SessionInfo info; + info.bundleName_ = "testBundleName1"; + info.moduleName_ = "testModuleName1"; + info.abilityName_ = "testAbilityName1"; + info.persistentId_ = 101; + info.appIndex_ = 0; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + sceneSession->property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sceneSession->sessionInfo_.isAbilityHook_ = true; + sptr windowSessionProperty = sptr::MakeSptr(); + ssm_->sceneSessionMap_[101] = sceneSession; + + auto result = ssm_->RequestSceneSession(info, windowSessionProperty); + ASSERT_NE(result, nullptr); + ASSERT_EQ(result->GetSessionInfo().moduleName_, info.moduleName_); +} + +/** + * @tc.name: RegisterSceneSessionDestructCallback + * @tc.desc: test function : RegisterSceneSessionDestructCallback + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, RegisterSceneSessionDestructCallback, Function | SmallTest | Level2) +{ + NotifySceneSessionDestructFunc func = [](int32_t persistentId) { return; }; + ssm_->RegisterSceneSessionDestructCallback(std::move(func)); + ASSERT_NE(nullptr, ssm_->onSeceneSessionDestruct_); +} + +/** + * @tc.name: RegisterSceneSessionDestructNotifyManagerFunc + * @tc.desc: test function : RegisterSceneSessionDestructNotifyManagerFunc + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, RegisterSceneSessionDestructNotifyManagerFunc, Function | SmallTest | Level2) +{ + SessionInfo info; + info.bundleName_ = "RegisterSceneSessionDestructNotifyManageFunc"; + info.moduleName_ = "RegisterSceneSessionDestructNotifyManageFunc"; + info.abilityName_ = "RegisterSceneSessionDestructNotifyManageFunc"; + info.persistentId_ = 999; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + NotifySceneSessionDestructFunc func = [](int32_t persistentId) { return; }; + ssm_->RegisterSceneSessionDestructCallback(std::move(func)); + ssm_->RegisterSceneSessionDestructNotifyManagerFunc(sceneSession); + ASSERT_NE(sceneSession->notifySceneSessionDestructFunc_, nullptr); +} + /** * @tc.name: GetKeyboardOccupiedAreaWithRotation1 * @tc.desc: PC device is not compatible -- Gitee From 374a46e19bba6f3f2d47c9266dcbc8df8d6ed5e5 Mon Sep 17 00:00:00 2001 From: yangsanjin1 Date: Tue, 29 Jul 2025 17:22:26 +0800 Subject: [PATCH 002/241] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangsanjin1 --- .../unittest/scene_session_manager_test12.cpp | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 500f0ef3ef..160f22ca72 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -1830,7 +1830,7 @@ HWTEST_F(SceneSessionManagerTest12, GetRouterStackInfo02, Function | SmallTest | info.abilityName_ = "GetRouterStackInfo02"; info.bundleName_ = "GetRouterStackInfo02"; info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - sptr scenesession = sptr::MakeSptr(info, nullptr); + sptr sceneSession = sptr::MakeSptr(info, nullptr); ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), scneSession}); auto listener = sptr::MakeSptr(); @@ -1958,11 +1958,11 @@ HWTEST_F(SceneSessionManagerTest12, GetHookedSessionByModuleName, Function | Sma info.appInstanceKey_ = ""; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - sceneSession->property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); auto res = ssm_->GetHookedSessionByModuleName(info); ASSERT_EQ(res, nullptr); - ssm_->sceneSessionMap_insert({101, sceneSession}); + ssm_->sceneSessionMap_.insert({101, sceneSession}); res = ssm_->GetHookedSessionByModuleName(info); ASSERT_EQ(res, sceneSession); @@ -1996,9 +1996,9 @@ HWTEST_F(SceneSessionManagerTest12, RequestSceneSession, Function | SmallTest | info.abilityName_ = "testAbilityName1"; info.persistentId_ = 101; info.appIndex_ = 0; - sptr sceneSession = sptr::MakeSptr(info, nullptr); + sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - sceneSession->property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sceneSession->sessionInfo_.isAbilityHook_ = true; sptr windowSessionProperty = sptr::MakeSptr(); ssm_->sceneSessionMap_[101] = sceneSession; @@ -2017,7 +2017,7 @@ HWTEST_F(SceneSessionManagerTest12, RegisterSceneSessionDestructCallback, Functi { NotifySceneSessionDestructFunc func = [](int32_t persistentId) { return; }; ssm_->RegisterSceneSessionDestructCallback(std::move(func)); - ASSERT_NE(nullptr, ssm_->onSeceneSessionDestruct_); + ASSERT_NE(nullptr, ssm_->onSceneSessionDestruct_); } /** @@ -2040,6 +2040,26 @@ HWTEST_F(SceneSessionManagerTest12, RegisterSceneSessionDestructNotifyManagerFun ASSERT_NE(sceneSession->notifySceneSessionDestructFunc_, nullptr); } +/** + * @tc.name: UpdateAbilityHookState + * @tc.desc: test function : UpdateAbilityHookState + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, UpdateAbilityHookState, Function | SmallTest | Level2) +{ + SessionInfo info; + info.bundleName_ = "UpdateAbilityHookState_bundle"; + info.moduleName_ = "UpdateAbilityHookState_module"; + info.abilityName_ = "UpdateAbilityHookState_ability"; + info.persistentId_ = 101; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + + ssm_->UpdateAbilityHookState(sceneSession, true); + EXPECT_EQ(true, sceneSession->GetSessionInfo().isAbilityHook_); + +} + /** * @tc.name: GetKeyboardOccupiedAreaWithRotation1 * @tc.desc: PC device is not compatible -- Gitee From b91f72d91c65f34f99348d4cd447e7c849c85913 Mon Sep 17 00:00:00 2001 From: yangsanjin1 Date: Thu, 31 Jul 2025 14:43:52 +0800 Subject: [PATCH 003/241] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangsanjin1 --- .../test/unittest/scene_session_manager_test12.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 160f22ca72..fa3ffffa02 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -1831,7 +1831,7 @@ HWTEST_F(SceneSessionManagerTest12, GetRouterStackInfo02, Function | SmallTest | info.bundleName_ = "GetRouterStackInfo02"; info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), scneSession}); + ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); auto listener = sptr::MakeSptr(); MockAccesstokenKit::MockIsSystemApp(true); @@ -1956,7 +1956,7 @@ HWTEST_F(SceneSessionManagerTest12, GetHookedSessionByModuleName, Function | Sma info.moduleName_ = "testModuleName1"; info.appIndex_ = 1; info.appInstanceKey_ = ""; - sptr sceneSession = sptr::MakeSptr(info, nullptr); + sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); auto res = ssm_->GetHookedSessionByModuleName(info); @@ -1996,7 +1996,7 @@ HWTEST_F(SceneSessionManagerTest12, RequestSceneSession, Function | SmallTest | info.abilityName_ = "testAbilityName1"; info.persistentId_ = 101; info.appIndex_ = 0; - sptr sceneSession = sptr::MakeSptr(info, nullptr); + sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sceneSession->sessionInfo_.isAbilityHook_ = true; @@ -2057,7 +2057,6 @@ HWTEST_F(SceneSessionManagerTest12, UpdateAbilityHookState, Function | SmallTest ssm_->UpdateAbilityHookState(sceneSession, true); EXPECT_EQ(true, sceneSession->GetSessionInfo().isAbilityHook_); - } /** -- Gitee From dcb9467d297c1a6d2bb1664c1ef45902e3f4ff27 Mon Sep 17 00:00:00 2001 From: yangwenxin Date: Fri, 1 Aug 2025 04:23:17 +0000 Subject: [PATCH 004/241] update window_scene/test/unittest/scene_session_manager_test12.cpp. Signed-off-by: yangwenxin --- window_scene/test/unittest/scene_session_manager_test12.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index fa3ffffa02..4d0bdd7999 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -1855,12 +1855,12 @@ HWTEST_F(SceneSessionManagerTest12, GetRouterStackInfo03, Function | SmallTest | MockAccesstokenKit::MockIsSystemApp(false); MockAccesstokenKit::MockIsSACalling(true); - auto result = ssm_->GetRouterStackInfo(1, nullptr); + result = ssm_->GetRouterStackInfo(1, nullptr); EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); MockAccesstokenKit::MockIsSystemApp(true); MockAccesstokenKit::MockIsSACalling(false); - auto result = ssm_->GetRouterStackInfo(1, nullptr); + result = ssm_->GetRouterStackInfo(1, nullptr); EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); MockAccesstokenKit::MockIsSystemApp(true); -- Gitee From 8079b7857d77e31936b74854b49fc39e1d1677f5 Mon Sep 17 00:00:00 2001 From: zhongqihong Date: Wed, 6 Aug 2025 16:05:17 +0800 Subject: [PATCH 005/241] =?UTF-8?q?ani=20=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhongqihong --- .../display_ani/include/display_ani_listener.h | 8 ++++---- .../display_ani/include/display_ani_utils.h | 6 +++--- .../display_ani/src/display_ani.cpp | 12 ++++++------ .../display_ani/src/display_ani_listener.cpp | 2 +- .../display_ani/src/display_ani_manager.cpp | 14 +++++++------- .../display_ani/src/display_ani_utils.cpp | 8 ++++---- .../src/ani_embeddable_window_stage.cpp | 3 +-- .../src/ani_extension_window_listener.cpp | 4 ++-- .../src/ani_extension_window_register_manager.cpp | 3 +-- .../screen_ani/include/screen_ani_manager.h | 6 +++--- .../screen_ani/src/screen_ani_listener.cpp | 2 +- .../screen_ani/src/screen_ani_manager.cpp | 10 +++++----- .../screen_ani/src/screen_ani_utils.cpp | 8 ++++---- .../window_stage_ani/src/ani_window.cpp | 6 ++---- .../window_stage_ani/src/ani_window_manager.cpp | 9 ++++----- .../window_stage_ani/src/ani_window_stage.cpp | 6 ++---- .../window_stage_ani/src/ani_window_utils.cpp | 4 ++-- 17 files changed, 52 insertions(+), 59 deletions(-) diff --git a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h index c79db46195..b6d3c777ae 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h +++ b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h @@ -16,12 +16,12 @@ #ifndef OHOS_ANI_DISPLAY_LISTENER_H #define OHOS_ANI_DISPLAY_LISTENER_H -#include -#include "dm_common.h" -#include "refbase.h" -#include "display_manager.h" #include "ani.h" +#include "display_manager.h" +#include "dm_common.h" #include "event_handler.h" +#include "refbase.h" +#include namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h index 23845605e8..1c56f3aa39 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h +++ b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h @@ -17,12 +17,12 @@ #include #include "ani.h" +#include "dm_common.h" #include "display_ani.h" -#include "singleton_container.h" #include "display_manager.h" -#include "window_manager_hilog.h" -#include "dm_common.h" #include "refbase.h" +#include "singleton_container.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp index ac51ee677e..7b2e040d2c 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp @@ -15,17 +15,17 @@ #include #include "ani.h" +#include "ani_err_utils.h" +#include "display.h" #include "display_ani.h" +#include "display_ani_manager.h" +#include "display_ani_utils.h" #include "display_info.h" -#include "display.h" -#include "singleton_container.h" #include "display_manager.h" -#include "window_manager_hilog.h" #include "dm_common.h" -#include "display_ani_utils.h" #include "refbase.h" -#include "display_ani_manager.h" -#include "ani_err_utils.h" +#include "singleton_container.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp index b412419331..efe956e7da 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp @@ -14,8 +14,8 @@ */ #include "display_ani_listener.h" -#include "window_manager_hilog.h" #include "display_ani_utils.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp index b8861d5902..28c06e8ebc 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp @@ -12,22 +12,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include #include +#include #include "ani.h" -#include "display_ani_listener.h" +#include "ani_err_utils.h" +#include "display.h" #include "display_ani.h" +#include "display_ani_listener.h" #include "display_ani_manager.h" +#include "display_ani_utils.h" #include "display_info.h" -#include "display.h" -#include "singleton_container.h" #include "display_manager.h" -#include "window_manager_hilog.h" #include "dm_common.h" -#include "display_ani_utils.h" #include "refbase.h" -#include "ani_err_utils.h" +#include "singleton_container.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp index 706cda4486..5b4891d47a 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp @@ -16,15 +16,15 @@ #include #include "ani.h" -#include "display_ani_utils.h" +#include "display.h" #include "display_ani.h" +#include "display_ani_utils.h" #include "display_info.h" -#include "display.h" -#include "singleton_container.h" #include "display_manager.h" -#include "window_manager_hilog.h" #include "dm_common.h" #include "refbase.h" +#include "singleton_container.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp index f61e4a3135..7eed7c9efc 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp @@ -13,9 +13,8 @@ * limitations under the License. */ -#include "ani_embeddable_window_stage.h" - #include "ani.h" +#include "ani_embeddable_window_stage.h" #include "window_manager_hilog.h" namespace OHOS { diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp index a9ca7d0160..cdb3169307 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp @@ -13,10 +13,10 @@ * limitations under the License. */ -#include "ani_extension_window_listener.h" - #include + #include "ani.h" +#include "ani_extension_window_listener.h" #include "ani_window_utils.h" #include "event_handler.h" #include "event_runner.h" diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp index 0724ed4c05..836dd7241f 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp @@ -13,10 +13,9 @@ * limitations under the License. */ -#include "ani_extension_window_register_manager.h" - #include "ani.h" #include "ani_extension_window_listener.h" +#include "ani_extension_window_register_manager.h" #include "singleton_container.h" #include "window_manager.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_manager.h b/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_manager.h index ff7d852a41..b98f1a982d 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_manager.h +++ b/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_manager.h @@ -16,12 +16,12 @@ #define SCREEN_MANAGER_ANI_H #include -#include "dm_common.h" -#include "refbase.h" -#include "screen_manager.h" #include "ani.h" +#include "dm_common.h" +#include "refbase.h" #include "screen_ani_listener.h" +#include "screen_manager.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp index cfb53b02b2..88fcec7f10 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp @@ -13,8 +13,8 @@ * limitations under the License. */ #include "screen_ani_listener.h" -#include "window_manager_hilog.h" #include "screen_ani_utils.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp index b1f3a2d9c4..65837e637a 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp @@ -12,18 +12,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include #include +#include #include "ani.h" -#include "singleton_container.h" -#include "window_manager_hilog.h" +#include "ani_err_utils.h" #include "dm_common.h" #include "refbase.h" +#include "screen_ani_listener.h" #include "screen_ani_manager.h" #include "screen_ani_utils.h" -#include "screen_ani_listener.h" -#include "ani_err_utils.h" +#include "singleton_container.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp index ca04305b27..aad779d45d 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp @@ -16,13 +16,13 @@ #include #include "ani.h" -#include "screen_ani_utils.h" +#include "dm_common.h" +#include "refbase.h" #include "screen.h" -#include "singleton_container.h" +#include "screen_ani_utils.h" #include "screen_manager.h" +#include "singleton_container.h" #include "window_manager_hilog.h" -#include "dm_common.h" -#include "refbase.h" namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp index db50789cbd..e07c4bf6c1 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp @@ -13,19 +13,17 @@ * limitations under the License. */ - -#include "ani_window.h" - #include #include #include "ani.h" #include "ani_err_utils.h" +#include "ani_window.h" #include "ani_window_utils.h" #include "window_helper.h" -#include "window_scene.h" #include "window_manager.h" #include "window_manager_hilog.h" +#include "window_scene.h" #include "wm_common.h" using OHOS::Rosen::WindowScene; diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp index eb1ca962ab..c757224879 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp @@ -13,15 +13,14 @@ * limitations under the License. */ -#include "ani_window_manager.h" - #include #include "ani.h" -#include "window_scene.h" -#include "window_manager_hilog.h" -#include "ani_window_utils.h" #include "ani_window.h" +#include "ani_window_manager.h" +#include "ani_window_utils.h" +#include "window_manager_hilog.h" +#include "window_scene.h" namespace OHOS { namespace Rosen { 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 21cb29abf8..fd5d88f179 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 @@ -13,17 +13,15 @@ * limitations under the License. */ - -#include "ani_window_stage.h" - #include #include "ani.h" #include "ani_window.h" #include "ani_window_manager.h" +#include "ani_window_stage.h" #include "ani_window_utils.h" -#include "window_manager_hilog.h" #include "permission.h" +#include "window_manager_hilog.h" #include "window_scene.h" using OHOS::Rosen::WindowScene; diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp index 2d50c99e3d..5be8471b92 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "ani_window_utils.h" #include #include @@ -21,10 +20,11 @@ #include "ani.h" #include "ani_err_utils.h" #include "ani_window.h" +#include "ani_window_utils.h" #include "bundle_constants.h" #include "ipc_skeleton.h" -#include "window_manager_hilog.h" #include "ui_content.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { -- Gitee From 94baccc59b31a1778e8120e60e239be35a83ecb5 Mon Sep 17 00:00:00 2001 From: zhongqihong Date: Wed, 6 Aug 2025 16:10:16 +0800 Subject: [PATCH 006/241] updata Signed-off-by: zhongqihong --- .../src/ani_scene_session_manager.cpp | 7 ++++--- .../src/ani_scene_session_utils.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp index e3d4c6248e..d1a7e728b1 100644 --- a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp @@ -13,13 +13,14 @@ * limitations under the License. */ +#include + +#include "ani.h" #include "ani_scene_session_manager.h" #include "ani_scene_session_utils.h" -#include "ani.h" #include "root_scene.h" -#include "wm_common.h" #include "window_manager_hilog.h" -#include +#include "wm_common.h" namespace OHOS { namespace Rosen { diff --git a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp index 86b4412e8a..4485aa115b 100644 --- a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp +++ b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp @@ -12,9 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "ani.h" #include "ani_err_utils.h" #include "ani_scene_session_utils.h" -#include "ani.h" #include "window_manager_hilog.h" namespace OHOS { -- Gitee From b8af17497880308ecce5b3e105e4b910f311ead6 Mon Sep 17 00:00:00 2001 From: zhongqihong Date: Sat, 9 Aug 2025 14:48:41 +0800 Subject: [PATCH 007/241] updata Signed-off-by: zhongqihong --- .../display_ani/include/display_ani_listener.h | 3 ++- .../display_runtime/display_ani/include/display_ani_utils.h | 1 + .../ani/display_runtime/display_ani/src/ani_err_utils.cpp | 4 +++- .../kits/ani/display_runtime/display_ani/src/display_ani.cpp | 4 +++- .../display_runtime/display_ani/src/display_ani_listener.cpp | 1 + .../display_runtime/display_ani/src/display_ani_manager.cpp | 4 +++- .../ani/display_runtime/display_ani/src/display_ani_utils.cpp | 3 ++- .../include/ani_extension_window_register_manager.h | 1 + .../src/ani_embeddable_window_stage.cpp | 3 ++- .../ani/embeddable_window_stage/src/ani_extension_window.cpp | 3 ++- .../src/ani_extension_window_listener.cpp | 3 ++- .../src/ani_extension_window_register_manager.cpp | 3 ++- .../screen_runtime/screen_ani/include/screen_ani_listener.h | 1 + .../ani/screen_runtime/screen_ani/include/screen_ani_utils.h | 1 + .../kits/ani/screen_runtime/screen_ani/src/ani_err_utils.cpp | 4 +++- .../ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp | 2 ++ .../ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp | 4 +++- .../ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp | 3 ++- .../window_stage_ani/include/ani_window_register_manager.h | 1 + .../window_stage_ani/include/ani_window_utils.h | 2 ++ .../ani/window_runtime/window_stage_ani/src/ani_err_utils.cpp | 4 +++- .../ani/window_runtime/window_stage_ani/src/ani_window.cpp | 3 ++- .../window_stage_ani/src/ani_window_manager.cpp | 3 ++- .../window_stage_ani/src/ani_window_register_manager.cpp | 1 + .../window_runtime/window_stage_ani/src/ani_window_stage.cpp | 3 ++- .../window_runtime/window_stage_ani/src/ani_window_utils.cpp | 3 ++- .../include/ani_scene_session_utils.h | 1 + .../scene_session_manager_ani/src/ani_err_utils.cpp | 1 + .../src/ani_scene_session_manager.cpp | 3 ++- .../scene_session_manager_ani/src/ani_scene_session_utils.cpp | 3 ++- 30 files changed, 57 insertions(+), 19 deletions(-) diff --git a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h index b6d3c777ae..f7d2da9067 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h +++ b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_listener.h @@ -16,12 +16,13 @@ #ifndef OHOS_ANI_DISPLAY_LISTENER_H #define OHOS_ANI_DISPLAY_LISTENER_H +#include + #include "ani.h" #include "display_manager.h" #include "dm_common.h" #include "event_handler.h" #include "refbase.h" -#include namespace OHOS { namespace Rosen { diff --git a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h index 1c56f3aa39..b2ccbb4374 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h +++ b/interfaces/kits/ani/display_runtime/display_ani/include/display_ani_utils.h @@ -14,6 +14,7 @@ */ #ifndef OHOS_ANI_DISPLAY_UTILS_H #define OHOS_ANI_DISPLAY_UTILS_H + #include #include "ani.h" diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/ani_err_utils.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/ani_err_utils.cpp index e60d854ce2..f9aa1f2cbd 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/ani_err_utils.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/ani_err_utils.cpp @@ -14,10 +14,12 @@ */ #include "ani_err_utils.h" + +#include + #include "display_ani_utils.h" #include "window_manager_hilog.h" -#include namespace OHOS::Rosen { diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp index 7b2e040d2c..613e020d30 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp @@ -12,12 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "display_ani.h" + #include #include "ani.h" #include "ani_err_utils.h" #include "display.h" -#include "display_ani.h" #include "display_ani_manager.h" #include "display_ani_utils.h" #include "display_info.h" diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp index efe956e7da..979f667b9e 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_listener.cpp @@ -14,6 +14,7 @@ */ #include "display_ani_listener.h" + #include "display_ani_utils.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp index 28c06e8ebc..28b2a50193 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp @@ -12,6 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "display_ani_manager.h" + #include #include @@ -20,7 +23,6 @@ #include "display.h" #include "display_ani.h" #include "display_ani_listener.h" -#include "display_ani_manager.h" #include "display_ani_utils.h" #include "display_info.h" #include "display_manager.h" diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp index 5b4891d47a..fcbc001f6a 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp @@ -13,12 +13,13 @@ * limitations under the License. */ +#include "display_ani_utils.h" + #include #include "ani.h" #include "display.h" #include "display_ani.h" -#include "display_ani_utils.h" #include "display_info.h" #include "display_manager.h" #include "dm_common.h" diff --git a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h index ed367b67ff..620e27f027 100644 --- a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h +++ b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h @@ -17,6 +17,7 @@ #define OHOS_ANI_EXTENSION_WINDOW_REGISTER_MANAGER_H #include + #include "ani.h" #include "ani_extension_window_listener.h" #include "refbase.h" diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp index 7eed7c9efc..f61e4a3135 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_embeddable_window_stage.cpp @@ -13,8 +13,9 @@ * limitations under the License. */ -#include "ani.h" #include "ani_embeddable_window_stage.h" + +#include "ani.h" #include "window_manager_hilog.h" namespace OHOS { diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp index 59b5898054..9edbce47fd 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp @@ -13,8 +13,9 @@ * limitations under the License. */ -#include "ani.h" #include "ani_extension_window.h" + +#include "ani.h" #include "ani_extension_window_register_manager.h" #include "extension_window_impl.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp index cdb3169307..b03454baea 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp @@ -13,10 +13,11 @@ * limitations under the License. */ +#include "ani_extension_window_listener.h" + #include #include "ani.h" -#include "ani_extension_window_listener.h" #include "ani_window_utils.h" #include "event_handler.h" #include "event_runner.h" diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp index 836dd7241f..0724ed4c05 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp @@ -13,9 +13,10 @@ * limitations under the License. */ +#include "ani_extension_window_register_manager.h" + #include "ani.h" #include "ani_extension_window_listener.h" -#include "ani_extension_window_register_manager.h" #include "singleton_container.h" #include "window_manager.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_listener.h b/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_listener.h index e672481e92..028a2bab85 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_listener.h +++ b/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_listener.h @@ -17,6 +17,7 @@ #define OHOS_ANI_SCREEN_LISTENER_H #include + #include "ani.h" #include "event_handler.h" #include "screen_manager.h" diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_utils.h b/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_utils.h index f5923bb245..f8441075f0 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_utils.h +++ b/interfaces/kits/ani/screen_runtime/screen_ani/include/screen_ani_utils.h @@ -14,6 +14,7 @@ */ #ifndef OHOS_ANI_SCREEN_UTILS_H #define OHOS_ANI_SCREEN_UTILS_H + #include #include "ani.h" diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/ani_err_utils.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/ani_err_utils.cpp index 47ace25c35..4c6b2b4fb4 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/ani_err_utils.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/ani_err_utils.cpp @@ -14,10 +14,12 @@ */ #include "ani_err_utils.h" + +#include + #include "screen_ani_utils.h" #include "window_manager_hilog.h" -#include namespace OHOS::Rosen { constexpr const char* DM_ERROR_MSG_OK = "ok"; diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp index 88fcec7f10..2ba1df85c9 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_listener.cpp @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "screen_ani_listener.h" + #include "screen_ani_utils.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp index 65837e637a..46d92d6a17 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp @@ -12,6 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "screen_ani_manager.h" + #include #include @@ -20,7 +23,6 @@ #include "dm_common.h" #include "refbase.h" #include "screen_ani_listener.h" -#include "screen_ani_manager.h" #include "screen_ani_utils.h" #include "singleton_container.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp index aad779d45d..2cf382606b 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp @@ -13,13 +13,14 @@ * limitations under the License. */ +#include "screen_ani_utils.h" + #include #include "ani.h" #include "dm_common.h" #include "refbase.h" #include "screen.h" -#include "screen_ani_utils.h" #include "screen_manager.h" #include "singleton_container.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_register_manager.h b/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_register_manager.h index 9f9648e7e4..efb575f086 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_register_manager.h +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_register_manager.h @@ -18,6 +18,7 @@ #include #include + #include "ani_window_listener.h" #include "refbase.h" #include "window.h" diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_utils.h b/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_utils.h index b175edc30b..caa75b7395 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_utils.h +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/include/ani_window_utils.h @@ -15,7 +15,9 @@ #ifndef OHOS_JS_WINDOW_UTILS_H #define OHOS_JS_WINDOW_UTILS_H + #include + #include "ani.h" #include "native_engine/native_engine.h" #include "native_engine/native_value.h" diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_err_utils.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_err_utils.cpp index e30755d2d0..c984078fc4 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_err_utils.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_err_utils.cpp @@ -14,10 +14,12 @@ */ #include "ani_err_utils.h" + +#include + #include "ani_window_utils.h" #include "window_manager_hilog.h" -#include namespace OHOS::Rosen { constexpr const char* WM_ERROR_MSG_OK = "ok"; diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp index e07c4bf6c1..3abd7b9757 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp @@ -13,12 +13,13 @@ * limitations under the License. */ +#include "ani_window.h" + #include #include #include "ani.h" #include "ani_err_utils.h" -#include "ani_window.h" #include "ani_window_utils.h" #include "window_helper.h" #include "window_manager.h" diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp index c757224879..f8d18dc151 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_manager.cpp @@ -13,11 +13,12 @@ * limitations under the License. */ +#include "ani_window_manager.h" + #include #include "ani.h" #include "ani_window.h" -#include "ani_window_manager.h" #include "ani_window_utils.h" #include "window_manager_hilog.h" #include "window_scene.h" diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_register_manager.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_register_manager.cpp index 1219f1c737..55697e2dff 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_register_manager.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_register_manager.cpp @@ -14,6 +14,7 @@ */ #include "ani_window_register_manager.h" + #include "singleton_container.h" #include "window_manager.h" #include "window_manager_hilog.h" 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 fd5d88f179..a022dc288e 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 @@ -13,12 +13,13 @@ * limitations under the License. */ +#include "ani_window_stage.h" + #include #include "ani.h" #include "ani_window.h" #include "ani_window_manager.h" -#include "ani_window_stage.h" #include "ani_window_utils.h" #include "permission.h" #include "window_manager_hilog.h" diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp index 5be8471b92..caa5b4f673 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_utils.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "ani_window_utils.h" + #include #include #include @@ -20,7 +22,6 @@ #include "ani.h" #include "ani_err_utils.h" #include "ani_window.h" -#include "ani_window_utils.h" #include "bundle_constants.h" #include "ipc_skeleton.h" #include "ui_content.h" diff --git a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/include/ani_scene_session_utils.h b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/include/ani_scene_session_utils.h index 4531513544..6439b85870 100644 --- a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/include/ani_scene_session_utils.h +++ b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/include/ani_scene_session_utils.h @@ -15,6 +15,7 @@ #ifndef OHOS_ANI_SCENE_SESSION_UTILS_H #define OHOS_ANI_SCENE_SESSION_UTILS_H + #include "ani.h" #include "wm_common.h" diff --git a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_err_utils.cpp b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_err_utils.cpp index bdb8005778..958ee3274c 100644 --- a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_err_utils.cpp +++ b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_err_utils.cpp @@ -14,6 +14,7 @@ */ #include "ani_err_utils.h" + #include "ani_scene_session_utils.h" #include "window_manager_hilog.h" diff --git a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp index d1a7e728b1..1a034b41cf 100644 --- a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp @@ -13,10 +13,11 @@ * limitations under the License. */ +#include "ani_scene_session_manager.h" + #include #include "ani.h" -#include "ani_scene_session_manager.h" #include "ani_scene_session_utils.h" #include "root_scene.h" #include "window_manager_hilog.h" diff --git a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp index 4485aa115b..276f8950c7 100644 --- a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp +++ b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_utils.cpp @@ -13,9 +13,10 @@ * limitations under the License. */ +#include "ani_scene_session_utils.h" + #include "ani.h" #include "ani_err_utils.h" -#include "ani_scene_session_utils.h" #include "window_manager_hilog.h" namespace OHOS { -- Gitee From 31d2ab786f7505496264b3590aa7eba0c248184f Mon Sep 17 00:00:00 2001 From: xiaomin1017 Date: Wed, 13 Aug 2025 03:18:13 +0000 Subject: [PATCH 008/241] =?UTF-8?q?sceneSession=20js=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=BC=80=E6=94=BEwindowName=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaomin1017 --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 2 ++ 1 file changed, 2 insertions(+) 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 d17da56b6b..af23801536 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 @@ -429,6 +429,8 @@ napi_value JsSceneSession::Create(napi_env env, const sptr& sessio CreateJsValue(env, static_cast(session->IsSystemKeyboard()))); napi_set_named_property(env, objValue, "bundleName", CreateJsValue(env, session->GetSessionInfo().bundleName_)); + napi_set_named_property(env, objValue, "windowName", + CreateJsValue(env, session->GetWindowName())); napi_set_named_property(env, objValue, "zLevel", CreateJsValue(env, static_cast(session->GetSubWindowZLevel()))); napi_set_named_property(env, objValue, "subWindowOutlineEnabled", -- Gitee From 744be95bee66a4907d6299033d3c57a465fb9a21 Mon Sep 17 00:00:00 2001 From: l30067243 Date: Thu, 14 Aug 2025 15:37:22 +0800 Subject: [PATCH 009/241] fix: need commit after calling SetSecurityLayer Signed-off-by: l30067243 --- window_scene/session/host/src/scene_session.cpp | 10 ++++++---- .../session_manager/src/scene_session_manager.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index a7782f0254..316e78609b 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -422,6 +422,7 @@ WSError SceneSession::ForegroundTask(const sptr& property auto leashWinSurfaceNode = session->GetLeashWinSurfaceNode(); if (leashWinSurfaceNode && sessionProperty) { bool lastPrivacyMode = sessionProperty->GetPrivacyMode() || sessionProperty->GetSystemPrivacyMode(); + AutoRSTransaction trans(GetRSUIContext()); leashWinSurfaceNode->SetSecurityLayer(lastPrivacyMode); } session->MarkAvoidAreaAsDirty(); @@ -4624,7 +4625,8 @@ void SceneSession::SetPrivacyMode(bool isPrivacy) } bool lastPrivacyMode = property->GetPrivacyMode() || property->GetSystemPrivacyMode(); if (lastPrivacyMode == isPrivacy) { - TLOGW(WmsLogTag::WMS_ATTRIBUTE, "mode is same as: %{public}d", isPrivacy); + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "mode is same as: win=[%{public}d, %{public}s], isPrivacy=%{public}d", + GetWindowId(), GetWindowName().c_str(), isPrivacy); return; } property->SetPrivacyMode(isPrivacy); @@ -4649,9 +4651,9 @@ void SceneSession::NotifyPrivacyModeChange() { bool isPrivacyMode = GetSessionProperty()->GetPrivacyMode(); bool currExtPrivacyMode = combinedExtWindowFlags_.privacyModeFlag; - TLOGD(WmsLogTag::WMS_SCB, "id:%{public}d, currExtPrivacyMode:%{public}d, session property privacyMode: %{public}d, " - "last privacyMode:%{public}d", - GetPersistentId(), currExtPrivacyMode, isPrivacyMode, isPrivacyMode_); + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "win:[%{public}d, %{public}s], currExtPrivacyMode:%{public}d, " + "session property privacyMode:%{public}d, last privacyMode:%{public}d", + GetPersistentId(), GetWindowName().c_str(), currExtPrivacyMode, isPrivacyMode, isPrivacyMode_); bool mixedPrivacyMode = currExtPrivacyMode || isPrivacyMode; if (mixedPrivacyMode != isPrivacyMode_) { isPrivacyMode_ = mixedPrivacyMode; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index abaf295c08..cab28ce0a5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8429,8 +8429,8 @@ bool SceneSessionManager::JudgeNeedNotifyPrivacyInfo(DisplayId displayId, } } while (false); - TLOGD(WmsLogTag::WMS_MAIN, "display[%{public}" PRIu64 "] need notify privacy state: %{public}d.", - displayId, needNotify); + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "display=%{public}" PRIu64 ", needNotify=%{public}d, sendTimes=%{public}d", + displayId, needNotify, reSendTimes); if (needNotify) { reSendTimes = MAX_RESEND_TIMES; privacyBundleMap_[displayId] = privacyBundles; @@ -8462,7 +8462,7 @@ void SceneSessionManager::UpdatePrivateStateAndNotify(uint32_t persistentId) !bundleListForNotify.empty() || specialExtWindowHasPrivacyMode_.load()); ScreenSessionManagerClient::GetInstance().SetScreenPrivacyWindowList(displayId, bundleListForNotify); if (!bundleListForNotify.empty()) { - TLOGI(WmsLogTag::WMS_MAIN, "first privacy window bundle name: %{public}s.", bundleListForNotify[0].c_str()); + TLOGW(WmsLogTag::WMS_ATTRIBUTE, "first privacy window bundle: %{public}s", bundleListForNotify[0].c_str()); } for (const auto& bundle : bundleListForNotify) { TLOGD(WmsLogTag::WMS_MAIN, "notify dms privacy bundle, display=%{public}" PRIu64 ", bundle=%{public}s.", @@ -8508,6 +8508,8 @@ void SceneSessionManager::GetSceneSessionPrivacyModeBundles(DisplayId displayId, sceneSession->GetCombinedExtWindowFlags().privacyModeFlag; bool IsSystemWindowVisible = sceneSession->GetSessionInfo().isSystem_ && sceneSession->IsVisible(); if ((isForeground || IsSystemWindowVisible) && isPrivate) { + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "found privacy win=[%{public}d, %{public}s]", + sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str()); if (!sceneSession->GetSessionInfo().bundleName_.empty()) { privacyBundles.insert(sceneSession->GetSessionInfo().bundleName_); } else { -- Gitee From 4a076935ec2cf8b50bc9cb26aa6b51b8ce84126e Mon Sep 17 00:00:00 2001 From: yecong2332 Date: Thu, 14 Aug 2025 16:00:02 +0800 Subject: [PATCH 010/241] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A2=84=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yecong2332 --- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++++- 1 file changed, 5 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 5e81bc652b..8970728f75 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5545,6 +5545,10 @@ void SceneSessionManager::RemovePreLoadStartingWindowFromMap(const SessionInfo& void SceneSessionManager::PreLoadStartingWindow(sptr sceneSession) { + if (!systemConfig_.IsPhoneWindow()) { + TLOGD(WmsLogTag::WMS_PATTERN, "only for phone"); + return; + } const char* const where = __func__; auto loadTask = [this, weakSceneSession = wptr(sceneSession), where]() { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:PreLoadStartingWindow"); @@ -5609,7 +5613,7 @@ bool SceneSessionManager::CheckAndGetPreLoadResourceId(const StartingWindowInfo& return false; } const auto& extName = iconPath.substr(pos); - if (extName != ".png" && extName != ".jpg") { + if (extName != ".png" && extName != ".jpg" && extName != ".webp" && extName != ".astc") { TLOGI(WmsLogTag::WMS_PATTERN, "format not need preLoad: %{private}s", iconPath.c_str()); return false; } -- Gitee From 4bd6791d046b08360a17a808e3921150a8ced3f4 Mon Sep 17 00:00:00 2001 From: l30067243 Date: Thu, 14 Aug 2025 16:58:30 +0800 Subject: [PATCH 011/241] fix syntax error Signed-off-by: l30067243 --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 316e78609b..5e2bb1d2ed 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -422,7 +422,7 @@ WSError SceneSession::ForegroundTask(const sptr& property auto leashWinSurfaceNode = session->GetLeashWinSurfaceNode(); if (leashWinSurfaceNode && sessionProperty) { bool lastPrivacyMode = sessionProperty->GetPrivacyMode() || sessionProperty->GetSystemPrivacyMode(); - AutoRSTransaction trans(GetRSUIContext()); + AutoRSTransaction trans(session->GetRSUIContext()); leashWinSurfaceNode->SetSecurityLayer(lastPrivacyMode); } session->MarkAvoidAreaAsDirty(); -- Gitee From 3a1029ac452bc6b1e6dec21274730214150312e6 Mon Sep 17 00:00:00 2001 From: shuangshuangliu Date: Wed, 13 Aug 2025 16:37:18 +0800 Subject: [PATCH 012/241] =?UTF-8?q?TDD=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: Ic07f2fa09a444739ebefc7aca5b7dd0b15b90327 --- wm/test/unittest/BUILD.gn | 15 +++ .../floating_ball_manager_new_test.cpp | 116 ++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 wm/test/unittest/floating_ball_manager_new_test.cpp diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index b83717f68e..1df07ee488 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -19,6 +19,7 @@ group("unittest") { testonly = true deps = [ + ":wm_floating_ball_manager_new_test", ":wm_floating_ball_manager_test", ":wm_floating_ball_test", ":wm_gtx_input_event_sender_test", @@ -661,6 +662,20 @@ ohos_unittest("wm_floating_ball_manager_test") { ] } +ohos_unittest("wm_floating_ball_manager_new_test") { + module_out_path = module_out_path + + sources = [ "floating_ball_manager_new_test.cpp" ] + + deps = [ ":wm_unittest_common" ] + + external_deps = [ + "ability_runtime:runtime", + "c_utils:utils", + "hilog:libhilog", + ] +} + ohos_unittest("wm_window_manager_agent_proxy_test") { module_out_path = module_out_path diff --git a/wm/test/unittest/floating_ball_manager_new_test.cpp b/wm/test/unittest/floating_ball_manager_new_test.cpp new file mode 100644 index 0000000000..7f2d2d9049 --- /dev/null +++ b/wm/test/unittest/floating_ball_manager_new_test.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2023 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 "floating_ball_manager.h" +#include "wm_common.h" +#include "parameters.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class FloatingBallManagerNewTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +class MockNewWindow : public Window { +public: + MockNewWindow() {}; + ~MockNewWindow() {}; +}; + +void FloatingBallManagerNewTest::SetUpTestCase() +{ +} + +void FloatingBallManagerNewTest::TearDownTestCase() +{ +} + +void FloatingBallManagerNewTest::SetUp() +{ +} + +void FloatingBallManagerNewTest::TearDown() +{ +} + +namespace { + +/** + * @tc.name: activeControllerPtrNull + * @tc.desc: activeControllerPtrNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallManagerNewTest, activeControllerPtrNull, TestSize.Level1) +{ + auto mw = sptr::MakeSptr(); + ASSERT_NE(nullptr, mw); + auto fbController = sptr::MakeSptr(mw, 101, nullptr); + // null fbController + EXPECT_EQ(false, FloatingBallManager::IsActiveController(fbController)); + EXPECT_EQ(false, FloatingBallManager::HasActiveController()); +} + +/** + * @tc.name: activeControllerDoFbActionEvent + * @tc.desc: activeControllerDoFbActionEvent + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallManagerNewTest, activeControllerDoFbActionEvent, TestSize.Level1) +{ + auto mw = sptr::MakeSptr(); + ASSERT_NE(nullptr, mw); + auto fbController = sptr::MakeSptr(mw, 101, nullptr); + std::string clickAction = "click"; + std::string closeAction = "close"; + FloatingBallManager::DoFbActionEvent("on"); + FloatingBallManager::DoFbActionEvent(clickAction); + FloatingBallManager::DoFbActionEvent(closeAction); + FloatingBallManager::DoDestroy(); + + // has fbController + FloatingBallManager::SetActiveController(fbController); + EXPECT_EQ(true, FloatingBallManager::IsActiveController(fbController)); + EXPECT_EQ(true, FloatingBallManager::HasActiveController()); + FloatingBallManager::DoFbActionEvent(clickAction); + FloatingBallManager::DoFbActionEvent(closeAction); + FloatingBallManager::DoDestroy(); + auto fbController1 = sptr::MakeSptr(mw, 102, nullptr); + FloatingBallManager::RemoveActiveController(fbController1); + FloatingBallManager::RemoveActiveController(fbController); +} + +/** + * @tc.name: IsSupportFloatingBall01 + * @tc.desc: IsSupportFloatingBall01 + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallManagerNewTest, IsSupportFloatingBall01, TestSize.Level1) +{ + const std::string multiWindowUIType = system::GetParameter("const.window.multiWindowUIType", ""); + bool isDeviceSupported = (multiWindowUIType == "HandsetSmartWindow" || multiWindowUIType == "TabletSmartWindow"); + bool isSupportFloatingBall = FloatingBallManager::IsSupportFloatingBall(); + EXPECT_EQ(isDeviceSupported, isSupportFloatingBall); +} +} +} +} \ No newline at end of file -- Gitee From 4f6df9050a087f5cdd8cdc9860973b1cd8ceb636 Mon Sep 17 00:00:00 2001 From: WenJunYuan <1903700887@qq.com> Date: Fri, 15 Aug 2025 10:59:02 +0800 Subject: [PATCH 013/241] =?UTF-8?q?feature:=20=E4=B8=BB=E5=AD=90=E7=AA=97?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E5=90=8C=E4=B8=80=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: WenJunYuan <1903700887@qq.com> --- interfaces/innerkits/wm/window.h | 3 ++- previewer/include/window.h | 2 +- previewer/src/window.cpp | 3 ++- utils/include/rs_adapter.h | 3 ++- utils/src/rs_adapter.cpp | 9 ++++++--- wm/include/window_scene_session_impl.h | 3 ++- wm/include/window_session_impl.h | 3 ++- wm/src/window.cpp | 10 ++++++---- wm/src/window_scene_session_impl.cpp | 3 ++- wm/src/window_session_impl.cpp | 5 +++-- 10 files changed, 28 insertions(+), 16 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index fe67e9d0fd..3575de6218 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -876,7 +876,8 @@ public: */ static sptr Create(const std::string& windowName, sptr& option, const std::shared_ptr& context = nullptr, - WMError& errCode = DefaultCreateErrCode); + WMError& errCode = DefaultCreateErrCode, + const std::shared_ptr& rsUiContext = nullptr); /** * @brief create main/uiextension window with session diff --git a/previewer/include/window.h b/previewer/include/window.h index 7b159c8425..15364944f9 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -136,7 +136,7 @@ class WINDOW_EXPORT Window : public RefBase { public: static sptr Create(const std::string& windowName, sptr& option, const std::shared_ptr& context = nullptr, - WMError& errCode = DefaultCreateErrCode); + WMError& errCode = DefaultCreateErrCode, const std::shared_ptr& rsUIContext = nullptr); static sptr Find(const std::string& windowName); static sptr GetTopWindowWithContext(const std::shared_ptr& context = nullptr); static sptr GetTopWindowWithId(uint32_t mainWinId); diff --git a/previewer/src/window.cpp b/previewer/src/window.cpp index b2d250e8ad..bf203360ee 100644 --- a/previewer/src/window.cpp +++ b/previewer/src/window.cpp @@ -24,7 +24,8 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "Window"}; } sptr Window::Create(const std::string& windowName, sptr& option, - const std::shared_ptr& context, WMError& errCode) + const std::shared_ptr& context, WMError& errCode, + const std::shared_ptr& rsUIContext) { if (option == nullptr) { option = new(std::nothrow) WindowOption(); diff --git a/utils/include/rs_adapter.h b/utils/include/rs_adapter.h index e1fc776e7f..4c88fb9ab1 100644 --- a/utils/include/rs_adapter.h +++ b/utils/include/rs_adapter.h @@ -172,7 +172,8 @@ public: static bool IsClientMultiInstanceEnabled(); static void InitRSUIDirector(std::shared_ptr& rsUIDirector, bool shouldCreateRenderThread = true, - bool isMultiInstance = false); + bool isMultiInstance = false, + const std::shared_ptr& rsUiContext = nullptr); static void SetRSUIContext(const std::shared_ptr& rsNode, const std::shared_ptr& rsUIContext, bool skipCheckInMultiInstance = false); diff --git a/utils/src/rs_adapter.cpp b/utils/src/rs_adapter.cpp index d29b1ea898..2bebb68d2a 100644 --- a/utils/src/rs_adapter.cpp +++ b/utils/src/rs_adapter.cpp @@ -472,7 +472,8 @@ bool RSAdapterUtil::IsClientMultiInstanceEnabled() } void RSAdapterUtil::InitRSUIDirector(std::shared_ptr& rsUIDirector, - bool shouldCreateRenderThread, bool isMultiInstance) + bool shouldCreateRenderThread, bool isMultiInstance, + const std::shared_ptr& rsUiContext) { RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(); if (rsUIDirector) { @@ -482,9 +483,11 @@ void RSAdapterUtil::InitRSUIDirector(std::shared_ptr& rsUIDirector } rsUIDirector = RSUIDirector::Create(); if (rsUIDirector) { - rsUIDirector->Init(shouldCreateRenderThread, isMultiInstance); + rsUIDirector->Init(shouldCreateRenderThread, isMultiInstance, rsUiContext); TLOGI(WmsLogTag::WMS_SCB, - "Create RSUIDirector: %{public}s", RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str()); + "Create RSUIDirector: %{public}s, rsUIContext: %{public}s", + RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str(), + RSAdapterUtil::RSUIContextToStr(rsUiContext).c_str(),); } else { TLOGE(WmsLogTag::WMS_SCB, "Failed to create RSUIDirector"); } diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index f4383261f6..dd9dca65e7 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -26,7 +26,8 @@ using NotifyWindowRecoverStateChangeFunc = std::function& option); + explicit WindowSceneSessionImpl(const sptr& option, + const std::shared_ptr& rsUIContext = nullptr); ~WindowSceneSessionImpl(); WMError Create(const std::shared_ptr& context, const sptr& iSession, const std::string& identityToken = "", diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 9d6b4563b5..7b1d9bf337 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -78,7 +78,8 @@ using IKBWillHideListener = IKeyboardWillHideListener; class WindowSessionImpl : public Window, public virtual SessionStageStub { public: - explicit WindowSessionImpl(const sptr& option); + explicit WindowSessionImpl(const sptr& option, + const std::shared_ptr& rsUIContext = nullptr); ~WindowSessionImpl(); static sptr Find(const std::string& name); diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 2a4627dbd4..ed11614e21 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -36,13 +36,14 @@ constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "Window" static sptr CreateWindowWithSession(sptr& option, const std::shared_ptr& context, WMError& errCode, - sptr iSession = nullptr, const std::string& identityToken = "", bool isModuleAbilityHookEnd = false) + sptr iSession = nullptr, const std::string& identityToken = "", bool isModuleAbilityHookEnd = false, + const std::shared_ptr& rsUiContext = nullptr) { WLOGFD("in"); sptr windowSessionImpl = nullptr; auto sessionType = option->GetWindowSessionType(); if (sessionType == WindowSessionType::SCENE_SESSION) { - windowSessionImpl = sptr::MakeSptr(option); + windowSessionImpl = sptr::MakeSptr(option, rsUiContext); } else if (sessionType == WindowSessionType::EXTENSION_SESSION) { option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); windowSessionImpl = sptr::MakeSptr(option); @@ -63,7 +64,8 @@ static sptr CreateWindowWithSession(sptr& option, } sptr Window::Create(const std::string& windowName, sptr& option, - const std::shared_ptr& context, WMError& errCode) + const std::shared_ptr& context, WMError& errCode, + const std::shared_ptr& rsUiContext) { if (windowName.empty()) { WLOGFE("window name is empty"); @@ -87,7 +89,7 @@ sptr Window::Create(const std::string& windowName, sptr& o } option->SetWindowName(windowName); if (SceneBoardJudgement::IsSceneBoardEnabled()) { - return CreateWindowWithSession(option, context, errCode); + return CreateWindowWithSession(option, context, errCode, nullptr, "", false, rsUiContext); } if (option->GetOnlySupportSceneBoard()) { errCode = WMError::WM_ERROR_DEVICE_NOT_SUPPORT; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 44a16d17b6..4375a73631 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -144,7 +144,8 @@ std::mutex WindowSceneSessionImpl::keyboardPanelInfoChangeListenerMutex_; using WindowSessionImplMap = std::map>>; std::mutex WindowSceneSessionImpl::windowAttachStateChangeListenerMutex_; -WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr& option) : WindowSessionImpl(option) +WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr& option, + const std::shared_ptr& rsUIContext) : WindowSessionImpl(option, rsUIContext) { WLOGFI("[WMSCom] Constructor %{public}s", GetWindowName().c_str()); } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 7593c0a0eb..016c22ed1b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -268,7 +268,8 @@ std::atomic WindowSessionImpl::defaultDensityEnabledGlobalConfig_ = false; } \ } while (false) -WindowSessionImpl::WindowSessionImpl(const sptr& option) +WindowSessionImpl::WindowSessionImpl(const sptr& option, + const std::shared_ptr& rsUIContext) { WLOGFD("[WMSCom] Constructor"); property_ = sptr::MakeSptr(); @@ -309,7 +310,7 @@ WindowSessionImpl::WindowSessionImpl(const sptr& option) windowOption_ = option; handler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true, rsUIContext); if (WindowHelper::IsSubWindow(GetType())) { property_->SetDecorEnable(option->GetSubWindowDecorEnable()); } -- Gitee From fa5b00eeda98ac08ccc1e21a576f0dd6309e6596 Mon Sep 17 00:00:00 2001 From: l30067243 Date: Fri, 15 Aug 2025 11:41:31 +0800 Subject: [PATCH 014/241] fix comments Signed-off-by: l30067243 --- window_scene/session/host/src/scene_session.cpp | 3 +-- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 5e2bb1d2ed..66fd57c199 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -414,8 +414,7 @@ WSError SceneSession::ForegroundTask(const sptr& property int32_t persistentId = session->GetPersistentId(); auto ret = session->Session::Foreground(property); if (ret != WSError::WS_OK) { - TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session foreground failed, ret=%{public}d persistentId=%{public}d", - where, ret, persistentId); + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s ret=%{public}d win=%{public}d", where, ret, persistentId); return ret; } session->NotifySingleHandTransformChange(session->GetSingleHandTransform()); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index cab28ce0a5..5c00049441 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8429,7 +8429,7 @@ bool SceneSessionManager::JudgeNeedNotifyPrivacyInfo(DisplayId displayId, } } while (false); - TLOGI(WmsLogTag::WMS_ATTRIBUTE, "display=%{public}" PRIu64 ", needNotify=%{public}d, sendTimes=%{public}d", + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "display=%{public}" PRIu64 ", needNotify=%{public}d, sendTimes=%{public}d", displayId, needNotify, reSendTimes); if (needNotify) { reSendTimes = MAX_RESEND_TIMES; -- Gitee From 13717e58fb2f3bd37b7e20f2050bf622c6e3df3f Mon Sep 17 00:00:00 2001 From: WenJunYuan <1903700887@qq.com> Date: Fri, 15 Aug 2025 11:50:06 +0800 Subject: [PATCH 015/241] =?UTF-8?q?feature:=20=E4=B8=BB=E5=AD=90=E7=AA=97?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E5=90=8C=E4=B8=80=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: WenJunYuan <1903700887@qq.com> --- utils/src/rs_adapter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/src/rs_adapter.cpp b/utils/src/rs_adapter.cpp index 2bebb68d2a..946d90faee 100644 --- a/utils/src/rs_adapter.cpp +++ b/utils/src/rs_adapter.cpp @@ -484,10 +484,9 @@ void RSAdapterUtil::InitRSUIDirector(std::shared_ptr& rsUIDirector rsUIDirector = RSUIDirector::Create(); if (rsUIDirector) { rsUIDirector->Init(shouldCreateRenderThread, isMultiInstance, rsUiContext); - TLOGI(WmsLogTag::WMS_SCB, - "Create RSUIDirector: %{public}s, rsUIContext: %{public}s", + TLOGI(WmsLogTag::WMS_SCB, "Create RSUIDirector: %{public}s, rsUIContext: %{public}s", RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str(), - RSAdapterUtil::RSUIContextToStr(rsUiContext).c_str(),); + RSAdapterUtil::RSUIContextToStr(rsUiContext).c_str()); } else { TLOGE(WmsLogTag::WMS_SCB, "Failed to create RSUIDirector"); } -- Gitee From f8c6638de7ce27ad0aeaf1ff31e115bc3a3b5b57 Mon Sep 17 00:00:00 2001 From: shuangshuangliu Date: Wed, 13 Aug 2025 16:37:18 +0800 Subject: [PATCH 016/241] =?UTF-8?q?TDD=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: Ic07f2fa09a444739ebefc7aca5b7dd0b15b90327 --- wm/test/unittest/BUILD.gn | 20 + .../floating_ball_controller_new_test.cpp | 533 ++++++++++++++++++ .../floating_ball_option_new_test.cpp | 185 ++++++ 3 files changed, 738 insertions(+) create mode 100644 wm/test/unittest/floating_ball_controller_new_test.cpp create mode 100644 wm/test/unittest/floating_ball_option_new_test.cpp diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index b83717f68e..84610c18e7 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -20,6 +20,7 @@ group("unittest") { deps = [ ":wm_floating_ball_manager_test", + ":wm_floating_ball_new_test", ":wm_floating_ball_test", ":wm_gtx_input_event_sender_test", ":wm_input_transfer_station_test", @@ -647,6 +648,25 @@ ohos_unittest("wm_floating_ball_test") { ] } +ohos_unittest("wm_floating_ball_new_test") { + module_out_path = module_out_path + + sources = [ + "floating_ball_controller_new_test.cpp", + "floating_ball_option_new_test.cpp", + ] + + deps = [ ":wm_unittest_common" ] + + external_deps = [ + "ability_runtime:runtime", + "c_utils:utils", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + ] +} + ohos_unittest("wm_floating_ball_manager_test") { module_out_path = module_out_path diff --git a/wm/test/unittest/floating_ball_controller_new_test.cpp b/wm/test/unittest/floating_ball_controller_new_test.cpp new file mode 100644 index 0000000000..8ab9cb255f --- /dev/null +++ b/wm/test/unittest/floating_ball_controller_new_test.cpp @@ -0,0 +1,533 @@ +/* + * Copyright (c) 2023 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 "ability_context_impl.h" +#include "floating_ball_controller.h" +#include "floating_ball_manager.h" +#include "modifier_render_thread/rs_modifiers_draw_thread.h" +#include "parameters.h" +#include "window.h" +#include "wm_common.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { + +class MockNewWindow : public Window { +public: + WindowState state_ = WindowState::STATE_INITIAL; + const uint32_t mockWindowId_ = 101; + MockNewWindow() {}; + ~MockNewWindow() {}; + MOCK_METHOD3(Show, WMError(uint32_t reason, bool withAnimation, bool withFocus)); + MOCK_METHOD1(Destroy, WMError(uint32_t reason)); + MOCK_METHOD0(NotifyPrepareCloseFloatingBall, void()); + MOCK_METHOD2(UpdateFloatingBall, WMError(const FloatingBallTemplateBaseInfo& fbTemplateBaseInfo, + const std::shared_ptr& icon)); + MOCK_METHOD1(RestoreFbMainWindow, WMError(const std::shared_ptr& want)); + MOCK_METHOD1(GetFloatingBallWindowId, WMError(uint32_t& windowId)); + uint32_t GetWindowId() const override + { + return mockWindowId_; + } + + void SetWindowState(const WindowState& state) + { + state_ = state; + } + + WindowState GetWindowState() const override + { + return state_; + } +}; + +class MockNewLifeCycleListener : public IFbLifeCycle { +public: + void OnFloatingBallStart() override + { + return; + } + void OnFloatingBallStop() override + { + return; + } +}; + +class MockNewClickListener : public IFbClickObserver { +public: + + void OnClickEvent() override + { + return; + } +}; + +class FloatingBallControllerNewTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + + sptr fbController_; + sptr mw_; +}; + +void FloatingBallControllerNewTest::SetUpTestCase() +{ +} + +void FloatingBallControllerNewTest::TearDownTestCase() +{ +#ifdef RS_ENABLE_VK + RSModifiersDrawThread::Destroy(); +#endif +} + +void FloatingBallControllerNewTest::SetUp() +{ + int32_t windowId = 100; + mw_ = sptr::MakeSptr(); + ASSERT_NE(nullptr, mw_); + fbController_ = sptr::MakeSptr(mw_, windowId, nullptr); + ASSERT_NE(nullptr, fbController_); +} + +void FloatingBallControllerNewTest::TearDown() +{ + fbController_ = nullptr; + mw_ = nullptr; +} + +namespace { +/** + * @tc.name: CreateFloatingBallWindowAllNull + * @tc.desc: CreateFloatingBallWindowAllNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, CreateFloatingBallWindowAllNull, TestSize.Level1) +{ + sptr nullOption = nullptr; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->CreateFloatingBallWindow(nullOption)); +} + +/** + * @tc.name: CreateFloatingBallWindowAllNull + * @tc.desc: CreateFloatingBallWindowAllNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, CreateFloatingBallWindowAllNull001, TestSize.Level1) +{ + fbController_->contextPtr_ = nullptr; + sptr option = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->CreateFloatingBallWindow(option)); + option = nullptr; +} + +/** + * @tc.name: CreateFloatingBallWindowAllNull + * @tc.desc: CreateFloatingBallWindowAllNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, CreateFloatingBallWindowAllNull002, TestSize.Level1) +{ + std::shared_ptr contextPtr = + std::make_shared(); + fbController_->contextPtr_ = &contextPtr; + fbController_->mainWindow_ = nullptr; + sptr option = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->CreateFloatingBallWindow(option)); + option = nullptr; + fbController_->contextPtr_ = nullptr; +} + +/** + * @tc.name: CreateFloatingBallWindowNotNullOption + * @tc.desc: CreateFloatingBallWindowNotNullOption + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, CreateFloatingBallWindowNotNullOption, TestSize.Level1) +{ + std::shared_ptr contextPtr = + std::make_shared(); + fbController_->contextPtr_ = &contextPtr; + sptr option = sptr::MakeSptr(); + mw_->SetWindowState(WindowState::STATE_INITIAL); + EXPECT_EQ(WMError::WM_ERROR_FB_CREATE_FAILED, fbController_->CreateFloatingBallWindow(option)); + option = nullptr; + fbController_->contextPtr_ = nullptr; +} + +/** + * @tc.name: CreateFloatingBallWindowNotNullOption + * @tc.desc: CreateFloatingBallWindowNotNullOption + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, CreateFloatingBallWindowNotNullOption001, TestSize.Level1) +{ + std::shared_ptr contextPtr = + std::make_shared(); + fbController_->contextPtr_ = &contextPtr; + sptr option = sptr::MakeSptr(); + mw_->SetWindowState(WindowState::STATE_SHOWN); + EXPECT_EQ(WMError::WM_ERROR_FB_CREATE_FAILED, fbController_->CreateFloatingBallWindow(option)); + option = nullptr; + fbController_->contextPtr_ = nullptr; +} + +/** + * @tc.name: CreateFloatingBallWindowUpdateNull + * @tc.desc: CreateFloatingBallWindowUpdateNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, CreateFloatingBallWindowUpdateNull, TestSize.Level1) +{ + std::shared_ptr contextPtr = + std::make_shared(); + fbController_->contextPtr_ = &contextPtr; + mw_->SetWindowState(WindowState::STATE_SHOWN); + sptr option = sptr::MakeSptr(); + auto res = fbController_->CreateFloatingBallWindow(option); + EXPECT_EQ(WMError::WM_ERROR_FB_CREATE_FAILED, res); + fbController_->UpdateMainWindow(nullptr); + EXPECT_EQ(100, fbController_->mainWindowId_); + option = nullptr; + fbController_->contextPtr_ = nullptr; +} + +/** + * @tc.name: CreateFloatingBallWindowUpdateNotNull + * @tc.desc: CreateFloatingBallWindowUpdateNotNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, CreateFloatingBallWindowUpdateNotNull, TestSize.Level1) +{ + std::shared_ptr contextPtr = + std::make_shared(); + fbController_->contextPtr_ = &contextPtr; + sptr option = sptr::MakeSptr(); + auto res = fbController_->CreateFloatingBallWindow(option); + EXPECT_EQ(WMError::WM_ERROR_FB_CREATE_FAILED, res); + fbController_->UpdateMainWindow(mw_); + EXPECT_EQ(101, fbController_->mainWindowId_); + option = nullptr; + fbController_->contextPtr_ = nullptr; +} + +/** + * @tc.name: StartFloatingBallNull + * @tc.desc: StartFloatingBallNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StartFloatingBallNull, TestSize.Level1) +{ + sptr nullOption = nullptr; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->StartFloatingBall(nullOption)); +} + +/** + * @tc.name: StartFloatingBallNotNull + * @tc.desc: StartFloatingBallNotNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StartFloatingBallNotNull, TestSize.Level1) +{ + fbController_->curState_ = FbWindowState::STATE_STARTING; + sptr option = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_ERROR_FB_REPEAT_OPERATION, fbController_->StartFloatingBall(option)); + option = nullptr; +} + +/** + * @tc.name: StartFloatingBallNotNull + * @tc.desc: StartFloatingBallNotNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StartFloatingBallNotNull01, TestSize.Level1) +{ + fbController_->curState_ = FbWindowState::STATE_STARTED; + sptr option = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_ERROR_FB_REPEAT_OPERATION, fbController_->StartFloatingBall(option)); + option = nullptr; +} + +/** + * @tc.name: StartFloatingBallSetActiveController + * @tc.desc: StartFloatingBallSetActiveController + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StartFloatingBallSetActiveController, TestSize.Level1) +{ + fbController_->curState_ = FbWindowState::STATE_UNDEFINED; + sptr option = sptr::MakeSptr(); + FloatingBallManager::SetActiveController(fbController_); + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->StartFloatingBall(option)); + FloatingBallManager::RemoveActiveController(fbController_); + option = nullptr; +} + +/** + * @tc.name: StartFloatingBallSetActiveController + * @tc.desc: StartFloatingBallSetActiveController + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StartFloatingBallSetActiveController01, TestSize.Level1) +{ + auto activeFbController = sptr::MakeSptr(mw_, 100, nullptr); + sptr option = sptr::MakeSptr(); + FloatingBallManager::SetActiveController(activeFbController); + EXPECT_EQ(WMError::WM_ERROR_FB_REPEAT_CONTROLLER, fbController_->StartFloatingBall(option)); + + FloatingBallManager::RemoveActiveController(activeFbController); + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->StartFloatingBall(option)); + option = nullptr; +} + +/** + * @tc.name: StartFloatingBallGetControllerState + * @tc.desc: StartFloatingBallGetControllerState + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StartFloatingBallGetControllerState, TestSize.Level1) +{ + std::unique_ptr contextPtr = + std::make_unique(); + fbController_->contextPtr_ = contextPtr.get(); + sptr option = sptr::MakeSptr(); + EXPECT_NE(WMError::WM_OK, fbController_->StartFloatingBall(option)); + EXPECT_EQ(FbWindowState::STATE_UNDEFINED, fbController_->GetControllerState()); + option = nullptr; + fbController_->contextPtr_ = nullptr; +} + +/** + * @tc.name: LifeCycleTestNull + * @tc.desc: LifeCycleTestNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, LifeCycleTestNull, TestSize.Level1) +{ + EXPECT_EQ(WMError::WM_ERROR_FB_INTERNAL_ERROR, fbController_->RegisterFbLifecycle(nullptr)); +} + +/** + * @tc.name: LifeCycleTestNotNull + * @tc.desc: LifeCycleTestNotNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, LifeCycleTestNotNull, TestSize.Level1) +{ + auto lifeListener = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_OK, fbController_->RegisterFbLifecycle(lifeListener)); + fbController_->fbLifeCycleListeners_.clear(); +} + +/** + * @tc.name: LifeCycleTestRepeatRegister + * @tc.desc: LifeCycleTestRepeatRegister + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, LifeCycleTestRepeatRegister, TestSize.Level1) +{ + auto lifeListener = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_OK, fbController_->RegisterFbLifecycle(lifeListener)); + // repeat register + EXPECT_EQ(WMError::WM_OK, fbController_->RegisterFbLifecycle(lifeListener)); + fbController_->fbLifeCycleListeners_.emplace_back(nullptr); + fbController_->OnFloatingBallStart(); + fbController_->OnFloatingBallStop(); + fbController_->fbLifeCycleListeners_.clear(); +} + +/** + * @tc.name: LifeCycleTestUnregister + * @tc.desc: LifeCycleTestUnregister + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, LifeCycleTestUnregister, TestSize.Level1) +{ + auto lifeListener = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_ERROR_FB_INTERNAL_ERROR, fbController_->UnRegisterFbLifecycle(nullptr)); + EXPECT_EQ(WMError::WM_OK, fbController_->UnRegisterFbLifecycle(lifeListener)); + fbController_->fbLifeCycleListeners_.clear(); +} + +/** + * @tc.name: ClickTestNull + * @tc.desc: ClickTestNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, ClickTestNull, TestSize.Level1) +{ + EXPECT_EQ(WMError::WM_ERROR_FB_INTERNAL_ERROR, fbController_->RegisterFbClickObserver(nullptr)); +} + +/** + * @tc.name: ClickTestNotNull + * @tc.desc: ClickTestNotNull + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, ClickTestNotNull, TestSize.Level1) +{ + auto clickListener = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_OK, fbController_->RegisterFbClickObserver(clickListener)); + fbController_->fbClickObservers_.clear(); +} + +/** + * @tc.name: ClickTestRepeatRegister + * @tc.desc: ClickTestRepeatRegister + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, ClickTestRepeatRegister, TestSize.Level1) +{ + auto clickListener = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_OK, fbController_->RegisterFbClickObserver(clickListener)); + // repeat register + EXPECT_EQ(WMError::WM_OK, fbController_->RegisterFbClickObserver(clickListener)); + fbController_->fbClickObservers_.emplace_back(nullptr); + fbController_->OnFloatingBallClick(); + fbController_->fbClickObservers_.clear(); +} + +/** + * @tc.name: ClickTestUnregister + * @tc.desc: ClickTestUnregister + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, ClickTestUnregister, TestSize.Level1) +{ + auto clickListener = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_ERROR_FB_INTERNAL_ERROR, fbController_->UnRegisterFbClickObserver(nullptr)); + EXPECT_EQ(WMError::WM_OK, fbController_->UnRegisterFbClickObserver(clickListener)); + fbController_->fbClickObservers_.clear(); +} + +/** + * @tc.name: UpdateFloatingBall + * @tc.desc: UpdateFloatingBall + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, UpdateFloatingBall01, TestSize.Level1) +{ + fbController_->curState_ = FbWindowState::STATE_STOPPED; + sptr option = sptr::MakeSptr(); + EXPECT_EQ(WMError::WM_ERROR_FB_INVALID_STATE, fbController_->UpdateFloatingBall(option)); + + fbController_->curState_ = FbWindowState::STATE_STARTED; + sptr nullOption = nullptr; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->UpdateFloatingBall(nullOption)); + fbController_->window_ = nullptr; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->UpdateFloatingBall(option)); + + fbController_->window_ = mw_; + fbController_->curState_ = FbWindowState::STATE_STOPPED; + EXPECT_EQ(WMError::WM_ERROR_FB_INVALID_STATE, fbController_->UpdateFloatingBall(option)); + EXPECT_CALL(*(mw_), UpdateFloatingBall(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + fbController_->curState_ = FbWindowState::STATE_STARTED; + EXPECT_EQ(WMError::WM_OK, fbController_->UpdateFloatingBall(option)); + option = nullptr; +} + +/** + * @tc.name: StopFloatingBall + * @tc.desc: StopFloatingBall + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StopFloatingBall01, TestSize.Level1) +{ + fbController_->curState_ = FbWindowState::STATE_STOPPED; + EXPECT_EQ(WMError::WM_ERROR_FB_REPEAT_OPERATION, fbController_->StopFloatingBallFromClient()); + fbController_->curState_ = FbWindowState::STATE_STOPPING; + EXPECT_EQ(WMError::WM_ERROR_FB_REPEAT_OPERATION, fbController_->StopFloatingBallFromClient()); + fbController_->curState_ = FbWindowState::STATE_STARTED; + EXPECT_CALL(*(mw_), NotifyPrepareCloseFloatingBall()).Times(1); + fbController_->window_ = mw_; + EXPECT_EQ(WMError::WM_OK, fbController_->StopFloatingBallFromClient()); + fbController_->window_ = nullptr; + fbController_->curState_ = FbWindowState::STATE_STARTED; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->StopFloatingBallFromClient()); +} + +/** + * @tc.name: StopFloatingBall + * @tc.desc: StopFloatingBall + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, StopFloatingBall02, TestSize.Level1) +{ + fbController_->stopFromClient_ = false; + fbController_->curState_ = FbWindowState::STATE_STOPPING; + EXPECT_EQ(WMError::WM_ERROR_FB_REPEAT_OPERATION, fbController_->StopFloatingBall()); + fbController_->curState_ = FbWindowState::STATE_STOPPED; + EXPECT_EQ(WMError::WM_ERROR_FB_REPEAT_OPERATION, fbController_->StopFloatingBall()); + + fbController_->curState_ = FbWindowState::STATE_STARTED; + EXPECT_CALL(*(mw_), Destroy(_)).Times(1); + fbController_->window_ = mw_; + EXPECT_EQ(WMError::WM_OK, fbController_->StopFloatingBall()); + EXPECT_EQ(FbWindowState::STATE_STOPPED, fbController_->GetControllerState()); + + fbController_->window_ = nullptr; + fbController_->curState_ = FbWindowState::STATE_STARTED; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->StopFloatingBall()); + EXPECT_EQ(WMError::WM_ERROR_FB_INTERNAL_ERROR, fbController_->DestroyFloatingBallWindow()); + EXPECT_EQ(nullptr, fbController_->GetFbWindow()); +} + +/** + * @tc.name: RestoreFloatingBallAbility + * @tc.desc: RestoreFloatingBallAbility + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, RestoreFloatingBallAbility, TestSize.Level1) +{ + std::shared_ptr want = std::make_shared(); + fbController_->curState_ = FbWindowState::STATE_STARTED; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->RestoreMainWindow(want)); + fbController_->window_ = mw_; + fbController_->curState_ = FbWindowState::STATE_STOPPING; + EXPECT_EQ(WMError::WM_ERROR_FB_INVALID_STATE, fbController_->RestoreMainWindow(want)); + fbController_->curState_ = FbWindowState::STATE_STARTED; + EXPECT_CALL(*(mw_), RestoreFbMainWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); + EXPECT_EQ(WMError::WM_OK, fbController_->RestoreMainWindow(want)); +} + +/** + * @tc.name: GetFloatingBallInfo + * @tc.desc: GetFloatingBallInfo + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerNewTest, GetFloatingBallInfo, TestSize.Level1) +{ + EXPECT_CALL(*(mw_), GetFloatingBallWindowId(_)).Times(1).WillOnce(Return(WMError::WM_OK)); + fbController_->window_ = mw_; + uint32_t mockId = 1; + EXPECT_EQ(WMError::WM_ERROR_FB_INVALID_STATE, fbController_->GetFloatingBallWindowInfo(mockId)); + fbController_->curState_ = FbWindowState::STATE_STARTED; + fbController_->window_ = nullptr; + EXPECT_EQ(WMError::WM_ERROR_FB_STATE_ABNORMALLY, fbController_->GetFloatingBallWindowInfo(mockId)); + fbController_->window_ = mw_; + EXPECT_EQ(WMError::WM_OK, fbController_->GetFloatingBallWindowInfo(mockId)); +} +} +} +} \ No newline at end of file diff --git a/wm/test/unittest/floating_ball_option_new_test.cpp b/wm/test/unittest/floating_ball_option_new_test.cpp new file mode 100644 index 0000000000..6c19b79a22 --- /dev/null +++ b/wm/test/unittest/floating_ball_option_new_test.cpp @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2023 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 "parameters.h" +#include "floating_ball_option.h" +#include "wm_common.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { + +class FloatingBallOptionNewTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void FloatingBallOptionNewTest::SetUpTestCase() +{ +} + +void FloatingBallOptionNewTest::TearDownTestCase() +{ +} + +void FloatingBallOptionNewTest::SetUp() +{ +} + +void FloatingBallOptionNewTest::TearDown() +{ +} + +namespace { +/** + * @tc.name: TestParamSetAndGetTemplateType + * @tc.desc: TestParamSetAndGetTemplateType + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetTemplateType, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + uint32_t templateType = 1; + option->SetTemplate(templateType); + EXPECT_EQ(templateType, option->GetTemplate()); +} + +/** + * @tc.name: TestParamSetAndGetTitle + * @tc.desc: TestParamSetAndGetTitle + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetTitle, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + std::string title = "title"; + option->SetTitle(title); + EXPECT_EQ(title, option->GetTitle()); +} + +/** + * @tc.name: TestParamSetAndGetContent + * @tc.desc: TestParamSetAndGetContent + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetContent, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + std::string content = "content"; + option->SetContent(content); + EXPECT_EQ(content, option->GetContent()); +} + +/** + * @tc.name: TestParamSetAndGetColor + * @tc.desc: TestParamSetAndGetColor + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetColor, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + std::string color = "#RRGGBB"; + option->SetBackgroundColor(color); + EXPECT_EQ(color, option->GetBackgroundColor()); +} + +/** + * @tc.name: TestParamSetAndGetIcon + * @tc.desc: TestParamSetAndGetIcon + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetIcon, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + std::shared_ptr icon = nullptr; + option->SetIcon(icon); + EXPECT_EQ(nullptr, option->GetIcon()); +} + +/** + * @tc.name: TestParamSetAndGetAssignmentTitle + * @tc.desc: TestParamSetAndGetAssignmentTitle + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetAssignmentTitle, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + std::string title = "title"; + option->SetTitle(title); + + FloatingBallTemplateBaseInfo fbTemplateBaseInfo; + option->GetFbTemplateBaseInfo(fbTemplateBaseInfo); + EXPECT_EQ(title, fbTemplateBaseInfo.title_); +} + +/** + * @tc.name: TestParamSetAndGetAssignmentTemplateType + * @tc.desc: TestParamSetAndGetAssignmentTemplateType + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetAssignmentTemplateType, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + uint32_t templateType = 1; + option->SetTemplate(templateType); + + FloatingBallTemplateBaseInfo fbTemplateBaseInfo; + option->GetFbTemplateBaseInfo(fbTemplateBaseInfo); + EXPECT_EQ(templateType, fbTemplateBaseInfo.template_); +} + +/** + * @tc.name: TestParamSetAndGetAssignmentContent + * @tc.desc: TestParamSetAndGetAssignmentContent + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetAssignmentContent, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + std::string content = "content"; + option->SetContent(content); + + FloatingBallTemplateBaseInfo fbTemplateBaseInfo; + option->GetFbTemplateBaseInfo(fbTemplateBaseInfo); + EXPECT_EQ(content, fbTemplateBaseInfo.content_); +} + +/** + * @tc.name: TestParamSetAndGetAssignmentColor + * @tc.desc: TestParamSetAndGetAssignmentColor + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallOptionNewTest, TestParamSetAndGetAssignmentColor, TestSize.Level1) +{ + auto option = sptr::MakeSptr(); + std::string color = "#RRGGBB"; + option->SetBackgroundColor(color); + EXPECT_EQ(color, option->GetBackgroundColor()); + + FloatingBallTemplateBaseInfo fbTemplateBaseInfo; + option->GetFbTemplateBaseInfo(fbTemplateBaseInfo); + EXPECT_EQ(color, fbTemplateBaseInfo.backgroundColor_); +} +} +} +} \ No newline at end of file -- Gitee From 3055536a0f0f37cb2f5bc9b29acda62ecb7d4a84 Mon Sep 17 00:00:00 2001 From: WenJunYuan <1903700887@qq.com> Date: Fri, 15 Aug 2025 14:25:01 +0800 Subject: [PATCH 017/241] =?UTF-8?q?feature:=20=E4=B8=BB=E5=AD=90=E7=AA=97?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E5=90=8C=E4=B8=80=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: WenJunYuan <1903700887@qq.com> --- utils/src/rs_adapter.cpp | 2 +- wm/src/window_session_impl.cpp | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/utils/src/rs_adapter.cpp b/utils/src/rs_adapter.cpp index 946d90faee..b2992bdb21 100644 --- a/utils/src/rs_adapter.cpp +++ b/utils/src/rs_adapter.cpp @@ -484,7 +484,7 @@ void RSAdapterUtil::InitRSUIDirector(std::shared_ptr& rsUIDirector rsUIDirector = RSUIDirector::Create(); if (rsUIDirector) { rsUIDirector->Init(shouldCreateRenderThread, isMultiInstance, rsUiContext); - TLOGI(WmsLogTag::WMS_SCB, "Create RSUIDirector: %{public}s, rsUIContext: %{public}s", + TLOGI(WmsLogTag::WMS_SCB, "Create RSUIDirector: %{public}s, rsUIContext: %{public}s", RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str(), RSAdapterUtil::RSUIContextToStr(rsUiContext).c_str()); } else { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 016c22ed1b..571009f482 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -273,6 +273,26 @@ WindowSessionImpl::WindowSessionImpl(const sptr& option, { WLOGFD("[WMSCom] Constructor"); property_ = sptr::MakeSptr(); + windowOption_ = option; + handler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); + + InitPropertyFromOption(option); + + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true, rsUIContext); + if (WindowHelper::IsSubWindow(GetType())) { + property_->SetDecorEnable(option->GetSubWindowDecorEnable()); + } + surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), optionWindowType); + if (surfaceNode_ != nullptr) { + vsyncStation_ = std::make_shared(surfaceNode_->GetId()); + } + WindowHelper::SplitStringByDelimiter( + system::GetParameter("const.window.containerColorLists", ""), ",", containerColorList_); + SetDefaultDensityEnabledValue(defaultDensityEnabledGlobalConfig_); +} + +void WindowSessionImpl::InitPropertyFromOption(const sptr& option) +{ WindowType optionWindowType = option->GetWindowType(); SessionInfo sessionInfo; sessionInfo.bundleName_ = option->GetBundleName(); @@ -307,20 +327,6 @@ WindowSessionImpl::WindowSessionImpl(const sptr& option, updateRectCallback_ = sptr::MakeSptr(); isMainHandlerAvailable_ = option->GetMainHandlerAvailable(); isIgnoreSafeArea_ = WindowHelper::IsSubWindow(optionWindowType); - windowOption_ = option; - handler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); - - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true, rsUIContext); - if (WindowHelper::IsSubWindow(GetType())) { - property_->SetDecorEnable(option->GetSubWindowDecorEnable()); - } - surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), optionWindowType); - if (surfaceNode_ != nullptr) { - vsyncStation_ = std::make_shared(surfaceNode_->GetId()); - } - WindowHelper::SplitStringByDelimiter( - system::GetParameter("const.window.containerColorLists", ""), ",", containerColorList_); - SetDefaultDensityEnabledValue(defaultDensityEnabledGlobalConfig_); } bool WindowSessionImpl::IsPcWindow() const -- Gitee From 1ea572defa74537a0309e9e63621c89febaa1e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Fri, 15 Aug 2025 16:50:19 +0800 Subject: [PATCH 018/241] =?UTF-8?q?createCreateJsError=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../window_manager_napi/js_window_manager.cpp | 3 +- .../window_runtime/window_napi/js_window.cpp | 94 ++++++++++++------- .../window_stage_napi/js_window_stage.cpp | 59 +++++++----- 3 files changed, 96 insertions(+), 60 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index aa2d6ad6a4..87b00d673c 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -782,7 +782,8 @@ napi_value JsWindowManager::OnFindWindowSync(napi_env env, napi_callback_info in } else { sptr window = Window::Find(windowName); if (window == nullptr) { - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[windowLifecycle][OnFindWindowSync]msg: window is nullptr"); return NapiGetUndefined(env); } else { return CreateJsWindowObject(env, window); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 17b40ab4ee..b1296afacd 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1359,7 +1359,8 @@ napi_value JsWindow::OnShowWindow(napi_env env, napi_callback_info info) auto asyncTask = [weakToken, env, task = napiAsyncTask, focusOnShow, isShowWithOptions] { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnShowWindow]msg: window is nullptr or get invalid param")); TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); return; } @@ -1386,7 +1387,7 @@ napi_value JsWindow::OnShowWindow(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "Window show failed")); + "[window][OnShowWindow]msg: Window show failed")); } TLOGNI(WmsLogTag::WMS_LIFE, "Window [%{public}u, %{public}s] show end, ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -1513,7 +1514,8 @@ napi_value JsWindow::OnDestroyWindow(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnDestroyWindow]msg: window is nullptr or get invalid param")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -1527,7 +1529,8 @@ napi_value JsWindow::OnDestroyWindow(napi_env env, napi_callback_info info) TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s end, window [%{public}u, %{public}s] ret=%{public}d", where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); if (ret != WmErrorCode::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window destroy failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][OnDestroyWindow]msg: Window destroy failed")); return; } windowToken_ = nullptr; // ensure window dtor when finalizer invalid @@ -1565,7 +1568,8 @@ napi_value JsWindow::HideWindowFunction(napi_env env, napi_callback_info info, W auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][HideWindowFunction]msg: window is nullptr or get invalid param.")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -1579,7 +1583,8 @@ napi_value JsWindow::HideWindowFunction(napi_env env, napi_callback_info info, W if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window hide failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][HideWindowFunction]msg: Window hide failed")); } TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s end, window [%{public}u] ret=%{public}d", where, weakWindow->GetWindowId(), ret); @@ -2595,7 +2600,8 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i { if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnRegisterWindowCallback]msg: window is nullptr"); } sptr windowToken = windowToken_; constexpr size_t argcMin = 2; @@ -2627,7 +2633,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WmErrorCode ret = registerManager_->RegisterListener(windowToken, cbType, CaseType::CASE_WINDOW, env, callback, parameter); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][OnRegisterWindowCallback]msg: register listener failed."); } TLOGI(WmsLogTag::DEFAULT, "Id=%{public}u, type=%{public}s", windowToken->GetWindowId(), cbType.c_str()); // if comptible mode app adpt to immersive, avoid area change will be called when regist @@ -2642,7 +2648,8 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info { if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnUnregisterWindowCallback]msg: window is nullptr"); } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -2671,7 +2678,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info } if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][OnUnregisterWindowCallback]msg: unregister listener failed"); } WLOGFI("Unregister end, window [%{public}u, %{public}s], type=%{public}s", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), cbType.c_str()); @@ -2693,7 +2700,8 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_DIALOG, "window is nullptr!"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnBindDialogTarget]msg: window is nullptr."); } if (!Permission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_DIALOG, "permission denied, require system application!"); @@ -2736,15 +2744,16 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Bind Dialog Target failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][OnBindDialogTarget]msg: Bind Dialog Target failed")); } TLOGI(WmsLogTag::WMS_SYSTEM, "BindDialogTarget end, window [%{public}u, %{public}s]", weakToken->GetWindowId(), weakToken->GetWindowName().c_str()); }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnBindDialogTarget") != napi_status::napi_ok) { - napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][OnBindDialogTarget]msg: send event failed")); } return result; } @@ -2818,7 +2827,8 @@ static void LoadContentTask(std::shared_ptr contentStorage, std if (ret == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window load content failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][LoadContentTask]msg: Window load content failed")); } WLOGFI("end, window [%{public}u, %{public}s] ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -2852,7 +2862,8 @@ napi_value JsWindow::LoadContentScheduleOld(napi_env env, napi_callback_info inf auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR))); + task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR), + "[window][LoadContentScheduleOld]msg: window is nullptr.")); return; } if (errCode != WMError::WM_OK) { @@ -2909,7 +2920,8 @@ napi_value JsWindow::LoadContentScheduleNew(napi_env env, napi_callback_info inf auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr or get invalid param"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][LoadContentScheduleNew]msg: Window is nullptr.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, isLoadedByName); @@ -2955,19 +2967,22 @@ napi_value JsWindow::OnGetUIContext(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { WLOGFE("window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnGetUIContext]msg: window is nullptr"); } auto uicontent = windowToken_->GetUIContent(); if (uicontent == nullptr) { WLOGFW("uicontent is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnGetUIContext]msg: uicontent is nullptr"); } napi_value uiContext = uicontent->GetUINapiContext(); if (uiContext == nullptr) { WLOGFE("uiContext obtained from jsEngine is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnGetUIContext]msg: uiContext obtained from jsEngine is nullptr"); } else { return uiContext; } @@ -3004,7 +3019,8 @@ napi_value JsWindow::OnSetUIContent(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnSetUIContent]msg: window is nullptr.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, false); @@ -3768,7 +3784,8 @@ napi_value JsWindow::OnIsWindowShowingSync(napi_env env, napi_callback_info info { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnIsWindowShowingSync]msg: window is nullptr"); } bool state = (windowToken_->GetWindowState() == WindowState::STATE_SHOWN); TLOGD(WmsLogTag::WMS_LIFE, "Id=%{public}u, state=%{public}u", windowToken_->GetWindowId(), state); @@ -6824,8 +6841,8 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s window is nullptr", where); - task->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr")); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnMinimize]msg: window is nullptr")); return; } WMError ret = window->Minimize(); @@ -6833,7 +6850,8 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed.")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][OnMinimize]msg: Minimize failed.")); } TLOGNI(WmsLogTag::WMS_PC, "%{public}s Window [%{public}u, %{public}s] minimize end, ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -8345,7 +8363,8 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "window is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnCreateSubWindowWithOptions]msg: window is null")); return NapiGetUndefined(env); } if (!windowToken_->IsPcOrFreeMultiWindowCapabilityEnabled()) { @@ -8393,7 +8412,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "window is nullptr")); + "[window][OnCreateSubWindowWithOptions]msg: asyncTask window is nullptr")); return; } if (!WindowHelper::IsFloatOrSubWindow(window->GetType()) && @@ -8412,15 +8431,15 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (subWindow == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s create sub window failed.", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "create sub window failed")); + "[window][OnCreateSubWindowWithOptions]msg: create sub window failed")); return; } task->Resolve(env, CreateJsWindowObject(env, subWindow)); TLOGNI(WmsLogTag::WMS_SUB, "%{public}s create sub window %{public}s end", where, windowName.c_str()); }; if (napi_send_event(env, asyncTask, napi_eprio_vip, "OnCreateSubWindowWithOptions") != napi_status::napi_ok) { - napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][OnCreateSubWindowWithOptions]msg: send event failed")); } return result; } @@ -8446,13 +8465,15 @@ napi_value JsWindow::OnSetParentWindow(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnSetParentWindow]msg: window is nullptr")); return; } WMError ret = window->SetParentWindow(newParentWindowId); if (ret != WMError::WM_OK) { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set parent window failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][OnSetParentWindow]msg: set parent window failed")); return; } task->Resolve(env, NapiGetUndefined(env)); @@ -8460,8 +8481,8 @@ napi_value JsWindow::OnSetParentWindow(napi_env env, napi_callback_info info) where, window->GetWindowId(), newParentWindowId); }; if (napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnSetParentWindow") != napi_status::napi_ok) { - napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][OnSetParentWindow]msg: send event failed")); } return result; } @@ -8476,7 +8497,7 @@ napi_value JsWindow::OnGetParentWindow(napi_env env, napi_callback_info info) WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetParentWindow(parentWindow)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_SUB, "get failed, result=%{public}d", ret); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][OnGetParentWindow]msg: get parent window failed"); } if (parentWindow == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "parentWindow is nullptr"); @@ -8485,7 +8506,8 @@ napi_value JsWindow::OnGetParentWindow(napi_env env, napi_callback_info info) auto objValue = CreateJsWindowObject(env, parentWindow); if (objValue == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "create js window failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnGetParentWindow]msg: get parent window failed"); } TLOGI(WmsLogTag::WMS_SUB, "window id: %{public}u set parent window id: %{public}u end", windowToken_->GetWindowId(), parentWindow->GetWindowId()); diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 950239ec45..82d845b1d5 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -263,7 +263,8 @@ napi_value JsWindowStage::OnGetMainWindow(napi_env env, napi_callback_info info) auto asyncTask = [weak = windowScene_, env, task = napiAsyncTask] { auto weakScene = weak.lock(); if (weakScene == nullptr) { - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, + "[window][OnGetMainWindow]msg: window scene is nullptr")); TLOGNE(WmsLogTag::WMS_LIFE, "WindowScene_ is nullptr!"); return; } @@ -274,7 +275,7 @@ napi_value JsWindowStage::OnGetMainWindow(napi_env env, napi_callback_info info) window->GetWindowId(), window->GetWindowName().c_str()); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "Get main window failed.")); + "[window][OnGetMainWindow]msg: Get main window failed.")); TLOGNE(WmsLogTag::WMS_LIFE, "Get main window failed."); } }; @@ -289,13 +290,15 @@ napi_value JsWindowStage::OnGetMainWindowSync(napi_env env, napi_callback_info i auto weakScene = windowScene_.lock(); if (weakScene == nullptr) { WLOGFE("WindowScene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, + "[window][OnGetMainWindowSync]msg: windowScene is nullptr")); return NapiGetUndefined(env); } auto window = weakScene->GetMainWindow(); if (window == nullptr) { WLOGFE("Window is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnGetMainWindowSync]msg: get main window failed")); return NapiGetUndefined(env); } @@ -307,7 +310,8 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) auto weakScene = windowScene_.lock(); if (weakScene == nullptr) { WLOGFE("Window scene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnEvent]msg: window scene is nullptr.")); return NapiGetUndefined(env); } size_t argc = 4; @@ -336,13 +340,14 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) auto window = weakScene->GetMainWindow(); if (window == nullptr) { WLOGFE("Get window failed"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnEvent]msg: get window failed.")); return NapiGetUndefined(env); } auto ret = g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "register event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret)); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][OnEvent]msg: regist event failed.")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] register event %{public}s", @@ -356,7 +361,8 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) auto weakScene = windowScene_.lock(); if (weakScene == nullptr) { WLOGFE("Window scene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OffEvent]msg: window scene is nullptr")); return NapiGetUndefined(env); } size_t argc = 4; @@ -373,7 +379,8 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) auto window = weakScene->GetMainWindow(); if (window == nullptr) { WLOGFE("Get window failed"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OffEvent]msg: get main window failed")); return NapiGetUndefined(env); } napi_value value = nullptr; @@ -390,7 +397,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) } if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "unregister event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret)); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][OffEvent]msg: unregister event failed")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] unregister event %{public}s", @@ -413,7 +420,7 @@ static void LoadContentTask(std::shared_ptr contentStorage, std task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "Window load content failed")); + "[window][LoadContentTask]msg: Window load content failed")); } WLOGI("Window [%{public}u, %{public}s] load content end, ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -462,7 +469,8 @@ napi_value JsWindowStage::OnLoadContent(napi_env env, napi_callback_info info, b auto weakScene = weak.lock(); sptr win = weakScene ? weakScene->GetMainWindow() : nullptr; if (win == nullptr) { - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnLoadContent]msg: window is nullptr.")); TLOGNE(WmsLogTag::WMS_LIFE, "Get window failed"); return; } @@ -535,7 +543,8 @@ napi_value JsWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info inf auto weakScene = weak.lock(); if (weakScene == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window scene is null"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnCreateSubWindow]msg: asyncTask window scene is null")); return; } sptr windowOption = new Rosen::WindowOption(); @@ -545,7 +554,7 @@ napi_value JsWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info inf if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Get window failed"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "Get window failed")); + "[window][OnCreateSubWindow]msg: get window failed")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); @@ -585,7 +594,8 @@ napi_value JsWindowStage::OnGetSubWindow(napi_env env, napi_callback_info info) auto weakScene = weak.lock(); if (weakScene == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window scene is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnGetSubWindow]msg: window scene is nullptr")); return; } std::vector> subWindowVec = weakScene->GetSubWindow(); @@ -821,7 +831,8 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba auto windowScene = windowScene_.lock(); if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "WindowScene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, + "[window][OnCreateSubWindowWithOptions]msg: windowScene is null")); return NapiGetUndefined(env); } size_t argc = 4; @@ -865,7 +876,7 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s Get window failed", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "Get window failed")); + "[window][OnCreateSubWindowWithOptions]msg: Get window failed")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); @@ -883,7 +894,8 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf auto windowScene = windowScene_.lock(); if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "windowScene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnRemoveStartingWindow]msg: windowScene is null")); return NapiGetUndefined(env); } @@ -900,20 +912,21 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf auto window = weakWindow.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_STARTUP_PAGE, "%{public}s window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, - WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr.")); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnRemoveStartingWindow]msg: asyncTask window is nullptr.")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->NotifyRemoveStartingWindow()); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Notify remove starting window failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][OnRemoveStartingWindow]msg: Notify remove starting window failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnRemoveStartingWindow") != napi_status::napi_ok) { - napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][OnRemoveStartingWindow]msg: send event failed")); } return result; } -- Gitee From d62c48fd6b126169a0517c8a8b9b2790b2e59464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Fri, 15 Aug 2025 16:51:44 +0800 Subject: [PATCH 019/241] =?UTF-8?q?createCreateJsError=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- wm/test/unittest/window_session_impl_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 151e4d3b3d..66bb15a4be 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1462,7 +1462,7 @@ HWTEST_F(WindowSessionImplTest, NotifyAfterLifecycleBackground, TestSize.Level1) WSError res = window->NotifyCloseExistPipWindow(); EXPECT_EQ(res, WSError::WS_OK); - EXPECT_EQ(WMError::WS_OK, window->Destroy()); + EXPECT_EQ(WMError::WM_OK, window->Destroy()); } /** -- Gitee From dbd39a604d20f321af597ddae730f3f04e384eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Fri, 15 Aug 2025 17:32:39 +0800 Subject: [PATCH 020/241] =?UTF-8?q?createCreateJsError=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../window_runtime/window_manager_napi/js_window_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index 87b00d673c..16dc677fc8 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -782,8 +782,8 @@ napi_value JsWindowManager::OnFindWindowSync(napi_env env, napi_callback_info in } else { sptr window = Window::Find(windowName); if (window == nullptr) { - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[windowLifecycle][OnFindWindowSync]msg: window is nullptr"); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnFindWindowSync]msg: window is nullptr")); return NapiGetUndefined(env); } else { return CreateJsWindowObject(env, window); -- Gitee From 084c283157746d3ec1814a827fb5240ed9a0a12c Mon Sep 17 00:00:00 2001 From: second_89ed Date: Sat, 16 Aug 2025 04:19:48 +0800 Subject: [PATCH 021/241] fix vkeyboard doesn't work when entering sharing mode Signed-off-by: second_89ed --- .../src/scene_session_dirty_manager.cpp | 4 + .../scene_session_dirty_manager_test2.cpp | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 5326d29771..099eb9232f 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -39,8 +39,10 @@ static int32_t g_screenRotationOffset = system::GetIntParameter("const. constexpr float ZORDER_UIEXTENSION_INDEX = 0.1; constexpr int WINDOW_NAME_TYPE_UNKNOWN = 0; constexpr int WINDOW_NAME_TYPE_THUMBNAIL = 1; +constexpr int WINDOW_NAME_TYPE_VOICEINPUT = 2; const std::string SCREENSHOT_WINDOW_NAME_PREFIX = "ScreenShotWindow"; const std::string PREVIEW_WINDOW_NAME_PREFIX = "PreviewWindow"; +const std::string VOICEINPUT_WINDOW_NAME_PREFIX = "__VoiceHardwareInput"; } // namespace static bool operator==(const MMI::Rect left, const MMI::Rect right) @@ -801,6 +803,8 @@ std::pair> SceneSessionDirtyMa }; if (startsWith(windowName, SCREENSHOT_WINDOW_NAME_PREFIX) || startsWith(windowName, PREVIEW_WINDOW_NAME_PREFIX)) { windowNameType = WINDOW_NAME_TYPE_THUMBNAIL; + }else if(startsWith(windowName, VOICEINPUT_WINDOW_NAME_PREFIX)){ + windowNameType = WINDOW_NAME_TYPE_VOICEINPUT; } auto pixelMap = windowSessionProperty->GetWindowMask(); MMI::WindowInfo windowInfo = { diff --git a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp index 3e6199dd24..4b7557aabf 100644 --- a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp +++ b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp @@ -700,6 +700,79 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithoutParentWindow, TestSi int32_t windowInfoSize = sceneSessionMap.size(); ASSERT_EQ(windowInfoSize, 0); } + +/** + * @tc.name: GetWindowInfoWithScreenshotPrefix + * @tc.desc: windowInfo with screenshot prefix + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithScreenshotPrefix, TestSize.Level2) +{ + SessionInfo info; + sptr session = sptr::MakeSptr(info, nullptr); + sptr windowSessionProperty = session->GetSessionProperty(); + session->SetSessionProperty(windowSessionProperty); + windowSessionProperty->SetWindowName("ScreenShotWindowExample"); + + auto result = manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD); + + EXPECT_EQ(result.first.windowNameType, 1); +} + +/** + * @tc.name: GetWindowInfoWithPreviewPrefix + * @tc.desc: windowInfo with preview prefix + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithPreviewPrefix, TestSize.Level2) +{ + SessionInfo info; + sptr session = sptr::MakeSptr(info, nullptr); + sptr windowSessionProperty = session->GetSessionProperty(); + session->SetSessionProperty(windowSessionProperty); + windowSessionProperty->SetWindowName("PreviewWindowExample"); + + auto result = manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD); + + EXPECT_EQ(result.first.windowNameType, 1); +} + +/** + * @tc.name: GetWindowInfoWithoutSpecialPrefix + * @tc.desc: windowInfo without special prefix + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithoutSpecialPrefix, TestSize.Level2) +{ + SessionInfo info; + sptr session = sptr::MakeSptr(info, nullptr); + sptr windowSessionProperty = session->GetSessionProperty(); + session->SetSessionProperty(windowSessionProperty); + windowSessionProperty->SetWindowName("RegularWindowExample"); + + auto result = manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD); + + EXPECT_EQ(result.first.windowNameType, 0); +} + +/** + * @tc.name: GetWindowInfoWithVoiceInputPrefix + * @tc.desc: windowInfo with preview prefix + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithVoiceInputPrefix, TestSize.Level2) +{ + std::vector lastWindowInfoList; + SessionInfo info; + sptr session = new (std::nothrow) SceneSession(info, nullptr); + sptr windowSessionProperty = session->GetSessionProperty(); + session->SetSessionProperty(windowSessionProperty); + windowSessionProperty->SetWindowName("__VoiceHardwareInputExample"); + + auto result = manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD); + + EXPECT_EQ(result.first.windowNameType, 2); +} } // namespace } // namespace Rosen } // namespace OHOS -- Gitee From d17ca8116bc0be8c3f665c144217b92bf0f38d59 Mon Sep 17 00:00:00 2001 From: second_89ed Date: Fri, 15 Aug 2025 20:33:25 +0000 Subject: [PATCH 022/241] update window_scene/session_manager/src/scene_session_dirty_manager.cpp. Signed-off-by: second_89ed --- .../session_manager/src/scene_session_dirty_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 099eb9232f..2d62d70ee5 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -803,7 +803,7 @@ std::pair> SceneSessionDirtyMa }; if (startsWith(windowName, SCREENSHOT_WINDOW_NAME_PREFIX) || startsWith(windowName, PREVIEW_WINDOW_NAME_PREFIX)) { windowNameType = WINDOW_NAME_TYPE_THUMBNAIL; - }else if(startsWith(windowName, VOICEINPUT_WINDOW_NAME_PREFIX)){ + } else if (startsWith(windowName, VOICEINPUT_WINDOW_NAME_PREFIX)){ windowNameType = WINDOW_NAME_TYPE_VOICEINPUT; } auto pixelMap = windowSessionProperty->GetWindowMask(); -- Gitee From 8f53e1f04f834a0114b937129323f8cba9b28961 Mon Sep 17 00:00:00 2001 From: second_89ed Date: Fri, 15 Aug 2025 20:41:36 +0000 Subject: [PATCH 023/241] update window_scene/session_manager/src/scene_session_dirty_manager.cpp. Signed-off-by: second_89ed --- .../session_manager/src/scene_session_dirty_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 2d62d70ee5..4a60464c2e 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -803,7 +803,7 @@ std::pair> SceneSessionDirtyMa }; if (startsWith(windowName, SCREENSHOT_WINDOW_NAME_PREFIX) || startsWith(windowName, PREVIEW_WINDOW_NAME_PREFIX)) { windowNameType = WINDOW_NAME_TYPE_THUMBNAIL; - } else if (startsWith(windowName, VOICEINPUT_WINDOW_NAME_PREFIX)){ + } else if (startsWith(windowName, VOICEINPUT_WINDOW_NAME_PREFIX)) { windowNameType = WINDOW_NAME_TYPE_VOICEINPUT; } auto pixelMap = windowSessionProperty->GetWindowMask(); -- Gitee From cbfba0ae765d6dc0c65fa110a84185ac5def0bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Sat, 16 Aug 2025 11:18:51 +0800 Subject: [PATCH 024/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9816-1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../window_manager_napi/js_window_manager.cpp | 2 +- .../window_runtime/window_napi/js_window.cpp | 59 ++++++++++--------- .../window_stage_napi/js_window_stage.cpp | 44 +++++++------- 3 files changed, 54 insertions(+), 51 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index 16dc677fc8..3fa11addf9 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -783,7 +783,7 @@ napi_value JsWindowManager::OnFindWindowSync(napi_env env, napi_callback_info in sptr window = Window::Find(windowName); if (window == nullptr) { napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnFindWindowSync]msg: window is nullptr")); + "[window][findWindow]msg: window is nullptr")); return NapiGetUndefined(env); } else { return CreateJsWindowObject(env, window); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index b1296afacd..1bfb626f46 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1530,7 +1530,7 @@ napi_value JsWindow::OnDestroyWindow(napi_env env, napi_callback_info info) where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); if (ret != WmErrorCode::WM_OK) { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][OnDestroyWindow]msg: Window destroy failed")); + "[window][destroyWindow]msg: Window destroy failed")); return; } windowToken_ = nullptr; // ensure window dtor when finalizer invalid @@ -1569,7 +1569,7 @@ napi_value JsWindow::HideWindowFunction(napi_env env, napi_callback_info info, W if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][HideWindowFunction]msg: window is nullptr or get invalid param.")); + "[window][hide]msg: window is nullptr or get invalid param.")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -2601,7 +2601,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnRegisterWindowCallback]msg: window is nullptr"); + "[window][on]msg: window is nullptr"); } sptr windowToken = windowToken_; constexpr size_t argcMin = 2; @@ -2633,7 +2633,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WmErrorCode ret = registerManager_->RegisterListener(windowToken, cbType, CaseType::CASE_WINDOW, env, callback, parameter); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][OnRegisterWindowCallback]msg: register listener failed."); + return NapiThrowError(env, ret, "[window][on('%{public}s')]msg: register listener failed.", cbType.c_str()); } TLOGI(WmsLogTag::DEFAULT, "Id=%{public}u, type=%{public}s", windowToken->GetWindowId(), cbType.c_str()); // if comptible mode app adpt to immersive, avoid area change will be called when regist @@ -2649,7 +2649,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnUnregisterWindowCallback]msg: window is nullptr"); + "[window][off]msg: window is nullptr"); } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -2678,7 +2678,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info } if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][OnUnregisterWindowCallback]msg: unregister listener failed"); + return NapiThrowError(env, ret, "[window][off('%{public}s')]msg: unregister listener failed", cbType.c_str()); } WLOGFI("Unregister end, window [%{public}u, %{public}s], type=%{public}s", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), cbType.c_str()); @@ -2701,7 +2701,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_DIALOG, "window is nullptr!"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnBindDialogTarget]msg: window is nullptr."); + "[window][bindDialogTarget]msg: window is nullptr."); } if (!Permission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_DIALOG, "permission denied, require system application!"); @@ -2737,7 +2737,8 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) auto asyncTask = [weakToken, env, task = napiAsyncTask, token]() { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][bindDialogTarget]msg: weak window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->BindDialogTarget(token)); @@ -2745,7 +2746,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][OnBindDialogTarget]msg: Bind Dialog Target failed")); + "[window][bindDialogTarget]msg: Bind Dialog Target failed")); } TLOGI(WmsLogTag::WMS_SYSTEM, "BindDialogTarget end, window [%{public}u, %{public}s]", @@ -2753,7 +2754,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnBindDialogTarget") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][OnBindDialogTarget]msg: send event failed")); + "[window][bindDialogTarget]msg: send event failed")); } return result; } @@ -2828,7 +2829,7 @@ static void LoadContentTask(std::shared_ptr contentStorage, std task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][LoadContentTask]msg: Window load content failed")); + "[window][loadContent]msg: Window load content failed")); } WLOGFI("end, window [%{public}u, %{public}s] ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -2863,7 +2864,7 @@ napi_value JsWindow::LoadContentScheduleOld(napi_env env, napi_callback_info inf if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr"); task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR), - "[window][LoadContentScheduleOld]msg: window is nullptr.")); + "[window][loadContent]msg: window is nullptr.")); return; } if (errCode != WMError::WM_OK) { @@ -2921,7 +2922,7 @@ napi_value JsWindow::LoadContentScheduleNew(napi_env env, napi_callback_info inf if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][LoadContentScheduleNew]msg: Window is nullptr.")); + "[window][loadContent]msg: Window is nullptr or get invalid param")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, isLoadedByName); @@ -2968,21 +2969,21 @@ napi_value JsWindow::OnGetUIContext(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { WLOGFE("window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnGetUIContext]msg: window is nullptr"); + "[window][getUIContext]msg: window is nullptr"); } auto uicontent = windowToken_->GetUIContent(); if (uicontent == nullptr) { WLOGFW("uicontent is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnGetUIContext]msg: uicontent is nullptr"); + "[window][getUIContext]msg: uicontent is nullptr"); } napi_value uiContext = uicontent->GetUINapiContext(); if (uiContext == nullptr) { WLOGFE("uiContext obtained from jsEngine is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnGetUIContext]msg: uiContext obtained from jsEngine is nullptr"); + "[window][getUIContext]msg: uiContext obtained from jsEngine is nullptr"); } else { return uiContext; } @@ -3020,7 +3021,7 @@ napi_value JsWindow::OnSetUIContent(napi_env env, napi_callback_info info) if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnSetUIContent]msg: window is nullptr.")); + "[window][setUIContent]msg: window is nullptr.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, false); @@ -3785,7 +3786,7 @@ napi_value JsWindow::OnIsWindowShowingSync(napi_env env, napi_callback_info info if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnIsWindowShowingSync]msg: window is nullptr"); + "[window][isWindowShowing]msg: window is nullptr"); } bool state = (windowToken_->GetWindowState() == WindowState::STATE_SHOWN); TLOGD(WmsLogTag::WMS_LIFE, "Id=%{public}u, state=%{public}u", windowToken_->GetWindowId(), state); @@ -6842,7 +6843,7 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnMinimize]msg: window is nullptr")); + "[window][minimize]msg: window is nullptr")); return; } WMError ret = window->Minimize(); @@ -6851,7 +6852,7 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "[window][OnMinimize]msg: Minimize failed.")); + "[window][minimize]msg: Minimize failed.")); } TLOGNI(WmsLogTag::WMS_PC, "%{public}s Window [%{public}u, %{public}s] minimize end, ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -8364,7 +8365,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "window is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnCreateSubWindowWithOptions]msg: window is null")); + "[window][createSubWindowWithOptions]msg: window is null")); return NapiGetUndefined(env); } if (!windowToken_->IsPcOrFreeMultiWindowCapabilityEnabled()) { @@ -8412,7 +8413,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnCreateSubWindowWithOptions]msg: asyncTask window is nullptr")); + "[window][createSubWindowWithOptions]msg: asyncTask window is nullptr")); return; } if (!WindowHelper::IsFloatOrSubWindow(window->GetType()) && @@ -8431,7 +8432,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (subWindow == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s create sub window failed.", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnCreateSubWindowWithOptions]msg: create sub window failed")); + "[window][createSubWindowWithOptions]msg: create sub window failed")); return; } task->Resolve(env, CreateJsWindowObject(env, subWindow)); @@ -8439,7 +8440,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in }; if (napi_send_event(env, asyncTask, napi_eprio_vip, "OnCreateSubWindowWithOptions") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][OnCreateSubWindowWithOptions]msg: send event failed")); + "[window][createSubWindowWithOptions]msg: send event failed")); } return result; } @@ -8466,14 +8467,14 @@ napi_value JsWindow::OnSetParentWindow(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnSetParentWindow]msg: window is nullptr")); + "[window][setParentWindow]msg: window is nullptr")); return; } WMError ret = window->SetParentWindow(newParentWindowId); if (ret != WMError::WM_OK) { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "[window][OnSetParentWindow]msg: set parent window failed")); + "[window][setParentWindow]msg: set parent window failed")); return; } task->Resolve(env, NapiGetUndefined(env)); @@ -8482,7 +8483,7 @@ napi_value JsWindow::OnSetParentWindow(napi_env env, napi_callback_info info) }; if (napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnSetParentWindow") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][OnSetParentWindow]msg: send event failed")); + "[window][setParentWindow]msg: send event failed")); } return result; } @@ -8497,7 +8498,7 @@ napi_value JsWindow::OnGetParentWindow(napi_env env, napi_callback_info info) WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetParentWindow(parentWindow)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_SUB, "get failed, result=%{public}d", ret); - return NapiThrowError(env, ret, "[window][OnGetParentWindow]msg: get parent window failed"); + return NapiThrowError(env, ret, "[window][getParentWindow]msg: get parent window failed"); } if (parentWindow == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "parentWindow is nullptr"); @@ -8507,7 +8508,7 @@ napi_value JsWindow::OnGetParentWindow(napi_env env, napi_callback_info info) if (objValue == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "create js window failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnGetParentWindow]msg: get parent window failed"); + "[window][getParentWindow]msg: get parent window failed"); } TLOGI(WmsLogTag::WMS_SUB, "window id: %{public}u set parent window id: %{public}u end", windowToken_->GetWindowId(), parentWindow->GetWindowId()); diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 82d845b1d5..3ead8063f3 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -264,7 +264,7 @@ napi_value JsWindowStage::OnGetMainWindow(napi_env env, napi_callback_info info) auto weakScene = weak.lock(); if (weakScene == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, - "[window][OnGetMainWindow]msg: window scene is nullptr")); + "[window][getMainWindow]msg: window scene is nullptr")); TLOGNE(WmsLogTag::WMS_LIFE, "WindowScene_ is nullptr!"); return; } @@ -275,7 +275,7 @@ napi_value JsWindowStage::OnGetMainWindow(napi_env env, napi_callback_info info) window->GetWindowId(), window->GetWindowName().c_str()); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnGetMainWindow]msg: Get main window failed.")); + "[window][getMainWindow]msg: Get main window failed.")); TLOGNE(WmsLogTag::WMS_LIFE, "Get main window failed."); } }; @@ -291,14 +291,14 @@ napi_value JsWindowStage::OnGetMainWindowSync(napi_env env, napi_callback_info i if (weakScene == nullptr) { WLOGFE("WindowScene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, - "[window][OnGetMainWindowSync]msg: windowScene is nullptr")); + "[window][getMainWindowSync]msg: windowScene is nullptr")); return NapiGetUndefined(env); } auto window = weakScene->GetMainWindow(); if (window == nullptr) { WLOGFE("Window is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnGetMainWindowSync]msg: get main window failed")); + "[window][getMainWindowSync]msg: get main window failed")); return NapiGetUndefined(env); } @@ -311,7 +311,7 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) if (weakScene == nullptr) { WLOGFE("Window scene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnEvent]msg: window scene is nullptr.")); + "[window][on]msg: window scene is nullptr.")); return NapiGetUndefined(env); } size_t argc = 4; @@ -341,13 +341,14 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) if (window == nullptr) { WLOGFE("Get window failed"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnEvent]msg: get window failed.")); + "[window][on('%{public}s')]msg: get window failed.", eventString.c_str())); return NapiGetUndefined(env); } auto ret = g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "register event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][OnEvent]msg: regist event failed.")); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on('%{public}s')]msg: regist event failed.", + eventString.c_str())); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] register event %{public}s", @@ -362,7 +363,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) if (weakScene == nullptr) { WLOGFE("Window scene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OffEvent]msg: window scene is nullptr")); + "[window][off]msg: window scene is nullptr")); return NapiGetUndefined(env); } size_t argc = 4; @@ -380,7 +381,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) if (window == nullptr) { WLOGFE("Get window failed"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OffEvent]msg: get main window failed")); + "[window][off('%{public}s')]msg: get main window failed", eventString.c_str())); return NapiGetUndefined(env); } napi_value value = nullptr; @@ -397,7 +398,8 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) } if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "unregister event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][OffEvent]msg: unregister event failed")); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, + "[window][off('%{public}s')]msg: unregister event failed", eventString.c_str())); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] unregister event %{public}s", @@ -420,7 +422,7 @@ static void LoadContentTask(std::shared_ptr contentStorage, std task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "[window][LoadContentTask]msg: Window load content failed")); + "[window][loadContent]msg: Window load content failed")); } WLOGI("Window [%{public}u, %{public}s] load content end, ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -470,7 +472,7 @@ napi_value JsWindowStage::OnLoadContent(napi_env env, napi_callback_info info, b sptr win = weakScene ? weakScene->GetMainWindow() : nullptr; if (win == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnLoadContent]msg: window is nullptr.")); + "[window][loadContent]msg: window is nullptr.")); TLOGNE(WmsLogTag::WMS_LIFE, "Get window failed"); return; } @@ -544,7 +546,7 @@ napi_value JsWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info inf if (weakScene == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window scene is null"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnCreateSubWindow]msg: asyncTask window scene is null")); + "[window][createSubWindow]msg: window scene is null")); return; } sptr windowOption = new Rosen::WindowOption(); @@ -554,7 +556,7 @@ napi_value JsWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info inf if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Get window failed"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnCreateSubWindow]msg: get window failed")); + "[window][createSubWindow]msg: get window failed")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); @@ -595,7 +597,7 @@ napi_value JsWindowStage::OnGetSubWindow(napi_env env, napi_callback_info info) if (weakScene == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window scene is nullptr"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnGetSubWindow]msg: window scene is nullptr")); + "[window][getSubWindow]msg: window scene is nullptr")); return; } std::vector> subWindowVec = weakScene->GetSubWindow(); @@ -832,7 +834,7 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "WindowScene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, - "[window][OnCreateSubWindowWithOptions]msg: windowScene is null")); + "[window][createSubWindowWithOptions]msg: windowScene is null")); return NapiGetUndefined(env); } size_t argc = 4; @@ -876,7 +878,7 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s Get window failed", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnCreateSubWindowWithOptions]msg: Get window failed")); + "[window][createSubWindowWithOptions]msg: Get window failed")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); @@ -895,7 +897,7 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "windowScene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnRemoveStartingWindow]msg: windowScene is null")); + "[window][removeStartingWindow]msg: windowScene is null")); return NapiGetUndefined(env); } @@ -913,7 +915,7 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf if (window == nullptr) { TLOGNE(WmsLogTag::WMS_STARTUP_PAGE, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnRemoveStartingWindow]msg: asyncTask window is nullptr.")); + "[window][removeStartingWindow]msg: window is nullptr.")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->NotifyRemoveStartingWindow()); @@ -921,12 +923,12 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][OnRemoveStartingWindow]msg: Notify remove starting window failed")); + "[window][removeStartingWindow]msg: Notify remove starting window failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnRemoveStartingWindow") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][OnRemoveStartingWindow]msg: send event failed")); + "[window][removeStartingWindow]msg: send event failed")); } return result; } -- Gitee From c4fe747e04e77ad9c2a54e27a08506ee64b61108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Sat, 16 Aug 2025 11:23:01 +0800 Subject: [PATCH 025/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9816-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 1bfb626f46..75330915dc 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1360,7 +1360,7 @@ napi_value JsWindow::OnShowWindow(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnShowWindow]msg: window is nullptr or get invalid param")); + "[window][showWindow]msg: window is nullptr or get invalid param")); TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); return; } @@ -1387,7 +1387,7 @@ napi_value JsWindow::OnShowWindow(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "[window][OnShowWindow]msg: Window show failed")); + "[window][showWindow]msg: window show failed")); } TLOGNI(WmsLogTag::WMS_LIFE, "Window [%{public}u, %{public}s] show end, ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -1515,7 +1515,7 @@ napi_value JsWindow::OnDestroyWindow(napi_env env, napi_callback_info info) if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnDestroyWindow]msg: window is nullptr or get invalid param")); + "[window][destroyWindow]msg: window is nullptr or get invalid param")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -1584,7 +1584,7 @@ napi_value JsWindow::HideWindowFunction(napi_env env, napi_callback_info info, W task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][HideWindowFunction]msg: Window hide failed")); + "[window][hide]msg: Window hide failed")); } TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s end, window [%{public}u] ret=%{public}d", where, weakWindow->GetWindowId(), ret); -- Gitee From 977635bd4a89287c6cbd4b742859342658e16be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Sat, 16 Aug 2025 11:58:08 +0800 Subject: [PATCH 026/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9816-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- .../window_stage_napi/js_window_stage.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 75330915dc..0deec7cc27 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2633,7 +2633,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WmErrorCode ret = registerManager_->RegisterListener(windowToken, cbType, CaseType::CASE_WINDOW, env, callback, parameter); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][on('%{public}s')]msg: register listener failed.", cbType.c_str()); + return NapiThrowError(env, ret, "[window][on]msg: register listener failed."); } TLOGI(WmsLogTag::DEFAULT, "Id=%{public}u, type=%{public}s", windowToken->GetWindowId(), cbType.c_str()); // if comptible mode app adpt to immersive, avoid area change will be called when regist @@ -2678,7 +2678,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info } if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][off('%{public}s')]msg: unregister listener failed", cbType.c_str()); + return NapiThrowError(env, ret, "[window][off]msg: unregister listener failed"); } WLOGFI("Unregister end, window [%{public}u, %{public}s], type=%{public}s", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), cbType.c_str()); diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 3ead8063f3..94e4f3c459 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -341,14 +341,13 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) if (window == nullptr) { WLOGFE("Get window failed"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][on('%{public}s')]msg: get window failed.", eventString.c_str())); + "[window][on]msg: get window failed.")); return NapiGetUndefined(env); } auto ret = g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "register event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on('%{public}s')]msg: regist event failed.", - eventString.c_str())); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on]msg: register event failed.")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] register event %{public}s", @@ -381,7 +380,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) if (window == nullptr) { WLOGFE("Get window failed"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][off('%{public}s')]msg: get main window failed", eventString.c_str())); + "[window][off]msg: get main window failed")); return NapiGetUndefined(env); } napi_value value = nullptr; @@ -398,8 +397,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) } if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "unregister event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, - "[window][off('%{public}s')]msg: unregister event failed", eventString.c_str())); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][off]msg: unregister event failed")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] unregister event %{public}s", -- Gitee From 4ea4f54511c23cb43191247854e29638b9a760cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Sat, 16 Aug 2025 14:49:25 +0800 Subject: [PATCH 027/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9816-3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../window_manager_napi/js_window_manager.cpp | 2 +- .../window_runtime/window_napi/js_window.cpp | 63 +++++++++---------- .../window_stage_napi/js_window_stage.cpp | 40 ++++++------ 3 files changed, 52 insertions(+), 53 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index 3fa11addf9..e7392ed591 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -783,7 +783,7 @@ napi_value JsWindowManager::OnFindWindowSync(napi_env env, napi_callback_info in sptr window = Window::Find(windowName); if (window == nullptr) { napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][findWindow]msg: window is nullptr")); + "[window][findWindow]msg: Window is nullptr.")); return NapiGetUndefined(env); } else { return CreateJsWindowObject(env, window); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 0deec7cc27..ab8049b1ed 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1360,7 +1360,7 @@ napi_value JsWindow::OnShowWindow(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][showWindow]msg: window is nullptr or get invalid param")); + "[window][showWindow]msg: Window is nullptr or get invalid param.")); TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); return; } @@ -1387,7 +1387,7 @@ napi_value JsWindow::OnShowWindow(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "[window][showWindow]msg: window show failed")); + "[window][showWindow]msg: Window show failed.")); } TLOGNI(WmsLogTag::WMS_LIFE, "Window [%{public}u, %{public}s] show end, ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -1515,7 +1515,7 @@ napi_value JsWindow::OnDestroyWindow(napi_env env, napi_callback_info info) if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][destroyWindow]msg: window is nullptr or get invalid param")); + "[window][destroyWindow]msg: Window is nullptr or get invalid param.")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -1530,7 +1530,7 @@ napi_value JsWindow::OnDestroyWindow(napi_env env, napi_callback_info info) where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); if (ret != WmErrorCode::WM_OK) { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][destroyWindow]msg: Window destroy failed")); + "[window][destroyWindow]msg: Window destroy failed.")); return; } windowToken_ = nullptr; // ensure window dtor when finalizer invalid @@ -1569,7 +1569,7 @@ napi_value JsWindow::HideWindowFunction(napi_env env, napi_callback_info info, W if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][hide]msg: window is nullptr or get invalid param.")); + "[window][hide]msg: Window is nullptr or get invalid param.")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -1584,7 +1584,7 @@ napi_value JsWindow::HideWindowFunction(napi_env env, napi_callback_info info, W task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][hide]msg: Window hide failed")); + "[window][hide]msg: Window hide failed.")); } TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s end, window [%{public}u] ret=%{public}d", where, weakWindow->GetWindowId(), ret); @@ -2601,7 +2601,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][on]msg: window is nullptr"); + "[window][on]msg: Window is nullptr."); } sptr windowToken = windowToken_; constexpr size_t argcMin = 2; @@ -2633,7 +2633,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WmErrorCode ret = registerManager_->RegisterListener(windowToken, cbType, CaseType::CASE_WINDOW, env, callback, parameter); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][on]msg: register listener failed."); + return NapiThrowError(env, ret, "[window][on]msg: Register listener failed."); } TLOGI(WmsLogTag::DEFAULT, "Id=%{public}u, type=%{public}s", windowToken->GetWindowId(), cbType.c_str()); // if comptible mode app adpt to immersive, avoid area change will be called when regist @@ -2648,8 +2648,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info { if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][off]msg: window is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][off]msg: Window is nullptr."); } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -2678,7 +2677,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info } if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][off]msg: unregister listener failed"); + return NapiThrowError(env, ret, "[window][off]msg: Unregister listener failed."); } WLOGFI("Unregister end, window [%{public}u, %{public}s], type=%{public}s", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), cbType.c_str()); @@ -2701,7 +2700,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_DIALOG, "window is nullptr!"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][bindDialogTarget]msg: window is nullptr."); + "[window][bindDialogTarget]msg: Window is nullptr."); } if (!Permission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_DIALOG, "permission denied, require system application!"); @@ -2738,7 +2737,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][bindDialogTarget]msg: weak window is nullptr")); + "[window][bindDialogTarget]msg: Weak window is nullptr.")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->BindDialogTarget(token)); @@ -2746,7 +2745,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][bindDialogTarget]msg: Bind Dialog Target failed")); + "[window][bindDialogTarget]msg: Bind Dialog Target failed.")); } TLOGI(WmsLogTag::WMS_SYSTEM, "BindDialogTarget end, window [%{public}u, %{public}s]", @@ -2754,7 +2753,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnBindDialogTarget") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][bindDialogTarget]msg: send event failed")); + "[window][bindDialogTarget]msg: Send event failed.")); } return result; } @@ -2829,7 +2828,7 @@ static void LoadContentTask(std::shared_ptr contentStorage, std task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][loadContent]msg: Window load content failed")); + "[window][loadContent]msg: Window load content failed.")); } WLOGFI("end, window [%{public}u, %{public}s] ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -2864,7 +2863,7 @@ napi_value JsWindow::LoadContentScheduleOld(napi_env env, napi_callback_info inf if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr"); task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR), - "[window][loadContent]msg: window is nullptr.")); + "[window][loadContent]msg: Window is nullptr.")); return; } if (errCode != WMError::WM_OK) { @@ -2969,21 +2968,21 @@ napi_value JsWindow::OnGetUIContext(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { WLOGFE("window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getUIContext]msg: window is nullptr"); + "[window][getUIContext]msg: Window is nullptr."); } auto uicontent = windowToken_->GetUIContent(); if (uicontent == nullptr) { WLOGFW("uicontent is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getUIContext]msg: uicontent is nullptr"); + "[window][getUIContext]msg: Uicontent is nullptr."); } napi_value uiContext = uicontent->GetUINapiContext(); if (uiContext == nullptr) { WLOGFE("uiContext obtained from jsEngine is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getUIContext]msg: uiContext obtained from jsEngine is nullptr"); + "[window][getUIContext]msg: UiContext obtained from jsEngine is nullptr."); } else { return uiContext; } @@ -3021,7 +3020,7 @@ napi_value JsWindow::OnSetUIContent(napi_env env, napi_callback_info info) if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setUIContent]msg: window is nullptr.")); + "[window][setUIContent]msg: Window is nullptr.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, false); @@ -3786,7 +3785,7 @@ napi_value JsWindow::OnIsWindowShowingSync(napi_env env, napi_callback_info info if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][isWindowShowing]msg: window is nullptr"); + "[window][isWindowShowing]msg: Window is nullptr."); } bool state = (windowToken_->GetWindowState() == WindowState::STATE_SHOWN); TLOGD(WmsLogTag::WMS_LIFE, "Id=%{public}u, state=%{public}u", windowToken_->GetWindowId(), state); @@ -6843,7 +6842,7 @@ napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][minimize]msg: window is nullptr")); + "[window][minimize]msg: Window is nullptr.")); return; } WMError ret = window->Minimize(); @@ -8365,7 +8364,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "window is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindowWithOptions]msg: window is null")); + "[window][createSubWindowWithOptions]msg: Window is nullptr.")); return NapiGetUndefined(env); } if (!windowToken_->IsPcOrFreeMultiWindowCapabilityEnabled()) { @@ -8413,7 +8412,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindowWithOptions]msg: asyncTask window is nullptr")); + "[window][createSubWindowWithOptions]msg: AsyncTask window is nullptr.")); return; } if (!WindowHelper::IsFloatOrSubWindow(window->GetType()) && @@ -8432,7 +8431,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (subWindow == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s create sub window failed.", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindowWithOptions]msg: create sub window failed")); + "[window][createSubWindowWithOptions]msg: Create sub window failed.")); return; } task->Resolve(env, CreateJsWindowObject(env, subWindow)); @@ -8440,7 +8439,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in }; if (napi_send_event(env, asyncTask, napi_eprio_vip, "OnCreateSubWindowWithOptions") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][createSubWindowWithOptions]msg: send event failed")); + "[window][createSubWindowWithOptions]msg: Send event failed.")); } return result; } @@ -8467,14 +8466,14 @@ napi_value JsWindow::OnSetParentWindow(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setParentWindow]msg: window is nullptr")); + "[window][setParentWindow]msg: Window is nullptr.")); return; } WMError ret = window->SetParentWindow(newParentWindowId); if (ret != WMError::WM_OK) { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "[window][setParentWindow]msg: set parent window failed")); + "[window][setParentWindow]msg: Set parent window failed.")); return; } task->Resolve(env, NapiGetUndefined(env)); @@ -8483,7 +8482,7 @@ napi_value JsWindow::OnSetParentWindow(napi_env env, napi_callback_info info) }; if (napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnSetParentWindow") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][setParentWindow]msg: send event failed")); + "[window][setParentWindow]msg: Send event failed.")); } return result; } @@ -8498,7 +8497,7 @@ napi_value JsWindow::OnGetParentWindow(napi_env env, napi_callback_info info) WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetParentWindow(parentWindow)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_SUB, "get failed, result=%{public}d", ret); - return NapiThrowError(env, ret, "[window][getParentWindow]msg: get parent window failed"); + return NapiThrowError(env, ret, "[window][getParentWindow]msg: Get parent window failed."); } if (parentWindow == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "parentWindow is nullptr"); @@ -8508,7 +8507,7 @@ napi_value JsWindow::OnGetParentWindow(napi_env env, napi_callback_info info) if (objValue == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "create js window failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getParentWindow]msg: get parent window failed"); + "[window][getParentWindow]msg: Get parent window failed."); } TLOGI(WmsLogTag::WMS_SUB, "window id: %{public}u set parent window id: %{public}u end", windowToken_->GetWindowId(), parentWindow->GetWindowId()); diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 94e4f3c459..5c60155761 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -264,7 +264,7 @@ napi_value JsWindowStage::OnGetMainWindow(napi_env env, napi_callback_info info) auto weakScene = weak.lock(); if (weakScene == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, - "[window][getMainWindow]msg: window scene is nullptr")); + "[window][getMainWindow]msg: Window scene is nullptr.")); TLOGNE(WmsLogTag::WMS_LIFE, "WindowScene_ is nullptr!"); return; } @@ -291,14 +291,14 @@ napi_value JsWindowStage::OnGetMainWindowSync(napi_env env, napi_callback_info i if (weakScene == nullptr) { WLOGFE("WindowScene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, - "[window][getMainWindowSync]msg: windowScene is nullptr")); + "[window][getMainWindowSync]msg: Window scene is nullptr.")); return NapiGetUndefined(env); } auto window = weakScene->GetMainWindow(); if (window == nullptr) { WLOGFE("Window is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getMainWindowSync]msg: get main window failed")); + "[window][getMainWindowSync]msg: Get main window failed.")); return NapiGetUndefined(env); } @@ -311,7 +311,7 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) if (weakScene == nullptr) { WLOGFE("Window scene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][on]msg: window scene is nullptr.")); + "[window][on]msg: Window scene is nullptr.")); return NapiGetUndefined(env); } size_t argc = 4; @@ -341,13 +341,13 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) if (window == nullptr) { WLOGFE("Get window failed"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][on]msg: get window failed.")); + "[window][on]msg: Get window failed.")); return NapiGetUndefined(env); } auto ret = g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "register event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on]msg: register event failed.")); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on]msg: Register event failed.")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] register event %{public}s", @@ -362,7 +362,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) if (weakScene == nullptr) { WLOGFE("Window scene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][off]msg: window scene is nullptr")); + "[window][off]msg: Window scene is nullptr.")); return NapiGetUndefined(env); } size_t argc = 4; @@ -380,7 +380,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) if (window == nullptr) { WLOGFE("Get window failed"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][off]msg: get main window failed")); + "[window][off]msg: Get main window failed.")); return NapiGetUndefined(env); } napi_value value = nullptr; @@ -397,7 +397,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) } if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "unregister event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][off]msg: unregister event failed")); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][off]msg: Unregister event failed.")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] unregister event %{public}s", @@ -420,7 +420,7 @@ static void LoadContentTask(std::shared_ptr contentStorage, std task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "[window][loadContent]msg: Window load content failed")); + "[window][loadContent]msg: Window load content failed.")); } WLOGI("Window [%{public}u, %{public}s] load content end, ret=%{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -470,7 +470,7 @@ napi_value JsWindowStage::OnLoadContent(napi_env env, napi_callback_info info, b sptr win = weakScene ? weakScene->GetMainWindow() : nullptr; if (win == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][loadContent]msg: window is nullptr.")); + "[window][loadContent]msg: Window is nullptr.")); TLOGNE(WmsLogTag::WMS_LIFE, "Get window failed"); return; } @@ -544,7 +544,7 @@ napi_value JsWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info inf if (weakScene == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window scene is null"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindow]msg: window scene is null")); + "[window][createSubWindow]msg: Window scene is nullptr.")); return; } sptr windowOption = new Rosen::WindowOption(); @@ -554,7 +554,7 @@ napi_value JsWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info inf if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Get window failed"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindow]msg: get window failed")); + "[window][createSubWindow]msg: Get window failed.")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); @@ -595,7 +595,7 @@ napi_value JsWindowStage::OnGetSubWindow(napi_env env, napi_callback_info info) if (weakScene == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window scene is nullptr"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getSubWindow]msg: window scene is nullptr")); + "[window][getSubWindow]msg: Window scene is nullptr.")); return; } std::vector> subWindowVec = weakScene->GetSubWindow(); @@ -832,7 +832,7 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "WindowScene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, - "[window][createSubWindowWithOptions]msg: windowScene is null")); + "[window][createSubWindowWithOptions]msg: Window scene is nullptr.")); return NapiGetUndefined(env); } size_t argc = 4; @@ -876,7 +876,7 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s Get window failed", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindowWithOptions]msg: Get window failed")); + "[window][createSubWindowWithOptions]msg: Get window failed.")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); @@ -895,7 +895,7 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "windowScene is null"); napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][removeStartingWindow]msg: windowScene is null")); + "[window][removeStartingWindow]msg: Window scene is nullptr.")); return NapiGetUndefined(env); } @@ -913,7 +913,7 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf if (window == nullptr) { TLOGNE(WmsLogTag::WMS_STARTUP_PAGE, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][removeStartingWindow]msg: window is nullptr.")); + "[window][removeStartingWindow]msg: Window is nullptr.")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->NotifyRemoveStartingWindow()); @@ -921,12 +921,12 @@ napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_inf task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][removeStartingWindow]msg: Notify remove starting window failed")); + "[window][removeStartingWindow]msg: Notify remove starting window failed.")); } }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnRemoveStartingWindow") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][removeStartingWindow]msg: send event failed")); + "[window][removeStartingWindow]msg: Send event failed.")); } return result; } -- Gitee From 4dad06c739ecf453c0c5dd8aa42bb9fc86adea86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Sat, 16 Aug 2025 14:54:21 +0800 Subject: [PATCH 028/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9816-3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index ab8049b1ed..9e475750d4 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2745,7 +2745,7 @@ napi_value JsWindow::OnBindDialogTarget(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][bindDialogTarget]msg: Bind Dialog Target failed.")); + "[window][bindDialogTarget]msg: Bind dialog target failed.")); } TLOGI(WmsLogTag::WMS_SYSTEM, "BindDialogTarget end, window [%{public}u, %{public}s]", @@ -2921,7 +2921,7 @@ napi_value JsWindow::LoadContentScheduleNew(napi_env env, napi_callback_info inf if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][loadContent]msg: Window is nullptr or get invalid param")); + "[window][loadContent]msg: Window is nullptr or get invalid param.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, isLoadedByName); -- Gitee From a6f4b5ff2f55f2e99cb6ef9075874af303f0a019 Mon Sep 17 00:00:00 2001 From: yuanwenjun <1903700887@qq.com> Date: Sat, 16 Aug 2025 17:01:55 +0800 Subject: [PATCH 029/241] fix: InitPropertyFromOption undefine Signed-off-by: yuanwenjun <1903700887@qq.com> --- wm/include/window_session_impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 7b1d9bf337..da5121cbff 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -847,6 +847,7 @@ protected: bool grayOutMaximizeButton_ = false; private: + void InitPropertyFromOption(const sptr& option); //Trans between colorGamut and colorSpace static ColorSpace GetColorSpaceFromSurfaceGamut(GraphicColorGamut colorGamut); static GraphicColorGamut GetSurfaceGamutFromColorSpace(ColorSpace colorSpace); -- Gitee From 143099f9c12bc2d53d47dc7e598f9e14ae8eec77 Mon Sep 17 00:00:00 2001 From: l30067243 Date: Sat, 16 Aug 2025 18:02:51 +0800 Subject: [PATCH 030/241] add error description info Signed-off-by: l30067243 --- .../window_manager_napi/js_window_manager.cpp | 22 +- .../window_runtime/window_napi/js_window.cpp | 316 +++++++++++------- .../window_stage_napi/js_window_stage.cpp | 39 ++- 3 files changed, 239 insertions(+), 138 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index aa2d6ad6a4..92c49594df 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -674,18 +674,21 @@ napi_value JsWindowManager::OnGetSnapshot(napi_env env, napi_callback_info info) NapiAsyncTask::CompleteCallback complete = [=](napi_env env, NapiAsyncTask& task, int32_t status) { if (dataPack->result != WMError::WM_OK) { - task.Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(dataPack->result))); + task.Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(dataPack->result), + "[window][getSnapshot]msg: get snapshot failed")); TLOGNW(WmsLogTag::WMS_SYSTEM, "Get snapshot not ok!"); return; } if (dataPack->pixelMap == nullptr) { - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getSnapshot]msg: pixel map is invalid")); TLOGNE(WmsLogTag::WMS_SYSTEM, "Get snapshot is nullptr!"); return; } auto nativePixelMap = Media::PixelMapNapi::CreatePixelMap(env, dataPack->pixelMap); if (nativePixelMap == nullptr) { - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getSnapshot]msg: create native pixel map failed")); TLOGNE(WmsLogTag::WMS_SYSTEM, "Create native pixelmap is nullptr!"); return; } @@ -894,7 +897,7 @@ napi_value JsWindowManager::OnRegisterWindowManagerCallback(napi_env env, napi_c WmErrorCode ret = registerManager_->RegisterListener(nullptr, cbType, CaseType::CASE_WINDOW_MANAGER, env, value); if (ret != WmErrorCode::WM_OK) { - napi_throw(env, JsErrUtils::CreateJsError(env, ret)); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on]msg: register " + cbType + " failed")); return NapiGetUndefined(env); } TLOGD(WmsLogTag::DEFAULT, "Register end, type=%{public}s", cbType.c_str()); @@ -932,7 +935,7 @@ napi_value JsWindowManager::OnUnregisterWindowManagerCallback(napi_env env, napi } } if (ret != WmErrorCode::WM_OK) { - napi_throw(env, JsErrUtils::CreateJsError(env, ret)); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][off]msg: unregister " + cbType + " failed")); return NapiGetUndefined(env); } TLOGD(WmsLogTag::DEFAULT, "Unregister end, type=%{public}s", cbType.c_str()); @@ -1151,13 +1154,15 @@ napi_value JsWindowManager::OnSetGestureNavigationEnabled(napi_env env, napi_cal task->Resolve(env, NapiGetUndefined(env)); WLOGD("SetGestureNavigationEnabled success"); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "SetGestureNavigationEnabled failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setGestureNavigationEnabled]msg: set gesture navigation failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetGestureNavigationEnabled") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setGestureNavigationEnabled]msg: failed to send event")); } return result; } @@ -1440,7 +1445,8 @@ napi_value JsWindowManager::OnGetTopNavDestinationName(napi_env env, napi_callba if (WM_JS_TO_ERROR_CODE_MAP.count(*errCodePtr) > 0) { retErrCode = WM_JS_TO_ERROR_CODE_MAP.at(*errCodePtr); } - task.Reject(env, JsErrUtils::CreateJsError(env, retErrCode)); + task.Reject(env, JsErrUtils::CreateJsError(env, retErrCode, + "[window][getTopNavDestinationName]msg: get top navigation name failed")); return; } TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s ok, topNavDestName: %{public}s, windowId: %{public}d", diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 17b40ab4ee..dcce40c025 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2567,20 +2567,23 @@ napi_value JsWindow::OnGetWindowPropertiesSync(napi_env env, napi_callback_info { if (windowToken_ == nullptr) { WLOGFW("window is nullptr or get invalid param"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowProperties]msg: invalid window"); } WindowPropertyInfo windowPropertyInfo; WMError ret = windowToken_->GetWindowPropertyInfo(windowPropertyInfo); if (ret != WMError::WM_OK) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "get window properties failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowProperties]msg: get property info failed"); } auto objValue = CreateJsWindowPropertiesObject(env, windowPropertyInfo); TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "Get Prop, wid: %{public}u", windowToken_->GetWindowId()); if (objValue != nullptr) { return objValue; } else { - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowProperties]msg: create window property object faield"); } } @@ -2595,7 +2598,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i { if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][on]msg: invalid window"); } sptr windowToken = windowToken_; constexpr size_t argcMin = 2; @@ -2627,7 +2630,7 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WmErrorCode ret = registerManager_->RegisterListener(windowToken, cbType, CaseType::CASE_WINDOW, env, callback, parameter); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][on]msg: register " + cbType + " failed"); } TLOGI(WmsLogTag::DEFAULT, "Id=%{public}u, type=%{public}s", windowToken->GetWindowId(), cbType.c_str()); // if comptible mode app adpt to immersive, avoid area change will be called when regist @@ -2642,7 +2645,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info { if (windowToken_ == nullptr) { WLOGFE("Window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][off]msg: invalid window"); } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -2671,7 +2674,7 @@ napi_value JsWindow::OnUnregisterWindowCallback(napi_env env, napi_callback_info } if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][off]msg: unregister " + cbType + " failed"); } WLOGFI("Unregister end, window [%{public}u, %{public}s], type=%{public}s", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), cbType.c_str()); @@ -3204,7 +3207,7 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf if (window == nullptr) { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", where); task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "Invalidate params.")); + "[window][setWindowLayoutFullScreen]msg: invalid window")); return; } // compatibleMode app adapt to immersive need apply avoidArea method @@ -3219,7 +3222,8 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf task.Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s failed, ret %{public}d", where, ret); - task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window OnSetLayoutFullScreen failed.")); + task.Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setWindowLayoutFullScreen]msg: set layout full screen failed")); } }; @@ -3301,7 +3305,8 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_IMMS, "window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowSystemBarEnable]msg: invalid window")); return; } auto errCode = WM_JS_TO_ERROR_CODE_MAP.at( @@ -3310,13 +3315,14 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info task->Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_IMMS, "set system bar enable failed, errcode: %{public}d", errCode); - task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "JsWindow::OnSetWindowSystemBarEnable failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode, + "[window][setWindowSystemBarEnable]msg: update system bar properties failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowSystemBarEnable") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "JsWindow::OnSetWindowSystemBarEnable failed")); + "[window][setWindowSystemBarEnable]msg: send event failed")); } return result; } @@ -3349,7 +3355,8 @@ napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_i auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setSpecificSystemBarEnabled]msg: invalid window")); return; } auto property = window->GetSystemBarPropertyByType(systemBarType); @@ -3362,13 +3369,13 @@ napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_i } else { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s failed, ret %{public}d", where, errCode); task->Reject(env, JsErrUtils::CreateJsError(env, errCode, - "JsWindow::OnSetSpecificSystemBarEnabled failed")); + "[window][setSpecificSystemBarEnabled]msg: set specific bar property failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetSpecificSystemBarEnabled") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "JsWindow::OnSetSpecificSystemBarEnabled failed")); + "[window][setSpecificSystemBarEnabled]msg: send event failed")); } return result; } @@ -3435,7 +3442,8 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_IMMS, "window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowSystemBarProperties]msg: invalid window")); return; } auto errCode = WM_JS_TO_ERROR_CODE_MAP.at( @@ -3445,13 +3453,13 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ } else { TLOGNE(WmsLogTag::WMS_IMMS, "set system bar properties failed, errcode: %{public}d", errCode); task->Reject(env, JsErrUtils::CreateJsError(env, errCode, - "JsWindow::OnSetWindowSystemBarProperties failed")); + "[window][setWindowSystemBarProperties]msg: update system bar properties failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowSystemBarProperties") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "JsWindow::OnSetWindowSystemBarProperties failed")); + "[window][setWindowSystemBarProperties]msg: send event failed")); } return result; } @@ -3460,16 +3468,19 @@ napi_value JsWindow::OnGetWindowSystemBarPropertiesSync(napi_env env, napi_callb { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "window is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowSystemBarProperties]msg: invalid window"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_IMMS, "only main window is allowed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][getWindowSystemBarProperties]msg: not main window"); } auto objValue = CreateJsSystemBarPropertiesObject(env, windowToken_); if (objValue == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "get properties failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY, + "[window][getWindowSystemBarProperties]msg: create system bar properties object failed"); } return objValue; } @@ -3497,7 +3508,8 @@ napi_value JsWindow::OnSetStatusBarColor(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_IMMS, "window is null"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setStatusBarColor]msg: invalid window")); return; } auto errCode = UpdateStatusBarProperty(window, contentColor); @@ -3506,13 +3518,13 @@ napi_value JsWindow::OnSetStatusBarColor(napi_env env, napi_callback_info info) } else { TLOGNE(WmsLogTag::WMS_IMMS, "set status bar property error: %{public}d", errCode); task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(errCode), - "JsWindow::OnSetStatusBarProperty failed")); + "[window][setStatusBarColor]msg: update status bar property failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetStatusBarColor") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY, - "JsWindow::OnSetStatusBarProperty failed")); + "[window][setStatusBarColor]msg: send event failed")); } return result; } @@ -3521,16 +3533,19 @@ napi_value JsWindow::OnGetStatusBarPropertySync(napi_env env, napi_callback_info { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "window is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getStatusBarProperty]msg: invalid window"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_IMMS, "only main window is allowed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][getStatusBarProperty]msg: not main window"); } auto objValue = GetStatusBarPropertyObject(env, windowToken_); if (objValue == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "get property failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY, + "[window][getStatusBarProperty]msg: get status bar property failed"); } return objValue; } @@ -3705,7 +3720,8 @@ napi_value JsWindow::OnGetWindowAvoidAreaSync(napi_env env, napi_callback_info i if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowAvoidArea]msg: invalid window"); } // getAvoidRect by avoidAreaType AvoidArea avoidArea; @@ -3722,7 +3738,8 @@ napi_value JsWindow::OnGetWindowAvoidAreaSync(napi_env env, napi_callback_info i return avoidAreaObj; } else { TLOGE(WmsLogTag::WMS_IMMS, "ConvertAvoidAreaToJsValue failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowAvoidArea]msg: convert avoid area failed"); } } @@ -3929,7 +3946,8 @@ napi_value JsWindow::OnIsWindowSupportWideGamut(napi_env env, napi_callback_info if (weakWindow == nullptr) { WLOGFE("window is nullptr or get invalid param"); task->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isWindowSupportWideGamut]msg: invalid window")); return; } bool flag = weakWindow->IsSupportWideGamut(); @@ -3940,7 +3958,8 @@ napi_value JsWindow::OnIsWindowSupportWideGamut(napi_env env, napi_callback_info if (napi_send_event(env, asyncTask, napi_eprio_high, "OnIsWindowSupportWideGamut") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isWindowSupportWideGamut]msg: failed to send event")); } return result; } @@ -3970,18 +3989,21 @@ napi_value JsWindow::OnSetBackgroundColor(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { WLOGFE("window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR)); + task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, + "[window][setBackgroundColor]msg: invalid window")); return; } if (errCode != WMError::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "Invalidate params.")); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode, + "[window][setBackgroundColor]msg: invalid params")); return; } WMError ret = weakWindow->SetBackgroundColor(color); if (ret == WMError::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set background color failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setBackgroundColor]msg: set background color failed")); } WLOGD("%{public}s window [%{public}u, %{public}s] end", where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); @@ -3989,7 +4011,8 @@ napi_value JsWindow::OnSetBackgroundColor(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetBackgroundColor") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setBackgroundColor]msg: failed to send event")); } return result; } @@ -4015,7 +4038,8 @@ napi_value JsWindow::OnSetWindowBackgroundColorSync(napi_env env, napi_callback_ if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "window is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowBackgroundColor]msg: invalid window"); } auto retErr = windowToken_->SetBackgroundColor(color); TLOGI(WmsLogTag::WMS_ATTRIBUTE, "win=%{public}u, color=%{public}s, retErr=%{public}d", @@ -4024,7 +4048,7 @@ napi_value JsWindow::OnSetWindowBackgroundColorSync(napi_env env, napi_callback_ if (ret == WmErrorCode::WM_OK) { return NapiGetUndefined(env); } else { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][setWindowBackgroundColor]msg: set background color failed"); } } @@ -4115,14 +4139,16 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "Invalidate params.")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowBrightness]msg: invalid window")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetBrightness(brightness)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set brightness failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setWindowBrightness]msg: set window brightness failed")); } TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "Window [%{public}u, %{public}s] set brightness end, result: %{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); @@ -4130,7 +4156,8 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowBrightness") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowBrightness]msg: failed to send event")); } return result; } @@ -4565,13 +4592,14 @@ napi_value JsWindow::OnSetWindowKeepScreenOn(napi_env env, napi_callback_info in [weakToken, keepScreenOn, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "System abnormal.")); + "[window][setWindowKeepScreenOn]msg: service abnormally")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "Window set keep screen on failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, + "[window][setWindowKeepScreenOn]msg: set keep screen on failed")); } }; @@ -4587,10 +4615,12 @@ napi_value JsWindow::OnSetWakeUpScreen(napi_env env, napi_callback_info info) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { WLOGFE("set wake up screen permission denied!"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP); + return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP, + "[window][setWakeUpScreen]msg: permission denied"); } if (windowToken_ == nullptr) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWakeUpScreen]msg: invalid window"); } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -4610,7 +4640,7 @@ napi_value JsWindow::OnSetWakeUpScreen(napi_env env, napi_callback_info info) WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetTurnScreenOn(wakeUp)); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][setWakeUpScreen]msg: turn screen on faield"); } WLOGI("Window [%{public}u, %{public}s] set wake up screen %{public}d end", @@ -4666,11 +4696,13 @@ napi_value JsWindow::OnSetPrivacyMode(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { WLOGFE("window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR)); + task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, + "[window][setPrivacyMode]msg: invalid window")); return; } if (errCode != WMError::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "Invalidate params")); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode, + "[window][setPrivacyMode]msg: invalid params")); return; } weakWindow->SetPrivacyMode(isPrivacyMode); @@ -4681,7 +4713,8 @@ napi_value JsWindow::OnSetPrivacyMode(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetPrivacyMode") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setPrivacyMode]msg: failed to send event")); } return result; } @@ -4719,12 +4752,13 @@ napi_value JsWindow::OnSetWindowPrivacyMode(napi_env env, napi_callback_info inf auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "Invalidate params")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowPrivacyMode]msg: invalid window")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetPrivacyMode(isPrivacyMode)); if (ret == WmErrorCode::WM_ERROR_NO_PERMISSION) { - task->Reject(env, JsErrUtils::CreateJsError(env, ret)); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setWindowPrivacyMode]msg: no permission")); WLOGI("%{public}s failed, window [%{public}u, %{public}s] mode=%{public}u", where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), isPrivacyMode); return; @@ -4736,7 +4770,8 @@ napi_value JsWindow::OnSetWindowPrivacyMode(napi_env env, napi_callback_info inf if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowPrivacyMode") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowPrivacyMode]msg: failed to send event")); } return result; } @@ -4952,20 +4987,20 @@ napi_value JsWindow::OnHideNonSystemFloatingWindows(napi_env env, napi_callback_ if (window == nullptr) { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, - WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr.")); + WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][hideNonSystemFloatingWindows]msg: invalid window")); return; } if (window->IsFloatingWindowAppType()) { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s window is app floating window", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "HideNonSystemFloatingWindows is not allowed since window is app window")); + "[window][hideNonSystemFloatingWindows]msg: current window is an app window")); return; } WMError ret = window->HideNonSystemFloatingWindows(shouldHide); if (ret != WMError::WM_OK) { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s failed", where); task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "Hide non-system floating windows failed")); + "[window][hideNonSystemFloatingWindows]msg: hide non-system floating windows failed")); return; } task->Resolve(env, NapiGetUndefined(env)); @@ -4975,7 +5010,8 @@ napi_value JsWindow::OnHideNonSystemFloatingWindows(napi_env env, napi_callback_ }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnHideNonSystemFloatingWindows") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "send event failed")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][hideNonSystemFloatingWindows]msg: send event failed")); } return result; } @@ -5015,7 +5051,8 @@ napi_value JsWindow::OnSetSingleFrameComposerEnabled(napi_env env, napi_callback std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); auto asyncTask = [weakToken = wptr(windowToken_), enabled, errCode, where, env, task = napiAsyncTask] { if (errCode != WmErrorCode::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "permission denied or invalid parameter.")); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode, + "[window][setSingleFrameComposerEnabled]msg: permission denied or invalid parameter")); return; } @@ -5024,7 +5061,8 @@ napi_value JsWindow::OnSetSingleFrameComposerEnabled(napi_env env, napi_callback if (weakWindow == nullptr) { WLOGFE("window is nullptr"); wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr.")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][setSingleFrameComposerEnabled]msg: invalid window")); return; } @@ -5035,7 +5073,7 @@ napi_value JsWindow::OnSetSingleFrameComposerEnabled(napi_env env, napi_callback wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); WLOGFE("Set single frame composer enabled failed, ret is %{public}d", wmErrorCode); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "Set single frame composer enabled failed")); + "[window][setSingleFrameComposerEnabled]msg: set single frame composer enabled failed")); return; } WLOGI("%{public}s end, window [%{public}u, %{public}s] enabled flag=%{public}d", @@ -5044,7 +5082,8 @@ napi_value JsWindow::OnSetSingleFrameComposerEnabled(napi_env env, napi_callback if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetSingleFrameComposerEnabled") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setSingleFrameComposerEnabled]msg: failed to send event")); } return result; } @@ -5496,7 +5535,7 @@ napi_value JsWindow::OnSetWindowColorSpace(napi_env env, napi_callback_info info if (weakWindow == nullptr) { WLOGFE("window is nullptr"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "OnSetWindowColorSpace failed")); + "[window][setWindowColorSpace]msg: invalid window")); return; } weakWindow->SetColorSpace(colorSpace); @@ -5508,7 +5547,8 @@ napi_value JsWindow::OnSetWindowColorSpace(napi_env env, napi_callback_info info if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowColorSpace") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowColorSpace]msg: failed to send event")); } return result; } @@ -5559,7 +5599,8 @@ napi_value JsWindow::OnGetWindowColorSpaceSync(napi_env env, napi_callback_info { if (windowToken_ == nullptr) { WLOGFE("window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowColorSpace]msg: invalid window"); } ColorSpace colorSpace = windowToken_->GetColorSpace(); WLOGFI("end, window [%{public}u, %{public}s] colorSpace=%{public}u", @@ -5682,13 +5723,15 @@ napi_value JsWindow::OnSnapshot(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { WLOGFE("window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshot]msg: invalid window")); return; } std::shared_ptr pixelMap = weakWindow->Snapshot(); if (pixelMap == nullptr) { - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshot]msg: snapshot failed")); WLOGFE("window snapshot get pixelmap is null"); return; } @@ -5705,7 +5748,8 @@ napi_value JsWindow::OnSnapshot(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSnapshot") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshot]msg: failed to send event")); } return result; } @@ -5714,20 +5758,22 @@ napi_value JsWindow::OnSnapshotSync(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowToken is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshotSync]msg: invalid window"); } std::shared_ptr pixelMap = nullptr; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->Snapshot(pixelMap)); TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}u snapshot end, result: %{public}d", windowToken_->GetWindowId(), ret); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][snapshotSync]msg: snapshot failed"); } auto nativePixelMap = Media::PixelMapNapi::CreatePixelMap(env, pixelMap); if (nativePixelMap == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}u get nativePixelMap is null", windowToken_->GetWindowId()); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshotSync]msg: create pixel map failed"); } return nativePixelMap; } @@ -5743,7 +5789,8 @@ napi_value JsWindow::OnSnapshotIgnorePrivacy(napi_env env, napi_callback_info in auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "window is nullptr"); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshotIgnorePrivacy]msg: invalid window")); return; } @@ -5754,7 +5801,8 @@ napi_value JsWindow::OnSnapshotIgnorePrivacy(napi_env env, napi_callback_info in TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "device not support"); return; } else if (ret != WmErrorCode::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshotIgnorePrivacy]msg: snapshot faield")); TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "get pixelmap failed, code:%{public}d", ret); return; } @@ -5771,7 +5819,8 @@ napi_value JsWindow::OnSnapshotIgnorePrivacy(napi_env env, napi_callback_info in if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSnapshotIgnorePrivacy") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][snapshotIgnorePrivacy]msg: failed to send event")); } return result; } @@ -5797,17 +5846,19 @@ napi_value JsWindow::OnSetSnapshotSkip(napi_env env, napi_callback_info info) } } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setSnapshotSkip]msg: invalid params"); } if (windowToken_ == nullptr) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setSnapshotSkip]msg: invalid window"); } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetSnapshotSkip(isSkip)); if (ret != WmErrorCode::WM_OK) { WLOGFE("Window SetSnapshotSkip failed"); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][setSnapshotSkip]msg: set snapshot skip failed"); } WLOGI("[%{public}u, %{public}s] set snapshotSkip end", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str()); @@ -6605,7 +6656,7 @@ napi_value JsWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "OnSetWaterMarkFlag failed.")); + "[window][setWaterMarkFlag]msg: invalid window")); return; } WMError ret = WMError::WM_OK; @@ -6618,7 +6669,7 @@ napi_value JsWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "SetWaterMarkFlag failed.")); + "[window][setWaterMarkFlag]msg: set water mark flag failed")); } WLOGI("%{public}s end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -6626,7 +6677,8 @@ napi_value JsWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWaterMarkFlag") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWaterMarkFlag]msg: failed to send event")); } return result; } @@ -7259,7 +7311,8 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) modalityType = JS_TO_NATIVE_MODALITY_TYPE_MAP.at(apiModalityType); } else { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to modalityType"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setPrivacyMode]msg: convert parameter to modality type failed"); } } napi_value result = nullptr; @@ -7270,14 +7323,15 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr.")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][setSubWindowModal]msg: invalid window")); return; } if (!WindowHelper::IsSubWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s invalid call, type:%{public}d", where, window->GetType()); task->Reject(env, JsErrUtils::CreateJsError(env, - WmErrorCode::WM_ERROR_INVALID_CALLING, "invalid window type.")); + WmErrorCode::WM_ERROR_INVALID_CALLING, "[window][setSubWindowModal]msg: invalid window type.")); return; } WMError ret = window->SetSubWindowModal(isModal, modalityType); @@ -7286,7 +7340,8 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); TLOGNE(WmsLogTag::WMS_SUB, "%{public}s set failed, ret is %{public}d", where, wmErrorCode); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][setSubWindowModal]msg: set subwindow modal failed")); return; } TLOGNI(WmsLogTag::WMS_SUB, @@ -7295,7 +7350,8 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetSubWindowModal") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setSubWindowModal]msg: send event failed")); } return result; } @@ -7619,7 +7675,8 @@ napi_value JsWindow::OnSetWindowContainerColor(napi_env env, napi_callback_info } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_DECOR, "WindowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowContainerColor]msg: invalid window"); } std::string activeColor; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], activeColor)) { @@ -7637,7 +7694,7 @@ napi_value JsWindow::OnSetWindowContainerColor(napi_env env, napi_callback_info WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_DECOR, "set window container color failed!"); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][setWindowContainerColor]msg: set window container color failed"); } return NapiGetUndefined(env); } @@ -7653,7 +7710,8 @@ napi_value JsWindow::OnSetWindowContainerModalColor(napi_env env, napi_callback_ } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_DECOR, "WindowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowContainerModalColor]msg: invalid window"); } std::string activeColor; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], activeColor)) { @@ -7672,7 +7730,7 @@ napi_value JsWindow::OnSetWindowContainerModalColor(napi_env env, napi_callback_ WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_DECOR, "set window container color failed!"); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][setWindowContainerModalColor]msg: set container modal color failed"); } return NapiGetUndefined(env); } @@ -7836,18 +7894,21 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_PC, "%{public}s window is nullptr", where); WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][setWindowMask]msg: invalid window")); return; } if (!WindowHelper::IsSubWindow(window->GetType()) && !WindowHelper::IsAppFloatingWindow(window->GetType())) { WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate window type")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][setWindowMask]msg: invalid window type")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMask(windowMask)); if (ret != WmErrorCode::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, ret)); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setWindowMask]msg: set window mask failed")); TLOGNE(WmsLogTag::WMS_PC, "%{public}s Window [%{public}u, %{public}s] set window mask failed", where, window->GetWindowId(), window->GetWindowName().c_str()); return; @@ -7915,13 +7976,15 @@ void SetWindowGrayScaleTask(const wptr& weakToken, double grayScale, complete = [err](napi_env env, NapiAsyncTask& task, int32_t status) { if (err == nullptr) { - task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowGrayScale]msg: invalid error code")); return; } if (*err == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, CreateJsError(env, static_cast(*err), "Set window gray scale failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, *err, + "[window][setWindowGrayScale]msg: set window gray scale failed")); } }; } @@ -7971,12 +8034,14 @@ napi_value JsWindow::OnSetImmersiveModeEnabledState(napi_env env, napi_callback_ } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "windowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setImmersiveModeEnabledState]msg: invalid window"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType()) && !WindowHelper::IsSubWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_IMMS, "not allowed since invalid window type"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][setImmersiveModeEnabledState]msg: not allowed window type"); } WmErrorCode ret = WmErrorCode::WM_OK; napi_value nativeVal = argv[0]; @@ -7999,7 +8064,8 @@ napi_value JsWindow::OnSetImmersiveModeEnabledState(napi_env env, napi_callback_ ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetImmersiveModeEnabledState(enable)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_IMMS, "set failed, ret %{public}d", ret); - return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY, + "[window][setImmersiveModeEnabledState]msg: set immersive mode enable state failed"); } TLOGI(WmsLogTag::WMS_IMMS, "win %{public}u set end", windowToken_->GetWindowId()); return NapiGetUndefined(env); @@ -8009,12 +8075,14 @@ napi_value JsWindow::OnGetImmersiveModeEnabledState(napi_env env, napi_callback_ { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "windowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getImmersiveModeEnabledState]msg: invalid window"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType()) && !WindowHelper::IsSubWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_IMMS, "not allowed since invalid window type"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][getImmersiveModeEnabledState]msg: not allowed window type"); } bool isEnabled = windowToken_->GetImmersiveModeEnabledState(); @@ -8026,13 +8094,14 @@ napi_value JsWindow::OnIsImmersiveLayout(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "windowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isImmersiveLayout]msg: invalid window"); } bool isImmersiveLayout = false; auto ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->IsImmersiveLayout(isImmersiveLayout)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_IMMS, "failed, ret %{public}d", ret); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][isImmersiveLayout]msg: get immersive layout failed"); } TLOGI(WmsLogTag::WMS_IMMS, "win %{public}u isImmersiveLayout %{public}u end", windowToken_->GetWindowId(), isImmersiveLayout); @@ -8308,7 +8377,8 @@ napi_value JsWindow::OnSetGestureBackEnabled(napi_env env, napi_callback_info in task.Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set failed, ret %{public}d", where, *errCodePtr); - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "set failed.")); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, + "[window][setGestureBackEnabled]msg: set gesture back failed")); } }; napi_value result = nullptr; @@ -8321,11 +8391,13 @@ napi_value JsWindow::OnGetGestureBackEnabled(napi_env env, napi_callback_info in { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isGestureBackEnabled]msg: invalid window"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_IMMS, "get failed since invalid window type"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][isGestureBackEnabled]msg: not main window"); } bool enable = true; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetGestureBackEnabled(enable)); @@ -8334,7 +8406,8 @@ napi_value JsWindow::OnGetGestureBackEnabled(napi_env env, napi_callback_info in return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); } else if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_IMMS, "get failed, ret %{public}d", ret); - return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY, + "[window][isGestureBackEnabled]msg: get gesture back failed"); } TLOGI(WmsLogTag::WMS_IMMS, "win [%{public}u, %{public}s] enable %{public}u", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), enable); @@ -8496,13 +8569,14 @@ napi_value JsWindow::OnGetWindowDensityInfo(napi_env env, napi_callback_info inf { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowToken is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowDensityInfo]msg: invalid window"); } WindowDensityInfo densityInfo; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetWindowDensityInfo(densityInfo)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "get failed, result=%{public}d", ret); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][getWindowDensityInfo]msg: get density info failed"); } auto objValue = ConvertWindowDensityInfoToJsValue(env, densityInfo); if (objValue != nullptr) { @@ -8511,7 +8585,8 @@ napi_value JsWindow::OnGetWindowDensityInfo(napi_env env, napi_callback_info inf return objValue; } else { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "create js windowDensityInfo failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowDensityInfo]msg: convert density info faield"); } } @@ -8531,13 +8606,14 @@ napi_value JsWindow::OnSetDefaultDensityEnabled(napi_env env, napi_callback_info } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowToken is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setDefaultDensityEnabled]msg: invalid window"); } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetWindowDefaultDensityEnabled(enabled)); TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}u set enabled=%{public}u result=%{public}d", windowToken_->GetWindowId(), enabled, ret); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][setDefaultDensityEnabled]msg: set default density failed"); } return NapiGetUndefined(env); } @@ -8546,7 +8622,8 @@ napi_value JsWindow::OnIsMainWindowFullScreenAcrossDisplays(napi_env env, napi_c { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowToken is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isMainWindowFullScreenAcrossDisplays]msg: invalid window"); } std::shared_ptr isAcrossDisplaysPtr = std::make_shared(false); std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); @@ -8570,10 +8647,12 @@ napi_value JsWindow::OnIsMainWindowFullScreenAcrossDisplays(napi_env env, napi_c task.Resolve(env, objValue); } else { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s convert to js value failed", where); - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isMainWindowFullScreenAcrossDisplays]msg: create js value failed")); } } else { - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr)); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, + "[window][isMainWindowFullScreenAcrossDisplays]msg: query faield")); } }; napi_value result = nullptr; @@ -8627,7 +8706,8 @@ napi_value JsWindow::OnSetSystemAvoidAreaEnabled(napi_env env, napi_callback_inf task.Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s failed, ret %{public}d", where, *errCodePtr); - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "set system avoid area enabled failed.")); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, + "[window][setSystemAvoidAreaEnabled]msg: set system avoid area enabled failed")); } }; napi_value result = nullptr; @@ -8640,17 +8720,19 @@ napi_value JsWindow::OnIsSystemAvoidAreaEnabled(napi_env env, napi_callback_info { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isSystemAvoidAreaEnabled]msg: invalid window"); } if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_IMMS, "only system window is valid"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][isSystemAvoidAreaEnabled]msg: not system window"); } uint32_t avoidAreaOption = 0; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetAvoidAreaOption(avoidAreaOption)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_IMMS, "get failed, ret %{public}d", ret); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][isSystemAvoidAreaEnabled]msg: get avoid area option failed"); } bool enabled = avoidAreaOption & static_cast(AvoidAreaOption::ENABLE_SYSTEM_WINDOW); if (auto objValue = CreateJsValue(env, enabled)) { @@ -8658,7 +8740,8 @@ napi_value JsWindow::OnIsSystemAvoidAreaEnabled(napi_env env, napi_callback_info return objValue; } else { TLOGE(WmsLogTag::WMS_IMMS, "create js object failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][isSystemAvoidAreaEnabled]msg: create js value failed"); } } @@ -8934,7 +9017,8 @@ napi_value JsWindow::OnSetWindowShadowEnabled(napi_env env, napi_callback_info i task.Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s set failed, result: %{public}d", where, *errCodePtr); - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "set window shadow failed.")); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, + "[window][setWindowShadowEnabled]msg: set window shadow failed")); } }; napi_value result = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 950239ec45..c6eb654737 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -307,7 +307,8 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) auto weakScene = windowScene_.lock(); if (weakScene == nullptr) { WLOGFE("Window scene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][on]msg: invalid window scene")); return NapiGetUndefined(env); } size_t argc = 4; @@ -336,13 +337,14 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) auto window = weakScene->GetMainWindow(); if (window == nullptr) { WLOGFE("Get window failed"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][on]msg: invalid main window, event=" + eventString)); return NapiGetUndefined(env); } auto ret = g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "register event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret)); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on]msg: register " + eventString + " failed")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] register event %{public}s", @@ -356,7 +358,8 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) auto weakScene = windowScene_.lock(); if (weakScene == nullptr) { WLOGFE("Window scene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][off]msg: invalid window scene")); return NapiGetUndefined(env); } size_t argc = 4; @@ -373,7 +376,8 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) auto window = weakScene->GetMainWindow(); if (window == nullptr) { WLOGFE("Get window failed"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][off]msg: invalid main window, event=" + eventString)); return NapiGetUndefined(env); } napi_value value = nullptr; @@ -390,7 +394,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) } if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "unregister event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret)); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][off]msg: unregister " + eventString + " failed")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] unregister event %{public}s", @@ -603,13 +607,15 @@ napi_value JsWindowStage::OnSetWindowModal(napi_env env, napi_callback_info info auto windowScene = windowScene_.lock(); if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_MAIN, "WindowScene is null"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, + "[window][setWindowModal]msg: invalid window scene")); return NapiGetUndefined(env); } auto window = windowScene->GetMainWindow(); if (window == nullptr) { TLOGE(WmsLogTag::WMS_MAIN, "window is nullptr"); - napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY)); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, + "[window][setWindowModal]msg: invalid main window")); return NapiGetUndefined(env); } if (window->IsPadAndNotFreeMutiWindowCompatibleMode()) { @@ -642,14 +648,16 @@ napi_value JsWindowStage::OnSetWindowModal(napi_env env, napi_callback_info info auto window = weakWindow.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_MAIN, "%{public}s failed, window is null", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowModal]msg: window is not valid")); return; } WMError ret = window->SetWindowModal(isModal); if (ret != WMError::WM_OK) { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); TLOGNE(WmsLogTag::WMS_MAIN, "%{public}s failed, ret is %{public}d", where, wmErrorCode); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set main window modal failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][setWindowModal]msg: set main window modal failed")); return; } task->Resolve(env, NapiGetUndefined(env)); @@ -658,7 +666,8 @@ napi_value JsWindowStage::OnSetWindowModal(napi_env env, napi_callback_info info }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowModal") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowModal]msg: send event failed")); } return result; } @@ -798,12 +807,14 @@ napi_value JsWindowStage::OnSetCustomDensity(napi_env env, napi_callback_info in auto windowScene = windowScene_.lock(); if (windowScene == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowScene is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STAGE_ABNORMALLY, + "[window][setCustomDensity]msg: invalid window scene"); } auto window = windowScene->GetMainWindow(); if (window == nullptr) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Window is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setCustomDensity]msg: invalid main window"); } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetCustomDensity(density, applyToSubWindow)); @@ -811,7 +822,7 @@ napi_value JsWindowStage::OnSetCustomDensity(napi_env env, napi_callback_info in "applyToSubWindow=%{public}d, result=%{public}u", window->GetWindowId(), window->GetWindowName().c_str(), density, applyToSubWindow, ret); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][setCustomDensity]msg: set custom density failed"); } return NapiGetUndefined(env); } -- Gitee From 06aa4ff2764edd5f95dad40df743a7f03b8fc361 Mon Sep 17 00:00:00 2001 From: yuanwenjun <1903700887@qq.com> Date: Sat, 16 Aug 2025 18:09:38 +0800 Subject: [PATCH 031/241] fix: InitPropertyFromOption undefine Signed-off-by: yuanwenjun <1903700887@qq.com> --- wm/src/window_session_impl.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 571009f482..59fc55c958 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -276,8 +276,14 @@ WindowSessionImpl::WindowSessionImpl(const sptr& option, windowOption_ = option; handler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); + WindowType optionWindowType = option->GetWindowType(); + SessionInfo sessionInfo; + sessionInfo.bundleName_ = option->GetBundleName(); + property_->SetSessionInfo(sessionInfo); + property_->SetWindowType(optionWindowType); InitPropertyFromOption(option); - + isIgnoreSafeArea_ = WindowHelper::IsSubWindow(optionWindowType); + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true, rsUIContext); if (WindowHelper::IsSubWindow(GetType())) { property_->SetDecorEnable(option->GetSubWindowDecorEnable()); @@ -291,15 +297,10 @@ WindowSessionImpl::WindowSessionImpl(const sptr& option, SetDefaultDensityEnabledValue(defaultDensityEnabledGlobalConfig_); } -void WindowSessionImpl::InitPropertyFromOption(const sptr& option) +void WindowSessionImpl::InitPropertyFromOption(const sptr& option) { - WindowType optionWindowType = option->GetWindowType(); - SessionInfo sessionInfo; - sessionInfo.bundleName_ = option->GetBundleName(); - property_->SetSessionInfo(sessionInfo); property_->SetWindowName(option->GetWindowName()); property_->SetRequestRect(option->GetWindowRect()); - property_->SetWindowType(optionWindowType); property_->SetFocusable(option->GetFocusable()); property_->SetTouchable(option->GetTouchable()); property_->SetDisplayId(option->GetDisplayId()); @@ -326,7 +327,7 @@ void WindowSessionImpl::InitPropertyFromOption(const sptr& option) getRotationResultFuture_ = sptr::MakeSptr(); updateRectCallback_ = sptr::MakeSptr(); isMainHandlerAvailable_ = option->GetMainHandlerAvailable(); - isIgnoreSafeArea_ = WindowHelper::IsSubWindow(optionWindowType); + } bool WindowSessionImpl::IsPcWindow() const -- Gitee From 21f411713003787dc2c20808549a36f6f5bc44ce Mon Sep 17 00:00:00 2001 From: "cuihongbin (A)" Date: Sat, 16 Aug 2025 21:10:06 +0800 Subject: [PATCH 032/241] =?UTF-8?q?=E4=BC=98=E5=8C=96CheckNeedUpdate?= =?UTF-8?q?=E7=9A=84=E5=B1=8F=E5=B9=95UT=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- .../src/scene_input_manager.cpp | 7 + .../scene_input_manager_test.cpp | 230 ++++++++++-------- 2 files changed, 142 insertions(+), 95 deletions(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 6f08827f33..735dd6c7c2 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -58,6 +58,9 @@ bool operator==(const MMI::ScreenInfo& a, const MMI::ScreenInfo& b) a.dpi != b.dpi || a.ppi != b.ppi) { return false; } + if (a.rotation !== b.rotation) { + return false; + } return true; } @@ -74,6 +77,10 @@ bool operator==(const MMI::DisplayInfo& a, const MMI::DisplayInfo& b) a.screenArea.area != b.screenArea.area || a.rsId != b.rsId) { return false; } + if (a.offsetX != b.offsetX || a.offsetY != b.offsetY || a.pointerActiveWidth = b.pointerActiveWidth || + a.pointerActiveHeight = b.pointerActiveHeight) { + return false; + } return true; } diff --git a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp index 40e0994ed5..8e757ab810 100644 --- a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp @@ -144,59 +144,6 @@ void MaxWindowInfoTest(sptr ssm_) SceneInputManager::GetInstance().FlushDisplayInfoToMMI(std::move(windowInfoList), std::move(pixelMapList)); } -/** - * @tc.name: CheckNeedUpdate - * @tc.desc: CheckNeedUpdate - * @tc.type: FUNC - */ -HWTEST_F(SceneInputManagerTest, CheckNeedUpdate5, TestSize.Level0) -{ - std::vector screenInfos; - std::vector displayInfos; - std::vector windowInfoList; - MMI::DisplayInfo displayinfo; - displayInfos.emplace_back(displayinfo); - MMI::WindowInfo windowinfo; - windowInfoList.emplace_back(windowinfo); - int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); - SceneInputManager::GetInstance().lastFocusId_ = 0; - SceneInputManager::GetInstance().lastDisplayInfos_ = displayInfos; - SceneInputManager::GetInstance().lastWindowInfoList_ = windowInfoList; - bool result = false; - windowInfoList[0].transform.emplace_back(1.0); - SceneInputManager::GetInstance().lastWindowInfoList_[0].transform.emplace_back(2.0); - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - windowInfoList[0].transform.clear(); - SceneInputManager::GetInstance().lastWindowInfoList_[0].transform.clear(); - - displayInfos[0].id = 1; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].id = 0; - - displayInfos[0].x = 1; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].x = 0; - - displayInfos[0].y = 1; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].y = 0; - - displayInfos[0].width = 1; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].width = 0; - - displayInfos[0].height = 1; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].height = 0; -} - /** * @tc.name: UpdateFocusedSessionId * @tc.desc: UpdateFocusedSessionId @@ -251,33 +198,6 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate6, TestSize.Level1) ASSERT_TRUE(result); windowInfoList[0].transform.clear(); SceneInputManager::GetInstance().lastWindowInfoList_[0].transform.clear(); - displayInfos[0].dpi = 1; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].dpi = 0; - - displayInfos[0].name = "TestName"; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].name = ""; - - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - - displayInfos[0].direction = MMI::Direction::DIRECTION90; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].direction = MMI::Direction::DIRECTION0; - - displayInfos[0].displayDirection = MMI::Direction::DIRECTION90; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].displayDirection = MMI::Direction::DIRECTION0; - - displayInfos[0].displayMode = MMI::DisplayMode::FULL; - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - displayInfos[0].displayMode = MMI::DisplayMode::UNKNOWN; } /** @@ -896,29 +816,149 @@ HWTEST_F(SceneInputManagerTest, ConstructDisplayGroupInfos, TestSize.Level1) } /** - * @tc.name: CheckNeedUpdate - * @tc.desc: CheckNeedUpdate + * @tc.name: CheckNeedUpdateForScreenInfos + * @tc.desc: CheckNeedUpdateForScreenInfos * @tc.type: FUNC */ -HWTEST_F(SceneInputManagerTest, CheckNeedUpdate, TestSize.Level1) +HWTEST_F(SceneInputManagerTest, CheckNeedUpdateForScreenInfos, TestSize.Level1) { std::vector screenInfos; std::vector displayInfos; std::vector windowInfoList; MMI::ScreenInfo screenInfo; - screenInfo.id = 3; + screenInfo.id = 1; + screenInfo.uniqueId = "test01"; + screenInfo.screenType = MMI::ScreenType::REAL; + screenInfo.width = 1; + screenInfo.height = 1; + screenInfo.physicalWidth = 1; + screenInfo.physicalHeight = 1; + screenInfo.tpDirection = MMI::Direction::DIRECTION90; + screenInfo.dpi = 1; + screenInfo.ppi = 1; + screenInfo.rotation = MMI::Rotation::ROTATION_0; screenInfos.emplace_back(screenInfo); - auto result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_TRUE(result); - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList); - ASSERT_FALSE(result); - std::vector screenInfos01; - MMI::ScreenInfo screenInfo01; - screenInfo01.id = 1; - screenInfos01.emplace_back(screenInfo01); - SceneInputManager::GetInstance().FlushEmptyInfoToMMI(); - result = SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos01, displayInfos, windowInfoList); - ASSERT_TRUE(result); + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + ASSERT_FALSE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].id = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].uniqueId = "test02"; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].screenType = MMI::ScreenType::VIRTUAL; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].width = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].height = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].physicalWidth = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].physicalHeight = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].tpDirection = MMI::Direction::DIRECTION270; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].dpi = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].ppi = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + screenInfos[0].rotation = MMI::Rotation::ROTATION_90; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + ASSERT_FALSE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); +} + +/** + * @tc.name: CheckNeedUpdateFordDisplayInfos + * @tc.desc: CheckNeedUpdateFordDisplayInfos + * @tc.type: FUNC + */ +HWTEST_F(SceneInputManagerTest, CheckNeedUpdateFordDisplayInfos, TestSize.Level1) +{ + std::vector screenInfos; + std::vector displayInfos; + std::vector windowInfoList; + MMI::DisplayInfo displayInfo; + displayInfo.id = 1; + displayInfo.x = 1; + displayInfo.y = 1; + displayInfo.width = 1; + displayInfo.height = 1; + displayInfo.dpi = 1; + displayInfo.name = "displayInfo01"; + displayInfo.direction = MMI::Direction::DIRECTION90; + displayInfo.displayDirection = MMI::Direction::DIRECTION90; + displayInfo.displayMode = MMI::DisplayMode::FULL; + displayInfo.transform.emplace_back(0.001); + displayInfo.scalePercent = 100; + displayInfo.expandHeight = 1; + displayInfo.isCurrentOffScreenRendering = true; + displayInfo.displaySourceMode = MMI::DisplaySourceMode::SCREEN_MAIN; + displayInfo.oneHandX = 1; + displayInfo.oneHandY = 1; + displayInfo.screenArea = { 1, { 1, 1, 1, 1 } }; + displayInfo.rsId = 1; + displayInfo.offsetX = 1; + displayInfo.offsetY = 1; + displayInfo.pointerActiveWidth = 1; + displayInfo.pointerActiveHeight = 1; + displayInfos.emplace_back(displayInfo); + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + ASSERT_FALSE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].id = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].x = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].y = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].width = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].height = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].dpi = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].name = "displayInfo02"; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].direction = MMI::Direction::DIRECTION180; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].displayDirection = MMI::Direction::DIRECTION180; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].displayMode = MMI::DisplayMode::SUB; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].transform[0] = 0.002; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfo.transform.emplace_back(0.00002); + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].scalePercent = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].expandHeight = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].isCurrentOffScreenRendering = false; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].displaySourceMode = MMI::DisplaySourceMode::SCREEN_EXTEND; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].oneHandX = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].oneHandY = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].rsId = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].offsetX = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].offsetY = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].pointerActiveWidth = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].pointerActiveHeight = 2; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].screenArea = { 2, { 1, 1, 1, 1 } }; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].screenArea = { 2, { 2, 1, 1, 1 } }; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].screenArea = { 2, { 2, 2, 1, 1 } }; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].screenArea = { 2, { 2, 2, 2, 1 } }; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].screenArea = { 2, { 2, 2, 2, 2 } }; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + ASSERT_FALSE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); } } // namespace } // namespace Rosen -- Gitee From 1412192412ddfa62531d2100372d415cce516941 Mon Sep 17 00:00:00 2001 From: WenJunYuan <1903700887@qq.com> Date: Sun, 17 Aug 2025 10:00:39 +0800 Subject: [PATCH 033/241] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=BC=82=E5=91=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: WenJunYuan <1903700887@qq.com> --- wm/src/window_session_impl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 59fc55c958..01d0caeb6b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -326,8 +326,7 @@ void WindowSessionImpl::InitPropertyFromOption(const sptr& option) getTargetInfoCallback_ = sptr::MakeSptr(); getRotationResultFuture_ = sptr::MakeSptr(); updateRectCallback_ = sptr::MakeSptr(); - isMainHandlerAvailable_ = option->GetMainHandlerAvailable(); - + isMainHandlerAvailable_ = option->GetMainHandlerAvailable(); } bool WindowSessionImpl::IsPcWindow() const -- Gitee From 42d926b667c079675d03945d68219dd1a36bf30c Mon Sep 17 00:00:00 2001 From: WenJunYuan <1903700887@qq.com> Date: Sun, 17 Aug 2025 14:23:44 +0800 Subject: [PATCH 034/241] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=BC=82=E5=91=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: WenJunYuan <1903700887@qq.com> --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 01d0caeb6b..95021098a4 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -326,7 +326,7 @@ void WindowSessionImpl::InitPropertyFromOption(const sptr& option) getTargetInfoCallback_ = sptr::MakeSptr(); getRotationResultFuture_ = sptr::MakeSptr(); updateRectCallback_ = sptr::MakeSptr(); - isMainHandlerAvailable_ = option->GetMainHandlerAvailable(); + isMainHandlerAvailable_ = option->GetMainHandlerAvailable(); } bool WindowSessionImpl::IsPcWindow() const -- Gitee From 47ed628b73c10bba7ba28ea1b064432af9e17647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Sun, 17 Aug 2025 13:55:30 +0000 Subject: [PATCH 035/241] update window_scene/session_manager/src/scene_input_manager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- window_scene/session_manager/src/scene_input_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 735dd6c7c2..3c7297ac50 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -58,7 +58,7 @@ bool operator==(const MMI::ScreenInfo& a, const MMI::ScreenInfo& b) a.dpi != b.dpi || a.ppi != b.ppi) { return false; } - if (a.rotation !== b.rotation) { + if (a.rotation != b.rotation) { return false; } return true; -- Gitee From 86c5a4fb95fec8aacf7f7ae06a9614d4f51e3cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Sun, 17 Aug 2025 15:11:55 +0000 Subject: [PATCH 036/241] update window_scene/session_manager/src/scene_input_manager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- window_scene/session_manager/src/scene_input_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 3c7297ac50..47d60a919e 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -77,8 +77,8 @@ bool operator==(const MMI::DisplayInfo& a, const MMI::DisplayInfo& b) a.screenArea.area != b.screenArea.area || a.rsId != b.rsId) { return false; } - if (a.offsetX != b.offsetX || a.offsetY != b.offsetY || a.pointerActiveWidth = b.pointerActiveWidth || - a.pointerActiveHeight = b.pointerActiveHeight) { + if (a.offsetX != b.offsetX || a.offsetY != b.offsetY || a.pointerActiveWidth != b.pointerActiveWidth || + a.pointerActiveHeight != b.pointerActiveHeight) { return false; } return true; -- Gitee From 511e31ed9029e178df024fb1255a66701bb16139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Mon, 18 Aug 2025 10:38:40 +0800 Subject: [PATCH 037/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9818-1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 10 +++++----- .../window_stage_napi/js_window_stage.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 9e475750d4..997a061a44 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1360,7 +1360,7 @@ napi_value JsWindow::OnShowWindow(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][showWindow]msg: Window is nullptr or get invalid param.")); + "[window][showWindow]msg: Window is nullptr.")); TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); return; } @@ -1515,7 +1515,7 @@ napi_value JsWindow::OnDestroyWindow(napi_env env, napi_callback_info info) if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][destroyWindow]msg: Window is nullptr or get invalid param.")); + "[window][destroyWindow]msg: Window is nullptr.")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -1569,7 +1569,7 @@ napi_value JsWindow::HideWindowFunction(napi_env env, napi_callback_info info, W if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][hide]msg: Window is nullptr or get invalid param.")); + "[window][hide]msg: Window is nullptr.")); return; } if (WindowHelper::IsMainWindow(weakWindow->GetType())) { @@ -2921,7 +2921,7 @@ napi_value JsWindow::LoadContentScheduleNew(napi_env env, napi_callback_info inf if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][loadContent]msg: Window is nullptr or get invalid param.")); + "[window][loadContent]msg: Window is nullptr.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, isLoadedByName); @@ -8412,7 +8412,7 @@ napi_value JsWindow::OnCreateSubWindowWithOptions(napi_env env, napi_callback_in if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindowWithOptions]msg: AsyncTask window is nullptr.")); + "[window][createSubWindowWithOptions]msg: Window is nullptr on asyncTask.")); return; } if (!WindowHelper::IsFloatOrSubWindow(window->GetType()) && diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 5c60155761..483151410b 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -347,7 +347,7 @@ napi_value JsWindowStage::OnEvent(napi_env env, napi_callback_info info) auto ret = g_listenerManager->RegisterListener(window, eventString, CaseType::CASE_STAGE, env, value); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "register event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on]msg: Register event failed.")); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][on]msg: Register event listener failed.")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] register event %{public}s", @@ -397,7 +397,7 @@ napi_value JsWindowStage::OffEvent(napi_env env, napi_callback_info info) } if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::DEFAULT, "unregister event %{public}s failed, ret=%{public}d", eventString.c_str(), ret); - napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][off]msg: Unregister event failed.")); + napi_throw(env, JsErrUtils::CreateJsError(env, ret, "[window][off]msg: Unregister event listener failed.")); return NapiGetUndefined(env); } WLOGI("Window [%{public}u, %{public}s] unregister event %{public}s", -- Gitee From 83ce34427caf156ce3052dedebe60bc184f8a78e Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Mon, 18 Aug 2025 10:57:41 +0800 Subject: [PATCH 038/241] =?UTF-8?q?JSError=E4=BF=A1=E6=81=AF=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peng fafu --- .../window_manager_napi/js_window_manager.cpp | 4 ++-- .../window_runtime/window_napi/js_window.cpp | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index aa2d6ad6a4..e2adc7e2e4 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -1584,8 +1584,8 @@ napi_value JsWindowManager::OnShiftAppWindowPointerEvent(napi_env env, napi_call }; napi_status status = napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnShiftAppWindowPointerEvent"); if (status != napi_status::napi_ok) { - napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][shiftAppWindowPointerEvent]msg:send event failed")); } return result; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 17b40ab4ee..5051036d67 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2787,7 +2787,8 @@ napi_value JsWindow::OnSetDialogBackGestureEnabled(napi_env env, napi_callback_i NapiAsyncTask::CompleteCallback complete = [weakToken, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setDialogBackGestureEnabled]msg:System abnormal")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { @@ -4803,7 +4804,8 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "WindowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setTouchableAreas]msg:window is null"); } Rect windowRect = windowToken_->GetRect(); std::vector touchableAreas; @@ -4819,7 +4821,8 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_EVENT, "%{public}s window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setTouchableAreas]msg:window is null")); return; } WMError ret = weakWindow->SetTouchHotAreas(touchableAreas); @@ -4833,8 +4836,8 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) where, weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetTouchableAreas") != napi_status::napi_ok) { - napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setTouchableAreas]msg:failed to send event")); } return result; } @@ -5274,8 +5277,8 @@ napi_value JsWindow::OnSetWindowTouchable(napi_env env, napi_callback_info info) weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowTouchable") != napi_status::napi_ok) { - napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowTouchable]msg:failed to send event")); } return result; } @@ -6669,7 +6672,7 @@ napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) [weakToken, isAddFlag, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "System abnormal.")); + "[window][setHandwritingFlag]msg:System abnormal.")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { -- Gitee From 2a5a1dd351af49a92aedb41b04e93655e56fa88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Mon, 18 Aug 2025 11:00:30 +0800 Subject: [PATCH 039/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9818-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- .../window_runtime/window_stage_napi/js_window_stage.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 997a061a44..516bb5cfed 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2921,7 +2921,7 @@ napi_value JsWindow::LoadContentScheduleNew(napi_env env, napi_callback_info inf if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][loadContent]msg: Window is nullptr.")); + "[window][loadContent]msg: Wadk window is nullptr.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, isLoadedByName); @@ -8507,7 +8507,7 @@ napi_value JsWindow::OnGetParentWindow(napi_env env, napi_callback_info info) if (objValue == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "create js window failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getParentWindow]msg: Get parent window failed."); + "[window][getParentWindow]msg: Create js window object failed."); } TLOGI(WmsLogTag::WMS_SUB, "window id: %{public}u set parent window id: %{public}u end", windowToken_->GetWindowId(), parentWindow->GetWindowId()); diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 483151410b..f1161d5f7b 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -552,9 +552,9 @@ napi_value JsWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info inf windowOption->SetWindowMode(Rosen::WindowMode::WINDOW_MODE_FLOATING); auto window = weakScene->CreateWindow(windowName, windowOption); if (window == nullptr) { - TLOGNE(WmsLogTag::WMS_LIFE, "Get window failed"); + TLOGNE(WmsLogTag::WMS_LIFE, "Create window failed"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindow]msg: Get window failed.")); + "[window][createSubWindow]msg: Create window failed.")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); @@ -874,9 +874,9 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba option->SetOnlySupportSceneBoard(true); auto window = windowScene->CreateWindow(windowName, option); if (window == nullptr) { - TLOGNE(WmsLogTag::WMS_SUB, "%{public}s Get window failed", where); + TLOGNE(WmsLogTag::WMS_SUB, "%{public}s Create window failed", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][createSubWindowWithOptions]msg: Get window failed.")); + "[window][createSubWindowWithOptions]msg: Create window failed.")); return; } task->Resolve(env, CreateJsWindowObject(env, window)); -- Gitee From 7d02a8a40959ca654b2ab68901954e6908ebf926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Mon, 18 Aug 2025 11:37:06 +0800 Subject: [PATCH 040/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9818-3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 516bb5cfed..523bff70cc 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2921,7 +2921,7 @@ napi_value JsWindow::LoadContentScheduleNew(napi_env env, napi_callback_info inf if (weakWindow == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "Window is nullptr or get invalid param"); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][loadContent]msg: Wadk window is nullptr.")); + "[window][loadContent]msg: Weak window is nullptr.")); return; } LoadContentTask(contentStorage, contextUrl, weakWindow, env, *task, isLoadedByName); -- Gitee From 9598da82e2723b9872d6297b1553857a851c0d1a Mon Sep 17 00:00:00 2001 From: shuangshuangliu Date: Fri, 15 Aug 2025 10:21:20 +0800 Subject: [PATCH 041/241] =?UTF-8?q?TDD=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shuangshuangliu Change-Id: If2662d89f76fb1634fd76d52da363493be1a5646 --- wm/test/unittest/BUILD.gn | 11 + .../input_transfer_station_new_test.cpp | 208 ++++++++++++++++++ 2 files changed, 219 insertions(+) create mode 100644 wm/test/unittest/input_transfer_station_new_test.cpp diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index b83717f68e..56e9391ec6 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -22,6 +22,7 @@ group("unittest") { ":wm_floating_ball_manager_test", ":wm_floating_ball_test", ":wm_gtx_input_event_sender_test", + ":wm_input_transfer_station_new_test", ":wm_input_transfer_station_test", ":wm_pattern_detach_callback_proxy_test", ":wm_pattern_detach_callback_test", @@ -323,6 +324,16 @@ ohos_unittest("wm_input_transfer_station_test") { external_deps = test_external_deps } +ohos_unittest("wm_input_transfer_station_new_test") { + module_out_path = module_out_path + + sources = [ "input_transfer_station_new_test.cpp" ] + + deps = [ ":wm_unittest_common" ] + + external_deps = test_external_deps +} + ohos_unittest("wm_window_input_channel_test") { module_out_path = module_out_path diff --git a/wm/test/unittest/input_transfer_station_new_test.cpp b/wm/test/unittest/input_transfer_station_new_test.cpp new file mode 100644 index 0000000000..a5cde6dd78 --- /dev/null +++ b/wm/test/unittest/input_transfer_station_new_test.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2021 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 "input_manager.h" +#include "input_transfer_station.h" +#include "mock_window_adapter.h" +#include "modifier_render_thread/rs_modifiers_draw_thread.h" +#include "singleton_mocker.h" +#include "window_impl.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; + } +using WindowMocker = SingletonMocker; +class InputTransferStationNewTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + sptr window_; + std::shared_ptr listener; +}; +void InputTransferStationNewTest::SetUpTestCase() {} + +void InputTransferStationNewTest::TearDownTestCase() +{ +#ifdef RS_ENABLE_VK + RSModifiersDrawThread::Destroy(); +#endif +} + +void InputTransferStationNewTest::SetUp() +{ + sptr option = new WindowOption(); + option->SetWindowName("inputwindow"); + window_ = new WindowImpl(option); + window_->Create(INVALID_WINDOW_ID); + listener = std::make_shared(InputEventListener()); +} + +void InputTransferStationNewTest::TearDown() +{ + window_->Destroy(); + window_ = nullptr; +} + +namespace { +/** + * @tc.name: AddInputWindow + * @tc.desc: add input window in station. + * @tc.type: FUNC + * @tc.require: issueI5I5L4 + */ +HWTEST_F(InputTransferStationNewTest, AddInputWindow, TestSize.Level0) +{ + InputTransferStation::GetInstance().isRegisteredMMI_ = true; + InputTransferStation::GetInstance().AddInputWindow(window_); + InputTransferStation::GetInstance().isRegisteredMMI_ = false; + window_->GetWindowProperty()->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); + InputTransferStation::GetInstance().destroyed_ = true; + InputTransferStation::GetInstance().AddInputWindow(window_); + InputTransferStation::GetInstance().destroyed_ = false; + InputTransferStation::GetInstance().AddInputWindow(window_); + InputTransferStation::GetInstance().inputListener_ = listener; + InputTransferStation::GetInstance().AddInputWindow(window_); + InputTransferStation::GetInstance().isGameControllerLoaded_ = true; + InputTransferStation::GetInstance().AddInputWindow(window_); + InputTransferStation::GetInstance().isGameControllerLoaded_ = false; + InputTransferStation::GetInstance().AddInputWindow(window_); + ASSERT_EQ(true, InputTransferStation::GetInstance().isGameControllerLoaded_); +} + +/** + * @tc.name: RemoveInputWindow + * @tc.desc: remove input window in station. + * @tc.type: FUNC + * @tc.require: issueI5I5L4 + */ +HWTEST_F(InputTransferStationNewTest, RemoveInputWindow, TestSize.Level0) +{ + InputTransferStation::GetInstance().destroyed_ = true; + InputTransferStation::GetInstance().RemoveInputWindow(window_->GetWindowId()); + + InputTransferStation::GetInstance().destroyed_ = false; + sptr inputChannel = sptr::MakeSptr(window_); + InputTransferStation::GetInstance().windowInputChannels_.insert({ window_->GetWindowId(), inputChannel }); + InputTransferStation::GetInstance().RemoveInputWindow(window_->GetWindowId()); + auto iter = InputTransferStation::GetInstance().windowInputChannels_.find(window_->GetWindowId()); + ASSERT_EQ(iter, InputTransferStation::GetInstance().windowInputChannels_.end()); +} + +/** + * @tc.name: OnInputEvent + * @tc.desc: OnInputEvent keyEvent + * @tc.type: FUNC + */ +HWTEST_F(InputTransferStationNewTest, OnInputEvent001, TestSize.Level1) +{ + auto keyEvent = MMI::KeyEvent::Create(); + auto tempKeyEvent = keyEvent; + keyEvent = nullptr; + listener->OnInputEvent(keyEvent); + keyEvent = tempKeyEvent; + InputTransferStation::GetInstance().destroyed_ = true; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); + listener->OnInputEvent(keyEvent); + ASSERT_EQ(channel, nullptr); +} + +/** + * @tc.name: OnInputEvent + * @tc.desc: OnInputEvent axisEvent + * @tc.type: FUNC + */ +HWTEST_F(InputTransferStationNewTest, OnInputEvent002, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + auto axisEvent = MMI::AxisEvent::Create(); + axisEvent = nullptr; + listener->OnInputEvent(axisEvent); + EXPECT_TRUE(g_errLog.find("AxisEvent is nullptr") != std::string::npos); + LOG_SetCallback(nullptr); +} + +/** + * @tc.name: OnInputEvent + * @tc.desc: OnInputEvent axisEvent + * @tc.type: FUNC + */ +HWTEST_F(InputTransferStationNewTest, OnInputEvent003, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + auto axisEvent = MMI::AxisEvent::Create(); + listener->OnInputEvent(axisEvent); + EXPECT_FALSE(g_errLog.find("Receive axisEvent, windowId: %{public}d") != std::string::npos); + LOG_SetCallback(nullptr); +} + +/** + * @tc.name: OnInputEvent + * @tc.desc: OnInputEvent pointerEvent + * @tc.type: FUNC + */ +HWTEST_F(InputTransferStationNewTest, OnInputEvent004, TestSize.Level1) +{ + auto pointerEvent = MMI::PointerEvent::Create(); + pointerEvent->SetPointerAction(static_cast(MMI::PointerEvent::POINTER_ACTION_DOWN)); + listener->OnInputEvent(pointerEvent); + pointerEvent->SetPointerAction(static_cast(MMI::PointerEvent::POINTER_ACTION_MOVE)); + pointerEvent->SetAgentWindowId(0); + listener->OnInputEvent(pointerEvent); + pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); + pointerEvent->SetPointerAction(static_cast(MMI::PointerEvent::POINTER_ACTION_DOWN)); + pointerEvent->AddFlag(MMI::InputEvent::EVENT_FLAG_GESTURE_SUPPLEMENT); + listener->OnInputEvent(pointerEvent); + EXPECT_EQ(pointerEvent->GetSourceType(), MMI::PointerEvent::SOURCE_TYPE_MOUSE); + pointerEvent->SetAgentWindowId(static_cast(-1)); + InputTransferStation::GetInstance().destroyed_ = true; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); + listener->OnInputEvent(pointerEvent); + ASSERT_EQ(channel, nullptr); +} + +/** + * @tc.name: GetInputChannel + * @tc.desc: GetInputChannel + * @tc.type: FUNC + */ +HWTEST_F(InputTransferStationNewTest, GetInputChannel, TestSize.Level0) +{ + InputTransferStation::GetInstance().destroyed_ = true; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); + ASSERT_EQ(channel, nullptr); + InputTransferStation::GetInstance().destroyed_ = false; + ASSERT_EQ(channel, nullptr); + InputTransferStation::GetInstance().AddInputWindow(window_); + InputTransferStation::GetInstance().GetInputChannel(0); +} +} // namespace +} +} // namespace Rosen +} // namespace OHOS -- Gitee From 15877ed60eec9adec4d82d50ec221f95c2e31464 Mon Sep 17 00:00:00 2001 From: yecong2332 Date: Mon, 18 Aug 2025 14:36:43 +0800 Subject: [PATCH 042/241] =?UTF-8?q?=E4=BF=AE=E6=94=B9tdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yecong2332 --- .../window_pattern/window_pattern_starting_window_test.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp index bca5c62d27..b7454ecb1d 100644 --- a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp +++ b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp @@ -456,6 +456,10 @@ HWTEST_F(WindowPatternStartingWindowTest, CheckAndGetPreLoadResourceId, TestSize EXPECT_EQ(true, ssm_->CheckAndGetPreLoadResourceId(startingWindowInfo, resId)); startingWindowInfo.iconPathEarlyVersion_ = "resource:///12345678.jpg"; EXPECT_EQ(true, ssm_->CheckAndGetPreLoadResourceId(startingWindowInfo, resId)); + startingWindowInfo.iconPathEarlyVersion_ = "resource:///12345678.webp"; + EXPECT_EQ(true, ssm_->CheckAndGetPreLoadResourceId(startingWindowInfo, resId)); + startingWindowInfo.iconPathEarlyVersion_ = "resource:///12345678.astc"; + EXPECT_EQ(true, ssm_->CheckAndGetPreLoadResourceId(startingWindowInfo, resId)); } /** @@ -467,6 +471,9 @@ HWTEST_F(WindowPatternStartingWindowTest, PreLoadStartingWindow, TestSize.Level1 { ASSERT_NE(ssm_, nullptr); sptr sceneSession = nullptr; + ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + ssm_->PreLoadStartingWindow(sceneSession); + ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ssm_->PreLoadStartingWindow(sceneSession); SessionInfo info; info.bundleName_ = "bundleName_"; -- Gitee From 6dca0a45d8866146b58e23232a450d2dff59467a Mon Sep 17 00:00:00 2001 From: cq_0418 Date: Mon, 18 Aug 2025 15:44:58 +0800 Subject: [PATCH 043/241] =?UTF-8?q?=E8=A1=A5=E5=85=85SetSupportedWindowMod?= =?UTF-8?q?e=20TDD=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cq_0418 --- .../window_scene_session_impl_test3.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index 40b80b39cc..e2d17fc949 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -2007,6 +2007,34 @@ HWTEST_F(WindowSceneSessionImplTest3, SetSupportedWindowModes02, TestSize.Level1 EXPECT_EQ(WMError::WM_OK, ret); } +/** + * @tc.name: SetSupportedWindowModes04 + * @tc.desc: SetSupportedWindowModes + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest3, SetSupportedWindowModes04, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("SetSupportedWindowModes04"); + sptr window = sptr::MakeSptr(option); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + window->hostSession_ = session; + window->property_->SetPersistentId(1); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + + std::vector supportedWindowModes; + supportedWindowModes.push_back(AppExecFwk::SupportWindowMode::FULLSCREEN); + supportedWindowModes.push_back(AppExecFwk::SupportWindowMode::SPLIT); + supportedWindowModes.push_back(AppExecFwk::SupportWindowMode::FLOATING); + + window->windowSystemConfig_.freeMultiWindowSupport_ = true; + window->windowSystemConfig_.freeMultiWindowEnable_ = false; + auto ret = window->SetSupportedWindowModes(supportedWindowModes); + EXPECT_EQ(WMError::WM_OK, ret); +} + /** * @tc.name: GrayOutMaximizeButton * @tc.desc: GrayOutMaximizeButton -- Gitee From d038d6327ebff9679184c5515992195e92adf540 Mon Sep 17 00:00:00 2001 From: xiazhiqi Date: Mon, 18 Aug 2025 08:09:21 +0000 Subject: [PATCH 044/241] fix cfi problem Signed-off-by: xiazhiqi Change-Id: Id5659cea637d6e6bf34811e583e41cd7bc72c1a5 --- window_scene/test/unittest/BUILD.gn | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 8a78b73dbb..013ac8a495 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -849,16 +849,14 @@ ohos_unittest("ws_scene_session_manager_stub_test") { ohos_unittest("ws_scene_session_manager_stub_test2") { module_out_path = module_out_path + configs = [ "${window_base_path}/window_scene/session:ui_effect_public_config" ] + sources = [ "${window_base_path}/window_scene/test/mock/mock_message_parcel.cpp", "scene_session_manager_stub_test2.cpp", ] - deps = [ - ":ws_unittest_common", - "${window_base_path}/window_scene/session:ui_effect_controller", - "${window_base_path}/window_scene/session:ui_effect_controller_client", - ] + deps = [ ":ws_unittest_common" ] external_deps = test_external_deps } -- Gitee From 47129431a99d6a3e939901fa46baa313ada6e828 Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Mon, 18 Aug 2025 16:09:58 +0800 Subject: [PATCH 045/241] =?UTF-8?q?=E9=80=80=E5=90=8E=E5=8F=B0=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E5=91=BD=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laiganlu --- window_scene/interfaces/include/ws_common.h | 2 +- .../js_scene_session_manager.cpp | 4 ++-- .../session/host/include/scene_session.h | 2 +- window_scene/session/host/include/session.h | 4 ++-- window_scene/session/host/src/scene_session.cpp | 2 +- window_scene/session/host/src/session.cpp | 10 +++++----- .../include/scene_session_manager.h | 2 +- .../src/scene_session_manager.cpp | 2 +- .../window_pattern_snapshot_test.cpp | 16 ++++++++-------- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index e484ecc07c..a361507cdf 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -1074,7 +1074,7 @@ enum class SnapshotNodeType : uint32_t { APP_NODE, }; -enum class ScreenLockReason { +enum class BackgroundReason { DEFAULT = 0, /* diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index b7d8fb1ea9..db4969cc99 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2188,10 +2188,10 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env, TLOGI(WmsLogTag::WMS_LIFE, "isSaveSnapshot: %{public}u", isSaveSnapshot); } - ScreenLockReason reason = ScreenLockReason::DEFAULT; + BackgroundReason reason = BackgroundReason::DEFAULT; if (argc >= ARGC_FIVE) { ConvertFromJsValue(env, argv[ARGC_FOUR], reason); - TLOGI(WmsLogTag::WMS_LIFE, "screenLockReason: %{public}u", reason); + TLOGI(WmsLogTag::WMS_LIFE, "backgroundReason: %{public}u", reason); } SceneSessionManager::GetInstance().RequestSceneSessionBackground(sceneSession, isDelegator, isToDesktop, diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 9d327a9443..d42c600aac 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -206,7 +206,7 @@ public: WSError Foreground(sptr property, bool isFromClient = false, const std::string& identityToken = "") override; WSError Background(bool isFromClient = false, const std::string& identityToken = "") override; - WSError BackgroundTask(const bool isSaveSnapshot = true, ScreenLockReason reason = ScreenLockReason::DEFAULT); + WSError BackgroundTask(const bool isSaveSnapshot = true, BackgroundReason reason = BackgroundReason::DEFAULT); WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override; WSError DisconnectTask(bool isFromClient = false, bool isSaveSnapshot = true); void SetClientIdentityToken(const std::string& clientIdentityToken); diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index fc32a0a89c..e5d8b434d1 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -274,7 +274,7 @@ public: void ResetSnapshot(); void SaveSnapshot(bool useFfrt, bool needPersist = true, std::shared_ptr persistentPixelMap = nullptr, bool updateSnapshot = false, - ScreenLockReason reason = ScreenLockReason::DEFAULT); + BackgroundReason reason = BackgroundReason::DEFAULT); void SetSaveSnapshotCallback(Task&& task) { if (task) { @@ -735,7 +735,7 @@ public: bool SupportSnapshotAllSessionStatus() const; void InitSnapshotCapacity(); SnapshotStatus GetWindowStatus() const; - SnapshotStatus GetSessionStatus(ScreenLockReason reason = ScreenLockReason::DEFAULT) const; + SnapshotStatus GetSessionSnapshotStatus(BackgroundReason reason = BackgroundReason::DEFAULT) const; DisplayOrientation GetWindowOrientation() const; uint32_t GetLastOrientation() const; bool HasSnapshotFreeMultiWindow(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 932968ca90..c1e818071f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -498,7 +498,7 @@ WSError SceneSession::NotifyFrameLayoutFinishFromApp(bool notifyListener, const return WSError::WS_OK; } -WSError SceneSession::BackgroundTask(const bool isSaveSnapshot, ScreenLockReason reason) +WSError SceneSession::BackgroundTask(const bool isSaveSnapshot, BackgroundReason reason) { auto needSaveSnapshot = !ScenePersistentStorage::HasKey("SetImageForRecent_" + std::to_string(GetPersistentId()), ScenePersistentStorageType::MAXIMIZE_STATE); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index d6db683e8e..6ffc701025 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2625,7 +2625,7 @@ std::shared_ptr Session::Snapshot(bool runInFfrt, float scalePa return nullptr; } auto surfaceNode = GetSurfaceNode(); - auto key = GetSessionStatus(); + auto key = GetSessionSnapshotStatus(); auto isPersistentImageFit = IsPersistentImageFit(); if (isPersistentImageFit) key = defaultStatus; if (!surfaceNode || !surfaceNode->IsBufferAvailable()) { @@ -2707,12 +2707,12 @@ bool Session::GetEnableAddSnapshot() const } void Session::SaveSnapshot(bool useFfrt, bool needPersist, std::shared_ptr persistentPixelMap, - bool updateSnapshot, ScreenLockReason reason) + bool updateSnapshot, BackgroundReason reason) { if (scenePersistence_ == nullptr) { return; } - auto key = GetSessionStatus(reason); + auto key = GetSessionSnapshotStatus(reason); auto rotate = WSSnapshotHelper::GetDisplayOrientation(currentRotation_); if (persistentPixelMap) { key = defaultStatus; @@ -2895,7 +2895,7 @@ SnapshotStatus Session::GetWindowStatus() const return std::make_pair(snapshotScreen, orientation); } -SnapshotStatus Session::GetSessionStatus(ScreenLockReason reason) const +SnapshotStatus Session::GetSessionSnapshotStatus(BackgroundReason reason) const { if (!SupportSnapshotAllSessionStatus()) { return defaultStatus; @@ -2906,7 +2906,7 @@ SnapshotStatus Session::GetSessionStatus(ScreenLockReason reason) const } else { snapshotScreen = WSSnapshotHelper::GetScreenStatus(); } - if (reason == ScreenLockReason::EXPAND_TO_FOLD_SINGLE_POCKET) { + if (reason == BackgroundReason::EXPAND_TO_FOLD_SINGLE_POCKET) { snapshotScreen = SCREEN_EXPAND; } uint32_t orientation = WSSnapshotHelper::GetOrientation(currentRotation_); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index e9ba28d36e..902af226c8 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -699,7 +699,7 @@ public: int32_t requestId = DEFAULT_REQUEST_FROM_SCB_ID); WSError RequestSceneSessionBackground(const sptr& sceneSession, const bool isDelegator = false, const bool isToDesktop = false, const bool isSaveSnapshot = true, - ScreenLockReason reason = ScreenLockReason::DEFAULT); + BackgroundReason reason = BackgroundReason::DEFAULT); WSError RequestSceneSessionDestruction(const sptr& sceneSession, bool needRemoveSession = true, bool isSaveSnapshot = true, const bool isForceClean = false, bool isUserRequestedExit = false); WSError RequestSceneSessionDestructionInner(sptr& sceneSession, diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c48cdaca15..7eaad3f5aa 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3317,7 +3317,7 @@ WMError SceneSessionManager::CreateUIEffectController(const sptr& sceneSession, - const bool isDelegator, const bool isToDesktop, const bool isSaveSnapshot, ScreenLockReason reason) + const bool isDelegator, const bool isToDesktop, const bool isSaveSnapshot, BackgroundReason reason) { auto task = [this, weakSceneSession = wptr(sceneSession), isDelegator, isToDesktop, isSaveSnapshot, reason] { auto sceneSession = weakSceneSession.promote(); 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 538698fecd..c94e1bd2cc 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 @@ -715,29 +715,29 @@ HWTEST_F(WindowPatternSnapshotTest, GetWindowStatus, TestSize.Level1) } /** - * @tc.name: GetSessionStatus - * @tc.desc: GetSessionStatus Test + * @tc.name: GetSessionSnapshotStatus + * @tc.desc: GetSessionSnapshotStatus Test * @tc.type: FUNC */ -HWTEST_F(WindowPatternSnapshotTest, GetSessionStatus, TestSize.Level1) +HWTEST_F(WindowPatternSnapshotTest, GetSessionSnapshotStatus, TestSize.Level1) { SessionInfo info; sptr sceneSession = sptr::MakeSptr(info, nullptr); sceneSession->capacity_ = defaultCapacity; - auto ret = sceneSession->GetSessionStatus(); + auto ret = sceneSession->GetSessionSnapshotStatus(); EXPECT_EQ(ret, defaultStatus); sceneSession->capacity_ = maxCapacity; sceneSession->state_ = SessionState::STATE_DISCONNECT; sceneSession->currentRotation_ = 0; - sceneSession->GetSessionStatus(); + sceneSession->GetSessionSnapshotStatus(); sceneSession->state_ = SessionState::STATE_ACTIVE; - ret = sceneSession->GetSessionStatus(); + ret = sceneSession->GetSessionSnapshotStatus(); EXPECT_EQ(ret.second, 0); - ScreenLockReason reason = ScreenLockReason::EXPAND_TO_FOLD_SINGLE_POCKET; - ret = sceneSession->GetSessionStatus(reason); + BackgroundReason reason = BackgroundReason::EXPAND_TO_FOLD_SINGLE_POCKET; + ret = sceneSession->GetSessionSnapshotStatus(reason); EXPECT_EQ(ret.first, 1); } -- Gitee From 9f160bd16f8c114fc0debd1692a65094084fd724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E4=B9=A6=E5=8C=85=E6=8C=87=E6=8C=A5=E5=AE=98?= Date: Mon, 18 Aug 2025 16:29:58 +0800 Subject: [PATCH 046/241] change type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 红书包指挥官 --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index ae00ed918b..9c189aadfc 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1204,7 +1204,7 @@ bool WindowSceneSessionImpl::PreNotifyKeyEvent(const std::shared_ptrGetKeyCode() == MMI::KeyEvent::KEYCODE_TAB || keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_ENTER) && isConsumed && keyEvent->GetKeyAction() == MMI::KeyEvent::KEY_ACTION_DOWN) { - TLOGD(WmsLogTag::WMS_EVENT, "wid:%{public}d, keyCode:%{public}d, isConsumed:%{public}d", + TLOGD(WmsLogTag::WMS_EVENT, "wid:%{public}u, keyCode:%{public}d, isConsumed:%{public}d", GetWindowId(), keyEvent->GetKeyCode(), isConsumed); NotifyWatchGestureConsumeResult(keyEvent->GetKeyCode(), isConsumed); } -- Gitee From 1cf4bf59c1b0a05cecaf19ae4544c97aab0e981a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=95=AC=E6=9D=BE?= <18328528985@163.com> Date: Tue, 12 Aug 2025 21:44:16 +0800 Subject: [PATCH 047/241] =?UTF-8?q?5s=E5=86=85=E6=8B=89=E8=B5=B7=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E9=99=90=E5=88=B6=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周敬松 <18328528985@163.com> --- .../session/host/include/scene_session.h | 2 +- window_scene/session/host/src/system_session.cpp | 16 ++++++++-------- .../test/unittest/system_session_test.cpp | 9 ++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index ca78210ea2..73dba4cbd0 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -987,8 +987,8 @@ protected: virtual void NotifyUpdateFloatingBall(const FloatingBallTemplateInfo& fbTemplateInfo) {}; virtual void NotifyStopFloatingBall() {}; virtual void NotifyRestoreFloatingBallMainWindow(const std::shared_ptr& want) {}; - uint64_t fbClickTime_ = 0; std::mutex fbClickMutex_; + uint8_t fbClickCnt_ {0}; FloatingBallTemplateInfo fbTemplateInfo_ = {}; /* diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index 8ec537e494..142830df5e 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -28,7 +28,7 @@ constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "System constexpr uint32_t MIN_SYSTEM_WINDOW_WIDTH = 5; constexpr uint32_t MIN_SYSTEM_WINDOW_HEIGHT = 5; -constexpr uint64_t FLOATING_BALL_CLICK_INTERVAL = 5000; +constexpr uint8_t MAX_FB_CLICK_COUNT = 8; const std::string FB_CLICK_EVENT = "click"; SystemSession::SystemSession(const SessionInfo& info, const sptr& specificCallback) @@ -501,15 +501,13 @@ WMError SystemSession::RestoreFbMainWindow(const std::shared_ptr& w session->GetSessionInfo().bundleName_.c_str(), want->GetBundle().c_str()); return WMError::WM_ERROR_FB_RESTORE_MAIN_WINDOW_FAILED; } - uint64_t nowTime = static_cast(std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count()); { std::lock_guard lock(session->fbClickMutex_); - if (nowTime - session->fbClickTime_ >= FLOATING_BALL_CLICK_INTERVAL) { - TLOGNW(WmsLogTag::WMS_SYSTEM, "%{public}s Start time is too long from click, deny", where); + if (session->fbClickCnt_ == 0) { + TLOGNE(WmsLogTag::WMS_SYSTEM, "%{public}s not click, deny", where); return WMError::WM_ERROR_FB_RESTORE_MAIN_WINDOW_FAILED; } - session->fbClickTime_ = 0; + session->fbClickCnt_--; } TLOGNI(WmsLogTag::WMS_SYSTEM, "%{public}s restore window, bundle %{public}s, ability %{public}s, session bundle %{public}s", @@ -580,8 +578,10 @@ WSError SystemSession::SendFbActionEvent(const std::string& action) return WSError::WS_ERROR_NULLPTR; } if (action == FB_CLICK_EVENT) { - fbClickTime_ = static_cast(std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count()); + std::lock_guard lock(fbClickMutex_); + if (fbClickCnt_ < MAX_FB_CLICK_COUNT) { + ++fbClickCnt_; + } } return sessionStage_->SendFbActionEvent(action); } diff --git a/window_scene/test/unittest/system_session_test.cpp b/window_scene/test/unittest/system_session_test.cpp index f7eab8d5ba..a421e35164 100644 --- a/window_scene/test/unittest/system_session_test.cpp +++ b/window_scene/test/unittest/system_session_test.cpp @@ -965,15 +965,14 @@ HWTEST_F(SystemSessionTest, RestoreFbMainWindow, Function | SmallTest | Level2) EXPECT_EQ(systemSession->RestoreFbMainWindow(want), WMError::WM_ERROR_INVALID_CALLING); LOCK_GUARD_EXPR(SCENE_GUARD, systemSession->SetCallingPid(IPCSkeleton::GetCallingPid())); - EXPECT_EQ(systemSession->RestoreFbMainWindow(want), WMError::WM_ERROR_FB_RESTORE_MAIN_WINDOW_FAILED); - std::string bundle = "testBundle"; want->SetBundle(bundle); EXPECT_EQ(systemSession->RestoreFbMainWindow(want), WMError::WM_ERROR_FB_RESTORE_MAIN_WINDOW_FAILED); + systemSession->EditSessionInfo().bundleName_ = bundle; - uint64_t nowTime = static_cast(std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count()); - systemSession->fbClickTime_ = nowTime - 1000; + EXPECT_EQ(systemSession->RestoreFbMainWindow(want), WMError::WM_ERROR_FB_RESTORE_MAIN_WINDOW_FAILED); + + ++systemSession->fbClickCnt_; EXPECT_EQ(systemSession->RestoreFbMainWindow(want), WMError::WM_OK); } -- Gitee From e34db75839dbff33e1b7d328772d84418f77ac38 Mon Sep 17 00:00:00 2001 From: zhanglitao Date: Mon, 18 Aug 2025 17:07:57 +0800 Subject: [PATCH 048/241] =?UTF-8?q?Modifier=E9=81=97=E7=95=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanglitao --- .../unittest/move_drag_controller_test.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index 613989cd18..3645d9c7d9 100644 --- a/window_scene/test/unittest/move_drag_controller_test.cpp +++ b/window_scene/test/unittest/move_drag_controller_test.cpp @@ -288,38 +288,38 @@ HWTEST_F(MoveDragControllerTest, UpdateGravityWhenDrag, TestSize.Level0) moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); moveDragController->type_ = AreaType::RIGHT; moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); - auto gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - EXPECT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + auto modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + EXPECT_EQ(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - EXPECT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + EXPECT_EQ(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - EXPECT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + EXPECT_EQ(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - EXPECT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + EXPECT_EQ(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_UP); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - EXPECT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + EXPECT_EQ(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_CANCEL); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - EXPECT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + EXPECT_EQ(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UNKNOWN); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - EXPECT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + EXPECT_EQ(modifier, nullptr); } } @@ -1797,21 +1797,21 @@ HWTEST_F(MoveDragControllerTest, UpdateSubWindowGravityWhenFollow01, TestSize.Le followController->type_ = AreaType::UNDEFINED; moveDragController->UpdateSubWindowGravityWhenFollow(nullptr, nullptr); - auto gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - ASSERT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + auto modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + ASSERT_EQ(modifier, nullptr); moveDragController->UpdateSubWindowGravityWhenFollow(nullptr, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - ASSERT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + ASSERT_EQ(modifier, nullptr); moveDragController->UpdateSubWindowGravityWhenFollow(followController, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - ASSERT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + ASSERT_EQ(modifier, nullptr); followController->type_ = AreaType::TOP; moveDragController->UpdateSubWindowGravityWhenFollow(followController, surfaceNode); - gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); - ASSERT_EQ(gravityIter, surfaceNode->propertyModifiers_.end()); + modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); + ASSERT_EQ(modifier, nullptr); } } // namespace } // namespace Rosen -- Gitee From da80029bcc797a7c227fb8cd27ea8de3e8460a2f Mon Sep 17 00:00:00 2001 From: l30067243 Date: Mon, 18 Aug 2025 19:05:22 +0800 Subject: [PATCH 049/241] fix comments Signed-off-by: l30067243 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 7a6eea3c1d..5a315aaed9 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2588,7 +2588,7 @@ napi_value JsWindow::OnGetWindowPropertiesSync(napi_env env, napi_callback_info return objValue; } else { return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowProperties]msg: create window property object faield"); + "[window][getWindowProperties]msg: create window property object failed"); } } -- Gitee From 2f691972bc4ef8f15b42feeedb0ec3f0943e7613 Mon Sep 17 00:00:00 2001 From: l30067243 Date: Mon, 18 Aug 2025 19:31:48 +0800 Subject: [PATCH 050/241] fix static errors Signed-off-by: l30067243 --- .../window_runtime/window_napi/js_window.cpp | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 5a315aaed9..6f67159a56 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4148,7 +4148,6 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - napi_value lastParam = (argc <= 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); napi_value result = nullptr; @@ -4156,9 +4155,8 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info auto asyncTask = [weakToken = wptr(windowToken_), brightness, env, task = napiAsyncTask] { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - task->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowBrightness]msg: invalid window")); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowBrightness]msg: invalid window")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetBrightness(brightness)); @@ -4173,9 +4171,8 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowBrightness") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); - napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowBrightness]msg: failed to send event")); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowBrightness]msg: failed to send event")); } return result; } @@ -7915,21 +7912,18 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_PC, "%{public}s window is nullptr", where); WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "[window][setWindowMask]msg: invalid window")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "[window][setWindowMask]msg:invalid window")); return; } if (!WindowHelper::IsSubWindow(window->GetType()) && !WindowHelper::IsAppFloatingWindow(window->GetType())) { WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "[window][setWindowMask]msg: invalid window type")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "[window][setWindowMask]msg: invalid type")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMask(windowMask)); if (ret != WmErrorCode::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setWindowMask]msg: set window mask failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setWindowMask]msg: set mask failed")); TLOGNE(WmsLogTag::WMS_PC, "%{public}s Window [%{public}u, %{public}s] set window mask failed", where, window->GetWindowId(), window->GetWindowName().c_str()); return; @@ -7939,8 +7933,8 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) where, window->GetWindowId(), window->GetWindowName().c_str()); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowMask") != napi_status::napi_ok) { - napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowMask]msg: send event failed")); } return result; } @@ -8731,8 +8725,7 @@ napi_value JsWindow::OnSetSystemAvoidAreaEnabled(napi_env env, napi_callback_inf task.Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s failed, ret %{public}d", where, *errCodePtr); - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, - "[window][setSystemAvoidAreaEnabled]msg: set system avoid area enabled failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "set system avoid area enabled failed.")); } }; napi_value result = nullptr; -- Gitee From 496dc3068e4c491c87b9f02d08016958d6c1d047 Mon Sep 17 00:00:00 2001 From: l30067243 Date: Mon, 18 Aug 2025 19:35:05 +0800 Subject: [PATCH 051/241] fix spelling mistakes Signed-off-by: l30067243 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 6f67159a56..4cbb501176 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4655,7 +4655,7 @@ napi_value JsWindow::OnSetWakeUpScreen(napi_env env, napi_callback_info info) WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetTurnScreenOn(wakeUp)); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][setWakeUpScreen]msg: turn screen on faield"); + return NapiThrowError(env, ret, "[window][setWakeUpScreen]msg: turn screen on failed"); } WLOGI("Window [%{public}u, %{public}s] set wake up screen %{public}d end", @@ -5819,7 +5819,7 @@ napi_value JsWindow::OnSnapshotIgnorePrivacy(napi_env env, napi_callback_info in return; } else if (ret != WmErrorCode::WM_OK) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][snapshotIgnorePrivacy]msg: snapshot faield")); + "[window][snapshotIgnorePrivacy]msg: snapshot failed")); TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "get pixelmap failed, code:%{public}d", ret); return; } @@ -8605,7 +8605,7 @@ napi_value JsWindow::OnGetWindowDensityInfo(napi_env env, napi_callback_info inf } else { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "create js windowDensityInfo failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowDensityInfo]msg: convert density info faield"); + "[window][getWindowDensityInfo]msg: convert density info failed"); } } @@ -8671,7 +8671,7 @@ napi_value JsWindow::OnIsMainWindowFullScreenAcrossDisplays(napi_env env, napi_c } } else { task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, - "[window][isMainWindowFullScreenAcrossDisplays]msg: query faield")); + "[window][isMainWindowFullScreenAcrossDisplays]msg: query failed")); } }; napi_value result = nullptr; -- Gitee From 1dd1262f67f6d4e3aab7c2906afcb3ed64938b18 Mon Sep 17 00:00:00 2001 From: zhanglitao Date: Mon, 18 Aug 2025 19:58:16 +0800 Subject: [PATCH 052/241] =?UTF-8?q?Modifier=E9=81=97=E7=95=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanglitao --- .../unittest/move_drag_controller_test.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index 3645d9c7d9..c0018cc2f1 100644 --- a/window_scene/test/unittest/move_drag_controller_test.cpp +++ b/window_scene/test/unittest/move_drag_controller_test.cpp @@ -289,37 +289,37 @@ HWTEST_F(MoveDragControllerTest, UpdateGravityWhenDrag, TestSize.Level0) moveDragController->type_ = AreaType::RIGHT; moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); auto modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - EXPECT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - EXPECT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - EXPECT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - EXPECT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_UP); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - EXPECT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_CANCEL); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - EXPECT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UNKNOWN); moveDragController->UpdateGravityWhenDrag(pointerEvent, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - EXPECT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); } } @@ -1798,20 +1798,20 @@ HWTEST_F(MoveDragControllerTest, UpdateSubWindowGravityWhenFollow01, TestSize.Le followController->type_ = AreaType::UNDEFINED; moveDragController->UpdateSubWindowGravityWhenFollow(nullptr, nullptr); auto modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - ASSERT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); moveDragController->UpdateSubWindowGravityWhenFollow(nullptr, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - ASSERT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); moveDragController->UpdateSubWindowGravityWhenFollow(followController, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - ASSERT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); followController->type_ = AreaType::TOP; moveDragController->UpdateSubWindowGravityWhenFollow(followController, surfaceNode); modifier = surfaceNode->GetModifierByType(ModifierNG::RSModifierType::CLIP_TO_FRAME); - ASSERT_EQ(modifier, nullptr); + EXPECT_NE(modifier, nullptr); } } // namespace } // namespace Rosen -- Gitee From f7f70ae85e4bfbfdc797a2e59d01223309a8791b Mon Sep 17 00:00:00 2001 From: l30067243 Date: Mon, 18 Aug 2025 20:38:52 +0800 Subject: [PATCH 053/241] fix static error Signed-off-by: l30067243 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 4cbb501176..00461160cd 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4171,8 +4171,8 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowBrightness") != napi_status::napi_ok) { TLOGE(WmsLogTag::WMS_IMMS, "napi_send_event failed"); - napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowBrightness]msg: failed to send event")); + napiAsyncTask->Reject(env, + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); } return result; } -- Gitee From b169704cdf800c1661c1601fe6f24dcde0368e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=B4=AA=E6=96=8C?= Date: Mon, 18 Aug 2025 13:26:36 +0000 Subject: [PATCH 054/241] update window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔洪斌 --- .../unittest/event_distribution/scene_input_manager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp index 8e757ab810..3b4eda9c3a 100644 --- a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp @@ -924,7 +924,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdateFordDisplayInfos, TestSize.Level1 ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); displayInfos[0].transform[0] = 0.002; ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); - displayInfo.transform.emplace_back(0.00002); + displayInfos[0].transform.emplace_back(0.00002); ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); displayInfos[0].scalePercent = 2; ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); -- Gitee From 4c9325dbb44db1436f22d1fa2460fa859936c7a3 Mon Sep 17 00:00:00 2001 From: l30067243 Date: Tue, 19 Aug 2025 09:33:38 +0800 Subject: [PATCH 055/241] fix static error Signed-off-by: l30067243 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 00461160cd..403b12afb4 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4163,8 +4163,7 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setWindowBrightness]msg: set window brightness failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set brightness failed")); } TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "Window [%{public}u, %{public}s] set brightness end, result: %{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); -- Gitee From 2ddd3ce096be1aa28eb30624cebade0f90b2b5c5 Mon Sep 17 00:00:00 2001 From: jjxxx123 <1720356274@qq.com> Date: Tue, 19 Aug 2025 10:26:23 +0800 Subject: [PATCH 056/241] the same to master Signed-off-by: jjxxx123 <1720356274@qq.com> --- .../intention_event/src/intention_event_manager.cpp | 4 ++-- wm/src/window_scene_session_impl.cpp | 8 +++++--- wm/src/window_session_impl.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index 2c0c0a7070..887e4670b8 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -193,8 +193,8 @@ void IntentionEventManager::InputEventListener::OnInputEvent( SetPointerEventStatus(pointerEvent->GetPointerId(), action, sourceType, sceneSession); } static uint32_t eventId = 0; - TLOGI(WmsLogTag::WMS_INPUT_KEY_FLOW, "id:%{public}d,eid:%{public}d,wid:%{public}u" - ",wn:%{public}s,ac:%{public}d,sys:%{public}d", eventId++, pointerEvent->GetId(), windowId, + TLOGI(WmsLogTag::WMS_INPUT_KEY_FLOW, "eid:%{public}d,InputId:%{public}d,wid:%{public}u" + ",wName:%{public}s,ac:%{public}d,sys:%{public}d", eventId++, pointerEvent->GetId(), windowId, sceneSession->GetSessionInfo().abilityName_.c_str(), action, sceneSession->GetSessionInfo().isSystem_); } if (sceneSession->GetSessionInfo().isSystem_) { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 93840a3f28..46f507663d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1091,10 +1091,12 @@ void WindowSceneSessionImpl::ConsumePointerEventInner(const std::shared_ptrMarkProcessed(); } if (isPointDown || isPointUp) { - TLOGNI(WmsLogTag::WMS_INPUT_KEY_FLOW, "Consume:id:%{public}d,wid:%{public}u,pointId:%{public}d" - ",srcType:%{public}d,rect:[%{public}d,%{public}d,%{public}u,%{public}u],notify:%{public}d", + TLOGI(WmsLogTag::WMS_INPUT_KEY_FLOW, "InputId:%{public}d,wid:%{public}u,pointId:%{public}d" + ",srcType:%{public}d,rect:[%{public}d,%{public}d,%{public}u,%{public}u]" + ",notify:%{public}d", pointerEvent->GetId(), GetWindowId(), pointerEvent->GetPointerId(), - sourceType, rect.posX_, rect.posY_, rect.width_, rect.height_, needNotifyEvent); + sourceType, rect.posX_, rect.posY_, rect.width_, rect.height_, + needNotifyEvent); } } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 7dcfa9f55e..4711caad75 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -6059,7 +6059,7 @@ void WindowSessionImpl::NotifyPointerEvent(const std::shared_ptrGetPointerAction() != MMI::PointerEvent::POINTER_ACTION_MOVE) { - TLOGW(WmsLogTag::WMS_INPUT_KEY_FLOW, "not consume, wid:%{public}u", GetWindowId()); + TLOGW(WmsLogTag::WMS_INPUT_KEY_FLOW, "pointerEvent not consumed, windowId:%{public}u", GetWindowId()); } pointerEvent->MarkProcessed(); } -- Gitee From 4a92ddf10e812239f8cb1192b9d23a2c9c5ccce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Tue, 19 Aug 2025 11:44:31 +0800 Subject: [PATCH 057/241] chaneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../include/scene_session_manager.h | 4 +- .../src/scene_session_manager.cpp | 60 +++++++++++++------ 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 902af226c8..655786baae 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1025,7 +1025,7 @@ private: WSError RequestSceneSessionActivationInner(sptr& sceneSession, bool isNewActive, int32_t requestId = DEFAULT_REQUEST_FROM_SCB_ID) REQUIRES(SCENE_GUARD); WSError SetBrightness(const sptr& sceneSession, float brightness); - void PostBrightnessTask(float brightness); + void PostBrightnessTask(const sptr& sceneSession, float brightness); WSError UpdateBrightness(int32_t persistentId); void SetDisplayBrightness(float brightness); float GetDisplayBrightness() const; @@ -1230,7 +1230,7 @@ private: SystemSessionConfig systemConfig_; float snapshotScale_ = 0.5; int32_t brightnessSessionId_ = INVALID_SESSION_ID; - float displayBrightness_ = UNDEFINED_BRIGHTNESS; + std::atomic displayBrightness_ = UNDEFINED_BRIGHTNESS; bool isScreenLocked_ { false }; bool isPrepareTerminateEnable_ { false }; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1a104d886f..08d1da27cc 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6123,7 +6123,7 @@ WSError SceneSessionManager::SetBrightness(const sptr& sceneSessio #ifdef POWERMGR_DISPLAY_MANAGER_ENABLE if (GetDisplayBrightness() != brightness && GetFocusedSessionId() == sceneSession->GetPersistentId()) { - PostBrightnessTask(brightness); + PostBrightnessTask(sceneSession, brightness); } #else TLOGD(WmsLogTag::WMS_ATTRIBUTE, "Can not found the sub system of DisplayPowerMgr"); @@ -6132,21 +6132,40 @@ WSError SceneSessionManager::SetBrightness(const sptr& sceneSessio return WSError::WS_OK; } -void SceneSessionManager::PostBrightnessTask(float brightness) +void SceneSessionManager::PostBrightnessTask(const sptr& sceneSession, float brightness) { #ifdef POWERMGR_DISPLAY_MANAGER_ENABLE - bool postTaskRet = true; bool isPC = systemConfig_.IsPcWindow(); if (std::fabs(brightness - UNDEFINED_BRIGHTNESS) < std::numeric_limits::min()) { if (!isPC) { - auto task = [] { + wptr weakSceneSession(sceneSession); + auto task = [where = __func__, weakSceneSession] { + auto sceneSession = weakSceneSession.promote(); + if (sceneSession == nullptr) { + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession is null", where); + return; + } + if (!sceneSession->IsSessionForeground()) { + TLOGNW(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession state is invalid", where); + return; + } DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); + SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness }; - postTaskRet = eventHandler_->PostTask(task, "DisplayPowerMgr:RestoreBrightness", 0); + eventHandler_->AddExportTask("DisplayPowerMgr:RestoreBrightness", task); } - SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness } else { - auto task = [brightness, isPC] { + wptr weakSceneSession(sceneSession); + auto task = [where = __func__, weakSceneSession, brightness, isPC] { + auto sceneSession = weakSceneSession.promote(); + if (sceneSession == nullptr) { + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession is null", where); + return; + } + if (!sceneSession->IsSessionForeground()) { + TLOGNW(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession state is invalid", where); + return; + } if (isPC) { DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().SetBrightness( static_cast(brightness * MAX_BRIGHTNESS)); @@ -6154,12 +6173,9 @@ void SceneSessionManager::PostBrightnessTask(float brightness) DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().OverrideBrightness( static_cast(brightness * MAX_BRIGHTNESS)); } + SetDisplayBrightness(brightness); }; - postTaskRet = eventHandler_->PostTask(task, "DisplayPowerMgr:OverrideBrightness", 0); - SetDisplayBrightness(brightness); - } - if (!postTaskRet) { - TLOGE(WmsLogTag::WMS_ATTRIBUTE, "post task failed. task is SetBrightness"); + eventHandler_->AddExportTask("DisplayPowerMgr:OverrideBrightness", task); } #endif } @@ -6185,17 +6201,23 @@ WSError SceneSessionManager::UpdateBrightness(int32_t persistentId) TLOGI(WmsLogTag::WMS_ATTRIBUTE, "Brightness: [%{public}f, %{public}f]", GetDisplayBrightness(), brightness); if (std::fabs(brightness - UNDEFINED_BRIGHTNESS) < std::numeric_limits::min()) { if (IsNeedUpdateBrightness(persistentId, brightness)) { - TLOGI(WmsLogTag::WMS_ATTRIBUTE, "adjust brightness with default value"); - DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); - SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness + auto task = [where = __func__] { + TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s adjust brightness with default value", where); + DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); + SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness + }; + eventHandler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_RestoreBrightness", task); brightnessSessionId_ = INVALID_WINDOW_ID; } } else { if (std::fabs(brightness - GetDisplayBrightness()) > std::numeric_limits::min()) { - TLOGI(WmsLogTag::WMS_ATTRIBUTE, "adjust brightness with value"); - DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().OverrideBrightness( - static_cast(brightness * MAX_BRIGHTNESS)); - SetDisplayBrightness(brightness); + auto task = [where = __func__, brightness] { + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s adjust brightness with value", where); + DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().OverrideBrightness( + static_cast(brightness * MAX_BRIGHTNESS)); + SetDisplayBrightness(brightness); + }; + eventHandler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_OverrideBrightness", task); } brightnessSessionId_ = sceneSession->GetPersistentId(); } -- Gitee From ada6221381f770c09f28a63c4403decb79b4dcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Tue, 19 Aug 2025 11:53:01 +0800 Subject: [PATCH 058/241] chaneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wm/src/window_scene_session_impl.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index c1e4a99e8e..a6e0e6f846 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6248,7 +6248,18 @@ WMError WindowSceneSessionImpl::IsImmersiveLayout(bool& isImmersiveLayout) const if (IsWindowSessionInvalid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - isImmersiveLayout = isIgnoreSafeArea_; + if (IsPcOrPadFreeMuiltiWindowMode()) { + auto uiContent = GetUIContentSharedPtr(); + if (uiContent == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "uicontent is null"); + return WMError::WM_ERROR_INVALID_WINDOW; + } + Rect drawableRect; + uiContent->GetWinodwPaintSize(drawableRect); + isImmersiveLayout = drawableRect == GetRect(); + } else { + isImmersiveLayout = isIgnoreSafeArea_; + } return WMError::WM_OK; } -- Gitee From 3225a16b4ade8f31d859e091220c35a9c4933fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Tue, 19 Aug 2025 12:02:07 +0800 Subject: [PATCH 059/241] cahneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../src/scene_session_manager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 08d1da27cc..2b922dc469 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6158,14 +6158,14 @@ void SceneSessionManager::PostBrightnessTask(const sptr& sceneSess wptr weakSceneSession(sceneSession); auto task = [where = __func__, weakSceneSession, brightness, isPC] { auto sceneSession = weakSceneSession.promote(); - if (sceneSession == nullptr) { - TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession is null", where); - return; - } - if (!sceneSession->IsSessionForeground()) { - TLOGNW(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession state is invalid", where); - return; - } + if (sceneSession == nullptr) { + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession is null", where); + return; + } + if (!sceneSession->IsSessionForeground()) { + TLOGNW(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession state is invalid", where); + return; + } if (isPC) { DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().SetBrightness( static_cast(brightness * MAX_BRIGHTNESS)); -- Gitee From 0821d8128c3c8dc66c4011e002bee891c371e84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Tue, 19 Aug 2025 12:09:16 +0800 Subject: [PATCH 060/241] chaneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../src/scene_session_manager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2b922dc469..fa1d71ae0a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6139,7 +6139,7 @@ void SceneSessionManager::PostBrightnessTask(const sptr& sceneSess if (std::fabs(brightness - UNDEFINED_BRIGHTNESS) < std::numeric_limits::min()) { if (!isPC) { wptr weakSceneSession(sceneSession); - auto task = [where = __func__, weakSceneSession] { + auto task = [this, where = __func__, weakSceneSession] { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession is null", where); @@ -6152,11 +6152,11 @@ void SceneSessionManager::PostBrightnessTask(const sptr& sceneSess DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness }; - eventHandler_->AddExportTask("DisplayPowerMgr:RestoreBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:RestoreBrightness", task); } } else { wptr weakSceneSession(sceneSession); - auto task = [where = __func__, weakSceneSession, brightness, isPC] { + auto task = [this, where = __func__, weakSceneSession, brightness, isPC] { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s sceneSession is null", where); @@ -6175,7 +6175,7 @@ void SceneSessionManager::PostBrightnessTask(const sptr& sceneSess } SetDisplayBrightness(brightness); }; - eventHandler_->AddExportTask("DisplayPowerMgr:OverrideBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:OverrideBrightness", task); } #endif } @@ -6201,23 +6201,23 @@ WSError SceneSessionManager::UpdateBrightness(int32_t persistentId) TLOGI(WmsLogTag::WMS_ATTRIBUTE, "Brightness: [%{public}f, %{public}f]", GetDisplayBrightness(), brightness); if (std::fabs(brightness - UNDEFINED_BRIGHTNESS) < std::numeric_limits::min()) { if (IsNeedUpdateBrightness(persistentId, brightness)) { - auto task = [where = __func__] { + auto task = [this, where = __func__] { TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s adjust brightness with default value", where); DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness }; - eventHandler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_RestoreBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_RestoreBrightness", task); brightnessSessionId_ = INVALID_WINDOW_ID; } } else { if (std::fabs(brightness - GetDisplayBrightness()) > std::numeric_limits::min()) { - auto task = [where = __func__, brightness] { + auto task = [this, where = __func__, brightness] { TLOGI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s adjust brightness with value", where); DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().OverrideBrightness( static_cast(brightness * MAX_BRIGHTNESS)); SetDisplayBrightness(brightness); }; - eventHandler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_OverrideBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_OverrideBrightness", task); } brightnessSessionId_ = sceneSession->GetPersistentId(); } -- Gitee From ce71aedd7fe82a2b759054b481900a3993c55ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Tue, 19 Aug 2025 14:29:55 +0800 Subject: [PATCH 061/241] change1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wm/src/window_scene_session_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index a6e0e6f846..d90e601c99 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6248,14 +6248,14 @@ WMError WindowSceneSessionImpl::IsImmersiveLayout(bool& isImmersiveLayout) const if (IsWindowSessionInvalid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - if (IsPcOrPadFreeMuiltiWindowMode()) { + if (IsPcOrPadFreeMultiWindowMode()) { auto uiContent = GetUIContentSharedPtr(); if (uiContent == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "uicontent is null"); return WMError::WM_ERROR_INVALID_WINDOW; } Rect drawableRect; - uiContent->GetWinodwPaintSize(drawableRect); + uiContent->GetWindowPaintSize(drawableRect); isImmersiveLayout = drawableRect == GetRect(); } else { isImmersiveLayout = isIgnoreSafeArea_; -- Gitee From 0c0b69da875e540305ea12b70582ef4f1998fd92 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 14:05:18 +0800 Subject: [PATCH 062/241] =?UTF-8?q?fix:=20=E6=95=B4=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../window_runtime/window_napi/js_window.cpp | 188 +++++++++--------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 52d82e086d..894f1be430 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1660,21 +1660,21 @@ napi_value JsWindow::OnRecover(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT_PC, "%{public}s window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][recover]msg: window is nullptr"); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->Recover(1)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window recover failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][recover]msg: failed")); } TLOGNI(WmsLogTag::WMS_LAYOUT_PC, "%{public}s end, window [%{public}u] ret=%{public}d", where, window->GetWindowId(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnRecover") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][recover]msg: send event failed")); } return result; } @@ -1793,7 +1793,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowTo]msg: failed"); } // 2: params num; 2: index of callback napi_value lastParam = (argc <= 2) ? nullptr : @@ -1805,21 +1805,21 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][moveWindowTo]msg: window is nullptr"); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->MoveTo(x, y)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window move failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[Window][MoveWindowTo]msg: move failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnMoveWindowTo") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[Window][MoveWindowTo]msg: failed to send event")); } return result; } @@ -1867,17 +1867,17 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 2) { // 2: minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Argc is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Failed to convert parameter to y"); } MoveConfiguration moveConfiguration; size_t lastParamIndex = INDEX_TWO; @@ -1885,7 +1885,7 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info) lastParamIndex = INDEX_THREE; // MoveConfiguration is optional param if (!GetMoveConfigurationFromJsValue(env, argv[INDEX_TWO], moveConfiguration)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to moveConfiguration"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Failed to convert parameter to moveConfiguration"); } } NapiAsyncTask::ExecuteCallback execute; @@ -1946,17 +1946,17 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 2) { // 2:minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][moveWindowToGlobal]msg: Argc is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobal]msg: Failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][moveWindowToGlobal]msg: Failed to convert parameter to y"); } MoveConfiguration moveConfiguration; size_t lastParamIndex = INDEX_TWO; @@ -1964,7 +1964,7 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) lastParamIndex = INDEX_THREE; // MoveConfiguration is optional param if (!GetMoveConfigurationFromJsValue(env, argv[INDEX_TWO], moveConfiguration)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to moveConfiguration and rectAnimationConfig"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][moveWindowToGlobal]msg: Failed to convert parameter to moveConfiguration and rectAnimationConfig"); } } NapiAsyncTask::ExecuteCallback execute; @@ -1988,18 +1988,18 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != TWO_PARAMS_SIZE) { TLOGE(WmsLogTag::WMS_LAYOUT, "Invalid argc: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobalDisplay]msg: invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to y"); } napi_value result = nullptr; @@ -2008,7 +2008,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf auto window = windowToken.promote(); if (!window) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][moveWindowToGlobalDisplay]msg: window is nullptr"); return; } auto moveResult = window->MoveWindowToGlobalDisplay(x, y); @@ -2017,7 +2017,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (ret == WmErrorCode::WM_OK) { napiAsyncTask->Resolve(env, NapiGetUndefined(env)); } else { - napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, ret, "Failed to move window")); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][moveWindowToGlobalDisplay]msg: failed to move window")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: window: [%{public}u, %{public}s], x: %{public}d, y: %{public}d, ret: %{public}d", @@ -2025,7 +2025,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "Failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][moveWindowToGlobalDisplay]msg: failed to send event")); } return result; } @@ -2084,28 +2084,28 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) auto asyncTask = [windowToken = wptr(windowToken_), errCode, width, height, env, task = napiAsyncTask, where = __func__] { if (errCode != WMError::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, errCode)); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode),"[window][resize]msg: failed"); TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: invalid param", where); return; } auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR)); + task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR),"[window][resize]msg: window is nullptr"); return; } WMError ret = window->Resize(static_cast(width), static_cast(height)); if (ret == WMError::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window resize failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][resize]msg: failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resize]msg: failed to send event")); } return result; } @@ -2230,7 +2230,7 @@ napi_value JsWindow::OnResizeWindowAsync(napi_env env, napi_callback_info info) errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][resizeWindowAsync]msg: invalid param"); } wptr weakToken(windowToken_); @@ -2460,7 +2460,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LAYOUT, "permission denied!"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP); + return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP,"[window][setwindowMode]msg: permission denied!"); } WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; @@ -2489,7 +2489,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) } } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setwindowMode]msg: failed"); } napi_value lastParam = (argc == 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); @@ -2500,21 +2500,21 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][setwindowMode]msg: window is nullptr"); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMode(winMode)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set mode failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setwindowMode]msg: Window set mode failed")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowMode") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setwindowMode]msg: failed to send event")); } return result; } @@ -4866,12 +4866,12 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argc > 2) { // 2: maximum params num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setResizeByDragEnabled]msg: argc is invalid"); } bool dragEnabled = true; if (!ConvertFromJsValue(env, argv[0], dragEnabled)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to dragEnabled"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setResizeByDragEnabled]msg: failed to convert parameter to dragEnabled"); } napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); napi_value result = nullptr; @@ -4881,21 +4881,21 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][setResizeByDragEnabled]msg: window is nullptr"); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetResizeByDragEnabled(dragEnabled)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "set dragEnabled failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setResizeByDragEnabled]msg: set dragEnabled failed")); } TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Window [%{public}u, %{public}s] set dragEnabled end", where, window->GetWindowId(), window->GetWindowName().c_str()); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetResizeByDragEnabled") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setResizeByDragEnabled]msg: failed to send event")); } return result; } @@ -5655,7 +5655,7 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) } } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setForbidSplitMove]msg: invalid param"); } napi_value lastParam = (argc <= 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); @@ -5665,7 +5665,7 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "Invalidate params.")); + "[window][setForbidSplitMove]msg: Invalidate params.")); return; } WmErrorCode ret; @@ -5679,12 +5679,12 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window OnSetForbidSplitMove failed.")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setForbidSplitMove]msg: failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetForbidSplitMove") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setForbidSplitMove]msg: failed to send event")); } return result; } @@ -6719,12 +6719,12 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][setAspectRatio]msg: windowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "SetAspectRatio is not allowed since window is main window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][setAspectRatio]msg: setAspectRatio is not allowed since window is main window"); } double aspectRatio = 0.0; @@ -6739,7 +6739,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) } if (errCode == WMError::WM_ERROR_INVALID_PARAM || aspectRatio <= 0.0) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setAspectRatio]msg: falied"); } napi_value lastParam = (argc == 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -6750,7 +6750,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "OnSetAspectRatio failed.")); + "[window][setAspectRatio]msg: falied")); return; } WMError ret = window->SetAspectRatio(aspectRatio); @@ -6758,14 +6758,14 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "SetAspectRatio failed.")); + "[window][setAspectRatio]msg: falied")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setAspectRatio]msg: falied")); } return result; } @@ -6777,17 +6777,17 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM," [window][resetAspectRatio]msg: argc is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][resetAspectRatio]msg: windowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "ResetAspectRatio is not allowed since window is main window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][resetAspectRatio]msg: "); } napi_value lastParam = (argc == 0) ? nullptr : @@ -6798,21 +6798,21 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, - WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "OnResetAspectRatio failed.")); + WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resetAspectRatio]msg: failed.")); return; } WMError ret = window->ResetAspectRatio(); if (ret == WMError::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "ResetAspectRatio failed.")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][resetAspectRatio]msg: failed.")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resetAspectRatio]msg: failed to send event")); } return result; } @@ -6870,12 +6870,12 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WindowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][maximize]msg: windowToken is nullptr"); } if (!(WindowHelper::IsMainWindow(windowToken_->GetType()) || windowToken_->IsSubWindowMaximizeSupported())) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "only support main or sub Window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][maximize]msg: only support main or sub Window"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -6887,7 +6887,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) presentationValue < static_cast(MaximizePresentation::FOLLOW_APP_IMMERSIVE_SETTING) || presentationValue > static_cast(MaximizePresentation::ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER)) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Failed to convert parameter to presentationValue"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][maximize]msg: failed to convert parameter to presentationValue"); } } MaximizePresentation presentation = static_cast(presentationValue); @@ -6900,7 +6900,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { task->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][maximize]msg: window is nullptr")); return; } WMError ret = window->Maximize(presentation); @@ -6908,12 +6908,12 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Maximize failed.")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "[window][maximize]msg: failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnMaximize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][maximize]msg: send event failed")); } return result; } @@ -7058,13 +7058,13 @@ napi_value JsWindow::OnEnableDrag(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][enableDrag]msg: argc is invalid"); } bool enableDrag = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enableDrag)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter from jsValue"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][enableDrag]msg: failed to convert parameter from jsValue"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); NapiAsyncTask::ExecuteCallback execute = @@ -7085,17 +7085,17 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setWindowLimits]msg: argc is invalid"); } WindowLimits windowLimits; if (!ParseWindowLimits(env, argv[INDEX_ZERO], windowLimits)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert object to windowLimits"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setWindowLimits]msg:Failed to convert object to windowLimits"); } if (windowLimits.maxWidth_ < 0 || windowLimits.maxHeight_ < 0 || windowLimits.minWidth_ < 0 || windowLimits.minHeight_ < 0) { TLOGE(WmsLogTag::WMS_LAYOUT, "Width or height should be greater than or equal to 0"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setWindowLimits]msg: Width or height should be greater than or equal to 0"); } size_t lastParamIndex = INDEX_ONE; bool isForcible = false; @@ -7103,15 +7103,15 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) lastParamIndex = INDEX_TWO; if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][setWindowLimits]msg: window is nullptr"); } if (!windowToken_->IsPcOrFreeMultiWindowCapabilityEnabled()) { TLOGE(WmsLogTag::WMS_LAYOUT, "device not support"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, "[window][setWindowLimits]msg: device not support"); } if (!ConvertFromJsValue(env, argv[INDEX_ONE], isForcible)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isForcible"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setWindowLimits]msg: Failed to convert parameter to isForcible"); } } napi_value lastParam = (argc <= lastParamIndex) ? nullptr : @@ -7123,7 +7123,7 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][setWindowLimits]msg: window is nullptr"); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowLimits(windowLimits, isForcible)); @@ -7131,17 +7131,17 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) auto objValue = GetWindowLimitsAndConvertToJsValue(env, windowLimits); if (objValue == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "Window set window limits failed")); + "[window][setWindowLimits]msg: set window limits failed")); } else { task->Resolve(env, objValue); } } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set window limits failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setWindowLimits]msg: set window limits failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowLimits") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setWindowLimits]msg: failed to send event")); } return result; } @@ -7154,17 +7154,17 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][getWindowLimits]msg: argc is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][getWindowLimits]msg: window is nullptr"); } WindowLimits windowLimits; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetWindowLimits(windowLimits)); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + return NapiThrowError(env, ret,"[window][getWindowLimits]msg: falied"); } auto objValue = GetWindowLimitsAndConvertToJsValue(env, windowLimits); TLOGI(WmsLogTag::WMS_LAYOUT, "Window [%{public}u, %{public}s] get window limits end", @@ -7172,7 +7172,7 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) if (objValue != nullptr) { return objValue; } else { - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][getWindowLimits]msg: nullptr"); } } @@ -7360,12 +7360,12 @@ napi_value JsWindow::OnSetFollowParentMultiScreenPolicy(napi_env env, napi_callb napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != ARG_COUNT_ONE) { TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setFollowParentMultiScreenPolicy]msg: argc is invalid"); } bool enabled = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enabled)) { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to enabled"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setFollowParentMultiScreenPolicy]msg: Failed to convert parameter to enabled"); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); @@ -7373,7 +7373,7 @@ napi_value JsWindow::OnSetFollowParentMultiScreenPolicy(napi_env env, napi_callb napi_status status = napi_send_event(env, asyncTask, napi_eprio_high, "OnSetFollowParentMultiScreenPolicy"); if (status != napi_status::napi_ok) { napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][setFollowParentMultiScreenPolicy]msg: send event failed")); } return result; } @@ -8065,13 +8065,13 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) auto window = windowToken_; if (window == nullptr) { TLOGE(WmsLogTag::WMS_PC, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][getWindowStatus]msg: window is nullptr"); } WindowStatus windowStatus; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->GetWindowStatus(windowStatus)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_PC, "failed, ret=%{public}d", ret); - return NapiThrowError(env, ret); + return NapiThrowError(env, ret, "[window][getWindowStatus]msg: falied"); } auto objValue = CreateJsValue(env, windowStatus); if (objValue != nullptr) { @@ -8079,7 +8079,7 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) return objValue; } else { TLOGE(WmsLogTag::WMS_PC, "create js value windowStatus failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][getWindowStatus]msg: create js value windowStatus failed"); } } @@ -8172,7 +8172,7 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "windowToken is nullptr."); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][startMoving]msg: windowToken is nullptr"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -8182,7 +8182,7 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) } if (WindowHelper::IsInputWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "is not allowed since input window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][startMoving]msg: not allowed since input window"); } std::shared_ptr err = std::make_shared(WmErrorCode::WM_OK); const char* const funcName = __func__; @@ -8203,13 +8203,13 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) NapiAsyncTask::CompleteCallback complete = [err](napi_env env, NapiAsyncTask& task, int32_t status) { if (err == nullptr) { task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "System abnormal.")); + "[window][startMoving]msg: System abnormal.")); return; } if (*err == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, CreateJsError(env, static_cast(*err), "Move system window failed.")); + task.Reject(env, CreateJsError(env, static_cast(*err), "[window][startMoving]msg: Move system window failed.")); } }; napi_value result = nullptr; @@ -8268,7 +8268,7 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "windowToken is nullptr."); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][stopMoving]msg: windowToken is nullptr"); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); @@ -8277,19 +8277,19 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT_PC, "%{public}s window is nullptr.", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][stopMoving]msg: window is nullptr"); return; } WmErrorCode ret = window->StopMoveWindow(); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "Stop moving window failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][stopMoving]msg: Stop moving window failed")); } }; if (napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnStopMoving") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][stopMoving]msg: send event failed")); } return result; } @@ -8888,12 +8888,12 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != INDEX_ONE) { TLOGE(WmsLogTag::WMS_SUB, "argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setFollowParentWindowLayoutEnabled]msg: argc is invalid"); } bool isFollow = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], isFollow)) { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to enable"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setFollowParentWindowLayoutEnabled]msg: falied to convert parameter to enable"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); const char* const where = __func__; @@ -8903,12 +8903,12 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); - task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)),"[window][setFollowParentWindowLayoutEnabled]msg: window is nullptr"); return; } if (!WindowHelper::IsSubWindow(window->GetType()) && !WindowHelper::IsDialogWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s only sub window and dialog is valid", where); - task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING))); + task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING)),"[window][setFollowParentWindowLayoutEnabled]msg: only sub window and dialog is valid"); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetFollowParentWindowLayoutEnabled(isFollow)); @@ -8916,13 +8916,13 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal task->Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s failed, ret %{public}d", where, ret); - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "set follow parent layout failed.")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setFollowParentWindowLayoutEnabled]msg: set follow parent layout failed.")); } }; napi_status status = napi_send_event(env, asyncTask, napi_eprio_high, "SetFollowParentWindowLayoutEnabled"); if (status != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][setFollowParentWindowLayoutEnabled]msg: send event failed")); } return result; } -- Gitee From 322e564df1f3ecba7522fb531d49574778a86fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Tue, 19 Aug 2025 15:03:43 +0800 Subject: [PATCH 063/241] chaneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- window_scene/session_manager/include/scene_session_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 655786baae..b2f57be65a 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1230,7 +1230,7 @@ private: SystemSessionConfig systemConfig_; float snapshotScale_ = 0.5; int32_t brightnessSessionId_ = INVALID_SESSION_ID; - std::atomic displayBrightness_ = UNDEFINED_BRIGHTNESS; + std::atomic displayBrightness_ = UNDEFINED_BRIGHTNESS; bool isScreenLocked_ { false }; bool isPrepareTerminateEnable_ { false }; -- Gitee From 3f3106b1c9d26d66cf9b0b3557ac96e9479b803b Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 19 Aug 2025 10:33:19 +0800 Subject: [PATCH 064/241] fold to expand Signed-off-by: zzz --- ...dary_display_sensor_fold_state_manager.cpp | 4 +-- ...display_sensor_fold_state_manager_test.cpp | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp index 181a48acbb..0ec8ea5417 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp @@ -160,7 +160,7 @@ FoldStatus SecondaryDisplaySensorFoldStateManager::GetNextFoldStateHalf(float an FoldStatus state = FoldStatus::UNKNOWN; if (allowUserSensorForLargeFoldDevice == SMALLER_BOUNDARY_FLAG) { - if (std::islessequal(angle, OPEN_GRL_HALF_FOLDED_MIN_THRESHOLD)) { + if (std::islessequal(angle, OPEN_GRL_HALF_FOLDED_MIN_THRESHOLD) && hall == HALL_FOLDED_THRESHOLD) { state = FoldStatus::FOLDED; } else if (std::isgreaterequal(angle, OPEN_GRL_HALF_FOLDED_MIN_THRESHOLD + GRL_HALF_FOLDED_BUFFER) && hall == HALL_FOLDED_THRESHOLD) { @@ -295,7 +295,7 @@ FoldStatus SecondaryDisplaySensorFoldStateManager::CalculateNewABFoldStatus(floa { if ((previousHall == HALL_THRESHOLD && hall == HALL_FOLDED_THRESHOLD) || (previousHall == hall && std::islessequal(angle - previousAngle, ANGLE_DIFF_OF_SECONDARY_AB) && - std::islessequal(angle, OPEN_GRL_HALF_FOLDED_MIN_THRESHOLD))) { + std::islessequal(angle, CLOSE_GRL_HALF_FOLDED_MIN_THRESHOLD))) { return FoldStatus::FOLDED; } else if (std::isgreaterequal(angle, GRL_HALF_FOLDED_MAX_THRESHOLD - GRL_HALF_FOLDED_BUFFER)) { return FoldStatus::EXPAND; diff --git a/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp b/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp index 449a1b9f7c..c72a209282 100644 --- a/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp +++ b/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp @@ -380,6 +380,37 @@ HWTEST_F(SecondaryDisplaySensorFoldStateManagerTest, GetNextFoldStateHalf02, Tes EXPECT_EQ(static_cast(result8), 3); } +/** + * @tc.name: GetNextFoldStateHalf03 + * @tc.desc: test function : GetNextFoldStateHalf + * @tc.type: FUNC + */ +HWTEST_F(SecondaryDisplaySensorFoldStateManagerTest, GetNextFoldStateHalf03, TestSize.Level1) +{ + SecondaryDisplaySensorFoldStateManager manager; + int32_t allowUserSensorForLargeFoldDevice = 0; + FoldStatus state = FoldStatus::UNKNOWN; + float angel = 40.0F; + uint16_t hall = 0; + auto result = manager.GetNextFoldStateHalf(angel, hall, state, allowUserSensorForLargeFoldDevice); + EXPECT_EQ(static_cast(result), 2); + + angel = 60.0F; + hall = 0; + result = manager.GetNextFoldStateHalf(angel, hall, state, allowUserSensorForLargeFoldDevice); + EXPECT_EQ(static_cast(result), 3); + + angel = 40.0F; + hall = 1; + result = manager.GetNextFoldStateHalf(angel, hall, state, allowUserSensorForLargeFoldDevice); + EXPECT_EQ(static_cast(result), 3); + + angel = 60.0F; + hall = 1; + result = manager.GetNextFoldStateHalf(angel, hall, state, allowUserSensorForLargeFoldDevice); + EXPECT_EQ(static_cast(result), 3); +} + /** * @tc.name: GetGlobalFoldState * @tc.desc: test function : GetGlobalFoldState -- Gitee From 81825f038079f4f88bb5e8268f4f8d37443c0266 Mon Sep 17 00:00:00 2001 From: hubijie Date: Wed, 13 Aug 2025 16:03:07 +0800 Subject: [PATCH 065/241] =?UTF-8?q?updateRect=E5=92=8CConnect=E4=BF=9D?= =?UTF-8?q?=E5=BA=8F=20Signed-off-by:=20hubijie=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/innerkits/wm/wm_common.h | 29 +++++++++++++++++ .../common/include/window_session_property.h | 4 +++ .../common/src/window_session_property.cpp | 12 +++++++ .../session/host/src/scene_session.cpp | 7 +++++ .../session/host/src/zidl/session_proxy.cpp | 6 ++++ .../session/host/src/zidl/session_stub.cpp | 2 ++ window_scene/test/unittest/BUILD.gn | 5 ++- .../unittest/scene_session_lifecycle_test.cpp | 31 +++++++++++++++++++ wm/src/window_session_impl.cpp | 6 ++-- .../window_session_impl_layout_test.cpp | 4 +-- 10 files changed, 100 insertions(+), 6 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 11a210bc4a..32c6e366dd 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -2853,6 +2853,35 @@ struct ShadowsInfo : public Parcelable { } }; +/** + * @struct MissionInfo + * + * @brief infos of mission + */ +struct MissionInfo : public Parcelable { + bool startupInvisibility_ = false; + + MissionInfo() {} + MissionInfo(bool startupInvisibility) : startupInvisibility_(startupInvisibility) {} + + bool Marshalling(Parcel& parcel) const override + { + if (!parcel.WriteBool(startupInvisibility_)) { + return false; + } + return true; + } + + static MissionInfo* Unmarshalling(Parcel& parcel) + { + auto missionInfo = std::make_unique(); + if (!missionInfo || !parcel.ReadBool(missionInfo->startupInvisibility_)) { + return nullptr; + } + return missionInfo.release(); + } +}; + /** * @brief Enumerates session state of recent session */ diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 1ce9252616..e679777f2f 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -272,6 +272,8 @@ public: bool GetUseControlStateFromProperty() const; void SetAncoRealBundleName(const std::string& ancoRealBundleName); std::string GetAncoRealBundleName() const; + void SetMissionInfo(const MissionInfo& missionInfo); + MissionInfo GetMissionInfo() const; /* * UIExtension @@ -570,6 +572,8 @@ private: mutable std::mutex lifecycleUseControlMutex_; bool isUseControlState_ = false; std::string ancoRealBundleName_ = ""; + MissionInfo missionInfo_; + mutable std::mutex missionInfoMutex_; /* * Window Property diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 90ad66a800..bfeace6aed 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -2554,6 +2554,18 @@ void WindowSessionProperty::UnmarshallingWindowAnchorInfo(Parcel& parcel, Window property->SetWindowAnchorInfo(*windowAnchorInfo); } +void WindowSessionProperty::SetMissionInfo(const MissionInfo& missionInfo) +{ + std::lock_guard lock(missionInfoMutex_); + missionInfo_ = missionInfo; +} + +MissionInfo WindowSessionProperty::GetMissionInfo() const +{ + std::lock_guard lock(missionInfoMutex_); + return missionInfo_; +} + bool WindowSessionProperty::MarshallingShadowsInfo(Parcel& parcel) const { return parcel.WriteParcelable(&shadowsInfo_); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 51558e40cc..82db9c44fc 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -44,6 +44,7 @@ #endif // DEVICE_STATUS_ENABLE #include "interfaces/include/ws_common.h" #include "pixel_map.h" +#include "process_options.h" #include "rs_adapter.h" #include "session_coordinate_helper.h" #include "session/screen/include/screen_session.h" @@ -154,6 +155,12 @@ WSError SceneSession::ConnectInner(const sptr& sessionStage, property->SetAppInstanceKey(session->GetAppInstanceKey()); property->SetUseControlStateToProperty(session->isAppUseControl_); property->SetAncoRealBundleName(session->IsAnco() ? session->GetSessionInfo().bundleName_ : ""); + if (session->GetSessionInfo().processOptions != nullptr) { + MissionInfo missionInfo; + missionInfo.startupInvisibility_ = session->GetSessionInfo().processOptions->startupVisibility == + AAFwk::StartupVisibility::STARTUP_HIDE; + property->SetMissionInfo(missionInfo); + } } session->RetrieveStatusBarDefaultVisibility(); auto ret = LOCK_GUARD_EXPR(SCENE_GUARD, session->Session::ConnectInner( diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 19e662a22a..e87e3f5f8e 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -337,6 +337,12 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt property->SetCompatibleModeProperty(reply.ReadParcelable()); property->SetUseControlStateToProperty(reply.ReadBool()); property->SetAncoRealBundleName(reply.ReadString()); + sptr missionInfo = reply.ReadParcelable(); + if (missionInfo == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "read missionInfo is nullptr."); + return WSError::WS_ERROR_IPC_FAILED; + } + property->SetMissionInfo(*missionInfo); } int32_t ret = reply.ReadInt32(); return static_cast(ret); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 4c9dff978f..66e09fa723 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -505,6 +505,8 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteParcelable(property->GetCompatibleModeProperty()); reply.WriteBool(property->GetUseControlStateFromProperty()); reply.WriteString(property->GetAncoRealBundleName()); + MissionInfo missionInfo = property->GetMissionInfo(); + reply.WriteParcelable(&missionInfo); } reply.WriteUint32(static_cast(errCode)); return ERR_NONE; diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 8a78b73dbb..927a24b455 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -940,7 +940,10 @@ ohos_unittest("ws_scene_session_lifecycle_test") { deps = [ ":ws_unittest_common" ] external_deps = test_external_deps - external_deps += [ "ability_base:session_info" ] + external_deps += [ + "ability_base:session_info", + "ability_runtime:process_options" + ] cflags = [] defines = [] diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 16139cf023..aa90e8819a 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -27,6 +27,7 @@ #include "mock/mock_session_stage.h" #include "input_event.h" #include +#include "process_options.h" #include "ui/rs_surface_node.h" #include "session/container/include/window_event_channel.h" #include "window_event_channel_base.h" @@ -870,6 +871,36 @@ HWTEST_F(SceneSessionLifecycleTest, ConnectInner02, TestSize.Level0) ASSERT_EQ(result, WSError::WS_OK); } +/** + * @tc.name: ConnectInner02 + * @tc.desc: ConnectInner02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionLifecycleTest, ConnectInner03, TestSize.Level0) +{ + SessionInfo info; + info.bundleName_ = "ConnectInner03"; + info.abilityName_ = "ConnectInner03"; + + std::shared_ptr processOptions = std::make_shared(); + processOptions->startupVisibility = AAFwk::StartupVisibility::STARTUP_HIDE; + info.processOptions = processOptions; + + sptr sceneSession = sptr::MakeSptr(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sptr mockSessionStage = sptr::MakeSptr(); + ASSERT_NE(mockSessionStage, nullptr); + SystemSessionConfig systemConfig; + sptr property = sptr::MakeSptr(); + ASSERT_NE(property, nullptr); + + sptr eventChannel = sptr::MakeSptr(mockSessionStage); + ASSERT_NE(eventChannel, nullptr); + sceneSession->SetSessionState(SessionState::STATE_DISCONNECT); + auto result = sceneSession->ConnectInner(mockSessionStage, eventChannel, nullptr, systemConfig, property, nullptr); + ASSERT_EQ(result, WSError::WS_OK); +} + /** * @tc.name: Reconnect * @tc.desc: Reconnect diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 7d60f96bf8..e9a61914fa 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -73,7 +73,7 @@ constexpr uint32_t API_VERSION_MOD = 1000; constexpr int32_t WINDOW_ROTATION_CHANGE = 50; constexpr uint32_t INVALID_TARGET_API_VERSION = 0; constexpr uint32_t OPAQUE = 0xFF000000; -constexpr int32_t WINDOW_CONNECT_TIMEOUT = 3000; +constexpr int32_t WINDOW_CONNECT_TIMEOUT = 1000; constexpr int32_t WINDOW_LIFECYCLE_TIMEOUT = 100; /* @@ -671,7 +671,7 @@ WMError WindowSessionImpl::Connect() iSessionStage, iWindowEventChannel, surfaceNode_, windowSystemConfig_, property_, token, identityToken_); if (SysCapUtil::GetBundleName() != AppExecFwk::Constants::SCENE_BOARD_BUNDLE_NAME && - WindowHelper::IsMainWindow(GetType())) { + WindowHelper::IsMainWindow(GetType()) && !property_->GetMissionInfo().startupInvisibility_) { auto startTime = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count(); updateRectCallback_->GetUpdateRectResult(WINDOW_CONNECT_TIMEOUT); @@ -7145,7 +7145,7 @@ void WindowSessionImpl::NotifyWindowStatusDidChange(WindowMode mode) void WindowSessionImpl::NotifyFirstValidLayoutUpdate(const Rect& preRect, const Rect& newRect) { bool isFirstValidLayoutUpdate = true; - if (preRect.IsUninitializedSize() && !newRect.IsUninitializedSize() && + if (!newRect.IsUninitializedSize() && isFirstValidLayoutUpdate_.compare_exchange_strong(isFirstValidLayoutUpdate, false)) { updateRectCallback_->OnFirstValidRectUpdate(GetPersistentId()); TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, rect:%{public}s", GetPersistentId(), newRect.ToString().c_str()); diff --git a/wm/test/unittest/layout/window_session_impl_layout_test.cpp b/wm/test/unittest/layout/window_session_impl_layout_test.cpp index 15e6413388..527799e486 100644 --- a/wm/test/unittest/layout/window_session_impl_layout_test.cpp +++ b/wm/test/unittest/layout/window_session_impl_layout_test.cpp @@ -409,13 +409,13 @@ HWTEST_F(WindowSessionImplLayoutTest, NotifyFirstValidLayoutUpdate, TestSize.Lev sptr window = sptr::MakeSptr(option); window->property_->SetPersistentId(2025); - Rect preRect = { 0, 0, 1000, 1000 }; + Rect preRect = { 0, 0, 0, 0 }; Rect newRect = { 0, 0, 0, 0 }; window->isFirstValidLayoutUpdate_ = true; window->NotifyFirstValidLayoutUpdate(preRect, newRect); EXPECT_EQ(window->isFirstValidLayoutUpdate_, true); - preRect = { 0, 0, 0, 0 }; + preRect = { 0, 0, 1000, 1000 }; window->NotifyFirstValidLayoutUpdate(preRect, newRect); EXPECT_EQ(window->isFirstValidLayoutUpdate_, true); -- Gitee From 6f36c8b985985b4ca58455646192161a1268e9f7 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 16:27:57 +0800 Subject: [PATCH 066/241] =?UTF-8?q?fix:=20=E6=95=B4=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../window_runtime/window_napi/js_window.cpp | 235 ++++++++++++------ 1 file changed, 154 insertions(+), 81 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 894f1be430..dbcf4ba0b1 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1660,7 +1660,8 @@ napi_value JsWindow::OnRecover(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT_PC, "%{public}s window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][recover]msg: window is nullptr"); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][recover]msg: window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->Recover(1)); @@ -1793,7 +1794,8 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowTo]msg: failed"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowTo]msg: failed"); } // 2: params num; 2: index of callback napi_value lastParam = (argc <= 2) ? nullptr : @@ -1805,21 +1807,24 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][moveWindowTo]msg: window is nullptr"); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][moveWindowTo]msg: window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->MoveTo(x, y)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[Window][MoveWindowTo]msg: move failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[Window][MoveWindowTo]msg: move failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnMoveWindowTo") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[Window][MoveWindowTo]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[Window][MoveWindowTo]msg: failed to send event")); } return result; } @@ -1867,17 +1872,20 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 2) { // 2: minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToAsync]msg: Argc is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Failed to convert parameter to x"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToAsync]msg: Failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Failed to convert parameter to y"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToAsync]msg: Failed to convert parameter to y"); } MoveConfiguration moveConfiguration; size_t lastParamIndex = INDEX_TWO; @@ -1885,7 +1893,8 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info) lastParamIndex = INDEX_THREE; // MoveConfiguration is optional param if (!GetMoveConfigurationFromJsValue(env, argv[INDEX_TWO], moveConfiguration)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to moveConfiguration"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToAsync]msg: Failed to convert parameter to moveConfiguration"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToAsync]msg: Failed to convert parameter to moveConfiguration"); } } NapiAsyncTask::ExecuteCallback execute; @@ -1946,17 +1955,20 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 2) { // 2:minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][moveWindowToGlobal]msg: Argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToGlobal]msg: Argc is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobal]msg: Failed to convert parameter to x"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToGlobal]msg: Failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][moveWindowToGlobal]msg: Failed to convert parameter to y"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToGlobal]msg: Failed to convert parameter to y"); } MoveConfiguration moveConfiguration; size_t lastParamIndex = INDEX_TWO; @@ -1964,7 +1976,8 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) lastParamIndex = INDEX_THREE; // MoveConfiguration is optional param if (!GetMoveConfigurationFromJsValue(env, argv[INDEX_TWO], moveConfiguration)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to moveConfiguration and rectAnimationConfig"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][moveWindowToGlobal]msg: Failed to convert parameter to moveConfiguration and rectAnimationConfig"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToGlobal]msg: Failed to convert parameter to moveConfiguration and rectAnimationConfig"); } } NapiAsyncTask::ExecuteCallback execute; @@ -1988,18 +2001,21 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != TWO_PARAMS_SIZE) { TLOGE(WmsLogTag::WMS_LAYOUT, "Invalid argc: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobalDisplay]msg: invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToGlobalDisplay]msg: invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to x"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to y"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to y"); } napi_value result = nullptr; @@ -2008,7 +2024,8 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf auto window = windowToken.promote(); if (!window) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][moveWindowToGlobalDisplay]msg: window is nullptr"); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][moveWindowToGlobalDisplay]msg: window is nullptr"); return; } auto moveResult = window->MoveWindowToGlobalDisplay(x, y); @@ -2017,7 +2034,8 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (ret == WmErrorCode::WM_OK) { napiAsyncTask->Resolve(env, NapiGetUndefined(env)); } else { - napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][moveWindowToGlobalDisplay]msg: failed to move window")); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][moveWindowToGlobalDisplay]msg: failed to move window")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: window: [%{public}u, %{public}s], x: %{public}d, y: %{public}d, ret: %{public}d", @@ -2025,7 +2043,8 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][moveWindowToGlobalDisplay]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][moveWindowToGlobalDisplay]msg: failed to send event")); } return result; } @@ -2084,28 +2103,31 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) auto asyncTask = [windowToken = wptr(windowToken_), errCode, width, height, env, task = napiAsyncTask, where = __func__] { if (errCode != WMError::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, errCode),"[window][resize]msg: failed"); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "[window][resize]msg: failed")); TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: invalid param", where); return; } auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR),"[window][resize]msg: window is nullptr"); + task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, + "[window][resize]msg: window is nullptr")); return; } WMError ret = window->Resize(static_cast(width), static_cast(height)); if (ret == WMError::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][resize]msg: failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][resize]msg: failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resize]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][resize]msg: failed to send event")); } return result; } @@ -2230,7 +2252,8 @@ napi_value JsWindow::OnResizeWindowAsync(napi_env env, napi_callback_info info) errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][resizeWindowAsync]msg: invalid param"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][resizeWindowAsync]msg: invalid param"); } wptr weakToken(windowToken_); @@ -2460,7 +2483,8 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LAYOUT, "permission denied!"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP,"[window][setwindowMode]msg: permission denied!"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP, + "[window][setwindowMode]msg: permission denied!"); } WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; @@ -2500,21 +2524,24 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][setwindowMode]msg: window is nullptr"); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setwindowMode]msg: window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMode(winMode)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setwindowMode]msg: Window set mode failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setwindowMode]msg: Window set mode failed")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowMode") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setwindowMode]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setwindowMode]msg: failed to send event")); } return result; } @@ -4866,12 +4893,14 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argc > 2) { // 2: maximum params num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setResizeByDragEnabled]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setResizeByDragEnabled]msg: argc is invalid"); } bool dragEnabled = true; if (!ConvertFromJsValue(env, argv[0], dragEnabled)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to dragEnabled"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setResizeByDragEnabled]msg: failed to convert parameter to dragEnabled"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setResizeByDragEnabled]msg: failed to convert parameter to dragEnabled"); } napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); napi_value result = nullptr; @@ -4881,21 +4910,24 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][setResizeByDragEnabled]msg: window is nullptr"); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setResizeByDragEnabled]msg: window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetResizeByDragEnabled(dragEnabled)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setResizeByDragEnabled]msg: set dragEnabled failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setResizeByDragEnabled]msg: set dragEnabled failed")); } TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Window [%{public}u, %{public}s] set dragEnabled end", where, window->GetWindowId(), window->GetWindowName().c_str()); }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetResizeByDragEnabled") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setResizeByDragEnabled]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setResizeByDragEnabled]msg: failed to send event")); } return result; } @@ -5655,7 +5687,8 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) } } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setForbidSplitMove]msg: invalid param"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setForbidSplitMove]msg: invalid param"); } napi_value lastParam = (argc <= 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); @@ -5684,7 +5717,8 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetForbidSplitMove") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setForbidSplitMove]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setForbidSplitMove]msg: failed to send event")); } return result; } @@ -6719,12 +6753,14 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][setAspectRatio]msg: windowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setAspectRatio]msg: windowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "SetAspectRatio is not allowed since window is main window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][setAspectRatio]msg: setAspectRatio is not allowed since window is main window"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][setAspectRatio]msg: setAspectRatio is not allowed since window is main window"); } double aspectRatio = 0.0; @@ -6739,7 +6775,8 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) } if (errCode == WMError::WM_ERROR_INVALID_PARAM || aspectRatio <= 0.0) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setAspectRatio]msg: falied"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setAspectRatio]msg: falied"); } napi_value lastParam = (argc == 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -6765,7 +6802,8 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setAspectRatio]msg: falied")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setAspectRatio]msg: falied")); } return result; } @@ -6777,17 +6815,20 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM," [window][resetAspectRatio]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][resetAspectRatio]msg: argc is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][resetAspectRatio]msg: windowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][resetAspectRatio]msg: windowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "ResetAspectRatio is not allowed since window is main window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][resetAspectRatio]msg: "); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][resetAspectRatio]msg: ResetAspectRatio is not allowed since window is main window"); } napi_value lastParam = (argc == 0) ? nullptr : @@ -6812,7 +6853,8 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resetAspectRatio]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][resetAspectRatio]msg: failed to send event")); } return result; } @@ -6870,12 +6912,14 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WindowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][maximize]msg: windowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][maximize]msg: windowToken is nullptr"); } if (!(WindowHelper::IsMainWindow(windowToken_->GetType()) || windowToken_->IsSubWindowMaximizeSupported())) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "only support main or sub Window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][maximize]msg: only support main or sub Window"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][maximize]msg: only support main or sub Window"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -6887,7 +6931,8 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) presentationValue < static_cast(MaximizePresentation::FOLLOW_APP_IMMERSIVE_SETTING) || presentationValue > static_cast(MaximizePresentation::ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER)) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Failed to convert parameter to presentationValue"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][maximize]msg: failed to convert parameter to presentationValue"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][maximize]msg: failed to convert parameter to presentationValue"); } } MaximizePresentation presentation = static_cast(presentationValue); @@ -6900,7 +6945,8 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { task->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][maximize]msg: window is nullptr")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][maximize]msg: window is nullptr")); return; } WMError ret = window->Maximize(presentation); @@ -6908,12 +6954,14 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "[window][maximize]msg: failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][maximize]msg: failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnMaximize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][maximize]msg: send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][maximize]msg: send event failed")); } return result; } @@ -7058,13 +7106,15 @@ napi_value JsWindow::OnEnableDrag(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][enableDrag]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][enableDrag]msg: argc is invalid"); } bool enableDrag = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enableDrag)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter from jsValue"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][enableDrag]msg: failed to convert parameter from jsValue"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][enableDrag]msg: failed to convert parameter from jsValue"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); NapiAsyncTask::ExecuteCallback execute = @@ -7085,17 +7135,19 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setWindowLimits]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setWindowLimits]msg: argc is invalid"); } WindowLimits windowLimits; if (!ParseWindowLimits(env, argv[INDEX_ZERO], windowLimits)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert object to windowLimits"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setWindowLimits]msg:Failed to convert object to windowLimits"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setWindowLimits]msg:Failed to convert object to windowLimits"); } if (windowLimits.maxWidth_ < 0 || windowLimits.maxHeight_ < 0 || windowLimits.minWidth_ < 0 || windowLimits.minHeight_ < 0) { TLOGE(WmsLogTag::WMS_LAYOUT, "Width or height should be greater than or equal to 0"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setWindowLimits]msg: Width or height should be greater than or equal to 0"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setWindowLimits]msg: Width or height should be greater than or equal to 0"); } size_t lastParamIndex = INDEX_ONE; bool isForcible = false; @@ -7103,15 +7155,18 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) lastParamIndex = INDEX_TWO; if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][setWindowLimits]msg: window is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowLimits]msg: window is nullptr"); } if (!windowToken_->IsPcOrFreeMultiWindowCapabilityEnabled()) { TLOGE(WmsLogTag::WMS_LAYOUT, "device not support"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, "[window][setWindowLimits]msg: device not support"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, + "[window][setWindowLimits]msg: device not support"); } if (!ConvertFromJsValue(env, argv[INDEX_ONE], isForcible)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isForcible"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setWindowLimits]msg: Failed to convert parameter to isForcible"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setWindowLimits]msg: Failed to convert parameter to isForcible"); } } napi_value lastParam = (argc <= lastParamIndex) ? nullptr : @@ -7123,7 +7178,7 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][setWindowLimits]msg: window is nullptr"); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setWindowLimits]msg: window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowLimits(windowLimits, isForcible)); @@ -7131,7 +7186,7 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) auto objValue = GetWindowLimitsAndConvertToJsValue(env, windowLimits); if (objValue == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowLimits]msg: set window limits failed")); + "[window][setWindowLimits]msg: set window limits failed")); } else { task->Resolve(env, objValue); } @@ -7154,17 +7209,19 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][getWindowLimits]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][getWindowLimits]msg: argc is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][getWindowLimits]msg: window is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowLimits]msg: window is nullptr"); } WindowLimits windowLimits; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetWindowLimits(windowLimits)); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret,"[window][getWindowLimits]msg: falied"); + return NapiThrowError(env, ret, "[window][getWindowLimits]msg: falied"); } auto objValue = GetWindowLimitsAndConvertToJsValue(env, windowLimits); TLOGI(WmsLogTag::WMS_LAYOUT, "Window [%{public}u, %{public}s] get window limits end", @@ -7172,7 +7229,7 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) if (objValue != nullptr) { return objValue; } else { - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][getWindowLimits]msg: nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][getWindowLimits]msg: nullptr"); } } @@ -7360,12 +7417,14 @@ napi_value JsWindow::OnSetFollowParentMultiScreenPolicy(napi_env env, napi_callb napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != ARG_COUNT_ONE) { TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setFollowParentMultiScreenPolicy]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setFollowParentMultiScreenPolicy]msg: argc is invalid"); } bool enabled = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enabled)) { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to enabled"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setFollowParentMultiScreenPolicy]msg: Failed to convert parameter to enabled"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setFollowParentMultiScreenPolicy]msg: Failed to convert parameter to enabled"); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); @@ -7373,7 +7432,8 @@ napi_value JsWindow::OnSetFollowParentMultiScreenPolicy(napi_env env, napi_callb napi_status status = napi_send_event(env, asyncTask, napi_eprio_high, "OnSetFollowParentMultiScreenPolicy"); if (status != napi_status::napi_ok) { napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][setFollowParentMultiScreenPolicy]msg: send event failed")); + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setFollowParentMultiScreenPolicy]msg: send event failed")); } return result; } @@ -8065,13 +8125,15 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) auto window = windowToken_; if (window == nullptr) { TLOGE(WmsLogTag::WMS_PC, "window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][getWindowStatus]msg: window is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowStatus]msg: window is nullptr"); } WindowStatus windowStatus; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->GetWindowStatus(windowStatus)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_PC, "failed, ret=%{public}d", ret); - return NapiThrowError(env, ret, "[window][getWindowStatus]msg: falied"); + return NapiThrowError(env, ret, + "[window][getWindowStatus]msg: falied"); } auto objValue = CreateJsValue(env, windowStatus); if (objValue != nullptr) { @@ -8079,7 +8141,8 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) return objValue; } else { TLOGE(WmsLogTag::WMS_PC, "create js value windowStatus failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][getWindowStatus]msg: create js value windowStatus failed"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getWindowStatus]msg: create js value windowStatus failed"); } } @@ -8172,7 +8235,8 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "windowToken is nullptr."); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][startMoving]msg: windowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][startMoving]msg: windowToken is nullptr"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -8182,7 +8246,8 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) } if (WindowHelper::IsInputWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "is not allowed since input window"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING,"[window][startMoving]msg: not allowed since input window"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][startMoving]msg: not allowed since input window"); } std::shared_ptr err = std::make_shared(WmErrorCode::WM_OK); const char* const funcName = __func__; @@ -8268,7 +8333,8 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "windowToken is nullptr."); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,"[window][stopMoving]msg: windowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][stopMoving]msg: windowToken is nullptr"); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); @@ -8277,19 +8343,22 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT_PC, "%{public}s window is nullptr.", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY),"[window][stopMoving]msg: window is nullptr"); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][stopMoving]msg: window is nullptr")); return; } WmErrorCode ret = window->StopMoveWindow(); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][stopMoving]msg: Stop moving window failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][stopMoving]msg: Stop moving window failed")); } }; if (napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnStopMoving") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][stopMoving]msg: send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][stopMoving]msg: send event failed")); } return result; } @@ -8888,12 +8957,14 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != INDEX_ONE) { TLOGE(WmsLogTag::WMS_SUB, "argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setFollowParentWindowLayoutEnabled]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setFollowParentWindowLayoutEnabled]msg: argc is invalid"); } bool isFollow = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], isFollow)) { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to enable"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,"[window][setFollowParentWindowLayoutEnabled]msg: falied to convert parameter to enable"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setFollowParentWindowLayoutEnabled]msg: falied to convert parameter to enable"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); const char* const where = __func__; @@ -8903,12 +8974,12 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); - task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY)),"[window][setFollowParentWindowLayoutEnabled]msg: window is nullptr"); + task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][setFollowParentWindowLayoutEnabled]msg: window is nullptr")); return; } if (!WindowHelper::IsSubWindow(window->GetType()) && !WindowHelper::IsDialogWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s only sub window and dialog is valid", where); - task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING)),"[window][setFollowParentWindowLayoutEnabled]msg: only sub window and dialog is valid"); + task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING), "[window][setFollowParentWindowLayoutEnabled]msg: only sub window and dialog is valid")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetFollowParentWindowLayoutEnabled(isFollow)); @@ -8916,13 +8987,15 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal task->Resolve(env, NapiGetUndefined(env)); } else { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s failed, ret %{public}d", where, ret); - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setFollowParentWindowLayoutEnabled]msg: set follow parent layout failed.")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setFollowParentWindowLayoutEnabled]msg: set follow parent layout failed.")); } }; napi_status status = napi_send_event(env, asyncTask, napi_eprio_high, "SetFollowParentWindowLayoutEnabled"); if (status != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][setFollowParentWindowLayoutEnabled]msg: send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setFollowParentWindowLayoutEnabled]msg: send event failed")); } return result; } -- Gitee From f5d76a5b76e85c33285a327a21f319668fca7c8b Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 17:12:51 +0800 Subject: [PATCH 067/241] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../window_runtime/window_napi/js_window.cpp | 135 +++++++++--------- 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index dbcf4ba0b1..749fc1fe10 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2002,20 +2002,20 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (argc != TWO_PARAMS_SIZE) { TLOGE(WmsLogTag::WMS_LAYOUT, "Invalid argc: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobalDisplay]msg: invalid"); + "[window][moveWindowToGlobalDisplay]msg: invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to x"); + "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to y"); + "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to y"); } napi_value result = nullptr; @@ -2024,8 +2024,8 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf auto window = windowToken.promote(); if (!window) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][moveWindowToGlobalDisplay]msg: window is nullptr"); + napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][moveWindowToGlobalDisplay]msg: window is nullptr")); return; } auto moveResult = window->MoveWindowToGlobalDisplay(x, y); @@ -2035,7 +2035,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf napiAsyncTask->Resolve(env, NapiGetUndefined(env)); } else { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][moveWindowToGlobalDisplay]msg: failed to move window")); + "[window][moveWindowToGlobalDisplay]msg: failed to move window")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: window: [%{public}u, %{public}s], x: %{public}d, y: %{public}d, ret: %{public}d", @@ -2044,7 +2044,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][moveWindowToGlobalDisplay]msg: failed to send event")); + "[window][moveWindowToGlobalDisplay]msg: failed to send event")); } return result; } @@ -2111,7 +2111,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, - "[window][resize]msg: window is nullptr")); + "[window][resize]msg: window is nullptr")); return; } WMError ret = window->Resize(static_cast(width), static_cast(height)); @@ -2119,7 +2119,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][resize]msg: failed")); + "[window][resize]msg: failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -2127,7 +2127,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][resize]msg: failed to send event")); + "[window][resize]msg: failed to send event")); } return result; } @@ -2253,7 +2253,7 @@ napi_value JsWindow::OnResizeWindowAsync(napi_env env, napi_callback_info info) } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][resizeWindowAsync]msg: invalid param"); + "[window][resizeWindowAsync]msg: invalid param"); } wptr weakToken(windowToken_); @@ -2484,7 +2484,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LAYOUT, "permission denied!"); return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP, - "[window][setwindowMode]msg: permission denied!"); + "[window][setwindowMode]msg: permission denied!"); } WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; @@ -2533,7 +2533,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setwindowMode]msg: Window set mode failed")); + "[window][setwindowMode]msg: Window set mode failed")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -2541,7 +2541,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowMode") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setwindowMode]msg: failed to send event")); + "[window][setwindowMode]msg: failed to send event")); } return result; } @@ -4894,13 +4894,13 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (argc < 1 || argc > 2) { // 2: maximum params num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setResizeByDragEnabled]msg: argc is invalid"); + "[window][setResizeByDragEnabled]msg: argc is invalid"); } bool dragEnabled = true; if (!ConvertFromJsValue(env, argv[0], dragEnabled)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to dragEnabled"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setResizeByDragEnabled]msg: failed to convert parameter to dragEnabled"); + "[window][setResizeByDragEnabled]msg: failed to convert parameter to dragEnabled"); } napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); napi_value result = nullptr; @@ -4911,7 +4911,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setResizeByDragEnabled]msg: window is nullptr")); + "[window][setResizeByDragEnabled]msg: window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetResizeByDragEnabled(dragEnabled)); @@ -4919,7 +4919,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setResizeByDragEnabled]msg: set dragEnabled failed")); + "[window][setResizeByDragEnabled]msg: set dragEnabled failed")); } TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Window [%{public}u, %{public}s] set dragEnabled end", where, window->GetWindowId(), window->GetWindowName().c_str()); @@ -4927,7 +4927,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetResizeByDragEnabled") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setResizeByDragEnabled]msg: failed to send event")); + "[window][setResizeByDragEnabled]msg: failed to send event")); } return result; } @@ -5688,7 +5688,7 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setForbidSplitMove]msg: invalid param"); + "[window][setForbidSplitMove]msg: invalid param"); } napi_value lastParam = (argc <= 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); @@ -5718,7 +5718,7 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetForbidSplitMove") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setForbidSplitMove]msg: failed to send event")); + "[window][setForbidSplitMove]msg: failed to send event")); } return result; } @@ -6754,13 +6754,13 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setAspectRatio]msg: windowToken is nullptr"); + "[window][setAspectRatio]msg: windowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "SetAspectRatio is not allowed since window is main window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][setAspectRatio]msg: setAspectRatio is not allowed since window is main window"); + "[window][setAspectRatio]msg: setAspectRatio is not allowed since window is main window"); } double aspectRatio = 0.0; @@ -6776,7 +6776,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (errCode == WMError::WM_ERROR_INVALID_PARAM || aspectRatio <= 0.0) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setAspectRatio]msg: falied"); + "[window][setAspectRatio]msg: falied"); } napi_value lastParam = (argc == 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -6803,7 +6803,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setAspectRatio]msg: falied")); + "[window][setAspectRatio]msg: falied")); } return result; } @@ -6816,19 +6816,19 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][resetAspectRatio]msg: argc is invalid"); + "[window][resetAspectRatio]msg: argc is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][resetAspectRatio]msg: windowToken is nullptr"); + "[window][resetAspectRatio]msg: windowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "ResetAspectRatio is not allowed since window is main window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][resetAspectRatio]msg: ResetAspectRatio is not allowed since window is main window"); + "[window][resetAspectRatio]msg: ResetAspectRatio is not allowed since window is main window"); } napi_value lastParam = (argc == 0) ? nullptr : @@ -6854,7 +6854,7 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][resetAspectRatio]msg: failed to send event")); + "[window][resetAspectRatio]msg: failed to send event")); } return result; } @@ -6913,13 +6913,13 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][maximize]msg: windowToken is nullptr"); + "[window][maximize]msg: windowToken is nullptr"); } if (!(WindowHelper::IsMainWindow(windowToken_->GetType()) || windowToken_->IsSubWindowMaximizeSupported())) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "only support main or sub Window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][maximize]msg: only support main or sub Window"); + "[window][maximize]msg: only support main or sub Window"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -6932,7 +6932,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) presentationValue > static_cast(MaximizePresentation::ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER)) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Failed to convert parameter to presentationValue"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][maximize]msg: failed to convert parameter to presentationValue"); + "[window][maximize]msg: failed to convert parameter to presentationValue"); } } MaximizePresentation presentation = static_cast(presentationValue); @@ -6946,7 +6946,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][maximize]msg: window is nullptr")); + "[window][maximize]msg: window is nullptr")); return; } WMError ret = window->Maximize(presentation); @@ -6955,13 +6955,13 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "[window][maximize]msg: failed")); + "[window][maximize]msg: failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnMaximize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][maximize]msg: send event failed")); + "[window][maximize]msg: send event failed")); } return result; } @@ -7107,14 +7107,14 @@ napi_value JsWindow::OnEnableDrag(napi_env env, napi_callback_info info) if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][enableDrag]msg: argc is invalid"); + "[window][enableDrag]msg: argc is invalid"); } bool enableDrag = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enableDrag)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter from jsValue"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][enableDrag]msg: failed to convert parameter from jsValue"); + "[window][enableDrag]msg: failed to convert parameter from jsValue"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); NapiAsyncTask::ExecuteCallback execute = @@ -7141,13 +7141,13 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) if (!ParseWindowLimits(env, argv[INDEX_ZERO], windowLimits)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert object to windowLimits"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setWindowLimits]msg:Failed to convert object to windowLimits"); + "[window][setWindowLimits]msg:Failed to convert object to windowLimits"); } if (windowLimits.maxWidth_ < 0 || windowLimits.maxHeight_ < 0 || windowLimits.minWidth_ < 0 || windowLimits.minHeight_ < 0) { TLOGE(WmsLogTag::WMS_LAYOUT, "Width or height should be greater than or equal to 0"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setWindowLimits]msg: Width or height should be greater than or equal to 0"); + "[window][setWindowLimits]msg: Width or height should be greater than or equal to 0"); } size_t lastParamIndex = INDEX_ONE; bool isForcible = false; @@ -7156,17 +7156,17 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowLimits]msg: window is nullptr"); + "[window][setWindowLimits]msg: window is nullptr"); } if (!windowToken_->IsPcOrFreeMultiWindowCapabilityEnabled()) { TLOGE(WmsLogTag::WMS_LAYOUT, "device not support"); return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, - "[window][setWindowLimits]msg: device not support"); + "[window][setWindowLimits]msg: device not support"); } if (!ConvertFromJsValue(env, argv[INDEX_ONE], isForcible)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isForcible"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setWindowLimits]msg: Failed to convert parameter to isForcible"); + "[window][setWindowLimits]msg: Failed to convert parameter to isForcible"); } } napi_value lastParam = (argc <= lastParamIndex) ? nullptr : @@ -7178,7 +7178,8 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setWindowLimits]msg: window is nullptr")); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowLimits]msg: window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowLimits(windowLimits, isForcible)); @@ -7186,17 +7187,19 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) auto objValue = GetWindowLimitsAndConvertToJsValue(env, windowLimits); if (objValue == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowLimits]msg: set window limits failed")); + "[window][setWindowLimits]msg: set window limits failed")); } else { task->Resolve(env, objValue); } } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setWindowLimits]msg: set window limits failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setWindowLimits]msg: set window limits failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowLimits") != napi_status::napi_ok) { napiAsyncTask->Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setWindowLimits]msg: failed to send event")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowLimits]msg: failed to send event")); } return result; } @@ -7210,7 +7213,7 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][getWindowLimits]msg: argc is invalid"); + "[window][getWindowLimits]msg: argc is invalid"); } if (windowToken_ == nullptr) { @@ -7418,13 +7421,13 @@ napi_value JsWindow::OnSetFollowParentMultiScreenPolicy(napi_env env, napi_callb if (argc != ARG_COUNT_ONE) { TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setFollowParentMultiScreenPolicy]msg: argc is invalid"); + "[window][setFollowParentMultiScreenPolicy]msg: argc is invalid"); } bool enabled = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enabled)) { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to enabled"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setFollowParentMultiScreenPolicy]msg: Failed to convert parameter to enabled"); + "[window][setFollowParentMultiScreenPolicy]msg: Failed to convert parameter to enabled"); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); @@ -7433,7 +7436,7 @@ napi_value JsWindow::OnSetFollowParentMultiScreenPolicy(napi_env env, napi_callb if (status != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][setFollowParentMultiScreenPolicy]msg: send event failed")); + "[window][setFollowParentMultiScreenPolicy]msg: send event failed")); } return result; } @@ -8126,14 +8129,14 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGE(WmsLogTag::WMS_PC, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowStatus]msg: window is nullptr"); + "[window][getWindowStatus]msg: window is nullptr"); } WindowStatus windowStatus; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->GetWindowStatus(windowStatus)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_PC, "failed, ret=%{public}d", ret); return NapiThrowError(env, ret, - "[window][getWindowStatus]msg: falied"); + "[window][getWindowStatus]msg: falied"); } auto objValue = CreateJsValue(env, windowStatus); if (objValue != nullptr) { @@ -8142,7 +8145,7 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) } else { TLOGE(WmsLogTag::WMS_PC, "create js value windowStatus failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowStatus]msg: create js value windowStatus failed"); + "[window][getWindowStatus]msg: create js value windowStatus failed"); } } @@ -8236,7 +8239,7 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "windowToken is nullptr."); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][startMoving]msg: windowToken is nullptr"); + "[window][startMoving]msg: windowToken is nullptr"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -8247,7 +8250,7 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) if (WindowHelper::IsInputWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "is not allowed since input window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][startMoving]msg: not allowed since input window"); + "[window][startMoving]msg: not allowed since input window"); } std::shared_ptr err = std::make_shared(WmErrorCode::WM_OK); const char* const funcName = __func__; @@ -8334,7 +8337,7 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "windowToken is nullptr."); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][stopMoving]msg: windowToken is nullptr"); + "[window][stopMoving]msg: windowToken is nullptr"); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); @@ -8344,7 +8347,7 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT_PC, "%{public}s window is nullptr.", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][stopMoving]msg: window is nullptr")); + "[window][stopMoving]msg: window is nullptr")); return; } WmErrorCode ret = window->StopMoveWindow(); @@ -8352,13 +8355,13 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][stopMoving]msg: Stop moving window failed")); + "[window][stopMoving]msg: Stop moving window failed")); } }; if (napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnStopMoving") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][stopMoving]msg: send event failed")); + "[window][stopMoving]msg: send event failed")); } return result; } @@ -8958,13 +8961,13 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal if (argc != INDEX_ONE) { TLOGE(WmsLogTag::WMS_SUB, "argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setFollowParentWindowLayoutEnabled]msg: argc is invalid"); + "[window][setFollowParentWindowLayoutEnabled]msg: argc is invalid"); } bool isFollow = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], isFollow)) { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to enable"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setFollowParentWindowLayoutEnabled]msg: falied to convert parameter to enable"); + "[window][setFollowParentWindowLayoutEnabled]msg: falied to convert parameter to enable"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); const char* const where = __func__; @@ -8974,12 +8977,14 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); - task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][setFollowParentWindowLayoutEnabled]msg: window is nullptr")); + task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setFollowParentWindowLayoutEnabled]msg: window is nullptr")); return; } if (!WindowHelper::IsSubWindow(window->GetType()) && !WindowHelper::IsDialogWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s only sub window and dialog is valid", where); - task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING), "[window][setFollowParentWindowLayoutEnabled]msg: only sub window and dialog is valid")); + task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING), + "[window][setFollowParentWindowLayoutEnabled]msg: only sub window and dialog is valid")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetFollowParentWindowLayoutEnabled(isFollow)); @@ -8988,14 +8993,14 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal } else { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s failed, ret %{public}d", where, ret); task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setFollowParentWindowLayoutEnabled]msg: set follow parent layout failed.")); + "[window][setFollowParentWindowLayoutEnabled]msg: set follow parent layout failed.")); } }; napi_status status = napi_send_event(env, asyncTask, napi_eprio_high, "SetFollowParentWindowLayoutEnabled"); if (status != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][setFollowParentWindowLayoutEnabled]msg: send event failed")); + "[window][setFollowParentWindowLayoutEnabled]msg: send event failed")); } return result; } -- Gitee From 5c2bd1426ac0e4fcb4d15e8310a42c58b489dacd Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 19:02:52 +0800 Subject: [PATCH 068/241] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../window_runtime/window_napi/js_window.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 749fc1fe10..fac9b57056 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1795,7 +1795,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowTo]msg: failed"); + "[window][moveWindowTo]msg: failed"); } // 2: params num; 2: index of callback napi_value lastParam = (argc <= 2) ? nullptr : @@ -1824,7 +1824,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnMoveWindowTo") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[Window][MoveWindowTo]msg: failed to send event")); + "[Window][MoveWindowTo]msg: failed to send event")); } return result; } @@ -1873,19 +1873,19 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info) if (argc < 2) { // 2: minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToAsync]msg: Argc is invalid"); + "[window][moveWindowToAsync]msg: Argc is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToAsync]msg: Failed to convert parameter to x"); + "[window][moveWindowToAsync]msg: Failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToAsync]msg: Failed to convert parameter to y"); + "[window][moveWindowToAsync]msg: Failed to convert parameter to y"); } MoveConfiguration moveConfiguration; size_t lastParamIndex = INDEX_TWO; @@ -1894,7 +1894,7 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info) if (!GetMoveConfigurationFromJsValue(env, argv[INDEX_TWO], moveConfiguration)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to moveConfiguration"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToAsync]msg: Failed to convert parameter to moveConfiguration"); + "[window][moveWindowToAsync]msg: Failed to convert parameter to moveConfiguration"); } } NapiAsyncTask::ExecuteCallback execute; @@ -1956,28 +1956,28 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) if (argc < 2) { // 2:minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobal]msg: Argc is invalid"); + "[window][moveWindowToGlobal]msg: Argc is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobal]msg: Failed to convert parameter to x"); + "[window][moveWindowToGlobal]msg: Failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobal]msg: Failed to convert parameter to y"); + "[window][moveWindowToGlobal]msg: Failed to convert parameter to y"); } MoveConfiguration moveConfiguration; size_t lastParamIndex = INDEX_TWO; if (argc > TWO_PARAMS_SIZE && argv[INDEX_TWO] != nullptr && GetType(env, argv[INDEX_TWO]) == napi_object) { lastParamIndex = INDEX_THREE; // MoveConfiguration is optional param if (!GetMoveConfigurationFromJsValue(env, argv[INDEX_TWO], moveConfiguration)) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to moveConfiguration and rectAnimationConfig"); + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to moveConfiguration"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobal]msg: Failed to convert parameter to moveConfiguration and rectAnimationConfig"); + "[window][moveWindowToGlobal]msg: Failed to convert parameter to moveConfiguration"); } } NapiAsyncTask::ExecuteCallback execute; @@ -2524,7 +2524,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) auto window = windowToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setwindowMode]msg: window is nullptr")); return; } @@ -7135,7 +7135,8 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setWindowLimits]msg: argc is invalid"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setWindowLimits]msg: argc is invalid"); } WindowLimits windowLimits; if (!ParseWindowLimits(env, argv[INDEX_ZERO], windowLimits)) { @@ -8277,7 +8278,8 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) if (*err == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, CreateJsError(env, static_cast(*err), "[window][startMoving]msg: Move system window failed.")); + task.Reject(env, CreateJsError(env, static_cast(*err), + "[window][startMoving]msg: Move system window failed.")); } }; napi_value result = nullptr; -- Gitee From 53a17e9e02af0c0b4fe1fa73dd10af176e432257 Mon Sep 17 00:00:00 2001 From: zhangweihua Date: Tue, 19 Aug 2025 14:29:55 +0800 Subject: [PATCH 069/241] onoff bugfix Signed-off-by: zhangweihua --- .../src/screen_session_manager.cpp | 7 ++- .../screen_session_manager_test2.cpp | 63 +++++++++++++++++++ 2 files changed, 69 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 66e98b6eba..81d00cda90 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -3782,7 +3782,12 @@ void ScreenSessionManager::SetScreenPowerForFold(ScreenId screenId, ScreenPowerS (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() || FoldScreenStateInternel::IsDualDisplayFoldDevice() || FoldScreenStateInternel::IsSingleDisplayFoldDevice()); - if ((lastPowerForAllStatus_.load() == ScreenPowerStatus::POWER_STATUS_ON_ADVANCED || + if (lastPowerForAllStatus_.load() == ScreenPowerStatus::POWER_STATUS_ON_ADVANCED + && screenId == lastScreenId_.load() && FoldScreenStateInternel::IsSingleDisplayFoldDevice()) { + // 预下电 + TLOGI(WmsLogTag::DMS, "set advancedOn powerStatus off, screenId:%{public}" PRIu64, screenId); + SetRSScreenPowerStatus(screenId, ScreenPowerStatus::POWER_STATUS_OFF_ADVANCED); + } else if ((lastPowerForAllStatus_.load() == ScreenPowerStatus::POWER_STATUS_ON_ADVANCED || lastPowerForAllStatus_.load() == ScreenPowerStatus::POWER_STATUS_SUSPEND) && screenId == SCREEN_ID_MAIN && lastScreenId_.load() == SCREEN_ID_MAIN && isNeedScreenOffDevice) { if (!IsInAod()) { 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 b6d0bc89c1..08be41a626 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -37,6 +37,8 @@ constexpr uint32_t G_STATUS_WIDTH = 3184; const ScreenId SCREENID = 1000; constexpr uint32_t EXCEPTION_DPI = 10; constexpr uint32_t PC_MODE_DPI = 304; +const ScreenId SCREEN_ID_FULL = 0; +const ScreenId SCREEN_ID_MAIN = 5; } namespace { std::string g_errLog; @@ -78,6 +80,67 @@ void ScreenSessionManagerTest::TearDown() } namespace { + +/** + * @tc.name: SetScreenPowerForFold01 + * @tc.desc: SetScreenPowerForFold test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold01, TestSize.Level1) +{ + // 内屏预上电 + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + sptr ssm = sptr::MakeSptr(); + ssm->SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON_ADVANCED); + + // 下电 + ssm->lastPowerForAllStatus_.store(ScreenPowerStatus::POWER_STATUS_ON_ADVANCED); + ssm->lastScreenId_.store(SCREEN_ID_FULL); + ssm->SetScreenPowerForFold(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF); + if (FoldScreenStateInternel::IsSingleDisplayFoldDevice()) { + EXPECT_TRUE(g_errLog.find("set advancedOn powerStatus off") != std::string::npos); + } else { + EXPECT_TRUE(g_errLog.find("set advancedOn powerStatus off") == std::string::npos); + } +} + +/** + * @tc.name: SetScreenPowerForFold02 + * @tc.desc: SetScreenPowerForFold test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold02, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + sptr ssm = sptr::MakeSptr(); + ssm->SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON_ADVANCED); + + ssm->lastPowerForAllStatus_.store(ScreenPowerStatus::POWER_STATUS_OFF); + ssm->lastScreenId_.store(SCREEN_ID_FULL); + ssm->SetScreenPowerForFold(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF); + EXPECT_TRUE(g_errLog.find("set advancedOn powerStatus off") == std::string::npos); +} + +/** + * @tc.name: SetScreenPowerForFold03 + * @tc.desc: SetScreenPowerForFold test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold03, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + sptr ssm = sptr::MakeSptr(); + ssm->SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON_ADVANCED); + + ssm->lastPowerForAllStatus_.store(ScreenPowerStatus::POWER_STATUS_ON_ADVANCED); + ssm->lastScreenId_.store(SCREEN_ID_MAIN); + ssm->SetScreenPowerForFold(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF); + EXPECT_TRUE(g_errLog.find("set advancedOn powerStatus off") == std::string::npos); +} + /** * @tc.name: SwitchScrollParam01 * @tc.desc: SwitchScrollParam test -- Gitee From ce7f6df1483efa38d7a9442b120625511a1ae467 Mon Sep 17 00:00:00 2001 From: MirMort Date: Tue, 19 Aug 2025 19:10:57 +0800 Subject: [PATCH 070/241] =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=B1=8F=E6=8A=95?= =?UTF-8?q?=E5=B1=8F=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=20Signed-off-by:?= =?UTF-8?q?=20MirMort=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen_session_manager/src/screen_session_manager.cpp | 1 + .../src/zidl/screen_session_manager_proxy.cpp | 3 ++- .../src/zidl/screen_session_manager_stub.cpp | 4 +++- 3 files changed, 6 insertions(+), 2 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 13214a5708..b0718a727c 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -4923,6 +4923,7 @@ ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option, screenSessionMap_.insert(std::make_pair(smsScreenId, screenSession)); } screenSession->SetVirtualScreenFlag(option.virtualScreenFlag_); + TLOGI(WmsLogTag::DMS, "virtualScreenFlag: %{public}d", option.virtualScreenFlag_); NotifyScreenConnected(screenSession->ConvertToScreenInfo()); TLOGW(WmsLogTag::DMS, "create success. ScreenId: %{public}" PRIu64", rsId: %{public}" PRIu64"", smsScreenId, rsId); 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 0d481f5b77..db4d4f5091 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 @@ -1101,7 +1101,8 @@ ScreenId ScreenSessionManagerProxy::CreateVirtualScreen(VirtualScreenOption virt data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_) && data.WriteUInt64Vector(virtualOption.missionIds_) && data.WriteUint32(static_cast(virtualOption.virtualScreenType_)) && - data.WriteBool(virtualOption.isSecurity_); + data.WriteBool(virtualOption.isSecurity_) && + data.WriteUint32(static_cast(virtualOption.virtualScreenFlag_)); if (virtualOption.surface_ != nullptr && virtualOption.surface_->GetProducer() != nullptr) { res = res && data.WriteBool(true) && 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 e2152ca816..752a421607 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 @@ -231,6 +231,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& data.ReadUInt64Vector(&missionIds); VirtualScreenType virtualScreenType = static_cast(data.ReadUint32()); bool isSecurity = data.ReadBool(); + VirtualScreenFlag virtualScreenFlag = static_cast(data.ReadUint32()); bool isSurfaceValid = data.ReadBool(); sptr surface = nullptr; if (isSurfaceValid) { @@ -249,7 +250,8 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& .isForShot_ = isForShot, .missionIds_ = missionIds, .virtualScreenType_ = virtualScreenType, - .isSecurity_ = isSecurity + .isSecurity_ = isSecurity, + .virtualScreenFlag_ = virtualScreenFlag }; ScreenId screenId = CreateVirtualScreen(virScrOption, virtualScreenAgent); static_cast(reply.WriteUint64(static_cast(screenId))); -- Gitee From 01b70f2edab2f82ff01f92c9260511da93283212 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 19:15:36 +0800 Subject: [PATCH 071/241] =?UTF-8?q?fix:=20=E5=8E=BB=E9=99=A4=E8=A1=8C?= =?UTF-8?q?=E9=A6=96=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index fac9b57056..3d1f2bc651 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -7220,7 +7220,7 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowLimits]msg: window is nullptr"); + "[window][getWindowLimits]msg: window is nullptr"); } WindowLimits windowLimits; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetWindowLimits(windowLimits)); -- Gitee From 35fff3ca39a3fa3fe49720b882132c860209b7eb Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 19 Aug 2025 19:47:01 +0800 Subject: [PATCH 072/241] default dpi Signed-off-by: zzz --- .../screen_session_manager/src/screen_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 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 13214a5708..c4ee586d9d 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2936,11 +2936,11 @@ void ScreenSessionManager::InitExtendScreenDensity(sptr session, float defaultDensity = screenSession->GetScreenProperty().GetDefaultDensity(); TLOGW(WmsLogTag::DMS, "extendDensity = %{public}f", extendDensity); session->SetVirtualPixelRatio(extendDensity * g_extendScreenDpiCoef); - session->SetDefaultDensity(defaultDensity * g_extendScreenDpiCoef); + session->SetDefaultDensity(defaultDensity * EXTEND_SCREEN_DPI_DEFAULT_PARAMETER); session->SetDensityInCurResolution(curResolution); ScreenId screenId = session->GetScreenId(); property.SetVirtualPixelRatio(extendDensity * g_extendScreenDpiCoef); - property.SetDefaultDensity(defaultDensity * g_extendScreenDpiCoef); + property.SetDefaultDensity(defaultDensity * EXTEND_SCREEN_DPI_DEFAULT_PARAMETER); property.SetDensityInCurResolution(curResolution); { std::lock_guard lock_phy(phyScreenPropMapMutex_); -- Gitee From 27d06f4cb861f1f9c0320f9e0ad38c14690e9d0c Mon Sep 17 00:00:00 2001 From: zhangweihua Date: Tue, 19 Aug 2025 19:59:05 +0800 Subject: [PATCH 073/241] onoff bugfix Signed-off-by: zhangweihua --- .../screen_session_manager/src/screen_session_manager.cpp | 4 ++-- .../test/dms_unittest/screen_session_manager_test2.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 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 81d00cda90..cdbb25f4fe 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -3782,8 +3782,8 @@ void ScreenSessionManager::SetScreenPowerForFold(ScreenId screenId, ScreenPowerS (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() || FoldScreenStateInternel::IsDualDisplayFoldDevice() || FoldScreenStateInternel::IsSingleDisplayFoldDevice()); - if (lastPowerForAllStatus_.load() == ScreenPowerStatus::POWER_STATUS_ON_ADVANCED - && screenId == lastScreenId_.load() && FoldScreenStateInternel::IsSingleDisplayFoldDevice()) { + if (lastPowerForAllStatus_.load() == ScreenPowerStatus::POWER_STATUS_ON_ADVANCED && + screenId == lastScreenId_.load() && FoldScreenStateInternel::IsSingleDisplayFoldDevice()) { // 预下电 TLOGI(WmsLogTag::DMS, "set advancedOn powerStatus off, screenId:%{public}" PRIu64, screenId); SetRSScreenPowerStatus(screenId, ScreenPowerStatus::POWER_STATUS_OFF_ADVANCED); 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 08be41a626..8b03183e26 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -37,8 +37,8 @@ constexpr uint32_t G_STATUS_WIDTH = 3184; const ScreenId SCREENID = 1000; constexpr uint32_t EXCEPTION_DPI = 10; constexpr uint32_t PC_MODE_DPI = 304; -const ScreenId SCREEN_ID_FULL = 0; -const ScreenId SCREEN_ID_MAIN = 5; +constexpr ScreenId SCREEN_ID_FULL = 0; +constexpr ScreenId SCREEN_ID_MAIN = 5; } namespace { std::string g_errLog; -- Gitee From 84a1497d9dddb28e3ea41b0882c7e665076f541d Mon Sep 17 00:00:00 2001 From: MirMort Date: Tue, 19 Aug 2025 20:32:22 +0800 Subject: [PATCH 074/241] add Signed-off-by: MirMort --- dm/src/display_manager_adapter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 2bcd9bd367..238a270ed7 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -1476,6 +1476,7 @@ DMError ScreenManagerAdapter::SetVirtualScreenFlag(ScreenId screenId, VirtualScr if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { return DMError::DM_ERROR_INVALID_PARAM; } + TLOGI(WmsLogTag::DMS, "VirtualScreenFlag:%{public}d", screenFlag); if (screenSessionManagerServiceProxy_) { return screenSessionManagerServiceProxy_->SetVirtualScreenFlag(screenId, screenFlag); } -- Gitee From 5372ff005e069660302dca07d04d056ced66d695 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 20:32:27 +0800 Subject: [PATCH 075/241] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 3d1f2bc651..924cc1c010 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1816,7 +1816,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[Window][MoveWindowTo]msg: move failed")); + "[window][moveWindowTo]msg: move failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -1824,7 +1824,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnMoveWindowTo") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[Window][MoveWindowTo]msg: failed to send event")); + "[window][moveWindowTo]msg: failed to send event")); } return result; } -- Gitee From 45b024989b47a1193956fe48eec82927c994f330 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 21:33:26 +0800 Subject: [PATCH 076/241] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=BF=94=E5=9B=9E=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../window_runtime/window_napi/js_window.cpp | 143 +++++++++--------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 924cc1c010..6420169c1c 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1661,21 +1661,21 @@ napi_value JsWindow::OnRecover(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT_PC, "%{public}s window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][recover]msg: window is nullptr")); + "[window][recover]msg: Window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->Recover(1)); if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][recover]msg: failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][recover]msg: Failed")); } TLOGNI(WmsLogTag::WMS_LAYOUT_PC, "%{public}s end, window [%{public}u] ret=%{public}d", where, window->GetWindowId(), ret); }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnRecover") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][recover]msg: send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "[window][recover]msg: Send event failed")); } return result; } @@ -1808,7 +1808,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][moveWindowTo]msg: window is nullptr")); + "[window][moveWindowTo]msg: Window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->MoveTo(x, y)); @@ -1816,7 +1816,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][moveWindowTo]msg: move failed")); + "[window][moveWindowTo]msg: Move failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -1824,7 +1824,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnMoveWindowTo") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][moveWindowTo]msg: failed to send event")); + "[window][moveWindowTo]msg: Failed to send event")); } return result; } @@ -2002,20 +2002,20 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (argc != TWO_PARAMS_SIZE) { TLOGE(WmsLogTag::WMS_LAYOUT, "Invalid argc: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobalDisplay]msg: invalid"); + "[window][moveWindowToGlobalDisplay]msg: Invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to x"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to x"); + "[window][moveWindowToGlobalDisplay]msg: Failed to convert parameter to x"); } int32_t y = 0; if (!ConvertFromJsValue(env, argv[INDEX_ONE], y)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to y"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobalDisplay]msg: failed to convert parameter to y"); + "[window][moveWindowToGlobalDisplay]msg: Failed to convert parameter to y"); } napi_value result = nullptr; @@ -2025,7 +2025,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (!window) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][moveWindowToGlobalDisplay]msg: window is nullptr")); + "[window][moveWindowToGlobalDisplay]msg: Window is nullptr")); return; } auto moveResult = window->MoveWindowToGlobalDisplay(x, y); @@ -2035,7 +2035,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf napiAsyncTask->Resolve(env, NapiGetUndefined(env)); } else { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][moveWindowToGlobalDisplay]msg: failed to move window")); + "[window][moveWindowToGlobalDisplay]msg: Failed to move window")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: window: [%{public}u, %{public}s], x: %{public}d, y: %{public}d, ret: %{public}d", @@ -2044,7 +2044,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][moveWindowToGlobalDisplay]msg: failed to send event")); + "[window][moveWindowToGlobalDisplay]msg: Failed to send event")); } return result; } @@ -2066,7 +2066,8 @@ napi_value JsWindow::OnGetGlobalScaledRect(napi_env env, napi_callback_info info napi_value globalScaledRectObj = GetRectAndConvertToJsValue(env, globalScaledRect); if (globalScaledRectObj == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "globalScaledRectObj is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][getGlobalScaledRect]msg: GlobalScaledRectObj is nullptr"); } return globalScaledRectObj; } @@ -2103,7 +2104,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) auto asyncTask = [windowToken = wptr(windowToken_), errCode, width, height, env, task = napiAsyncTask, where = __func__] { if (errCode != WMError::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "[window][resize]msg: failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "[window][resize]msg: Failed")); TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: invalid param", where); return; } @@ -2111,7 +2112,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, - "[window][resize]msg: window is nullptr")); + "[window][resize]msg: Window is nullptr")); return; } WMError ret = window->Resize(static_cast(width), static_cast(height)); @@ -2119,7 +2120,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][resize]msg: failed")); + "[window][resize]msg: Failed")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -2127,7 +2128,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][resize]msg: failed to send event")); + "[window][resize]msg: Failed to send event")); } return result; } @@ -2253,7 +2254,7 @@ napi_value JsWindow::OnResizeWindowAsync(napi_env env, napi_callback_info info) } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][resizeWindowAsync]msg: invalid param"); + "[window][resizeWindowAsync]msg: Invalid param"); } wptr weakToken(windowToken_); @@ -2484,7 +2485,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LAYOUT, "permission denied!"); return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP, - "[window][setwindowMode]msg: permission denied!"); + "[window][setwindowMode]msg: Permission denied!"); } WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; @@ -2513,7 +2514,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) } } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setwindowMode]msg: failed"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, "[window][setwindowMode]msg: Failed"); } napi_value lastParam = (argc == 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); @@ -2525,7 +2526,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setwindowMode]msg: window is nullptr")); + "[window][setwindowMode]msg: Window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMode(winMode)); @@ -2541,7 +2542,7 @@ napi_value JsWindow::OnSetWindowMode(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowMode") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setwindowMode]msg: failed to send event")); + "[window][setwindowMode]msg: Failed to send event")); } return result; } @@ -4894,13 +4895,13 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (argc < 1 || argc > 2) { // 2: maximum params num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setResizeByDragEnabled]msg: argc is invalid"); + "[window][setResizeByDragEnabled]msg: Argc is invalid"); } bool dragEnabled = true; if (!ConvertFromJsValue(env, argv[0], dragEnabled)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to dragEnabled"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setResizeByDragEnabled]msg: failed to convert parameter to dragEnabled"); + "[window][setResizeByDragEnabled]msg: Failed to convert parameter to dragEnabled"); } napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); napi_value result = nullptr; @@ -4911,7 +4912,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setResizeByDragEnabled]msg: window is nullptr")); + "[window][setResizeByDragEnabled]msg: Window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetResizeByDragEnabled(dragEnabled)); @@ -4919,7 +4920,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setResizeByDragEnabled]msg: set dragEnabled failed")); + "[window][setResizeByDragEnabled]msg: Set dragEnabled failed")); } TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Window [%{public}u, %{public}s] set dragEnabled end", where, window->GetWindowId(), window->GetWindowName().c_str()); @@ -4927,7 +4928,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetResizeByDragEnabled") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setResizeByDragEnabled]msg: failed to send event")); + "[window][setResizeByDragEnabled]msg: Failed to send event")); } return result; } @@ -5688,7 +5689,7 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setForbidSplitMove]msg: invalid param"); + "[window][setForbidSplitMove]msg: Invalid param"); } napi_value lastParam = (argc <= 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); @@ -5712,13 +5713,13 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setForbidSplitMove]msg: failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][setForbidSplitMove]msg: Failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetForbidSplitMove") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setForbidSplitMove]msg: failed to send event")); + "[window][setForbidSplitMove]msg: Failed to send event")); } return result; } @@ -6754,13 +6755,13 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setAspectRatio]msg: windowToken is nullptr"); + "[window][setAspectRatio]msg: WindowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "SetAspectRatio is not allowed since window is main window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][setAspectRatio]msg: setAspectRatio is not allowed since window is main window"); + "[window][setAspectRatio]msg: SetAspectRatio is not allowed since window is main window"); } double aspectRatio = 0.0; @@ -6776,7 +6777,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (errCode == WMError::WM_ERROR_INVALID_PARAM || aspectRatio <= 0.0) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setAspectRatio]msg: falied"); + "[window][setAspectRatio]msg: Falied"); } napi_value lastParam = (argc == 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -6787,7 +6788,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setAspectRatio]msg: falied")); + "[window][setAspectRatio]msg: Falied")); return; } WMError ret = window->SetAspectRatio(aspectRatio); @@ -6795,7 +6796,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) task->Resolve(env, NapiGetUndefined(env)); } else { task->Reject(env, JsErrUtils::CreateJsError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret), - "[window][setAspectRatio]msg: falied")); + "[window][setAspectRatio]msg: Falied")); } TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -6803,7 +6804,7 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setAspectRatio]msg: falied")); + "[window][setAspectRatio]msg: Falied")); } return result; } @@ -6816,13 +6817,13 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][resetAspectRatio]msg: argc is invalid"); + "[window][resetAspectRatio]msg: Argc is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][resetAspectRatio]msg: windowToken is nullptr"); + "[window][resetAspectRatio]msg: WindowToken is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { @@ -6839,14 +6840,14 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, - WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resetAspectRatio]msg: failed.")); + WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resetAspectRatio]msg: Failed.")); return; } WMError ret = window->ResetAspectRatio(); if (ret == WMError::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][resetAspectRatio]msg: failed.")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret, "[window][resetAspectRatio]msg: Failed.")); } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s end, window [%{public}u, %{public}s] ret=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), ret); @@ -6854,7 +6855,7 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) if (napi_send_event(env, asyncTask, napi_eprio_high, "OnResetAspectRatio") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][resetAspectRatio]msg: failed to send event")); + "[window][resetAspectRatio]msg: Failed to send event")); } return result; } @@ -6913,13 +6914,13 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][maximize]msg: windowToken is nullptr"); + "[window][maximize]msg: WindowToken is nullptr"); } if (!(WindowHelper::IsMainWindow(windowToken_->GetType()) || windowToken_->IsSubWindowMaximizeSupported())) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "only support main or sub Window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][maximize]msg: only support main or sub Window"); + "[window][maximize]msg: Only support main or sub Window"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -6932,7 +6933,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) presentationValue > static_cast(MaximizePresentation::ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER)) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Failed to convert parameter to presentationValue"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][maximize]msg: failed to convert parameter to presentationValue"); + "[window][maximize]msg: Failed to convert parameter to presentationValue"); } } MaximizePresentation presentation = static_cast(presentationValue); @@ -6946,7 +6947,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][maximize]msg: window is nullptr")); + "[window][maximize]msg: Window is nullptr")); return; } WMError ret = window->Maximize(presentation); @@ -6955,13 +6956,13 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, - "[window][maximize]msg: failed")); + "[window][maximize]msg: Failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_immediate, "OnMaximize") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][maximize]msg: send event failed")); + "[window][maximize]msg: Send event failed")); } return result; } @@ -7107,14 +7108,14 @@ napi_value JsWindow::OnEnableDrag(napi_env env, napi_callback_info info) if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][enableDrag]msg: argc is invalid"); + "[window][enableDrag]msg: Argc is invalid"); } bool enableDrag = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enableDrag)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter from jsValue"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][enableDrag]msg: failed to convert parameter from jsValue"); + "[window][enableDrag]msg: Failed to convert parameter from jsValue"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); NapiAsyncTask::ExecuteCallback execute = @@ -7136,7 +7137,7 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) if (argc < 1 || argv[INDEX_ZERO] == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setWindowLimits]msg: argc is invalid"); + "[window][setWindowLimits]msg: Argc is invalid"); } WindowLimits windowLimits; if (!ParseWindowLimits(env, argv[INDEX_ZERO], windowLimits)) { @@ -7157,12 +7158,12 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowLimits]msg: window is nullptr"); + "[window][setWindowLimits]msg: Window is nullptr"); } if (!windowToken_->IsPcOrFreeMultiWindowCapabilityEnabled()) { TLOGE(WmsLogTag::WMS_LAYOUT, "device not support"); return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, - "[window][setWindowLimits]msg: device not support"); + "[window][setWindowLimits]msg: Device not support"); } if (!ConvertFromJsValue(env, argv[INDEX_ONE], isForcible)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isForcible"); @@ -7180,7 +7181,7 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: window is nullptr", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowLimits]msg: window is nullptr")); + "[window][setWindowLimits]msg: Window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowLimits(windowLimits, isForcible)); @@ -7188,19 +7189,19 @@ napi_value JsWindow::OnSetWindowLimits(napi_env env, napi_callback_info info) auto objValue = GetWindowLimitsAndConvertToJsValue(env, windowLimits); if (objValue == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowLimits]msg: set window limits failed")); + "[window][setWindowLimits]msg: Set window limits failed")); } else { task->Resolve(env, objValue); } } else { task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setWindowLimits]msg: set window limits failed")); + "[window][setWindowLimits]msg: Set window limits failed")); } }; if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWindowLimits") != napi_status::napi_ok) { napiAsyncTask->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWindowLimits]msg: failed to send event")); + "[window][setWindowLimits]msg: Failed to send event")); } return result; } @@ -7214,18 +7215,18 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][getWindowLimits]msg: argc is invalid"); + "[window][getWindowLimits]msg: Argc is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowLimits]msg: window is nullptr"); + "[window][getWindowLimits]msg: Window is nullptr"); } WindowLimits windowLimits; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetWindowLimits(windowLimits)); if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret, "[window][getWindowLimits]msg: falied"); + return NapiThrowError(env, ret, "[window][getWindowLimits]msg: Falied"); } auto objValue = GetWindowLimitsAndConvertToJsValue(env, windowLimits); TLOGI(WmsLogTag::WMS_LAYOUT, "Window [%{public}u, %{public}s] get window limits end", @@ -7233,7 +7234,7 @@ napi_value JsWindow::OnGetWindowLimits(napi_env env, napi_callback_info info) if (objValue != nullptr) { return objValue; } else { - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][getWindowLimits]msg: nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][getWindowLimits]msg: Nullptr"); } } @@ -8240,7 +8241,7 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "windowToken is nullptr."); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][startMoving]msg: windowToken is nullptr"); + "[window][startMoving]msg: WindowToken is nullptr"); } size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = { nullptr }; @@ -8251,7 +8252,7 @@ napi_value JsWindow::OnStartMoving(napi_env env, napi_callback_info info) if (WindowHelper::IsInputWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_LAYOUT, "is not allowed since input window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][startMoving]msg: not allowed since input window"); + "[window][startMoving]msg: Not allowed since input window"); } std::shared_ptr err = std::make_shared(WmErrorCode::WM_OK); const char* const funcName = __func__; @@ -8339,7 +8340,7 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "windowToken is nullptr."); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][stopMoving]msg: windowToken is nullptr"); + "[window][stopMoving]msg: WindowToken is nullptr"); } napi_value result = nullptr; std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); @@ -8349,7 +8350,7 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGNE(WmsLogTag::WMS_LAYOUT_PC, "%{public}s window is nullptr.", where); task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][stopMoving]msg: window is nullptr")); + "[window][stopMoving]msg: Window is nullptr")); return; } WmErrorCode ret = window->StopMoveWindow(); @@ -8363,7 +8364,7 @@ napi_value JsWindow::OnStopMoving(napi_env env, napi_callback_info info) if (napi_send_event(env, std::move(asyncTask), napi_eprio_high, "OnStopMoving") != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][stopMoving]msg: send event failed")); + "[window][stopMoving]msg: Send event failed")); } return result; } @@ -8963,13 +8964,13 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal if (argc != INDEX_ONE) { TLOGE(WmsLogTag::WMS_SUB, "argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setFollowParentWindowLayoutEnabled]msg: argc is invalid"); + "[window][setFollowParentWindowLayoutEnabled]msg: Argc is invalid"); } bool isFollow = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], isFollow)) { TLOGE(WmsLogTag::WMS_SUB, "Failed to convert parameter to enable"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setFollowParentWindowLayoutEnabled]msg: falied to convert parameter to enable"); + "[window][setFollowParentWindowLayoutEnabled]msg: Falied to convert parameter to enable"); } std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); const char* const where = __func__; @@ -8980,13 +8981,13 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][setFollowParentWindowLayoutEnabled]msg: window is nullptr")); + "[window][setFollowParentWindowLayoutEnabled]msg: Window is nullptr")); return; } if (!WindowHelper::IsSubWindow(window->GetType()) && !WindowHelper::IsDialogWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s only sub window and dialog is valid", where); task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING), - "[window][setFollowParentWindowLayoutEnabled]msg: only sub window and dialog is valid")); + "[window][setFollowParentWindowLayoutEnabled]msg: Only sub window and dialog is valid")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetFollowParentWindowLayoutEnabled(isFollow)); @@ -8995,14 +8996,14 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal } else { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s failed, ret %{public}d", where, ret); task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setFollowParentWindowLayoutEnabled]msg: set follow parent layout failed.")); + "[window][setFollowParentWindowLayoutEnabled]msg: Set follow parent layout failed.")); } }; napi_status status = napi_send_event(env, asyncTask, napi_eprio_high, "SetFollowParentWindowLayoutEnabled"); if (status != napi_status::napi_ok) { napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][setFollowParentWindowLayoutEnabled]msg: send event failed")); + "[window][setFollowParentWindowLayoutEnabled]msg: Send event failed")); } return result; } -- Gitee From cf7f1df375df3bd66066942bffbb22e24d995f03 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Tue, 19 Aug 2025 21:42:39 +0800 Subject: [PATCH 077/241] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=86=85=E5=AE=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 6420169c1c..aad9c41c56 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1795,7 +1795,7 @@ napi_value JsWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowTo]msg: failed"); + "[window][moveWindowTo]msg: Failed"); } // 2: params num; 2: index of callback napi_value lastParam = (argc <= 2) ? nullptr : @@ -7423,7 +7423,7 @@ napi_value JsWindow::OnSetFollowParentMultiScreenPolicy(napi_env env, napi_callb if (argc != ARG_COUNT_ONE) { TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setFollowParentMultiScreenPolicy]msg: argc is invalid"); + "[window][setFollowParentMultiScreenPolicy]msg: Argc is invalid"); } bool enabled = false; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enabled)) { @@ -8131,14 +8131,14 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) if (window == nullptr) { TLOGE(WmsLogTag::WMS_PC, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowStatus]msg: window is nullptr"); + "[window][getWindowStatus]msg: Window is nullptr"); } WindowStatus windowStatus; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->GetWindowStatus(windowStatus)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_PC, "failed, ret=%{public}d", ret); return NapiThrowError(env, ret, - "[window][getWindowStatus]msg: falied"); + "[window][getWindowStatus]msg: Falied"); } auto objValue = CreateJsValue(env, windowStatus); if (objValue != nullptr) { @@ -8147,7 +8147,7 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) } else { TLOGE(WmsLogTag::WMS_PC, "create js value windowStatus failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][getWindowStatus]msg: create js value windowStatus failed"); + "[window][getWindowStatus]msg: Create js value windowStatus failed"); } } -- Gitee From 5da636dc06c683795997197b29d7ae3a9cce956d Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Tue, 19 Aug 2025 22:07:48 +0800 Subject: [PATCH 078/241] add set fold displayMode error message Signed-off-by: ZhaoLiang --- interfaces/innerkits/dm/dm_common.h | 59 +++++++++---- .../display_runtime/js_display_manager.cpp | 12 ++- .../include/screen_session_manager.h | 2 +- .../src/screen_session_manager.cpp | 45 +++++++--- .../session/screen/include/screen_session.h | 4 + .../session/screen/src/screen_session.cpp | 10 +++ .../screen_session_manager_test.cpp | 86 +++++++++++++++++++ 7 files changed, 184 insertions(+), 34 deletions(-) diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 806b70038a..a8d431c7de 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -43,6 +43,14 @@ constexpr int DOT_PER_INCH_MAXIMUM_VALUE = 1000; constexpr int DOT_PER_INCH_MINIMUM_VALUE = 80; constexpr uint32_t BASELINE_DENSITY = 160; constexpr uint32_t HALF_SCREEN_PARAM = 2; +const std::string DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING = + "[wired casting]not support coordination when wired casting."; +const std::string DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING = + "[wireless casting]not support coordination when wireless casting."; +const std::string DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_RECORDING = + "[recording]not support coordination when wired recording."; +const std::string DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_TENTMODE = + "[tentmode]not support coordination when tentmode."; } /** @@ -207,6 +215,10 @@ enum class DMError : int32_t { DM_ERROR_DEVICE_NOT_SUPPORT = 801, DM_ERROR_UNKNOWN = -1, DM_ERROR_ILLEGAL_PARAM = 1400004, + DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING = 100001, + DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING = 100002, + DM_ERROR_NOT_SUPPORT_COOR_WHEN_RECORDING = 100003, + DM_ERROR_NOT_SUPPORT_COOR_WHEN_TENTMODE = 100004, }; /** @@ -228,24 +240,35 @@ enum class DmErrorCode : int32_t { * @brief Constructs the mapping of the DM errors to the DM error codes. */ const std::map DM_JS_TO_ERROR_CODE_MAP { - {DMError::DM_OK, DmErrorCode::DM_OK }, - {DMError::DM_ERROR_INVALID_PERMISSION, DmErrorCode::DM_ERROR_NO_PERMISSION }, - {DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_IPC_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_REMOTE_CREATE_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_NULLPTR, DmErrorCode::DM_ERROR_INVALID_SCREEN }, - {DMError::DM_ERROR_INVALID_PARAM, DmErrorCode::DM_ERROR_INVALID_PARAM }, - {DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_DEATH_RECIPIENT, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_INVALID_MODE_ID, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_WRITE_DATA_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_RENDER_SERVICE_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_UNREGISTER_AGENT_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_INVALID_CALLING, DmErrorCode::DM_ERROR_INVALID_CALLING }, - {DMError::DM_ERROR_NOT_SYSTEM_APP, DmErrorCode::DM_ERROR_NOT_SYSTEM_APP }, - {DMError::DM_ERROR_UNKNOWN, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_DEVICE_NOT_SUPPORT, DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT }, - {DMError::DM_ERROR_ILLEGAL_PARAM, DmErrorCode::DM_ERROR_ILLEGAL_PARAM }, + {DMError::DM_OK, DmErrorCode::DM_OK }, + {DMError::DM_ERROR_INVALID_PERMISSION, DmErrorCode::DM_ERROR_NO_PERMISSION }, + {DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_IPC_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_REMOTE_CREATE_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_NULLPTR, DmErrorCode::DM_ERROR_INVALID_SCREEN }, + {DMError::DM_ERROR_INVALID_PARAM, DmErrorCode::DM_ERROR_INVALID_PARAM }, + {DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_DEATH_RECIPIENT, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_INVALID_MODE_ID, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_WRITE_DATA_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_RENDER_SERVICE_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_UNREGISTER_AGENT_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_INVALID_CALLING, DmErrorCode::DM_ERROR_INVALID_CALLING }, + {DMError::DM_ERROR_NOT_SYSTEM_APP, DmErrorCode::DM_ERROR_NOT_SYSTEM_APP }, + {DMError::DM_ERROR_UNKNOWN, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_DEVICE_NOT_SUPPORT, DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT }, + {DMError::DM_ERROR_ILLEGAL_PARAM, DmErrorCode::DM_ERROR_ILLEGAL_PARAM }, + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_RECORDING, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_TENTMODE, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, +}; + +const std::map DM_ERROR_JS_TO_ERROR_MESSAGE_MAP { + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING, DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING }, + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING, DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING }, + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_RECORDING, DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_RECORDING }, + {DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_TENTMODE, DM_ERROR_MSG_NOT_SUPPORT_COOR_WHEN_TENTMODE }, }; using DisplayStateCallback = std::function; diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index 489cbd54dd..f348410958 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -867,11 +867,15 @@ napi_value OnSetFoldDisplayMode(napi_env env, napi_callback_info info) return NapiGetUndefined(env); } } - DmErrorCode errCode = DM_JS_TO_ERROR_CODE_MAP.at( - SingletonContainer::Get().SetFoldDisplayModeFromJs(mode, reason)); - TLOGI(WmsLogTag::DMS, "[NAPI]%{public}d", static_cast(errCode)); + DMError dmError = SingletonContainer::Get().SetFoldDisplayModeFromJs(mode, reason)); + std::string errMsg = ""; + if (DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.find(dmError) != DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.end()) { + errMsg = DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.at(dmError); + } + DmErrorCode errCode = DM_JS_TO_ERROR_CODE_MAP.at(dmError); + TLOGI(WmsLogTag::DMS, "[NAPI]%{public}d, error message: %{public}s", static_cast(errCode), errMsg.c_str()); if (errCode != DmErrorCode::DM_OK) { - napi_throw(env, JsErrUtils::CreateJsError(env, errCode)); + napi_throw(env, JsErrUtils::CreateJsError(env, errCode, errMsg)); return NapiGetUndefined(env); } return NapiGetUndefined(env); 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 5389d366a5..7db3e3d97a 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -621,7 +621,7 @@ private: int NotifyPowerEventForDualDisplay(DisplayPowerEvent event, EventStatus status, PowerStateChangeReason reason); bool IsExtendMode(); - bool IsScreenCasting(); + DMError CanEnterCoordination(); bool GetPcStatus() const; void SetPcStatus(bool isPc); const std::set g_packageNames_ {}; 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 2ec24cfb0a..65b267ed2c 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -4833,6 +4833,7 @@ ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option, return SCREEN_ID_INVALID; } screenSession->SetName(option.name_); + screenSession->SetVirtualScreenType(option.virtualScreenType_); screenSession->SetMirrorScreenType(MirrorScreenType::VIRTUAL_MIRROR); screenSession->SetSecurity(option.isSecurity_); { @@ -7185,12 +7186,14 @@ DMError ScreenSessionManager::SetFoldDisplayModeInner(const FoldDisplayMode disp if (foldScreenController_->GetTentMode() && (displayMode == FoldDisplayMode::FULL || displayMode == FoldDisplayMode::COORDINATION)) { TLOGW(WmsLogTag::DMS, "in TentMode, SetFoldDisplayMode to %{public}d failed", displayMode); - return DMError::DM_ERROR_INVALID_MODE_ID; + return DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_TENTMODE; } else if ((FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() || - FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) && IsScreenCasting() && + FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) && displayMode == FoldDisplayMode::COORDINATION) { - TLOGW(WmsLogTag::DMS, "is phone casting, SetFoldDisplayMode to %{public}d is not allowed", displayMode); - return DMError::DM_ERROR_INVALID_MODE_ID; + DMError err = CanEnterCoordination(); + if (err != DMError::DM_OK) { + return err; + } } if (reason.compare("backSelfie") == 0) { UpdateCameraBackSelfie(true); @@ -10233,15 +10236,35 @@ int32_t ScreenSessionManager::GetCameraPosition() return cameraPosition_; } -bool ScreenSessionManager::IsScreenCasting() +DMError ScreenSessionManager::CanEnterCoordination() { - if (virtualScreenCount_ > 0 || hdmiScreenCount_ > 0) { - TLOGI(WmsLogTag::DMS, "virtualScreenCount_: %{public}" PRIu32 ", hdmiScreenCount_: %{public}d", - virtualScreenCount_, hdmiScreenCount_); - return true; + if (hdmiScreenCount_ > 0) { + TLOGW(WmsLogTag::DMS, "hdmiScreenCount_: %{public}d cannot enter coordination", hdmiScreenCount_); + return DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING; } - TLOGI(WmsLogTag::DMS, "not casting"); - return false; + + if (virtualScreenCount_ == 0) { + return DMError::DM_OK; + } + std::lock_guard lock(screenSessionMapMutex_); + for (const auto& pair : screenSessionMap_) { + sptr session = pair.second; + if (!session) { + TLOGW(WmsLogTag::DMS, "screenId=%{public}" PRIu64", session is null", pair.first); + continue; + } + if (session->GetIsRealScreen()) { + continue; + } + if (session->GetVirtualScreenType() != VirtualScreenType::SCREEN_RECORDING) { + TLOGW(WmsLogTag::DMS, "wireless casting: %{public}u cannot enter coordination", session->GetVirtualScreenType()); + return DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING; + } else { + TLOGW(WmsLogTag::DMS, "screen recording cannot enter coordination"); + return DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_RECORDING; + } + } + return DMError::DM_OK; } SessionOption ScreenSessionManager::GetSessionOption(sptr screenSession) diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 2fb591baab..bb6e243c21 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -226,6 +226,9 @@ public: void SetVirtualScreenFlag(VirtualScreenFlag screenFlag); void SetSecurity(bool isSecurity); + VirtualScreenType GetVirtualScreenType(); + void SetVirtualScreenType(VirtualScreenType screenType); + std::string name_ { "UNKNOWN" }; ScreenId screenId_ {}; ScreenId rsId_ {}; @@ -388,6 +391,7 @@ private: ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; mutable std::mutex combinationMutex_; // above guarded by clientProxyMutex_ VirtualScreenFlag screenFlag_ { VirtualScreenFlag::DEFAULT }; + VirtualScreenType screenType_ { VirtualScreenType::UNKNOWN }; bool hasPrivateWindowForeground_ = false; bool isFakeInUse_ = false; // is fakeScreenSession can be used bool isBScreenHalf_ = false; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 43d4d9e89c..9e7db645e7 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -972,6 +972,16 @@ void ScreenSession::SetVirtualScreenFlag(VirtualScreenFlag screenFlag) screenFlag_ = screenFlag; } +VirtualScreenType ScreenSession::GetVirtualScreenType() +{ + return screenType_; +} + +void ScreenSession::SetVirtualScreenType(VirtualScreenType screenType) +{ + screenType_ = screenType; +} + void ScreenSession::SetSecurity(bool isSecurity) { isSecurity_ = isSecurity; diff --git a/window_scene/test/dms_unittest/screen_session_manager_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_test.cpp index 202c0cd118..9327f27c20 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -134,6 +134,30 @@ HWTEST_F(ScreenSessionManagerTest, RegisterDisplayManagerAgent, TestSize.Level1) EXPECT_EQ(DMError::DM_OK, ssm_->UnregisterDisplayManagerAgent(displayManagerAgent, type)); } +/** + * @tc.name: CanEnterCoordinationRecording + * @tc.desc: CanEnterCoordinationRecording test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, CanEnterCoordinationRecording, TestSize.Level3) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->virtualScreenCount_ = 1; + ssm_->hdmiScreenCount_ = 0; + + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOptionRecord"; + auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject()); + if (screenId != VIRTUAL_SCREEN_ID) { + ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID); + } + auto ret = ssm_->CanEnterCoordination(); + EXPECT_EQ(ret, DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_RECORDING); + ssm_->DestroyVirtualScreen(screenId) +} + + /** * @tc.name: WakeupBegin * @tc.desc: WakeupBegin test @@ -6005,6 +6029,68 @@ HWTEST_F(ScreenSessionManagerTest, IsScreenCasting, Function | SmallTest | Level ASSERT_EQ(ret, false); } +/** + * @tc.name: CanEnterCoordination01 + * @tc.desc: CanEnterCoordination01 test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, CanEnterCoordination01, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->virtualScreenCount_ = 0; + ssm_->hdmiScreenCount_ = 1; + auto ret = ssm_->CanEnterCoordination(); + EXPECT_EQ(ret, DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING); + + ssm_->virtualScreenCount_ = 0; + ssm_->hdmiScreenCount_ = 0; + auto ret = ssm_->CanEnterCoordination(); + EXPECT_EQ(ret, DMError::DM_OK); +} + +/** + * @tc.name: CanEnterCoordination02 + * @tc.desc: CanEnterCoordination02 test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, CanEnterCoordination02, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->screenSessionMap_[50] = nullptr; + ssm_->virtualScreenCount_ = 1; + ssm_->hdmiScreenCount_ = 0; + + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + virtualOption.virtualScreenType_ = VirtualScreenType::SCREEN_CASTING; + auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject()); + if (screenId != VIRTUAL_SCREEN_ID) { + ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID); + } + auto ret = ssm_->CanEnterCoordination(); + EXPECT_EQ(ret, DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING); + ssm_->DestroyVirtualScreen(screenId) +} + +/** + * @tc.name: CanEnterCoordination03 + * @tc.desc: CanEnterCoordination03 test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, CanEnterCoordination03, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + auto oldMap = ssm_->screenSessionMap_; + std::map> newScreenSessionMap_{}; + ssm_->screenSessionMap_ = newScreenSessionMap_; + ssm_->virtualScreenCount_ = 1; + ssm_->hdmiScreenCount_ = 0; + auto ret = ssm_->CanEnterCoordination(); + EXPECT_EQ(ret, DMError::DM_OK); + ssm_->screenSessionMap_ = oldMap; +} + /** * @tc.name: GetCameraPosition * @tc.desc: GetCameraPosition -- Gitee From bb3bd986cd1ae02b529716db731b241b278522bb Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Tue, 19 Aug 2025 22:20:17 +0800 Subject: [PATCH 079/241] edit error Signed-off-by: ZhaoLiang --- .../kits/napi/display_runtime/js_display_manager.cpp | 2 +- .../test/dms_unittest/screen_session_manager_test.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index f348410958..0598cc3061 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -867,7 +867,7 @@ napi_value OnSetFoldDisplayMode(napi_env env, napi_callback_info info) return NapiGetUndefined(env); } } - DMError dmError = SingletonContainer::Get().SetFoldDisplayModeFromJs(mode, reason)); + DMError dmError = SingletonContainer::Get().SetFoldDisplayModeFromJs(mode, reason); std::string errMsg = ""; if (DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.find(dmError) != DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.end()) { errMsg = DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.at(dmError); diff --git a/window_scene/test/dms_unittest/screen_session_manager_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_test.cpp index 9327f27c20..080f4d03ae 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -148,10 +148,8 @@ HWTEST_F(ScreenSessionManagerTest, CanEnterCoordinationRecording, TestSize.Level sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); VirtualScreenOption virtualOption; virtualOption.name_ = "createVirtualOptionRecord"; + virtualOption.virtualScreenType_ = VirtualScreenType::SCREEN_RECORDING; auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject()); - if (screenId != VIRTUAL_SCREEN_ID) { - ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID); - } auto ret = ssm_->CanEnterCoordination(); EXPECT_EQ(ret, DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_RECORDING); ssm_->DestroyVirtualScreen(screenId) @@ -6065,9 +6063,6 @@ HWTEST_F(ScreenSessionManagerTest, CanEnterCoordination02, Function | SmallTest virtualOption.name_ = "createVirtualOption"; virtualOption.virtualScreenType_ = VirtualScreenType::SCREEN_CASTING; auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject()); - if (screenId != VIRTUAL_SCREEN_ID) { - ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID); - } auto ret = ssm_->CanEnterCoordination(); EXPECT_EQ(ret, DMError::DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING); ssm_->DestroyVirtualScreen(screenId) -- Gitee From e8b6a0f7bc591663a4ff5ba312c34b582f7594d4 Mon Sep 17 00:00:00 2001 From: shuangshuangliu Date: Tue, 19 Aug 2025 10:13:14 +0800 Subject: [PATCH 080/241] =?UTF-8?q?TDD=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shuangshuangliu Change-Id: I0e8726b6e6d4043db8d6689fe2f3a8c8f39619e0 --- test/systemtest/wms/BUILD.gn | 26 ++++----- test/systemtest/wms/window_immersive_test.cpp | 8 +-- .../wms/window_input_method_test.cpp | 4 +- test/systemtest/wms/window_input_test.cpp | 8 +-- .../wms/window_mode_support_info_test.cpp | 24 ++------ .../wms/window_occupied_area_change_test.cpp | 9 --- .../wms/window_raisetoapptop_test.cpp | 18 ------ test/systemtest/wms/window_rotation_test.cpp | 20 ++----- .../wms/window_split_immersive_test.cpp | 4 +- test/systemtest/wms/window_split_test.cpp | 20 ++----- test/systemtest/wms/window_subwindow_test.cpp | 57 ------------------- .../wms/window_system_toast_test.cpp | 9 --- .../wms/window_touch_outside_test.cpp | 16 ++---- .../wms/window_visibility_info_test.cpp | 5 +- .../systemtest/wms/window_water_mark_test.cpp | 3 - utils/test/unittest/BUILD.gn | 6 +- utils/test/unittest/surface_draw_test.cpp | 39 +------------ 17 files changed, 48 insertions(+), 228 deletions(-) diff --git a/test/systemtest/wms/BUILD.gn b/test/systemtest/wms/BUILD.gn index 275cb1d37d..e23e314f4d 100644 --- a/test/systemtest/wms/BUILD.gn +++ b/test/systemtest/wms/BUILD.gn @@ -22,24 +22,11 @@ group("systemtest") { deps = [ ":wms_window_animate_to_test", ":wms_window_gesture_navigation_enabled_test", - ":wms_window_input_method_test", - ":wms_window_input_test", - ":wms_window_mode_support_info_test", ":wms_window_multi_ability_test", ":wms_window_nointeraction_listener_test", - ":wms_window_occupied_area_change_test", - ":wms_window_raisetoapptop_test", ":wms_window_recover_test", - ":wms_window_rotation_test", - ":wms_window_split_immersive_test", - ":wms_window_split_test", ":wms_window_status_change_test", - ":wms_window_subwindow_test", - ":wms_window_system_toast_window_test", ":wms_window_systemsubwindow_test", - ":wms_window_touch_outside_test", - ":wms_window_visibility_info_test", - ":wms_window_water_mark_test", ] if (!window_manager_use_sceneboard) { deps += [ @@ -51,8 +38,21 @@ group("systemtest") { ":wms_window_focus_test", ":wms_window_gamut_test", ":wms_window_immersive_test", + ":wms_window_input_method_test", + ":wms_window_input_test", ":wms_window_layout_test", + ":wms_window_mode_support_info_test", ":wms_window_move_drag_test", + ":wms_window_occupied_area_change_test", + ":wms_window_raisetoapptop_test", + ":wms_window_rotation_test", + ":wms_window_split_immersive_test", + ":wms_window_split_test", + ":wms_window_subwindow_test", + ":wms_window_system_toast_window_test", + ":wms_window_touch_outside_test", + ":wms_window_visibility_info_test", + ":wms_window_water_mark_test", ] } else { deps += [ diff --git a/test/systemtest/wms/window_immersive_test.cpp b/test/systemtest/wms/window_immersive_test.cpp index 265e9d4479..151384231c 100644 --- a/test/systemtest/wms/window_immersive_test.cpp +++ b/test/systemtest/wms/window_immersive_test.cpp @@ -434,9 +434,7 @@ HWTEST_F(WindowImmersiveTest, GetAvoidAreaByTypeTest01, TestSize.Level1) HWTEST_F(WindowImmersiveTest, DockWindowTest01, TestSize.Level1) { const sptr& dockWindow = Utils::CreateDockWindow(); - if (dockWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, dockWindow); if (WMError::WM_ERROR_INVALID_WINDOW == dockWindow->Show()) { ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, dockWindow->Show()); @@ -445,9 +443,7 @@ HWTEST_F(WindowImmersiveTest, DockWindowTest01, TestSize.Level1) } const sptr& window = Utils::CreateTestWindow(fullScreenAppinfo_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); usleep(WAIT_ASYNC_US); auto act = testSystemBarChangedListener_->tints_; for (SystemBarRegionTint tint : act) { diff --git a/test/systemtest/wms/window_input_method_test.cpp b/test/systemtest/wms/window_input_method_test.cpp index ff1a486938..80cbfb76b1 100644 --- a/test/systemtest/wms/window_input_method_test.cpp +++ b/test/systemtest/wms/window_input_method_test.cpp @@ -77,9 +77,7 @@ HWTEST_F(WindowInputMethodTest, ShowKeyboard01, TestSize.Level1) .parentId = INVALID_WINDOW_ID, }; const sptr& fullWindow = Utils::CreateTestWindow(windowInfo); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); KeyboardEffectOption effectOption; if (!SceneBoardJudgement::IsSceneBoardEnabled()) { sleep(TEST_SLEEP_SECOND); diff --git a/test/systemtest/wms/window_input_test.cpp b/test/systemtest/wms/window_input_test.cpp index 12ee48e0d9..b8f086ecd5 100644 --- a/test/systemtest/wms/window_input_test.cpp +++ b/test/systemtest/wms/window_input_test.cpp @@ -71,9 +71,7 @@ HWTEST_F(WindowInputTest, SetTouchHotAreas01, TestSize.Level1) { fullScreenWindow_.name = "window_hot_areas.1"; const sptr& window = Utils::CreateTestWindow(fullScreenWindow_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); ASSERT_EQ(WMError::WM_OK, window->Show()); std::vector requestedTouchHotAreas; @@ -123,9 +121,7 @@ HWTEST_F(WindowInputTest, SetTouchHotAreas02, TestSize.Level1) { fullScreenWindow_.name = "window_hot_areas.2"; const sptr& window = Utils::CreateTestWindow(fullScreenWindow_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_ASYNC_US); diff --git a/test/systemtest/wms/window_mode_support_info_test.cpp b/test/systemtest/wms/window_mode_support_info_test.cpp index d95ff6f25e..cba12d1b45 100644 --- a/test/systemtest/wms/window_mode_support_info_test.cpp +++ b/test/systemtest/wms/window_mode_support_info_test.cpp @@ -87,9 +87,7 @@ namespace { HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType01, TestSize.Level1) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestWindowModeSupportType()); window->Destroy(); @@ -103,9 +101,7 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType01, TestSize.Level1) HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType02, TestSize.Level1) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); EXPECT_NE(WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, window->Show()); EXPECT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetWindowMode()); @@ -131,9 +127,7 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType02, TestSize.Level1) HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType03, TestSize.Level1) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -163,9 +157,7 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType03, TestSize.Level1) HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType04, TestSize.Level1) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); @@ -182,9 +174,7 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType04, TestSize.Level1) HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType05, TestSize.Level1) { const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); - if (window1 == nullptr) { - return; - } + ASSERT_NE(nullptr, window1); window1->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); ASSERT_NE(nullptr, window2); @@ -212,9 +202,7 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType05, TestSize.Level1) HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType06, TestSize.Level1) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - if (window == nullptr) { - return; - } + ASSERT_NE(nullptr, window); window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); diff --git a/test/systemtest/wms/window_occupied_area_change_test.cpp b/test/systemtest/wms/window_occupied_area_change_test.cpp index 0771a8138a..18d3eb5bb2 100644 --- a/test/systemtest/wms/window_occupied_area_change_test.cpp +++ b/test/systemtest/wms/window_occupied_area_change_test.cpp @@ -115,9 +115,6 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, TestSize.Leve { fullScreenAppInfo_.name = "KeyboardHeightChangeTest01"; const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); - if (window1 == nullptr) { - return; - } ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); @@ -147,9 +144,6 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, TestSize.Leve { fullScreenAppInfo_.name = "KeyboardHeightChangeTest02"; const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); - if (window1 == nullptr) { - return; - } ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); @@ -179,9 +173,6 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest03, TestSize.Leve { fullScreenAppInfo_.name = "KeyboardHeightChangeTest03"; const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); - if (window1 == nullptr) { - return; - } ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); diff --git a/test/systemtest/wms/window_raisetoapptop_test.cpp b/test/systemtest/wms/window_raisetoapptop_test.cpp index d0dc266413..aa2c797cb7 100644 --- a/test/systemtest/wms/window_raisetoapptop_test.cpp +++ b/test/systemtest/wms/window_raisetoapptop_test.cpp @@ -73,9 +73,6 @@ HWTEST_F(WindowRaiseToAppTopTest, NormalRaise1, TestSize.Level1) { fullInfo_.name = "mainWindow.1"; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); - if (mainWindow == nullptr) { - return; - } ASSERT_NE(nullptr, mainWindow); activeWindows_.push_back(mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); @@ -114,9 +111,6 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWithDialog1, TestSize.Level1) { fullInfo_.name = "mainWindow.1"; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); - if (mainWindow == nullptr) { - return; - } ASSERT_NE(nullptr, mainWindow); activeWindows_.push_back(mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); @@ -162,9 +156,6 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, TestSize.Level1) { fullInfo_.name = "mainWindow.1"; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); - if (mainWindow == nullptr) { - return; - } ASSERT_NE(nullptr, mainWindow); activeWindows_.push_back(mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); @@ -174,9 +165,6 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, TestSize.Level1) fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow1 = Utils::CreateTestWindow(fullInfo_); - if (subWindow1 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow1); activeWindows_.push_back(subWindow1); ASSERT_EQ(WMError::WM_OK, subWindow1->Show()); @@ -215,9 +203,6 @@ HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, TestSize.Level1) fullInfo_.name = "mainWindow.1"; fullInfo_.type = WindowType::WINDOW_TYPE_FLOAT; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); - if (mainWindow == nullptr) { - return; - } ASSERT_NE(nullptr, mainWindow); activeWindows_.push_back(mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); @@ -227,9 +212,6 @@ HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, TestSize.Level1) fullInfo_.type = WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW; fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow1 = Utils::CreateTestWindow(fullInfo_); - if (subWindow1 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow1); activeWindows_.push_back(subWindow1); ASSERT_EQ(WMError::WM_OK, subWindow1->Show(0, true)); diff --git a/test/systemtest/wms/window_rotation_test.cpp b/test/systemtest/wms/window_rotation_test.cpp index 9f784f097f..1255bce916 100644 --- a/test/systemtest/wms/window_rotation_test.cpp +++ b/test/systemtest/wms/window_rotation_test.cpp @@ -129,9 +129,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, TestSize.Level1) fullInfo_.name = "fullscreen.1"; fullInfo_.orientation_ = Orientation::UNSPECIFIED; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); EXPECT_EQ(WMError::WM_OK, fullWindow->Show()); EXPECT_NE(WindowMode::WINDOW_MODE_FLOATING, fullWindow->GetWindowMode()); @@ -165,9 +163,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest2, TestSize.Level1) fullInfo_.name = "fullscreen.2"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); EXPECT_EQ(WMError::WM_OK, fullWindow->Show()); @@ -207,9 +203,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, TestSize.Level1) fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; fullInfo_.mode = WindowMode::WINDOW_MODE_FLOATING; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, fullWindow->GetWindowMode()); @@ -244,9 +238,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest4, TestSize.Level1) fullInfo_.name = "fullscreen.4"; fullInfo_.orientation_ = Orientation::HORIZONTAL; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetWindowMode()); @@ -287,9 +279,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, TestSize.Level1) fullInfo_.name = "fullscreen.5"; fullInfo_.orientation_ = Orientation::HORIZONTAL; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetWindowMode()); diff --git a/test/systemtest/wms/window_split_immersive_test.cpp b/test/systemtest/wms/window_split_immersive_test.cpp index 64b199bf07..0f14a81e57 100644 --- a/test/systemtest/wms/window_split_immersive_test.cpp +++ b/test/systemtest/wms/window_split_immersive_test.cpp @@ -97,9 +97,7 @@ HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, TestSize.Level1) // create fullscreen win and show fullInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); diff --git a/test/systemtest/wms/window_split_test.cpp b/test/systemtest/wms/window_split_test.cpp index 536ce1fcf0..d19fbb343c 100644 --- a/test/systemtest/wms/window_split_test.cpp +++ b/test/systemtest/wms/window_split_test.cpp @@ -94,9 +94,7 @@ HWTEST_F(WindowSplitTest, SplitWindow01, TestSize.Level1) splitInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); - if (priWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, priWindow); activeWindows_.push_back(priWindow); priWindow->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); sleep(SPLIT_TEST_SLEEP_S); @@ -104,9 +102,7 @@ HWTEST_F(WindowSplitTest, SplitWindow01, TestSize.Level1) sleep(SPLIT_TEST_SLEEP_S); const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); fullWindow->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); sleep(SPLIT_TEST_SLEEP_S); @@ -136,9 +132,7 @@ HWTEST_F(WindowSplitTest, SplitWindow02, TestSize.Level1) splitInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); fullWindow->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); sleep(SPLIT_TEST_SLEEP_S); @@ -176,9 +170,7 @@ HWTEST_F(WindowSplitTest, SplitScreen03, TestSize.Level1) splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -212,9 +204,7 @@ HWTEST_F(WindowSplitTest, SplitScreen04, TestSize.Level1) splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); - if (fullWindow == nullptr) { - return; - } + ASSERT_NE(nullptr, fullWindow); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); diff --git a/test/systemtest/wms/window_subwindow_test.cpp b/test/systemtest/wms/window_subwindow_test.cpp index b3dddc01d6..4bc04b89df 100644 --- a/test/systemtest/wms/window_subwindow_test.cpp +++ b/test/systemtest/wms/window_subwindow_test.cpp @@ -85,9 +85,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow01, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -113,9 +110,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow02, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -141,9 +135,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow03, TestSize.Level1) struct Rect rect = { 0, 2000, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -169,9 +160,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow04, TestSize.Level1) struct Rect rect = { 0, 2000, 3000, 2000 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -197,9 +185,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow05, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); sptr subWindow2 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); @@ -230,9 +215,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow06, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); - if (subWindow0 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow0); sptr subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); @@ -264,9 +246,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow07, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -292,9 +271,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow08, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, subWindow->Show()); @@ -312,9 +288,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow09, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -342,9 +315,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow10, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - if (subWindow == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -369,33 +339,18 @@ HWTEST_F(WindowSubWindowTest, SubWindow11, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); - if (subWindow0 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow0); sptr subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); - if (subWindow1 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow1); sptr subWindow2 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); - if (subWindow2 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow2); sptr subWindow3 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); - if (subWindow3 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow3); sptr subWindow4 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); - if (subWindow4 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow4); if (scene->GoForeground() == WMError::WM_OK) { ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -435,12 +390,6 @@ HWTEST_F(WindowSubWindowTest, SubWindow12, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0"); sptr subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0"); - if (subWindow0 == nullptr) { - return; - } - if (subWindow1 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow0); ASSERT_EQ(nullptr, subWindow1); @@ -469,17 +418,11 @@ HWTEST_F(WindowSubWindowTest, SubWindow13, TestSize.Level1) struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub1"); - if (subWindow0 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow0); ASSERT_EQ(WMError::WM_OK, subWindow0->Show()); ASSERT_EQ(WMError::WM_OK, subWindow0->Destroy()); sptr subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub1"); - if (subWindow1 == nullptr) { - return; - } ASSERT_NE(nullptr, subWindow1); ASSERT_EQ(WMError::WM_OK, subWindow1->Show()); ASSERT_EQ(WMError::WM_OK, subWindow1->Destroy()); diff --git a/test/systemtest/wms/window_system_toast_test.cpp b/test/systemtest/wms/window_system_toast_test.cpp index e7ec6a65fd..deac776116 100644 --- a/test/systemtest/wms/window_system_toast_test.cpp +++ b/test/systemtest/wms/window_system_toast_test.cpp @@ -137,9 +137,6 @@ HWTEST_F(WindowSystemToastWindowTest, SystemToastWindow02, TestSize.Level1) Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); sptr fltWin = CreateSystemToastWindow(WindowType::WINDOW_TYPE_SYSTEM_TOAST, fltWindRect); - if (fltWin == nullptr) { - return; - } ASSERT_NE(nullptr, fltWin); if (scene->GoForeground() == WMError::WM_OK) { @@ -171,9 +168,6 @@ HWTEST_F(WindowSystemToastWindowTest, SystemToastWindow03, TestSize.Level1) Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); sptr fltWin = CreateSystemToastWindow(WindowType::WINDOW_TYPE_SYSTEM_TOAST, fltWindRect); - if (fltWin == nullptr) { - return; - } ASSERT_NE(nullptr, fltWin); if (scene->GoForeground() == WMError::WM_OK) { ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); @@ -207,9 +201,6 @@ HWTEST_F(WindowSystemToastWindowTest, SystemToastWindow04, TestSize.Level1) Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); sptr fltWin = CreateSystemToastWindow(WindowType::WINDOW_TYPE_SYSTEM_TOAST, fltWindRect); - if (fltWin == nullptr) { - return; - } ASSERT_NE(nullptr, fltWin); if (scene->GoForeground() != WMError::WM_OK) { diff --git a/test/systemtest/wms/window_touch_outside_test.cpp b/test/systemtest/wms/window_touch_outside_test.cpp index 9939be2fb9..babe3a5c37 100644 --- a/test/systemtest/wms/window_touch_outside_test.cpp +++ b/test/systemtest/wms/window_touch_outside_test.cpp @@ -107,9 +107,7 @@ namespace { HWTEST_F(WindowTouchOutsideTest, onTouchInside, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); - if (firstWindow == nullptr) { - return; - } + ASSERT_EQ(nullptr, firstWindow); firstWindow->RegisterTouchOutsideListener(windowlistener1_); firstWindow->Show(); SingletonContainer::Get().ProcessPointDown(firstWindow->GetWindowId()); @@ -126,9 +124,7 @@ HWTEST_F(WindowTouchOutsideTest, onTouchInside, TestSize.Level1) HWTEST_F(WindowTouchOutsideTest, onTouchOutside, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); - if (firstWindow == nullptr) { - return; - } + ASSERT_EQ(nullptr, firstWindow); firstWindow->RegisterTouchOutsideListener(windowlistener1_); const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); @@ -149,9 +145,7 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, TestSize.Level1) HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); - if (firstWindow == nullptr) { - return; - } + ASSERT_EQ(nullptr, firstWindow); firstWindow->RegisterTouchOutsideListener(windowlistener1_); const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); @@ -171,9 +165,7 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, TestSize.Level1) HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); - if (firstWindow == nullptr) { - return; - } + ASSERT_EQ(nullptr, firstWindow); firstWindow->RegisterTouchOutsideListener(windowlistener1_); const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); diff --git a/test/systemtest/wms/window_visibility_info_test.cpp b/test/systemtest/wms/window_visibility_info_test.cpp index d8e1546eb4..b12dcff685 100644 --- a/test/systemtest/wms/window_visibility_info_test.cpp +++ b/test/systemtest/wms/window_visibility_info_test.cpp @@ -206,10 +206,7 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, TestSize.Level1) floatAppInfo_.name = "window1"; floatAppInfo_.rect = { 0, 0, 300, 100 }; sptr window1 = Utils::CreateTestWindow(floatAppInfo_); - if (window1 == nullptr) { - return; - } - + ASSERT_NE(nullptr, window1); subAppInfo_.name = "subWindow1"; subAppInfo_.rect = { 0, 600, 300, 100 }; subAppInfo_.parentId = window1->GetWindowId(); diff --git a/test/systemtest/wms/window_water_mark_test.cpp b/test/systemtest/wms/window_water_mark_test.cpp index 175ec7eec8..e2d3c3e034 100644 --- a/test/systemtest/wms/window_water_mark_test.cpp +++ b/test/systemtest/wms/window_water_mark_test.cpp @@ -143,9 +143,6 @@ HWTEST_F(WaterMarkTest, SetWaterMarkFlag01, TestSize.Level1) appInfo_.name = "window1"; appInfo_.rect = { 200, 200, 300, 300 }; sptr window = CreateWindow(appInfo_); - if (window == nullptr) { - return; - } ASSERT_NE(window, nullptr); window->Show(); sleep(NORMAL_SLEEP_TIME); diff --git a/utils/test/unittest/BUILD.gn b/utils/test/unittest/BUILD.gn index cd020b85ea..65e8e55d1e 100644 --- a/utils/test/unittest/BUILD.gn +++ b/utils/test/unittest/BUILD.gn @@ -33,7 +33,6 @@ group("unittest") { ":utils_screen_group_info_test", ":utils_screen_info_test", ":utils_string_test", - ":utils_surface_draw_test", ":utils_surface_reader_test", ":utils_window_helper_test", ":utils_window_property_test", @@ -42,6 +41,11 @@ group("unittest") { ":utils_wm_occlusion_region_test", ":wm_window_frame_trace_impl_test", ] + if (!window_manager_use_sceneboard) { + deps += [ + ":utils_surface_draw_test", + ] + } } test_external_deps = [ diff --git a/utils/test/unittest/surface_draw_test.cpp b/utils/test/unittest/surface_draw_test.cpp index 9510bdb069..dd8d9d9126 100644 --- a/utils/test/unittest/surface_draw_test.cpp +++ b/utils/test/unittest/surface_draw_test.cpp @@ -125,9 +125,6 @@ HWTEST_F(SurfaceDrawTest, DrawImage01, TestSize.Level1) { ASSERT_FALSE(SurfaceDraw::DrawImage(nullptr, 0, 0, "")); sptr window = CreateTestWindow("testDrawImage"); - if (window == nullptr) { - return; - } ASSERT_NE(nullptr, window); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -165,9 +162,6 @@ HWTEST_F(SurfaceDrawTest, DrawMasking01, TestSize.Level1) ASSERT_FALSE(SurfaceDraw::DrawMasking(nullptr, screenRect, transRect)); sptr window = CreateTestWindow("testDrawMasking"); - if (window == nullptr) { - return; - } ASSERT_NE(nullptr, window); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -192,9 +186,6 @@ HWTEST_F(SurfaceDrawTest, DrawMasking01, TestSize.Level1) HWTEST_F(SurfaceDrawTest, DoDrawImageRect01, TestSize.Level1) { sptr window = CreateTestWindow("testDoDrawImageRect"); - if (window == nullptr) { - return; - } ASSERT_NE(window, nullptr); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -207,9 +198,7 @@ HWTEST_F(SurfaceDrawTest, DoDrawImageRect01, TestSize.Level1) sptr layer = SurfaceDraw::GetLayer(surfaceNode); ASSERT_NE(layer, nullptr); sptr buffer = SurfaceDraw::GetSurfaceBuffer(layer, rect.width_, rect.height_); - if (buffer == nullptr) { - return; - } + ASSERT_NE(nullptr, buffer); ASSERT_FALSE(SurfaceDraw::DoDrawImageRect(buffer, rect, nullptr, color, false)); @@ -228,9 +217,6 @@ HWTEST_F(SurfaceDrawTest, DoDrawImageRect01, TestSize.Level1) HWTEST_F(SurfaceDrawTest, GetSurfaceSnapshot01, TestSize.Level1) { sptr window = CreateTestWindow("testDoDrawImageRect"); - if (window == nullptr) { - return; - } ASSERT_NE(window, nullptr); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -255,9 +241,6 @@ HWTEST_F(SurfaceDrawTest, DrawColor01, TestSize.Level1) { ASSERT_FALSE(SurfaceDraw::DrawColor(nullptr, 0, 0, 0)); sptr window = CreateTestWindow("DrawColor"); - if (window == nullptr) { - return; - } ASSERT_NE(nullptr, window); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -279,9 +262,6 @@ HWTEST_F(SurfaceDrawTest, DrawColor01, TestSize.Level1) HWTEST_F(SurfaceDrawTest, DoDraw01, TestSize.Level1) { sptr window = CreateTestWindow("DoDrawTest01"); - if (window == nullptr) { - return; - } ASSERT_NE(nullptr, window); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -304,9 +284,6 @@ HWTEST_F(SurfaceDrawTest, DoDraw01, TestSize.Level1) HWTEST_F(SurfaceDrawTest, DoDraw02, TestSize.Level1) { sptr window = CreateTestWindow("DoDraw02"); - if (window == nullptr) { - return; - } ASSERT_NE(window, nullptr); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -316,9 +293,7 @@ HWTEST_F(SurfaceDrawTest, DoDraw02, TestSize.Level1) sptr layer = SurfaceDraw::GetLayer(surfaceNode); ASSERT_NE(layer, nullptr); sptr buffer = SurfaceDraw::GetSurfaceBuffer(layer, rect.width_, rect.height_); - if (buffer == nullptr) { - return; - } + ASSERT_NE(nullptr, buffer); std::shared_ptr pixelMap = SurfaceDraw::DecodeImageToPixelMap(IMAGE_PLACE_HOLDER_PNG_PATH); ASSERT_NE(pixelMap, nullptr); ASSERT_FALSE(SurfaceDraw::DoDraw(nullptr, 0, 0, pixelMap)); @@ -333,9 +308,6 @@ HWTEST_F(SurfaceDrawTest, DoDraw02, TestSize.Level1) HWTEST_F(SurfaceDrawTest, DoDraw03, TestSize.Level1) { sptr window = CreateTestWindow("DoDrawTest03"); - if (window == nullptr) { - return; - } ASSERT_NE(nullptr, window); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated @@ -346,9 +318,7 @@ HWTEST_F(SurfaceDrawTest, DoDraw03, TestSize.Level1) sptr layer = SurfaceDraw::GetLayer(surfaceNode); ASSERT_NE(layer, nullptr); sptr buffer = SurfaceDraw::GetSurfaceBuffer(layer, rect.width_, rect.height_); - if (buffer == nullptr) { - return; - } + ASSERT_NE(nullptr, buffer); ASSERT_FALSE(SurfaceDraw::DoDraw(nullptr, 0, 0, color)); window->Destroy(); } @@ -361,9 +331,6 @@ HWTEST_F(SurfaceDrawTest, DoDraw03, TestSize.Level1) HWTEST_F(SurfaceDrawTest, DrawImageRect01, TestSize.Level1) { sptr window = CreateTestWindow("DrawImageRect"); - if (window == nullptr) { - return; - } ASSERT_NE(window, nullptr); window->Show(); usleep(WAIT_FOR_SYNC_US / 20); // wait for rect updated -- Gitee From a128b5b4481e9b32d12c7b519b04254c373de8ba Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Wed, 20 Aug 2025 09:46:27 +0800 Subject: [PATCH 081/241] edit review Signed-off-by: ZhaoLiang --- interfaces/innerkits/dm/dm_common.h | 4 ++-- interfaces/kits/napi/display_runtime/js_display_manager.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index a8d431c7de..f0ba02b523 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -197,6 +197,7 @@ enum class DisplayEvent : uint32_t { * @brief Enumerates DMError. */ enum class DMError : int32_t { + DM_ERROR_UNKNOWN = -1, DM_OK = 0, DM_ERROR_INIT_DMS_PROXY_LOCKED = 100, DM_ERROR_IPC_FAILED = 101, @@ -213,12 +214,11 @@ enum class DMError : int32_t { DM_ERROR_INVALID_PERMISSION = 201, DM_ERROR_NOT_SYSTEM_APP = 202, DM_ERROR_DEVICE_NOT_SUPPORT = 801, - DM_ERROR_UNKNOWN = -1, - DM_ERROR_ILLEGAL_PARAM = 1400004, DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRED_CASTING = 100001, DM_ERROR_NOT_SUPPORT_COOR_WHEN_WIRLESS_CASTING = 100002, DM_ERROR_NOT_SUPPORT_COOR_WHEN_RECORDING = 100003, DM_ERROR_NOT_SUPPORT_COOR_WHEN_TENTMODE = 100004, + DM_ERROR_ILLEGAL_PARAM = 1400004, }; /** diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index 0598cc3061..4092f88e1a 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -872,7 +872,10 @@ napi_value OnSetFoldDisplayMode(napi_env env, napi_callback_info info) if (DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.find(dmError) != DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.end()) { errMsg = DM_ERROR_JS_TO_ERROR_MESSAGE_MAP.at(dmError); } - DmErrorCode errCode = DM_JS_TO_ERROR_CODE_MAP.at(dmError); + DmErrorCode errCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL; + if (DM_JS_TO_ERROR_CODE_MAP.find(dmError) != DM_JS_TO_ERROR_CODE_MAP.end()) { + errCode = DM_JS_TO_ERROR_CODE_MAP.at(dmError); + } TLOGI(WmsLogTag::DMS, "[NAPI]%{public}d, error message: %{public}s", static_cast(errCode), errMsg.c_str()); if (errCode != DmErrorCode::DM_OK) { napi_throw(env, JsErrUtils::CreateJsError(env, errCode, errMsg)); -- Gitee From 9a7e91a48c278bf69fcbc1ff9d37f5263bbe082d Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Wed, 20 Aug 2025 09:49:21 +0800 Subject: [PATCH 082/241] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A2=84=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laiganlu --- .../common/include/window_session_property.h | 5 +++++ .../js_scene_session_manager.cpp | 15 +++++++++++++++ .../js_scene_session_manager.h | 2 ++ .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 18 +++++++++++++++--- .../window_pattern_starting_window_test.cpp | 4 ++-- 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 89adc5b4dc..81d0874957 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -794,6 +794,7 @@ struct SystemSessionConfig : public Parcelable { bool skipRedundantWindowStatusNotifications_ = false; uint32_t supportFunctionType_ = 0; bool supportSnapshotAllSessionStatus_ = false; + bool supportPreloadStartingWindow_ = false; bool supportCreateFloatWindow_ = false; float defaultCornerRadius_ = 0.0f; // default corner radius of window set by system config @@ -852,6 +853,9 @@ struct SystemSessionConfig : public Parcelable { if (!parcel.WriteBool(supportSnapshotAllSessionStatus_)) { return false; } + if (!parcel.WriteBool(supportPreloadStartingWindow_)) { + return false; + } if (!parcel.WriteFloat(defaultCornerRadius_)) { return false; } @@ -905,6 +909,7 @@ struct SystemSessionConfig : public Parcelable { config->skipRedundantWindowStatusNotifications_ = parcel.ReadBool(); config->supportFunctionType_ = parcel.ReadUint32(); config->supportSnapshotAllSessionStatus_ = parcel.ReadBool(); + config->supportPreloadStartingWindow_ = parcel.ReadBool(); if (!parcel.ReadFloat(config->defaultCornerRadius_)) { delete config; return nullptr; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index db4969cc99..be06d1d20e 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -318,6 +318,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::UpdateRecentMainSessionInfos); BindNativeFunction(env, exportObj, "supportSnapshotAllSessionStatus", moduleName, JsSceneSessionManager::SupportSnapshotAllSessionStatus); + BindNativeFunction(env, exportObj, "supportPreloadStartingWindow", moduleName, + JsSceneSessionManager::SupportPreloadStartingWindow); BindNativeFunction(env, exportObj, "setUIEffectControllerAliveInUI", moduleName, JsSceneSessionManager::SetUIEffectControllerAliveInUI); BindNativeFunction(env, exportObj, "setPiPSettingSwitchStatus", moduleName, @@ -3643,6 +3645,19 @@ napi_value JsSceneSessionManager::OnSupportSnapshotAllSessionStatus(napi_env env return NapiGetUndefined(env); } +napi_value JsSceneSessionManager::SupportPreloadStartingWindow(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_PATTERN, "[NAPI]"); + JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSupportPreloadStartingWindow(env, info) : nullptr; +} + +napi_value JsSceneSessionManager::OnSupportPreloadStartingWindow(napi_env env, napi_callback_info info) +{ + SceneSessionManager::GetInstance().ConfigSupportPreloadStartingWindow(); + return NapiGetUndefined(env); +} + napi_value JsSceneSessionManager::SupportCreateFloatWindow(napi_env env, napi_callback_info info) { TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]"); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h index e23b26c715..bf82225a4b 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h @@ -170,6 +170,7 @@ public: * Window Pattern */ static napi_value SupportSnapshotAllSessionStatus(napi_env env, napi_callback_info info); + static napi_value SupportPreloadStartingWindow(napi_env env, napi_callback_info info); /* * PiP Window @@ -400,6 +401,7 @@ private: * Window Pattern */ napi_value OnSupportSnapshotAllSessionStatus(napi_env env, napi_callback_info info); + napi_value OnSupportPreloadStartingWindow(napi_env env, napi_callback_info info); napi_value OnUpdateSystemDecorEnable(napi_env env, napi_callback_info info); }; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 902af226c8..b179856794 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -786,6 +786,7 @@ public: WMError SetStartWindowBackgroundColor(const std::string& moduleName, const std::string& abilityName, uint32_t color, int32_t uid) override; void ConfigSupportSnapshotAllSessionStatus(); + void ConfigSupportPreloadStartingWindow(); /* * Window Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1a104d886f..9b41b79fc5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3302,6 +3302,15 @@ void SceneSessionManager::ConfigSupportSnapshotAllSessionStatus() taskScheduler_->PostAsyncTask(task, "ConfigSupportSnapshotAllSessionStatus"); } +void SceneSessionManager::ConfigSupportPreloadStartingWindow() +{ + TLOGI(WmsLogTag::WMS_PATTERN, "support"); + auto task = [this] { + systemConfig_.supportPreloadStartingWindow_ = true; + }; + taskScheduler_->PostAsyncTask(task, "ConfigSupportPreloadStartingWindow"); +} + WMError SceneSessionManager::CreateUIEffectController(const sptr& controllerClient, sptr& controller, int32_t& controllerId) { @@ -5544,8 +5553,8 @@ void SceneSessionManager::RemovePreLoadStartingWindowFromMap(const SessionInfo& void SceneSessionManager::PreLoadStartingWindow(sptr sceneSession) { - if (!systemConfig_.IsPhoneWindow()) { - TLOGD(WmsLogTag::WMS_PATTERN, "only for phone"); + if (!systemConfig_.supportPreloadStartingWindow_) { + TLOGD(WmsLogTag::WMS_PATTERN, "not supported"); return; } const char* const where = __func__; @@ -5611,8 +5620,11 @@ bool SceneSessionManager::CheckAndGetPreLoadResourceId(const StartingWindowInfo& TLOGE(WmsLogTag::WMS_PATTERN, "format error: %{private}s", iconPath.c_str()); return false; } + static const std::unordered_set supportImageFormat = { + ".png", ".jpg", ".webp", ".astc" + }; const auto& extName = iconPath.substr(pos); - if (extName != ".png" && extName != ".jpg" && extName != ".webp" && extName != ".astc") { + if (!supportImageFormat.count(extName)) { TLOGI(WmsLogTag::WMS_PATTERN, "format not need preLoad: %{private}s", iconPath.c_str()); return false; } diff --git a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp index b7454ecb1d..9e44236f61 100644 --- a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp +++ b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp @@ -471,9 +471,9 @@ HWTEST_F(WindowPatternStartingWindowTest, PreLoadStartingWindow, TestSize.Level1 { ASSERT_NE(ssm_, nullptr); sptr sceneSession = nullptr; - ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + ssm_->systemConfig_.supportPreloadStartingWindow_ = false; ssm_->PreLoadStartingWindow(sceneSession); - ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + ssm_->systemConfig_.supportPreloadStartingWindow_ = true; ssm_->PreLoadStartingWindow(sceneSession); SessionInfo info; info.bundleName_ = "bundleName_"; -- Gitee From 6a63efbeebd816d08409ec6ce03d02138f22a5fb Mon Sep 17 00:00:00 2001 From: xherror Date: Tue, 19 Aug 2025 20:46:12 +0800 Subject: [PATCH 083/241] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E9=80=82=E9=85=8DGLB=EF=BC=8CSetDecorButtonS?= =?UTF-8?q?tyle=E3=80=81setWindowShadowRadius=E3=80=81setWindowTitle?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8A=9F=E8=83=BD=E4=B8=8D=E7=AC=A6=E5=90=88?= =?UTF-8?q?=E9=A2=84=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xherror --- wm/src/window_scene_session_impl.cpp | 6 +++--- .../window_scene_session_impl_animation_test.cpp | 6 +++++- wm/test/unittest/window_scene_session_impl_test4.cpp | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 21bc75ad23..705e9b9b56 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3302,7 +3302,7 @@ WMError WindowSceneSessionImpl::SetWindowTitle(const std::string& title) return WMError::WM_OK; } if (!(windowSystemConfig_.IsPcWindow() || windowSystemConfig_.IsPadWindow() || - IsDeviceFeatureCapableForFreeMultiWindow())) { + windowSystemConfig_.IsPhoneWindow() || IsDeviceFeatureCapableForFreeMultiWindow())) { TLOGE(WmsLogTag::WMS_DECOR, "device not support"); return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } @@ -4717,8 +4717,8 @@ WMError WindowSceneSessionImpl::SetWindowShadowRadius(float radius) return WMError::WM_ERROR_INVALID_WINDOW; } if (!windowSystemConfig_.IsPcWindow() && !windowSystemConfig_.IsPadWindow() && - !IsDeviceFeatureCapableForFreeMultiWindow()) { - TLOGE(WmsLogTag::WMS_ATTRIBUTE, "This is not PC or Pad, not supported."); + !windowSystemConfig_.IsPhoneWindow() && !IsDeviceFeatureCapableForFreeMultiWindow()) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "device not support."); return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } if (!WindowHelper::IsFloatOrSubWindow(GetType())) { diff --git a/wm/test/unittest/animation/window_scene_session_impl_animation_test.cpp b/wm/test/unittest/animation/window_scene_session_impl_animation_test.cpp index 17a47f145b..c3fb6f883e 100644 --- a/wm/test/unittest/animation/window_scene_session_impl_animation_test.cpp +++ b/wm/test/unittest/animation/window_scene_session_impl_animation_test.cpp @@ -220,7 +220,7 @@ HWTEST_F(WindowSceneSessionImplAnimationTest, SetWindowShadowRadius, TestSize.Le window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; window->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); ret = window->SetWindowShadowRadius(1.0f); - EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret); + EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret); window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; window->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); @@ -237,6 +237,10 @@ HWTEST_F(WindowSceneSessionImplAnimationTest, SetWindowShadowRadius, TestSize.Le window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; ret = window->SetWindowShadowRadius(1.0f); EXPECT_EQ(WMError::WM_OK, ret); + + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + ret = window->SetWindowShadowRadius(1.0f); + EXPECT_EQ(WMError::WM_OK, ret); const std::string feature = "large_screen"; std::string deviceType = OHOS::system::GetParameter("const.product.devicetype", ""); diff --git a/wm/test/unittest/window_scene_session_impl_test4.cpp b/wm/test/unittest/window_scene_session_impl_test4.cpp index ede5993e16..1321b6b127 100644 --- a/wm/test/unittest/window_scene_session_impl_test4.cpp +++ b/wm/test/unittest/window_scene_session_impl_test4.cpp @@ -1082,8 +1082,6 @@ HWTEST_F(WindowSceneSessionImplTest4, SetWindowTitle, TestSize.Level1) sptr session = sptr::MakeSptr(sessionInfo); window->hostSession_ = session; window->property_->SetPersistentId(1); - window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; - EXPECT_EQ(window->SetWindowTitle(title), WMError::WM_ERROR_DEVICE_NOT_SUPPORT); window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; window->windowSystemConfig_.freeMultiWindowSupport_ = false; window->windowSystemConfig_.isSystemDecorEnable_ = false; @@ -1101,6 +1099,12 @@ HWTEST_F(WindowSceneSessionImplTest4, SetWindowTitle, TestSize.Level1) EXPECT_EQ(window->Create(abilityContext_, session), WMError::WM_OK); EXPECT_EQ(window->SetWindowTitle(title), WMError::WM_OK); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + window->windowSystemConfig_.freeMultiWindowSupport_ = true; + window->windowSystemConfig_.isSystemDecorEnable_ = true; + window->property_->SetDecorEnable(true); + EXPECT_EQ(window->SetWindowTitle(title), WMError::WM_OK); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; window->property_->SetPcAppInpadCompatibleMode(true); window->windowSystemConfig_.freeMultiWindowEnable_ = false; -- Gitee From fb0208e1780908c7f371306c4a5499ca32cdb2d8 Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Wed, 20 Aug 2025 10:55:48 +0800 Subject: [PATCH 084/241] =?UTF-8?q?loadcontent=E8=A1=A5=E5=8F=91=E6=B2=89?= =?UTF-8?q?=E6=B5=B8=E5=BC=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peng fafu --- wm/include/window_extension_session_impl.h | 1 + wm/src/window_extension_session_impl.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index 96b64732fb..e133beaf0b 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -257,6 +257,7 @@ private: AAFwk::WantParams extensionConfig_ {}; bool hostGestureBackEnabled_ { true }; bool hostImmersiveModeEnabled_ { false }; + bool immersiveModeEnabled_ { false }; std::mutex hostWindowRectChangeListenerMutex_; std::mutex keyboardDidShowListenerMutex_; std::mutex keyboardDidHideListenerMutex_; diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index c07e1eb8d1..f85e966af2 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -839,6 +839,7 @@ WMError WindowExtensionSessionImpl::SetUIContentInner(const std::string& content } SetUIContentComplete(); NotifyModalUIExtensionMayBeCovered(true); + SetLayoutFullScreen(immersiveModeEnabled_); UpdateAccessibilityTreeInfo(); std::shared_ptr uiContent = GetUIContentSharedPtr(); @@ -1556,6 +1557,7 @@ WMError WindowExtensionSessionImpl::SetLayoutFullScreen(bool status) property_->SetIsLayoutFullScreen(status); isIgnoreSafeArea_ = status; isIgnoreSafeAreaNeedNotify_ = true; + immersiveModeEnabled_ = status; if (auto uiContent = GetUIContentSharedPtr()) { uiContent->SetIgnoreViewSafeArea(status); } -- Gitee From 86e74199dde809421030410176bb880c6a8c2a3f Mon Sep 17 00:00:00 2001 From: wangchuan Date: Wed, 20 Aug 2025 11:26:33 +0800 Subject: [PATCH 085/241] =?UTF-8?q?feix:=20=E4=BF=AE=E6=94=B9=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../window_runtime/window_napi/js_window.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index aad9c41c56..6d5c328981 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2104,7 +2104,7 @@ napi_value JsWindow::OnResize(napi_env env, napi_callback_info info) auto asyncTask = [windowToken = wptr(windowToken_), errCode, width, height, env, task = napiAsyncTask, where = __func__] { if (errCode != WMError::WM_OK) { - task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "[window][resize]msg: Failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, errCode, "[window][resize]msg: Invalid param")); TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: invalid param", where); return; } @@ -4895,7 +4895,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (argc < 1 || argc > 2) { // 2: maximum params num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][setResizeByDragEnabled]msg: Argc is invalid"); + "[window][setResizeByDragEnabled]msg: Number of parameters is invalid"); } bool dragEnabled = true; if (!ConvertFromJsValue(env, argv[0], dragEnabled)) { @@ -4919,8 +4919,7 @@ napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info i if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); } else { - task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setResizeByDragEnabled]msg: Set dragEnabled failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, ret)); } TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Window [%{public}u, %{public}s] set dragEnabled end", where, window->GetWindowId(), window->GetWindowName().c_str()); @@ -5699,7 +5698,7 @@ napi_value JsWindow::OnSetForbidSplitMove(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setForbidSplitMove]msg: Invalidate params.")); + "[window][setForbidSplitMove]msg: Window is nullptr")); return; } WmErrorCode ret; @@ -6755,13 +6754,13 @@ napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setAspectRatio]msg: WindowToken is nullptr"); + "[window][setAspectRatio]msg: Window is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { - TLOGE(WmsLogTag::WMS_LAYOUT, "SetAspectRatio is not allowed since window is main window"); + TLOGE(WmsLogTag::WMS_LAYOUT, "SetAspectRatio is only allowed main window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, - "[window][setAspectRatio]msg: SetAspectRatio is not allowed since window is main window"); + "[window][setAspectRatio]msg: SetAspectRatio is only allowed for the main window"); } double aspectRatio = 0.0; @@ -8987,7 +8986,7 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal if (!WindowHelper::IsSubWindow(window->GetType()) && !WindowHelper::IsDialogWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s only sub window and dialog is valid", where); task->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING), - "[window][setFollowParentWindowLayoutEnabled]msg: Only sub window and dialog is valid")); + "[window][setFollowParentWindowLayoutEnabled]msg: Support sub window or dialog only")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetFollowParentWindowLayoutEnabled(isFollow)); @@ -8996,7 +8995,7 @@ napi_value JsWindow::OnSetFollowParentWindowLayoutEnabled(napi_env env, napi_cal } else { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s failed, ret %{public}d", where, ret); task->Reject(env, JsErrUtils::CreateJsError(env, ret, - "[window][setFollowParentWindowLayoutEnabled]msg: Set follow parent layout failed.")); + "[window][setFollowParentWindowLayoutEnabled]msg: Set follow parent layout failed")); } }; napi_status status = napi_send_event(env, asyncTask, napi_eprio_high, "SetFollowParentWindowLayoutEnabled"); -- Gitee From 7a25c71eb714b661e6d310e144fc7b68e440361b Mon Sep 17 00:00:00 2001 From: kaicui Date: Tue, 19 Aug 2025 21:04:34 +0800 Subject: [PATCH 086/241] UIExtension ANI code optimization Signed-off-by: kaicui --- .../ets/@ohos.uiExtensionHost.ets | 146 +++++--- .../include/ani_extension_window.h | 14 +- .../include/ani_extension_window_listener.h | 21 +- .../ani_extension_window_register_manager.h | 12 +- .../src/ani_extension_window.cpp | 311 ++++++++++-------- .../src/ani_extension_window_listener.cpp | 98 +++--- .../ani_extension_window_register_manager.cpp | 133 ++++---- 7 files changed, 430 insertions(+), 305 deletions(-) diff --git a/interfaces/kits/ani/embeddable_window_stage/ets/@ohos.uiExtensionHost.ets b/interfaces/kits/ani/embeddable_window_stage/ets/@ohos.uiExtensionHost.ets index ea71131898..ebe8a72f44 100644 --- a/interfaces/kits/ani/embeddable_window_stage/ets/@ohos.uiExtensionHost.ets +++ b/interfaces/kits/ani/embeddable_window_stage/ets/@ohos.uiExtensionHost.ets @@ -14,8 +14,9 @@ */ import { BusinessError } from '@ohos.base'; +import hilog from '@ohos.hilog'; import window from '@ohos.window'; -import { Callback } from '@ohos.base' +import { Callback } from '@ohos.base'; /** * uiExtensionHost. @@ -26,56 +27,78 @@ import { Callback } from '@ohos.base' * @since 11 */ namespace uiExtensionHost { - export native function createExtentionWindow(win: long, hostId: int): UIExtensionHostWindowProxy; + export native function createExtensionWindow(win: long, hostId: int): UIExtensionHostWindowProxy; + + // UIExtension WmsLogTag + const WMS_UIEXT: int = 0xC0420D; + const WMS_UIEXT_TAG: string = "WMSUiext"; + const enum WmErrorCode { + WM_OK = 0, + WM_ERROR_INVALID_PARAM = 401 + } + const WM_ERRORCODE_INVALID_PARAM_MSG: string = `Parameter error. Possible causes: ` + + `1. Mandatory parameters are left unspecified; ` + + `2. Incorrect parameters types; ` + + `3. Parameter verification failed.`; + const WINDOW_SIZE_CHANGE_CB: string = "windowSizeChange"; + const AVOID_AREA_CHANGE_CB: string = "avoidAreaChange"; // internal class and function export type CallbackSize = (size: window.Size) => void; export type CallbackArea = (area: window.AvoidAreaOptions) => void; - const WMS_UIEXT: int = 0xC0420D; - const WMS_UIEXT_TAG: string = "WMSUiext"; - - function callBack(fn: object, fnArg: object): void { - let f = fn as (d: object) => void; - f(fnArg); + function sizeChangeCallback(fn: object, fnArg: object): void { + let f = fn as (d: object) => void; + f(fnArg); } - function avoidAreaChangeCallBack(cb: object, area: object, type: int): void { + function avoidAreaChangeCallback(cb: object, area: object, type: int): void { const func = cb as (data: window.AvoidAreaOptions) => void; func({type: type as window.AvoidAreaType, area: area as window.AvoidArea}); } + function keyboardHeightChangeCallback(cb: object, cbArg: int): void { + const func = cb as (cbArg: number) => void; + func(cbArg as number); + } + class UIESize implements window.Size { width: double; height: double; } + class UIERect implements window.Rect { left: double; top: double; width: double; height: double; - }; + } + class UIEAvoidArea implements window.AvoidArea { constructor() { - this.leftRect = new UIERect(); - this.topRect = new UIERect(); - this.rightRect = new UIERect(); - this.bottomRect = new UIERect(); + this.leftRect = new UIERect(); + this.topRect = new UIERect(); + this.rightRect = new UIERect(); + this.bottomRect = new UIERect(); } + visible: boolean; leftRect: window.Rect; topRect: window.Rect; rightRect: window.Rect; bottomRect: window.Rect; } + class UIEAreaAndType { type: window.AvoidAreaType; area: UIEAvoidArea; } + class UIEProperties implements UIExtensionHostWindowProxyProperties { constructor() { - this.uiExtensionHostWindowProxyRect = new UIERect(); + this.uiExtensionHostWindowProxyRect = new UIERect(); } + uiExtensionHostWindowProxyRect: window.Rect; } @@ -83,57 +106,96 @@ namespace uiExtensionHost { export class UIExtensionHostInternal implements UIExtensionHostWindowProxy { static { loadLibrary("embeddablewindowstageani_kit.z") } private nativeObj: long = 0; + private setNativeObj(nativeObj: long): void { - this.nativeObj = nativeObj; + this.nativeObj = nativeObj; } + private setAreaVisible(obj: window.AvoidArea, visible: boolean) { - obj.visible = visible; + obj.visible = visible; } public native getProperties(nativeObj: long, property: object): int; public native setProperties(nativeObj: long, property: object): int; public native getWindowAvoidArea(nativeObj: long, type: int, area: object): int; - public native setWaterMarkFlag(nativeObj: long, enable: boolean): void; - public native hidePrivacyContentForHost(nativeObj: long, shouldHide: boolean): void; + public native setWaterMarkFlag(nativeObj: long, enable: boolean): int; + public native hidePrivacyContentForHost(nativeObj: long, shouldHide: boolean): int; public native onAvoidAreaChange(nativeObj: long, callback: object, callbackData: object): int; public native offAvoidAreaChange(nativeObj: long, callback?: object): int; public native onWindowSizeChange(nativeObj: long, callback: object, callbackData: object): int; public native offWindowSizeChange(nativeObj: long, callback?: object): int; get properties(): UIExtensionHostWindowProxyProperties { - let property = new UIEProperties(); - let ret = this.getProperties(this.nativeObj, property as object); - return property; + let property = new UIEProperties(); + let ret = this.getProperties(this.nativeObj, property as object); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `getProperties failed, ret: ${ret}`); + } + return property; } - set properties(property: UIExtensionHostWindowProxyProperties) { - this.setProperties(this.nativeObj, property as object); + + set properties(properties: UIExtensionHostWindowProxyProperties) { + this.setProperties(this.nativeObj, properties as object); } + public on(type: string, callback: Callback): void { - if (type == 'avoidAreaChange') { - let area = new UIEAreaAndType(); - this.onAvoidAreaChange(this.nativeObj, callback as object, area as object); - } else { - let size = new UIESize(); - this.onWindowSizeChange(this.nativeObj, callback as object, size as object); + if (type === AVOID_AREA_CHANGE_CB) { + let area = new UIEAreaAndType(); + let ret = this.onAvoidAreaChange(this.nativeObj, callback as object, area as object); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `register ${type} callback failed, ret: ${ret}`); + } + } else if (type === WINDOW_SIZE_CHANGE_CB) { + let size = new UIESize(); + let ret = this.onWindowSizeChange(this.nativeObj, callback as object, size as object); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `register ${type} callback failed, ret: ${ret}`); } + } else { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `type ${type} is not supported`); + throw { + code: WmErrorCode.WM_ERROR_INVALID_PARAM, + message: WM_ERRORCODE_INVALID_PARAM_MSG + } as BusinessError as Error; + } } + public off(type: string, callback?: Callback): void { - if (type == 'avoidAreaChange') { - this.offAvoidAreaChange(this.nativeObj, callback); - } else { - this.offWindowSizeChange(this.nativeObj, callback); + if (type === AVOID_AREA_CHANGE_CB) { + let ret = this.offAvoidAreaChange(this.nativeObj, callback); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `unregister ${type} callback failed, ret: ${ret}`); } + } else if (type === WINDOW_SIZE_CHANGE_CB) { + let ret = this.offWindowSizeChange(this.nativeObj, callback); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `unregister ${type} callback failed, ret: ${ret}`); + } + } else { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `type ${type} is not supported`); + throw { + code: WmErrorCode.WM_ERROR_INVALID_PARAM, + message: WM_ERRORCODE_INVALID_PARAM_MSG + } as BusinessError as Error; + } } + getWindowAvoidArea(type: window.AvoidAreaType): window.AvoidArea { - let area: window.AvoidArea = new UIEAvoidArea(); - let ret = this.getWindowAvoidArea(this.nativeObj, type as int, area as object); - return area; + let area: window.AvoidArea = new UIEAvoidArea(); + let ret = this.getWindowAvoidArea(this.nativeObj, type as int, area as object); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `getWindowAvoidArea failed, ret: ${ret}`); + } + return area; } setWaterMarkFlag(enable: boolean): Promise { return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { - this.setWaterMarkFlag(this.nativeObj, enable); + let ret = this.setWaterMarkFlag(this.nativeObj, enable); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `setWaterMarkFlag failed, ret: ${ret}`); + } }).then((ret: NullishType) :void => { resolve(undefined); }).catch((err: NullishType) :void => { @@ -145,7 +207,10 @@ namespace uiExtensionHost { hidePrivacyContentForHost(shouldHide: boolean): Promise { return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { - this.hidePrivacyContentForHost(this.nativeObj, shouldHide); + let ret = this.hidePrivacyContentForHost(this.nativeObj, shouldHide); + if (ret !== WmErrorCode.WM_OK) { + hilog.error(WMS_UIEXT, WMS_UIEXT_TAG, `hidePrivacyContentForHost failed, ret: ${ret}`); + } }).then((ret: NullishType) :void => { resolve(undefined); }).catch((err: NullishType) :void => { @@ -154,6 +219,7 @@ namespace uiExtensionHost { }); } } + /** * Transition Controller * @@ -192,4 +258,4 @@ namespace uiExtensionHost { } } -export default uiExtensionHost; +export default uiExtensionHost; \ No newline at end of file diff --git a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window.h b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window.h index 83dd7213e7..ae0c05d2ec 100644 --- a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window.h +++ b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2025-2025 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 @@ -37,13 +37,13 @@ public: sptr sessionInfo); static ani_object CreateAniExtensionWindow(ani_env* env, sptr window, int32_t hostWindowId); WMError GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea); - WMError OnSetWaterMarkFlag(ani_env* env, ani_boolean enable); - WMError OnHidePrivacyContentForHost(ani_env* env, ani_boolean shouldHide); - WMError GetRect(Rect&); - WMError RegisterListener(const std::string& cbType, ani_env* env, ani_object fn, ani_object fnArg); - WMError UnregisterListener(const std::string& cbType, ani_env* env, ani_object fn); + WmErrorCode OnSetWaterMarkFlag(ani_env* env, ani_boolean enable); + WmErrorCode OnHidePrivacyContentForHost(ani_env* env, ani_boolean shouldHide); + WmErrorCode GetExtensionWindowRect(Rect& rect); + WmErrorCode RegisterListener(const std::string& cbType, ani_env* env, ani_object fn, ani_object fnArg); + WmErrorCode UnregisterListener(const std::string& cbType, ani_env* env, ani_object fn); private: - bool WindowIsValid(); + bool IsExtensionWindowValid(); std::shared_ptr extensionWindow_; int32_t hostWindowId_ = 0; sptr sessionInfo_ = nullptr; diff --git a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_listener.h b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_listener.h index 4d280abf98..baacb3d601 100644 --- a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_listener.h +++ b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_listener.h @@ -28,31 +28,38 @@ namespace OHOS { namespace Rosen { +const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; +const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; +const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent"; +const std::string WINDOW_EVENT_CB = "windowEvent"; +constexpr const char* ETS_UIEXTENSION_HOST_NAMESPACE_DESCRIPTOR = "L@ohos/uiExtensionHost/uiExtensionHost;"; + class AniExtensionWindowListener : public IWindowChangeListener, public IAvoidAreaChangedListener, public IWindowLifeCycle, public IOccupiedAreaChangeListener { public: AniExtensionWindowListener(ani_env* env, ani_ref func, ani_ref data) - : env_(env), callBack_(func), callBackData_(data), weakRef_(wptr (this)) {} + : env_(env), aniCallback_(func), aniCallbackData_(data), weakRef_(wptr (this)) {} ~AniExtensionWindowListener(); + ani_ref GetAniCallback() const { return aniCallback_; } + void SetAniCallback(ani_ref aniCallback) { aniCallback_ = aniCallback; } void OnSizeChange(Rect rect, WindowSizeChangeReason reason, - const std::shared_ptr& rsTransaction = nullptr) override; + const std::shared_ptr& rsTransaction = nullptr) override; void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, const sptr& info = nullptr) override; void OnSizeChange(const sptr& info, - const std::shared_ptr& rsTransaction = nullptr) override; + const std::shared_ptr& rsTransaction = nullptr) override; void SetMainEventHandler(); - bool IsSameRef(ani_ref newRef); void SetSizeInfo(uint32_t width, uint32_t height); private: - void CallBack(); + void CallSizeChangeCallback(); uint32_t currentWidth_ = 0; uint32_t currentHeight_ = 0; ani_env* env_ = nullptr; - ani_ref callBack_; - ani_ref callBackData_; + ani_ref aniCallback_; + ani_ref aniCallbackData_; wptr weakRef_ = nullptr; std::shared_ptr eventHandler_ = nullptr; DEFINE_VAR_DEFAULT_FUNC_SET(bool, IsDeprecatedInterface, isDeprecatedInterface, false) diff --git a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h index ed367b67ff..b558cc9bfd 100644 --- a/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h +++ b/interfaces/kits/ani/embeddable_window_stage/include/ani_extension_window_register_manager.h @@ -30,9 +30,9 @@ class AniExtensionWindowRegisterManager { public: AniExtensionWindowRegisterManager(); ~AniExtensionWindowRegisterManager(); - WMError RegisterListener(sptr window, const std::string& type, + WmErrorCode RegisterListener(sptr window, const std::string& type, CaseType caseType, ani_env* env, ani_object fn, ani_object fnArg); - WMError UnregisterListener(sptr window, std::string type, + WmErrorCode UnregisterListener(sptr window, const std::string& type, CaseType caseType, ani_env* env, ani_object fn); private: @@ -44,13 +44,13 @@ private: }; bool IsCallbackRegistered(ani_env* env, const std::string& type, ani_object fn); - WMError ProcessWindowChangeRegister(sptr listener, + WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister); - WMError ProcessAvoidAreaChangeRegister(sptr listener, + WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister); - WMError ProcessLifeCycleEventRegister(sptr listener, + WmErrorCode ProcessLifeCycleEventRegister(sptr listener, sptr window, bool isRegister); - WMError ProcessRegister(CaseType caseType, const sptr& listener, + WmErrorCode ProcessRegister(CaseType caseType, const sptr& listener, const sptr& window, const std::string& type, bool isRegister); std::map>> aniCbMap_; std::mutex mtx_; diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp index 59b5898054..a535a5361d 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window.cpp @@ -13,14 +13,20 @@ * limitations under the License. */ -#include "ani.h" #include "ani_extension_window.h" + +#include "ani.h" #include "ani_extension_window_register_manager.h" +#include "ani_window_utils.h" #include "extension_window_impl.h" #include "window_manager_hilog.h" namespace OHOS { namespace Rosen { +namespace { +constexpr const char* ETS_UIEXTENSION_HOST_CLASS_DESCRIPTOR = + "L@ohos/uiExtensionHost/uiExtensionHost/UIExtensionHostInternal;"; +} AniExtensionWindow::AniExtensionWindow( const std::shared_ptr extensionWindow, int32_t hostWindowId) @@ -28,7 +34,7 @@ AniExtensionWindow::AniExtensionWindow( hostWindowId_(hostWindowId), extensionRegisterManager_(std::make_unique()) { - TLOGI(WmsLogTag::WMS_UIEXT, "%{public}d", hostWindowId_); + TLOGI(WmsLogTag::WMS_UIEXT, "hostWindowId: %{public}d", hostWindowId_); } AniExtensionWindow::AniExtensionWindow( @@ -42,15 +48,15 @@ AniExtensionWindow::AniExtensionWindow( ani_object AniExtensionWindow::CreateAniExtensionWindow(ani_env* env, sptr window, int32_t hostWindowId) { - if (env == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "AniExtensionWindow env or window is nullptr"); + if (env == nullptr || window == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "env or window is nullptr"); return nullptr; } - ani_status ret; + ani_status ret {}; ani_class cls = nullptr; - if ((ret = env->FindClass("L@ohos/uiExtensionHost/uiExtensionHost/UIExtensionHostInternal;", &cls)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] null env %{public}u", ret); + if ((ret = env->FindClass(ETS_UIEXTENSION_HOST_CLASS_DESCRIPTOR, &cls)) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find class failed, ret: %{public}u", ret); return cls; } @@ -60,23 +66,23 @@ ani_object AniExtensionWindow::CreateAniExtensionWindow(ani_env* env, sptrClass_FindField(cls, "nativeObj", &contextField)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] get field fail %{public}u", ret); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find field failed, ret: %{public}u", ret); return nullptr; } ani_method initFunc = nullptr; if ((ret = env->Class_FindMethod(cls, "", ":V", &initFunc)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] get ctor fail %{public}u", ret); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find ctor method failed, ret: %{public}u", ret); return nullptr; } ani_object obj = nullptr; if ((ret = env->Object_New(cls, initFunc, &obj)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] obj new fail %{public}u", ret); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]New object failed, ret: %{public}u", ret); return nullptr; } ani_method setObjFunc = nullptr; if ((ret = env->Class_FindMethod(cls, "setNativeObj", "J:V", &setObjFunc)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] get ctor fail %{public}u", ret); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find method failed, ret: %{public}u", ret); return nullptr; } env->Object_CallMethod_Void(obj, setObjFunc, reinterpret_cast(aniExtensionWindow.release())); @@ -85,46 +91,46 @@ ani_object AniExtensionWindow::CreateAniExtensionWindow(ani_env* env, sptrGetAvoidAreaByType(type, avoidArea); } -WMError AniExtensionWindow::OnSetWaterMarkFlag(ani_env* env, ani_boolean enable) +WmErrorCode AniExtensionWindow::OnSetWaterMarkFlag(ani_env* env, ani_boolean enable) { if (extensionWindow_ == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); - return WMError::WM_DO_NOTHING; + AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } - WmErrorCode ret = WmErrorCode::WM_OK; - ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->SetWaterMarkFlag(enable)); - if (ret != WmErrorCode::WM_OK) { - return WMError::WM_DO_NOTHING; + WMError ret = extensionWindow_->SetWaterMarkFlag(enable); + if (WM_JS_TO_ERROR_CODE_MAP.at(ret) != WmErrorCode::WM_OK) { + AniWindowUtils::AniThrowError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret)); + return WM_JS_TO_ERROR_CODE_MAP.at(ret); } - TLOGI(WmsLogTag::WMS_UIEXT, "[ANI] OnSetWaterMarkFlag success,isEnable:%{public}u.", - enable); - return WMError::WM_OK; + TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]finished, enable: %{public}u", enable); + return WmErrorCode::WM_OK; } -WMError AniExtensionWindow::OnHidePrivacyContentForHost(ani_env* env, ani_boolean shouldHide) +WmErrorCode AniExtensionWindow::OnHidePrivacyContentForHost(ani_env* env, ani_boolean shouldHide) { if (extensionWindow_ == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); - return WMError::WM_DO_NOTHING; + AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } - WmErrorCode ret = WmErrorCode::WM_OK; - ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->HidePrivacyContentForHost(shouldHide)); - if (ret != WmErrorCode::WM_OK) { - return WMError::WM_DO_NOTHING; + WMError ret = extensionWindow_->HidePrivacyContentForHost(shouldHide); + if (WM_JS_TO_ERROR_CODE_MAP.at(ret) != WmErrorCode::WM_OK) { + AniWindowUtils::AniThrowError(env, WM_JS_TO_ERROR_CODE_MAP.at(ret)); + return WM_JS_TO_ERROR_CODE_MAP.at(ret); } - TLOGI(WmsLogTag::WMS_UIEXT, - "[ANI] OnHidePrivacyContentForHost success,shouldHide:%{public}u.", shouldHide); - return WMError::WM_OK; + TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]finished, shouldHide: %{public}u", shouldHide); + return WmErrorCode::WM_OK; } -bool AniExtensionWindow::WindowIsValid() +bool AniExtensionWindow::IsExtensionWindowValid() { if (extensionWindow_ == nullptr) { return false; @@ -136,181 +142,206 @@ bool AniExtensionWindow::WindowIsValid() return true; } -WMError AniExtensionWindow::UnregisterListener(const std::string& cbType, ani_env* env, ani_object fn) +WmErrorCode AniExtensionWindow::UnregisterListener(const std::string& cbType, ani_env* env, ani_object fn) { - if (!WindowIsValid()) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] window not available"); - return WMError::WM_DO_NOTHING; + if (!IsExtensionWindowValid()) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]extension window is invalid"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr window = extensionWindow_->GetWindow(); return extensionRegisterManager_->UnregisterListener(window, cbType, CaseType::CASE_WINDOW, env, fn); } -WMError AniExtensionWindow::RegisterListener(const std::string& cbType, ani_env* env, ani_object fn, ani_object fnArg) +WmErrorCode AniExtensionWindow::RegisterListener(const std::string& cbType, ani_env* env, + ani_object fn, ani_object fnArg) { - if (!WindowIsValid()) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] window not available"); - return WMError::WM_DO_NOTHING; + if (!IsExtensionWindowValid()) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]extension window is invalid"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr window = extensionWindow_->GetWindow(); return extensionRegisterManager_->RegisterListener(window, cbType, CaseType::CASE_WINDOW, env, fn, fnArg); } -WMError AniExtensionWindow::GetRect(Rect& rect) +WmErrorCode AniExtensionWindow::GetExtensionWindowRect(Rect& rect) { - if (!WindowIsValid()) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] window not available"); - return WMError::WM_DO_NOTHING; + if (!IsExtensionWindowValid()) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]extension window is invalid"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } rect = extensionWindow_->GetWindow()->GetRect(); - return WMError::WM_OK; + return WmErrorCode::WM_OK; } -static ani_int ExtWindowSetRect(ani_env* env, ani_object obj, OHOS::Rosen::Rect& rect) +static ani_status ExtWindowSetRect(ani_env* env, ani_object obj, OHOS::Rosen::Rect& rect) { ani_status ret {}; if ((ret = env->Object_SetFieldByName_Double(obj, "left", rect.posX_)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] set left field %{public}u", ret); - return (ani_int)WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Set left field failed, ret: %{public}u", ret); + return ret; } if ((ret = env->Object_SetFieldByName_Double(obj, "top", rect.posY_)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] set top field %{public}u", ret); - return (ani_int)WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Set top field failed, ret: %{public}u", ret); + return ret; } if ((ret = env->Object_SetFieldByName_Double(obj, "width", rect.width_)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] set width field %{public}u", ret); - return (ani_int)WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Set width field failed, ret: %{public}u", ret); + return ret; } if ((ret = env->Object_SetFieldByName_Double(obj, "height", rect.height_)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] set height field %{public}u", ret); - return (ani_int)WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Set height field failed, ret: %{public}u", ret); + return ret; } - return (ani_int)WMError::WM_OK; + return ANI_OK; } -static ani_int ExtWindowSetRectMember(ani_env* env, ani_object obj, const char* member, OHOS::Rosen::Rect& rect) +static ani_status ExtWindowSetRectMember(ani_env* env, ani_object obj, const char* member, OHOS::Rosen::Rect& rect) { ani_status ret {}; ani_ref rectRef {}; if ((ret = env->Object_GetFieldByName_Ref(obj, member, &rectRef)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] get field %{public}s %{public}u", member, ret); - return (ani_int)WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Get field %{public}s failed, ret: %{public}u", member, ret); + return ret; }; - return ExtWindowSetRect(env, (ani_object)rectRef, rect); + return ExtWindowSetRect(env, static_cast(rectRef), rect); } static ani_int ExtWindowGetProperties(ani_env* env, ani_object obj, ani_long nativeObj, ani_object propertyRef) { - WMError retCode = WMError::WM_OK; - AniExtensionWindow* aniExt = reinterpret_cast(nativeObj); + WmErrorCode retCode = WmErrorCode::WM_OK; + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(nativeObj); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } Rect rect {}; - if ((retCode = aniExt->GetRect(rect)) != WMError::WM_OK) { - return (ani_int)retCode; + if ((retCode = aniExtWinPtr->GetExtensionWindowRect(rect)) != WmErrorCode::WM_OK) { + return static_cast(retCode); }; - return ExtWindowSetRectMember(env, propertyRef, "uiExtensionHostWindowProxyRect", rect); -} - -static ani_int ExtWindowSetProperties(ani_env* env, ani_object obj, ani_long nativeObj, ani_object propertyRef) -{ - return (ani_int)WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + return static_cast( + ExtWindowSetRectMember(env, propertyRef, "uiExtensionHostWindowProxyRect", rect)); } static ani_int ExtWindowGetWindowAvoidArea(ani_env* env, ani_object obj, ani_long win, ani_int areaType, ani_object area) { - bool err = ((areaType > (int)AvoidAreaType::TYPE_NAVIGATION_INDICATOR) || - (areaType < (int)AvoidAreaType::TYPE_SYSTEM)); - if (err) { - return (ani_int)WMError::WM_ERROR_INVALID_PARAM; + bool hasAvoidAreaTypeErr = (areaType < static_cast(AvoidAreaType::TYPE_START) || + areaType >= static_cast(AvoidAreaType::TYPE_END)); + if (hasAvoidAreaTypeErr) { + AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM); } AvoidArea avoidArea {}; ani_status ret {}; - ret = env->Object_SetFieldByName_Boolean(area, "visible", areaType != (int)AvoidAreaType::TYPE_CUTOUT); + ret = env->Object_SetFieldByName_Boolean(area, "visible", areaType != + static_cast(AvoidAreaType::TYPE_CUTOUT)); if (ret != ANI_OK) { - TLOGI(WmsLogTag::WMS_UIEXT, "[ANI] set visible faild %{public}d", (int)ret); - return (ani_int)WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Set visible failed, ret: %{public}u", ret); + return static_cast(ret); } - AniExtensionWindow* winPtr = reinterpret_cast(win); - WMError retCode = winPtr->GetAvoidAreaByType((AvoidAreaType)areaType, avoidArea); + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(win); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + WMError retCode = aniExtWinPtr->GetAvoidAreaByType(static_cast(areaType), avoidArea); if (retCode != WMError::WM_OK) { - return (ani_int)retCode; + return static_cast(WM_JS_TO_ERROR_CODE_MAP.at(retCode)); } - if ((retCode = (WMError)ExtWindowSetRectMember(env, area, "leftRect", avoidArea.leftRect_)) != - WMError::WM_OK) { - return (ani_int)retCode; + ret = ExtWindowSetRectMember(env, area, "leftRect", avoidArea.leftRect_); + if (ret != ANI_OK) { + return static_cast(ret); } - if ((retCode = (WMError)ExtWindowSetRectMember(env, area, "rightRect", avoidArea.rightRect_)) != - WMError::WM_OK) { - return (ani_int)retCode; + ret = ExtWindowSetRectMember(env, area, "rightRect", avoidArea.rightRect_); + if (ret != ANI_OK) { + return static_cast(ret); } - if ((retCode = (WMError)ExtWindowSetRectMember(env, area, "topRect", avoidArea.topRect_)) != - WMError::WM_OK) { - return (ani_int)retCode; + ret = ExtWindowSetRectMember(env, area, "topRect", avoidArea.topRect_); + if (ret != ANI_OK) { + return static_cast(ret); } - if ((retCode = (WMError)ExtWindowSetRectMember(env, area, "bottomRect", avoidArea.bottomRect_)) != - WMError::WM_OK) { - return (ani_int)retCode; + ret = ExtWindowSetRectMember(env, area, "bottomRect", avoidArea.bottomRect_); + if (ret != ANI_OK) { + return static_cast(ret); } - return (ani_int)WMError::WM_OK; + return static_cast(WmErrorCode::WM_OK); } static ani_int ExtWindowSetWaterMarkFlag(ani_env* env, ani_object obj, ani_long nativeObj, ani_boolean enable) { - AniExtensionWindow* winPtr = reinterpret_cast(nativeObj); - WMError ret = WMError::WM_DO_NOTHING; - if (winPtr != nullptr) { - ret = winPtr->OnSetWaterMarkFlag(env, enable); - } else { - TLOGE(WmsLogTag::DEFAULT, "[ANI] AniExtensionWindow is nullptr"); - } - return (ani_int)ret; + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(nativeObj); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + return static_cast(aniExtWinPtr->OnSetWaterMarkFlag(env, enable)); } static ani_int ExtWindowHidePrivacyContentForHost(ani_env* env, ani_object obj, ani_long nativeObj, ani_boolean shouldHide) { - AniExtensionWindow* winPtr = reinterpret_cast(nativeObj); - WMError ret = WMError::WM_DO_NOTHING; - if (winPtr != nullptr) { - ret = winPtr->OnHidePrivacyContentForHost(env, shouldHide); - } else { - TLOGE(WmsLogTag::DEFAULT, "[ANI] AniExtensionWindow is nullptr"); - } - return (ani_int)ret; + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(nativeObj); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + return static_cast(aniExtWinPtr->OnHidePrivacyContentForHost(env, shouldHide)); } static ani_int ExtWindowOnAvoidAreaChange(ani_env* env, ani_object obj, ani_long nativeObj, ani_object fn, ani_object fnArg) { - AniExtensionWindow* winPtr = reinterpret_cast(nativeObj); - return (ani_int)winPtr->RegisterListener("avoidAreaChange", env, fn, fnArg); + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(nativeObj); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + return static_cast(aniExtWinPtr->RegisterListener(AVOID_AREA_CHANGE_CB, env, fn, fnArg)); } -static ani_int ExtWindowOffAvoidAreaChange(ani_env* env, ani_object obj, ani_long nativeObj, - ani_object fn) +static ani_int ExtWindowOffAvoidAreaChange(ani_env* env, ani_object obj, ani_long nativeObj, ani_object fn) { - AniExtensionWindow* winPtr = reinterpret_cast(nativeObj); - return (ani_int)winPtr->UnregisterListener("avoidAreaChange", env, fn); + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(nativeObj); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + return static_cast(aniExtWinPtr->UnregisterListener(AVOID_AREA_CHANGE_CB, env, fn)); } + static ani_int ExtWindowOnWindowSizeChange(ani_env* env, ani_object obj, ani_long nativeObj, ani_object fn, ani_object fnArg) { - AniExtensionWindow* winPtr = reinterpret_cast(nativeObj); - return (ani_int)winPtr->RegisterListener("windowSizeChange", env, fn, fnArg); + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(nativeObj); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + return static_cast(aniExtWinPtr->RegisterListener(WINDOW_SIZE_CHANGE_CB, env, fn, fnArg)); } -static ani_int ExtWindowOffWindowSizeChange(ani_env* env, ani_object obj, ani_long nativeObj, - ani_object fn) + +static ani_int ExtWindowOffWindowSizeChange(ani_env* env, ani_object obj, ani_long nativeObj, ani_object fn) { - AniExtensionWindow* winPtr = reinterpret_cast(nativeObj); - return (ani_int)winPtr->UnregisterListener("windowSizeChange", env, fn); + AniExtensionWindow* aniExtWinPtr = reinterpret_cast(nativeObj); + if (aniExtWinPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]aniExtWinPtr is nullptr"); + return static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + return static_cast(aniExtWinPtr->UnregisterListener(WINDOW_SIZE_CHANGE_CB, env, fn)); } -// test from ts -ani_object createExtentionWindow(ani_env* env, ani_long win, ani_int hostId) +ani_object createExtensionWindow(ani_env* env, ani_long win, ani_int hostId) { - TLOGI(WmsLogTag::WMS_UIEXT, "[ANI] create extwindow with hostId:%{public}d", hostId); - sptr winPtr; - return AniExtensionWindow::CreateAniExtensionWindow(env, winPtr, (int32_t)hostId); + TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]Create extwindow with hostId: %{public}d", hostId); + auto winPtr = reinterpret_cast*>(win); + if (winPtr == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]winPtr is nullptr"); + return nullptr; + } + sptr window = *winPtr; + return AniExtensionWindow::CreateAniExtensionWindow(env, window, hostId); } } } // namespace @@ -319,12 +350,11 @@ extern "C" { using namespace OHOS::Rosen; std::array extensionWindowNativeMethods = { ani_native_function {"getProperties", "JLstd/core/Object;:I", reinterpret_cast(ExtWindowGetProperties)}, - ani_native_function {"setProperties", "JLstd/core/Object;:I", reinterpret_cast(ExtWindowSetProperties)}, ani_native_function {"getWindowAvoidArea", "JILstd/core/Object;:I", reinterpret_cast(ExtWindowGetWindowAvoidArea)}, - ani_native_function {"setWaterMarkFlag", "JZ:V", + ani_native_function {"setWaterMarkFlag", "JZ:I", reinterpret_cast(ExtWindowSetWaterMarkFlag)}, - ani_native_function {"hidePrivacyContentForHost", "JZ:V", + ani_native_function {"hidePrivacyContentForHost", "JZ:I", reinterpret_cast(ExtWindowHidePrivacyContentForHost)}, ani_native_function {"onAvoidAreaChange", "JLstd/core/Object;Lstd/core/Object;:I", reinterpret_cast(ExtWindowOnAvoidAreaChange)}, @@ -338,42 +368,41 @@ std::array extensionWindowNativeMethods = { ANI_EXPORT ani_status ExtensionWindow_ANI_Constructor(ani_vm *vm, uint32_t *result) { using namespace OHOS::Rosen; - TLOGD(WmsLogTag::WMS_UIEXT, "[ANI] init ExtensionWindow begin"); - ani_status ret; + TLOGD(WmsLogTag::WMS_UIEXT, "[ANI]Init ExtensionWindow begin"); + ani_status ret {}; ani_env* env; if ((ret = vm->GetEnv(ANI_VERSION_1, &env)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] null env"); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Get env failed, ret: %{public}u", ret); return ANI_NOT_FOUND; } ani_class cls = nullptr; - if ((ret = env->FindClass("L@ohos/uiExtensionHost/uiExtensionHost/UIExtensionHostInternal;", &cls)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] null env %{public}u", ret); + if ((ret = env->FindClass(ETS_UIEXTENSION_HOST_CLASS_DESCRIPTOR, &cls)) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find class failed, ret: %{public}u", ret); return ANI_NOT_FOUND; } if ((ret = env->Class_BindNativeMethods(cls, extensionWindowNativeMethods.data(), extensionWindowNativeMethods.size())) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] bind fail %{public}u", ret); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Class bind native methods failed, ret: %{public}u", ret); return ANI_NOT_FOUND; } *result = ANI_VERSION_1; - // test ani_namespace ns; - if ((ret = env->FindNamespace("L@ohos/uiExtensionHost/uiExtensionHost;", &ns)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] find ns %{public}u", ret); + if ((ret = env->FindNamespace(ETS_UIEXTENSION_HOST_NAMESPACE_DESCRIPTOR, &ns)) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find namespace failed, ret: %{public}u", ret); return ANI_NOT_FOUND; } std::array functions = { - ani_native_function {"createExtentionWindow", nullptr, reinterpret_cast(createExtentionWindow)}, + ani_native_function {"createExtensionWindow", nullptr, reinterpret_cast(createExtensionWindow)}, }; if ((ret = env->Namespace_BindNativeFunctions(ns, functions.data(), functions.size())) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI] bind ns func %{public}u", ret); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Namespace bind native functions failed, ret: %{public}u", ret); return ANI_NOT_FOUND; } - TLOGD(WmsLogTag::WMS_UIEXT, "[ANI] init ExtensionWindow end"); + TLOGD(WmsLogTag::WMS_UIEXT, "[ANI]Init ExtensionWindow end"); return ANI_OK; } } diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp index a9ca7d0160..9d2d9fa464 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_listener.cpp @@ -15,40 +15,33 @@ #include "ani_extension_window_listener.h" -#include #include "ani.h" #include "ani_window_utils.h" #include "event_handler.h" #include "event_runner.h" +#include #include "window_manager_hilog.h" namespace OHOS { namespace Rosen { using namespace AbilityRuntime; namespace { -const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; -const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange"; -const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; -const std::string LIFECYCLE_EVENT_CB = "lifeCycleEvent"; -const std::string KEYBOARD_HEIGHT_CHANGE_CB = "keyboardHeightChange"; +constexpr const char* ETS_WINDOW_SIZE_CHANGE_CB = "sizeChangeCallback"; +constexpr const char* ETS_AVOID_AREA_CHANGE_CB = "avoidAreaChangeCallback"; +constexpr const char* ETS_KEYBOARD_HEIGHT_CHANGE_CB = "keyboardHeightChangeCallback"; } AniExtensionWindowListener::~AniExtensionWindowListener() { - if (callBack_ != nullptr) { - env_->GlobalReference_Delete(callBack_); + if (aniCallback_ != nullptr) { + env_->GlobalReference_Delete(aniCallback_); } - if (callBackData_ != nullptr) { - env_->GlobalReference_Delete(callBackData_); + if (aniCallbackData_ != nullptr) { + env_->GlobalReference_Delete(aniCallbackData_); } TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]~AniExtensionWindowListener"); } -bool AniExtensionWindowListener::IsSameRef(ani_ref newRef) -{ - return true; -} - void AniExtensionWindowListener::SetMainEventHandler() { auto mainRunner = AppExecFwk::EventRunner::GetMainEventRunner(); @@ -58,21 +51,21 @@ void AniExtensionWindowListener::SetMainEventHandler() eventHandler_ = std::make_shared(mainRunner); } -void AniExtensionWindowListener::CallBack() +void AniExtensionWindowListener::CallSizeChangeCallback() { ani_status ret {}; ani_function fn {}; ani_namespace ns {}; - if ((ret = env_->FindNamespace("L@ohos/uiExtensionHost/uiExtensionHost;", &ns)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]canot find ns %{public}d", ret); + if ((ret = env_->FindNamespace(ETS_UIEXTENSION_HOST_NAMESPACE_DESCRIPTOR, &ns)) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find namespace failed, ret: %{public}u", ret); return; } - if ((ret = env_->Namespace_FindFunction(ns, "callBack", "Lstd/core/Object;Lstd/core/Object;:V", &fn)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]canot find callBack %{public}d", ret); + if ((ret = env_->Namespace_FindFunction(ns, ETS_WINDOW_SIZE_CHANGE_CB, nullptr, &fn)) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Find function failed, ret: %{public}u", ret); return; } - if ((ret = env_->Function_Call_Void(fn, callBack_, callBackData_)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]canot find callBack %{public}d", ret); + if ((ret = env_->Function_Call_Void(fn, aniCallback_, aniCallbackData_)) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Call function failed, ret: %{public}u", ret); return; } } @@ -80,14 +73,14 @@ void AniExtensionWindowListener::CallBack() void AniExtensionWindowListener::SetSizeInfo(uint32_t width, uint32_t height) { ani_status ret {}; - if ((ret = env_->Object_SetFieldByName_Double((ani_object)callBackData_, "width", - (double)width)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]canot set width %{public}d", ret); + if ((ret = env_->Object_SetFieldByName_Double(static_cast(aniCallbackData_), "width", + static_cast(width))) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Set width failed, ret: %{public}u", ret); return; }; - if ((ret = env_->Object_SetFieldByName_Double((ani_object)callBackData_, "height", - (double)height)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]canot set height %{public}d", ret); + if ((ret = env_->Object_SetFieldByName_Double(static_cast(aniCallbackData_), "height", + static_cast(height))) != ANI_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Set height failed, ret: %{public}u", ret); return; } } @@ -98,27 +91,27 @@ void AniExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]OnSizeChange, [%{public}u, %{public}u], reason=%{public}u", rect.width_, rect.height_, reason); if (currentWidth_ == rect.width_ && currentHeight_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) { - TLOGD(WmsLogTag::WMS_UIEXT, "[ANI]no need to change size"); + TLOGD(WmsLogTag::WMS_UIEXT, "[ANI]No need to notify size change"); return; } - auto aniCallback = [self = weakRef_, rect, eng = env_] () { + auto onSizeChangeTask = [self = weakRef_, rect, eng = env_] () { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "AniExtensionWindowListener::OnSizeChange"); auto thisListener = self.promote(); - if (thisListener == nullptr || eng == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]this listener or eng is nullptr"); + if (thisListener == nullptr || eng == nullptr || thisListener->aniCallback_ == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]thisListener, eng or callback is nullptr"); return; } thisListener->SetSizeInfo(rect.width_, rect.height_); - thisListener->CallBack(); + thisListener->CallSizeChangeCallback(); }; if (reason == WindowSizeChangeReason::ROTATION) { - aniCallback(); + onSizeChangeTask(); } else { if (!eventHandler_) { - TLOGE(WmsLogTag::WMS_UIEXT, "get main event handler failed!"); + TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!"); return; } - eventHandler_->PostTask(aniCallback, "wms:AniExtensionWindowListener::OnSizeChange", 0, + eventHandler_->PostTask(onSizeChangeTask, "wms:AniExtensionWindowListener::SizeChangeCallback", 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } currentWidth_ = rect.width_; @@ -131,30 +124,45 @@ void AniExtensionWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, A TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]"); auto task = [self = weakRef_, eng = env_, avoidArea, type] { auto thisListener = self.promote(); - if (thisListener == nullptr || eng == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "this listener or eng is nullptr"); + if (thisListener == nullptr || eng == nullptr || thisListener->aniCallback_ == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]thisListener, eng or callback is nullptr"); return; } auto nativeAvoidArea = AniWindowUtils::CreateAniAvoidArea(eng, avoidArea, type); - AniWindowUtils::CallAniFunctionVoid(eng, "L@ohos/uiExtensionHost/uiExtensionHost;", "avoidAreaChangeCallBack", - nullptr, thisListener->callBack_, nativeAvoidArea, static_cast(type)); + AniWindowUtils::CallAniFunctionVoid(eng, ETS_UIEXTENSION_HOST_NAMESPACE_DESCRIPTOR, ETS_AVOID_AREA_CHANGE_CB, + nullptr, thisListener->aniCallback_, nativeAvoidArea, static_cast(type)); }; if (!eventHandler_) { - TLOGE(WmsLogTag::WMS_UIEXT, "get main event handler failed!"); + TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!"); return; } - eventHandler_->PostTask(task, __func__, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); + eventHandler_->PostTask(task, "wms:AniExtensionWindowListener::AvoidAreaChangeCallback", 0, + AppExecFwk::EventQueue::Priority::IMMEDIATE); } void AniExtensionWindowListener::OnSizeChange(const sptr& info, const std::shared_ptr& rsTransaction) { TLOGI(WmsLogTag::WMS_UIEXT, - "[ANI]OccupiedAreaChangeInfo, type: %{public}d, input rect:[%{public}d, %{public}d, %{public}d, %{public}d]", + "[ANI]OccupiedAreaChangeInfo, type: %{public}u, input rect:[%{public}d, %{public}d, %{public}u, %{public}u]", static_cast(info->type_), info->rect_.posX_, info->rect_.posY_, info->rect_.width_, info->rect_.height_); - // js callback should run in js thread - CallBack(); + auto onSizeChangeTask = [self = weakRef_, info, eng = env_] () { + auto thisListener = self.promote(); + if (thisListener == nullptr || eng == nullptr || thisListener->aniCallback_ == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]thisListener, eng or callback is nullptr"); + return; + } + AniWindowUtils::CallAniFunctionVoid(eng, ETS_UIEXTENSION_HOST_NAMESPACE_DESCRIPTOR, + ETS_KEYBOARD_HEIGHT_CHANGE_CB, nullptr, thisListener->aniCallback_, + static_cast(info->rect_.height_)); + }; + if (!eventHandler_) { + TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!"); + return; + } + eventHandler_->PostTask(onSizeChangeTask, "wms:AniExtensionWindowListener::SizeChangeCallback", 0, + AppExecFwk::EventQueue::Priority::IMMEDIATE); } } // namespace Rosen diff --git a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp index 0724ed4c05..ecef2c710c 100644 --- a/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp +++ b/interfaces/kits/ani/embeddable_window_stage/src/ani_extension_window_register_manager.cpp @@ -23,12 +23,6 @@ namespace OHOS { namespace Rosen { -namespace { -const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; -const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; -const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent"; -const std::string WINDOW_EVENT_CB = "windowEvent"; -} AniExtensionWindowRegisterManager::AniExtensionWindowRegisterManager() { @@ -48,49 +42,55 @@ AniExtensionWindowRegisterManager::~AniExtensionWindowRegisterManager() { } -WMError AniExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, +WmErrorCode AniExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister) { if (window == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); - return WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]window is nullptr"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr thisListener(listener); + WmErrorCode ret = WmErrorCode::WM_OK; if (isRegister) { - return window->RegisterWindowChangeListener(thisListener); + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowChangeListener(thisListener)); } else { - return window->UnregisterWindowChangeListener(thisListener); + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowChangeListener(thisListener)); } + return ret; } -WMError AniExtensionWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr listener, +WmErrorCode AniExtensionWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister) { if (window == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); - return WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]window is nullptr"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr thisListener(listener); + WmErrorCode ret = WmErrorCode::WM_OK; if (isRegister) { - return window->RegisterAvoidAreaChangeListener(thisListener); + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterAvoidAreaChangeListener(thisListener)); } else { - return window->UnregisterAvoidAreaChangeListener(thisListener); + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterAvoidAreaChangeListener(thisListener)); } + return ret; } -WMError AniExtensionWindowRegisterManager::ProcessLifeCycleEventRegister(sptr listener, +WmErrorCode AniExtensionWindowRegisterManager::ProcessLifeCycleEventRegister(sptr listener, sptr window, bool isRegister) { if (window == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "Window is nullptr"); - return WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]window is nullptr"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr thisListener(listener); + WmErrorCode ret = WmErrorCode::WM_OK; if (isRegister) { - return window->RegisterLifeCycleListener(thisListener); + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterLifeCycleListener(thisListener)); } else { - return window->UnregisterLifeCycleListener(thisListener); + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterLifeCycleListener(thisListener)); } + return ret; } bool AniExtensionWindowRegisterManager::IsCallbackRegistered(ani_env* env, const std::string& type, ani_object fn) @@ -101,9 +101,10 @@ bool AniExtensionWindowRegisterManager::IsCallbackRegistered(ani_env* env, const } for (auto iter = aniCbMap_[type].begin(); iter != aniCbMap_[type].end(); ++iter) { - sptr oldListener= iter->second; - bool registed = oldListener->IsSameRef(fn); - if (registed) { + ani_ref callback = static_cast(fn); + ani_boolean isEqual = ANI_FALSE; + env->Reference_StrictEquals(callback, iter->first, &isEqual); + if (isEqual) { TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Method %{public}s has already been registered", type.c_str()); return true; } @@ -111,100 +112,114 @@ bool AniExtensionWindowRegisterManager::IsCallbackRegistered(ani_env* env, const return false; } -WMError AniExtensionWindowRegisterManager::RegisterListener(sptr window, const std::string& type, +WmErrorCode AniExtensionWindowRegisterManager::RegisterListener(sptr window, const std::string& type, CaseType caseType, ani_env* env, ani_object fn, ani_object fnArg) { std::lock_guard lock(mtx_); if (IsCallbackRegistered(env, type, fn)) { - return WMError::WM_DO_NOTHING; + return WmErrorCode::WM_ERROR_REPEAT_OPERATION; } if (listenerCodeMap_[caseType].count(type) == 0) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Type %{public}s is not supported", type.c_str()); - return WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Type %{public}s listener is not supported", type.c_str()); + return WmErrorCode::WM_ERROR_INVALID_PARAM; } ani_status ret {}; ani_ref fnRef {}; if ((ret = env->GlobalReference_Create(fn, &fnRef)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]create global ref fail"); - return WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Create fn global reference failed, ret: %{public}u", ret); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; }; ani_ref fnArgRef {}; if ((ret = env->GlobalReference_Create(fnArg, &fnArgRef)) != ANI_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]create global ref fail"); - return WMError::WM_DO_NOTHING; + env->GlobalReference_Delete(fnRef); + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Create fnArg global reference failed, ret: %{public}u}", ret); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; }; sptr extensionWindowListener = sptr::MakeSptr(env, fnRef, fnArgRef); extensionWindowListener->SetMainEventHandler(); - WMError retCode = ProcessRegister(caseType, extensionWindowListener, window, type, true); - if (retCode != WMError::WM_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Register type %{public}s failed", type.c_str()); + WmErrorCode retCode = ProcessRegister(caseType, extensionWindowListener, window, type, true); + if (retCode != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Register type %{public}s listener failed, ret: %{public}d", + type.c_str(), retCode); + env->GlobalReference_Delete(fnRef); + env->GlobalReference_Delete(fnArgRef); return retCode; } aniCbMap_[type][fnRef] = extensionWindowListener; - TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]Register type %{public}s success! callback map size: %{public}zu", type.c_str(), - aniCbMap_[type].size()); - return WMError::WM_OK; + TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]Register type %{public}s listener success! callback map size: %{public}zu", + type.c_str(), aniCbMap_[type].size()); + return WmErrorCode::WM_OK; } -WMError AniExtensionWindowRegisterManager::UnregisterListener(sptr window, std::string type, +WmErrorCode AniExtensionWindowRegisterManager::UnregisterListener(sptr window, const std::string& type, CaseType caseType, ani_env* env, ani_object fn) { std::lock_guard lock(mtx_); if (aniCbMap_.empty() || aniCbMap_.find(type) == aniCbMap_.end()) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Type %{public}s was not registered", type.c_str()); - return WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Type %{public}s listener was not registered", type.c_str()); + return WmErrorCode::WM_ERROR_INVALID_PARAM; } if (listenerCodeMap_[caseType].count(type) == 0) { - TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Type %{public}s is not supported", type.c_str()); - return WMError::WM_DO_NOTHING; + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Type %{public}s listener is not supported", type.c_str()); + return WmErrorCode::WM_ERROR_INVALID_PARAM; } - if (fn == nullptr) { + ani_boolean isUndefined = ANI_FALSE; + env->Reference_IsUndefined(static_cast(fn), &isUndefined); + if (isUndefined == ANI_TRUE) { + TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]Unregister all callback, type: %{public}s", type.c_str()); for (auto it = aniCbMap_[type].begin(); it != aniCbMap_[type].end();) { - WMError ret = ProcessRegister(caseType, it->second, window, type, false); - if (ret != WMError::WM_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Unregister type %{public}s failed, no value", type.c_str()); + WmErrorCode ret = ProcessRegister(caseType, it->second, window, type, false); + if (ret != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Unregister type %{public}s listener failed, ret: %{public}d", + type.c_str(), ret); return ret; } + env->GlobalReference_Delete(it->second->GetAniCallback()); + it->second->SetAniCallback(nullptr); aniCbMap_[type].erase(it++); } } else { bool findFlag = false; for (auto it = aniCbMap_[type].begin(); it != aniCbMap_[type].end(); ++it) { - sptr oldListener= it->second; - bool isSame = oldListener->IsSameRef(fn); - if (!isSame) { + ani_ref callback = static_cast(fn); + ani_boolean isEqual = ANI_FALSE; + env->Reference_StrictEquals(callback, it->first, &isEqual); + if (!isEqual) { continue; } findFlag = true; - WMError ret = ProcessRegister(caseType, it->second, window, type, false); - if (ret != WMError::WM_OK) { - TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Unregister type %{public}s failed", type.c_str()); + WmErrorCode ret = ProcessRegister(caseType, it->second, window, type, false); + if (ret != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_UIEXT, "[ANI]Unregister type %{public}s listener failed, ret: %{public}d", + type.c_str(), ret); return ret; } + env->GlobalReference_Delete(it->second->GetAniCallback()); + it->second->SetAniCallback(nullptr); aniCbMap_[type].erase(it); break; } if (!findFlag) { TLOGE(WmsLogTag::WMS_UIEXT, - "[NAPI]Unregister type %{public}s failed because not found callback!", type.c_str()); - return WMError::WM_DO_NOTHING; + "[ANI]Unregister type %{public}s listener failed because not found callback!", type.c_str()); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } } - TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Unregister type %{public}s success! callback map size: %{public}zu", + TLOGI(WmsLogTag::WMS_UIEXT, "[ANI]Unregister type %{public}s listener success! callback map size: %{public}zu", type.c_str(), aniCbMap_[type].size()); // erase type when there is no callback in one type if (aniCbMap_[type].empty()) { aniCbMap_.erase(type); } - return WMError::WM_OK; + return WmErrorCode::WM_OK; } -WMError AniExtensionWindowRegisterManager::ProcessRegister(CaseType caseType, +WmErrorCode AniExtensionWindowRegisterManager::ProcessRegister(CaseType caseType, const sptr& listener, const sptr& window, const std::string& type, bool isRegister) { - WMError ret = WMError::WM_OK; + WmErrorCode ret = WmErrorCode::WM_OK; if (caseType == CaseType::CASE_WINDOW) { switch (listenerCodeMap_[caseType][type]) { case ListenerType::WINDOW_SIZE_CHANGE_CB: -- Gitee From dcbdde5c4b49e9b4420084e3977e88d12f0efc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Wed, 20 Aug 2025 12:17:38 +0800 Subject: [PATCH 087/241] chaneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../unittest/scene_session_manager_test4.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index dd74e35937..8da2531d47 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -1533,6 +1533,28 @@ HWTEST_F(SceneSessionManagerTest4, GetAllClearableSessions, TestSize.Level1) EXPECT_FALSE(sessionVector.empty()); } +/** + * @tc.name: PostBrightnessTask01 + * @tc.desc: PostBrightnessTask + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask01, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + ssm_->SetDisplayBrightness(999); + + sptr sceneSession = nullptr; + ssm_->PostBrightnessTask(sceneSession, 1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999); + + SessionInfo sessionInfo; + sessionInfo.isSystem_ = false; + sessionInfo.bundleName_ = "bundleName"; + sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + sceneSession->SetSessionState() +} + /** * @tc.name: UpdateBrightness * @tc.desc: UpdateBrightness -- Gitee From 3d6f83b83093509e3a6c59e331790cc4f50ed443 Mon Sep 17 00:00:00 2001 From: wangchuan Date: Wed, 20 Aug 2025 14:06:25 +0800 Subject: [PATCH 088/241] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchuan --- .../napi/window_runtime/window_napi/js_window.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 6d5c328981..eb71efeef7 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1873,7 +1873,7 @@ napi_value JsWindow::OnMoveWindowToAsync(napi_env env, napi_callback_info info) if (argc < 2) { // 2: minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToAsync]msg: Argc is invalid"); + "[window][moveWindowToAsync]msg: Number of parameters is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { @@ -1956,7 +1956,7 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) if (argc < 2) { // 2:minimum param num TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobal]msg: Argc is invalid"); + "[window][moveWindowToGlobal]msg: Number of parameters is invalid"); } int32_t x = 0; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], x)) { @@ -2002,7 +2002,7 @@ napi_value JsWindow::OnMoveWindowToGlobalDisplay(napi_env env, napi_callback_inf if (argc != TWO_PARAMS_SIZE) { TLOGE(WmsLogTag::WMS_LAYOUT, "Invalid argc: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][moveWindowToGlobalDisplay]msg: Invalid"); + "[window][moveWindowToGlobalDisplay]msg: Invalid argc"); } int32_t x = 0; @@ -6816,13 +6816,13 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) if (argc > 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, - "[window][resetAspectRatio]msg: Argc is invalid"); + "[window][resetAspectRatio]msg: Number of parameters is invalid"); } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][resetAspectRatio]msg: WindowToken is nullptr"); + "[window][resetAspectRatio]msg: Window is nullptr"); } if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { @@ -6839,7 +6839,7 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { task->Reject(env, JsErrUtils::CreateJsError(env, - WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resetAspectRatio]msg: Failed.")); + WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][resetAspectRatio]msg: window is nullptr")); return; } WMError ret = window->ResetAspectRatio(); @@ -6913,7 +6913,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WindowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][maximize]msg: WindowToken is nullptr"); + "[window][maximize]msg: window is nullptr"); } if (!(WindowHelper::IsMainWindow(windowToken_->GetType()) || windowToken_->IsSubWindowMaximizeSupported())) { -- Gitee From dfb39d90cdf946c0998632de967377a778c72dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Wed, 20 Aug 2025 14:17:25 +0800 Subject: [PATCH 089/241] change1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../unittest/scene_session_manager_test4.cpp | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 8da2531d47..953b5a9b3f 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -1545,14 +1545,60 @@ HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask01, TestSize.Level1) ssm_->SetDisplayBrightness(999); sptr sceneSession = nullptr; + ssm_->PostBrightnessTask(sceneSession, -1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); ssm_->PostBrightnessTask(sceneSession, 1.0f); - EXPECT_EQ(ssm_->GetDisplayBrightness(), 999); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); SessionInfo sessionInfo; sessionInfo.isSystem_ = false; sessionInfo.bundleName_ = "bundleName"; sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - sceneSession->SetSessionState() + sceneSession->SetSessionState(SessionState::STATE_DISCONNECT) + ssm_->PostBrightnessTask(sceneSession, -1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); + ssm_->PostBrightnessTask(sceneSession, 1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); + + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND) + ssm_->PostBrightnessTask(sceneSession, -1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), -1.0f); + ssm_->PostBrightnessTask(sceneSession, 1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 1.0f); +} + +/** + * @tc.name: PostBrightnessTask02 + * @tc.desc: PostBrightnessTask + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask01, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + ssm_->SetDisplayBrightness(999); + + sptr sceneSession = nullptr; + ssm_->PostBrightnessTask(sceneSession, -1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); + ssm_->PostBrightnessTask(sceneSession, 1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); + + SessionInfo sessionInfo; + sessionInfo.isSystem_ = false; + sessionInfo.bundleName_ = "bundleName"; + sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + sceneSession->SetSessionState(SessionState::STATE_DISCONNECT) + ssm_->PostBrightnessTask(sceneSession, -1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); + ssm_->PostBrightnessTask(sceneSession, 1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); + + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND) + ssm_->PostBrightnessTask(sceneSession, -1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); + ssm_->PostBrightnessTask(sceneSession, 1.0f); + EXPECT_EQ(ssm_->GetDisplayBrightness(), 1.0f); } /** -- Gitee From 913b4a9bd00d2558d4ac65e34a22a7924877a34b Mon Sep 17 00:00:00 2001 From: l30033162 Date: Wed, 20 Aug 2025 14:40:52 +0800 Subject: [PATCH 090/241] =?UTF-8?q?PC=E5=A4=9A=E7=94=A8=E6=88=B7=E5=88=87?= =?UTF-8?q?=E6=8D=A2=EF=BC=8COOBE=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30033162 --- .../screen_session_manager/src/screen_session_manager.cpp | 4 +++- 1 file changed, 3 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 53392c54e4..8d822beac8 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -8578,6 +8578,8 @@ void ScreenSessionManager::SetClient(const sptr& cl userSwitching_ = false; } } + { + std::unique_lock lock(oldScbPidsMutex_); SetClientProxy(client); auto userId = GetUserIdByCallingUid(); auto newScbPid = IPCSkeleton::GetCallingPid(); @@ -8592,6 +8594,7 @@ void ScreenSessionManager::SetClient(const sptr& cl NotifyClientProxyUpdateFoldDisplayMode(GetFoldDisplayMode()); SetClientInner(); SwitchScbNodeHandle(userId, newScbPid, true); + } AddScbClientDeathRecipient(client, newScbPid); static bool isNeedSwitchScreen = FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() || @@ -8620,7 +8623,6 @@ void ScreenSessionManager::SwitchScbNodeHandle(int32_t newUserId, int32_t newScb TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str()); screenEventTracker_.RecordEvent(oss.str()); - std::unique_lock lock(oldScbPidsMutex_); if (currentScbPId_ != INVALID_SCB_PID) { auto pidIter = std::find(oldScbPids_.begin(), oldScbPids_.end(), currentScbPId_); if (pidIter == oldScbPids_.end() && currentScbPId_ > 0) { -- Gitee From 9b16359ef70e8a3fb0d509017f79cd0fc014fcb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Wed, 20 Aug 2025 15:02:27 +0800 Subject: [PATCH 091/241] change1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../test/unittest/scene_session_manager_test4.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 953b5a9b3f..ea7e6cf152 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -1554,13 +1554,13 @@ HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask01, TestSize.Level1) sessionInfo.isSystem_ = false; sessionInfo.bundleName_ = "bundleName"; sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - sceneSession->SetSessionState(SessionState::STATE_DISCONNECT) + sceneSession->SetSessionState(SessionState::STATE_DISCONNECT); ssm_->PostBrightnessTask(sceneSession, -1.0f); EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); ssm_->PostBrightnessTask(sceneSession, 1.0f); EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); - sceneSession->SetSessionState(SessionState::STATE_FOREGROUND) + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); ssm_->PostBrightnessTask(sceneSession, -1.0f); EXPECT_EQ(ssm_->GetDisplayBrightness(), -1.0f); ssm_->PostBrightnessTask(sceneSession, 1.0f); @@ -1572,7 +1572,7 @@ HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask01, TestSize.Level1) * @tc.desc: PostBrightnessTask * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask01, TestSize.Level1) +HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask02, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; @@ -1588,13 +1588,13 @@ HWTEST_F(SceneSessionManagerTest4, PostBrightnessTask01, TestSize.Level1) sessionInfo.isSystem_ = false; sessionInfo.bundleName_ = "bundleName"; sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - sceneSession->SetSessionState(SessionState::STATE_DISCONNECT) + sceneSession->SetSessionState(SessionState::STATE_DISCONNECT); ssm_->PostBrightnessTask(sceneSession, -1.0f); EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); ssm_->PostBrightnessTask(sceneSession, 1.0f); EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); - sceneSession->SetSessionState(SessionState::STATE_FOREGROUND) + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); ssm_->PostBrightnessTask(sceneSession, -1.0f); EXPECT_EQ(ssm_->GetDisplayBrightness(), 999.0f); ssm_->PostBrightnessTask(sceneSession, 1.0f); -- Gitee From 054afb0b2b1f560abdd15d3ff2bcbd318bce80e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Wed, 20 Aug 2025 15:06:01 +0800 Subject: [PATCH 092/241] chaneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- window_scene/test/unittest/scene_session_manager_test8.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/test/unittest/scene_session_manager_test8.cpp b/window_scene/test/unittest/scene_session_manager_test8.cpp index 5162e883ac..f1e9f793cb 100644 --- a/window_scene/test/unittest/scene_session_manager_test8.cpp +++ b/window_scene/test/unittest/scene_session_manager_test8.cpp @@ -560,6 +560,7 @@ HWTEST_F(SceneSessionManagerTest8, SetBrightness, TestSize.Level1) sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); EXPECT_NE(nullptr, sceneSession); sceneSession->persistentId_ = 2024; + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); ssm_->SetDisplayBrightness(3.14f); std::shared_ptr pipeEventHandler = nullptr; -- Gitee From f0ec2ea5417519c08d74eee857443c4977d88e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Wed, 20 Aug 2025 15:24:54 +0800 Subject: [PATCH 093/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8pad=E6=A8=A1=E5=BC=8F=E5=88=87=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E5=90=8E=EF=BC=8C=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=8F=98=E5=8C=96=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- window_scene/session/host/src/session.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 6ffc701025..3ec3016fef 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3345,6 +3345,7 @@ WSError Session::SetCompatibleModeProperty(const sptr co TLOGE(WmsLogTag::WMS_COMPAT, "id: %{public}d property is nullptr", persistentId_); return WSError::WS_ERROR_NULLPTR; } + property->SetCompatibleModeProperty(compatibleModeProperty); if (!sessionStage_) { TLOGE(WmsLogTag::WMS_COMPAT, "sessionStage is null"); -- Gitee From f6e5eeaacab5b1d63a9e07d6ba3d52837e562656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Wed, 20 Aug 2025 15:31:15 +0800 Subject: [PATCH 094/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8pad=E6=A8=A1=E5=BC=8F=E5=88=87=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E5=90=8E=EF=BC=8C=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=8F=98=E5=8C=96=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- window_scene/session/host/src/session.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 3ec3016fef..7b35ae437e 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3345,8 +3345,10 @@ WSError Session::SetCompatibleModeProperty(const sptr co TLOGE(WmsLogTag::WMS_COMPAT, "id: %{public}d property is nullptr", persistentId_); return WSError::WS_ERROR_NULLPTR; } - property->SetCompatibleModeProperty(compatibleModeProperty); + if (compatibleModeProperty && compatibleModeProperty->IsDragResizeDisabled()) { + property->SetDragEnabled(false); + } if (!sessionStage_) { TLOGE(WmsLogTag::WMS_COMPAT, "sessionStage is null"); return WSError::WS_ERROR_NULLPTR; -- Gitee From 3bb4378bfa03a6537aa1b314ea2d0e78dadb591b Mon Sep 17 00:00:00 2001 From: jingbotao Date: Sat, 16 Aug 2025 19:28:31 +0800 Subject: [PATCH 095/241] =?UTF-8?q?=E8=B7=A8=E5=B1=8F=E6=8B=93=E5=B1=95?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E6=8C=82=E8=BD=BD=E8=8A=82=E7=82=B9=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: jingbotao --- .../session/host/include/main_session.h | 3 +- .../session/host/include/scene_session.h | 12 ++-- .../session/host/include/sub_session.h | 3 +- .../session/host/src/main_session.cpp | 5 +- .../session/host/src/scene_session.cpp | 65 ++++++++++++------- window_scene/session/host/src/sub_session.cpp | 41 ++++++++---- .../include/scene_session_manager.h | 7 +- .../src/scene_session_manager.cpp | 8 +++ .../layout/main_session_layout_test.cpp | 16 ++--- .../layout/scene_session_layout_test.cpp | 31 +++++++++ .../layout/sub_session_layout_test.cpp | 23 +++---- 11 files changed, 140 insertions(+), 74 deletions(-) diff --git a/window_scene/session/host/include/main_session.h b/window_scene/session/host/include/main_session.h index ba20880777..a62e60df20 100644 --- a/window_scene/session/host/include/main_session.h +++ b/window_scene/session/host/include/main_session.h @@ -95,8 +95,7 @@ private: void SetSubWindowBoundsDuringCross(const WSRect& parentRect, bool isGlobal, bool needFlush) override; void NotifySubSessionRectChangeByAnchor(const WSRect& parentRect, SizeChangeReason reason = SizeChangeReason::UNDEFINED, DisplayId displayId = DISPLAY_ID_INVALID) override; - void HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason reason, - const sptr& screenSession) override; + void HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason reason, DisplayId displayId) override; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_MAIN_SESSION_H diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 9d327a9443..9da9634237 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -147,6 +147,9 @@ using NotifyAnimateToFunc = std::function>&()>; using GetFbPanelWindowIdFunc = std::function; +using FindScenePanelRsNodeByZOrderFunc = std::function(DisplayId displayId, + uint32_t targetZOrder)>; + struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; uint32_t callingTokenId { 0 }; @@ -263,8 +266,7 @@ public: void HandleCrossMoveTo(WSRect& globalRect); virtual void HandleCrossMoveToSurfaceNode(WSRect& globalRect) {} virtual bool IsNeedCrossDisplayRendering() const { return false; } - virtual void HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason reason, - const sptr& screenSession) {} + virtual void HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason reason, DisplayId displayId) {} virtual void SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool needFlush = true); virtual void OpenKeyboardSyncTransaction() {} @@ -302,6 +304,7 @@ public: void SetFloatingScale(float floatingScale) override; WSError RaiseAboveTarget(int32_t subWindowId) override; WSError RaiseMainWindowAboveTarget(int32_t targetId) override; + std::shared_ptr GetWindowDragMoveMountedNode(DisplayId displayId, uint32_t targetZOrder); /* * PiP Window @@ -783,6 +786,7 @@ public: void ResetCompatibleModeDragScaleFlags(); void RegisterAppHookWindowInfoFunc(GetHookWindowInfoFunc&& func); WMError GetAppHookWindowInfoFromServer(HookWindowInfo& hookWindowInfo) override; + void SetFindScenePanelRsNodeByZOrderFunc(FindScenePanelRsNodeByZOrderFunc&& func); /* * Gesture Back @@ -962,6 +966,7 @@ protected: bool isFollowParentLayout_ = false; NotifyWindowAnchorInfoChangeFunc onWindowAnchorInfoChangeFunc_ = nullptr; WindowAnchorInfo windowAnchorInfo_; + FindScenePanelRsNodeByZOrderFunc FindScenePanelRsNodeByZOrderFunc_; int32_t cloneNodeCount_ = 0; virtual void NotifySubSessionRectChangeByAnchor(const WSRect& parentRect, @@ -1237,8 +1242,7 @@ private: WSError UpdateRectForDrag(const WSRect& rect); void UpdateSessionRectPosYFromClient(SizeChangeReason reason, DisplayId& configDisplayId, WSRect& rect); void HandleSubSessionSurfaceNode(bool isAdd, DisplayId draggingOrMovingParentDisplayId); - virtual void HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason reason, - const sptr& screenSession) {} + virtual void HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason reason, DisplayId displayId) {} virtual void AddSurfaceNodeToScreen(DisplayId draggingOrMovingParentDisplayId) {} virtual void RemoveSurfaceNodeFromScreen() {} void SetParentRect(); diff --git a/window_scene/session/host/include/sub_session.h b/window_scene/session/host/include/sub_session.h index a46f24497a..045f9cf945 100644 --- a/window_scene/session/host/include/sub_session.h +++ b/window_scene/session/host/include/sub_session.h @@ -37,8 +37,7 @@ public: bool IsNeedCrossDisplayRendering() const override; void HandleCrossMoveToSurfaceNode(WSRect& globalRect) override; std::set GetNewDisplayIdsDuringMoveTo(WSRect& newRect); - void HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason reason, - const sptr& screenSession) override; + void HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason reason, DisplayId displayId) override; void SetParentSessionCallback(NotifySetParentSessionFunc&& func) override; WMError NotifySetParentSession(int32_t oldParentWindowId, int32_t newParentWindowId) override; diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index f45e13b645..221fbc14b4 100644 --- a/window_scene/session/host/src/main_session.cpp +++ b/window_scene/session/host/src/main_session.cpp @@ -413,12 +413,11 @@ void MainSession::NotifySubSessionRectChangeByAnchor(const WSRect& parentRect, } } -void MainSession::HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason reason, - const sptr& screenSession) +void MainSession::HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason reason, DisplayId displayId) { for (const auto& subSession : GetSubSession()) { if (subSession && subSession->GetWindowAnchorInfo().isAnchorEnabled_ && subSession->IsSessionForeground()) { - subSession->HandleCrossSurfaceNodeByWindowAnchor(reason, screenSession); + subSession->HandleCrossSurfaceNodeByWindowAnchor(reason, displayId); } } } diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 932968ca90..29c000f25a 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -102,6 +102,12 @@ bool CheckIfRectElementIsTooLarge(const WSRect& rect) } return false; } + +bool isMainOrExtendScreenMode(const ScreenSourceMode& screenSourceMode) +{ + return screenSourceMode == ScreenSourceMode::SCREEN_MAIN || + screenSourceMode == ScreenSourceMode::SCREEN_EXTEND; +} } // namespace MaximizeMode SceneSession::maximizeMode_ = MaximizeMode::MODE_RECOVER; @@ -4223,6 +4229,16 @@ WSError SceneSession::KeyFrameAnimateEnd() return WSError::WS_OK; } +std::shared_ptr SceneSession::GetWindowDragMoveMountedNode(DisplayId displayId, + uint32_t targetZOrder) +{ + if (!FindScenePanelRsNodeByZOrderFunc_) { + TLOGE(WmsLogTag::WMS_LAYOUT, "FindScenePanelRsNodeByZOrderFunc_ is null"); + return nullptr; + } + return FindScenePanelRsNodeByZOrderFunc_(displayId, targetZOrder); +} + /** @note @window.drag */ void SceneSession::HandleMoveDragSurfaceNode(SizeChangeReason reason) { @@ -4237,6 +4253,7 @@ void SceneSession::HandleMoveDragSurfaceNode(SizeChangeReason reason) TLOGE(WmsLogTag::WMS_LAYOUT, "startScreenSession is null, startDisplayId: %{public}" PRIu64, startDisplayId); return; } + bool isStartScreenMainOrExtend = isMainOrExtendScreenMode(startScreenSession->GetSourceMode()); if (reason == SizeChangeReason::DRAG || reason == SizeChangeReason::DRAG_MOVE) { for (const auto displayId : moveDragController_->GetNewAddedDisplayIdsDuringMoveDrag()) { if (displayId == moveDragController_->GetMoveDragStartDisplayId()) { @@ -4247,17 +4264,18 @@ void SceneSession::HandleMoveDragSurfaceNode(SizeChangeReason reason) TLOGD(WmsLogTag::WMS_LAYOUT, "ScreenSession is null"); continue; } - bool isStartScreenMainOrExtend = startScreenSession->GetSourceMode() == ScreenSourceMode::SCREEN_MAIN - || startScreenSession->GetSourceMode() == ScreenSourceMode::SCREEN_EXTEND; - bool isDestScreenMainOrExtend = screenSession->GetSourceMode() == ScreenSourceMode::SCREEN_MAIN - || screenSession->GetSourceMode() == ScreenSourceMode::SCREEN_EXTEND; + bool isDestScreenMainOrExtend = isMainOrExtendScreenMode(screenSession->GetSourceMode()); // Not main to extend or extend to main or extend to extend, no need to add cross parent child if (!(isStartScreenMainOrExtend && isDestScreenMainOrExtend)) { TLOGD(WmsLogTag::WMS_LAYOUT, "No need to add cross-parent child elements for out-of-scope situations, " "DisplayId: %{public}" PRIu64, displayId); continue; } - + auto dragMoveMountedNode = GetWindowDragMoveMountedNode(displayId, this->GetZOrder()); + if (dragMoveMountedNode == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "dragMoveMountedNode is null"); + continue; + } { AutoRSTransaction trans(movedSurfaceNode->GetRSUIContext()); movedSurfaceNode->SetPositionZ(MOVE_DRAG_POSITION_Z); @@ -4265,37 +4283,29 @@ void SceneSession::HandleMoveDragSurfaceNode(SizeChangeReason reason) } { - AutoRSTransaction trans(screenSession->GetRSUIContext()); - TLOGI(WmsLogTag::WMS_LAYOUT, "Add window to display: %{public}" PRIu64, displayId); - screenSession->GetDisplayNode()->AddCrossScreenChild(movedSurfaceNode, -1, true); + AutoRSTransaction trans(dragMoveMountedNode->GetRSUIContext()); + dragMoveMountedNode->AddCrossScreenChild(movedSurfaceNode, -1, true); } - HandleSubSessionSurfaceNodeByWindowAnchor(reason, screenSession); + HandleSubSessionSurfaceNodeByWindowAnchor(reason, displayId); + TLOGI(WmsLogTag::WMS_LAYOUT, "Add window to display: %{public}" PRIu64 "persistentId: %{public}d", + displayId, GetPersistentId()); } } else if (reason == SizeChangeReason::DRAG_END) { for (const auto displayId : moveDragController_->GetDisplayIdsDuringMoveDrag()) { if (displayId == moveDragController_->GetMoveDragStartDisplayId()) { continue; } - auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSessionById(displayId); - if (screenSession == nullptr) { - TLOGD(WmsLogTag::WMS_LAYOUT, "ScreenSession is null"); - continue; - } - bool isStartScreenMainOrExtend = startScreenSession->GetSourceMode() == ScreenSourceMode::SCREEN_MAIN - || startScreenSession->GetSourceMode() == ScreenSourceMode::SCREEN_EXTEND; - bool isDestScreenMainOrExtend = screenSession->GetSourceMode() == ScreenSourceMode::SCREEN_MAIN - || screenSession->GetSourceMode() == ScreenSourceMode::SCREEN_EXTEND; - // Not main to extend or extend to main or extend to extend, no need to add cross parent child - if (!(isStartScreenMainOrExtend && isDestScreenMainOrExtend)) { - TLOGD(WmsLogTag::WMS_LAYOUT, "No need to add cross-parent child elements for out-of-scope situations, " - "DisplayId: %{public}" PRIu64, displayId); + auto dragMoveMountedNode = GetWindowDragMoveMountedNode(displayId, this->GetZOrder()); + if (dragMoveMountedNode == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "dragMoveMountedNode is null"); continue; } movedSurfaceNode->SetPositionZ(moveDragController_->GetOriginalPositionZ()); - screenSession->GetDisplayNode()->RemoveCrossScreenChild(movedSurfaceNode); + dragMoveMountedNode->RemoveCrossScreenChild(movedSurfaceNode); movedSurfaceNode->SetIsCrossNode(false); - TLOGI(WmsLogTag::WMS_LAYOUT, "Remove window from display: %{public}" PRIu64, displayId); - HandleSubSessionSurfaceNodeByWindowAnchor(reason, screenSession); + HandleSubSessionSurfaceNodeByWindowAnchor(reason, displayId); + TLOGI(WmsLogTag::WMS_LAYOUT, "Remove window from display: %{public}" PRIu64 "persistentId: %{public}d", + displayId, GetPersistentId()); } } } @@ -9250,4 +9260,9 @@ WSError SceneSession::SetFrameRectForPartialZoomInInner(const Rect& frameRect) TLOGI(WmsLogTag::WMS_ANIMATION, "frameRect: %{public}s", frameRect.ToString().c_str()); return WSError::WS_OK; } + +void SceneSession::SetFindScenePanelRsNodeByZOrderFunc(FindScenePanelRsNodeByZOrderFunc&& func) +{ + FindScenePanelRsNodeByZOrderFunc_ = std::move(func); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index 307d487866..e76dd251f2 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -361,34 +361,39 @@ WMError SubSession::NotifySetParentSession(int32_t oldParentWindowId, int32_t ne }, __func__); } -void SubSession::HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason reason, const sptr& screenSession) +void SubSession::HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason reason, DisplayId displayId) { - if (!screenSession) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, ScreenSession is null", GetPersistentId()); - return; - } auto surfaceNode = GetSurfaceNodeForMoveDrag(); if (!surfaceNode) { TLOGE(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, SurfaceNode is null", GetPersistentId()); return; } - DisplayId displayId = screenSession->GetDisplayId(); if (reason == SizeChangeReason::DRAG || reason == SizeChangeReason::DRAG_MOVE) { + auto dragMoveMountedNode = GetWindowDragMoveMountedNode(displayId, this->GetZOrder()); + if (dragMoveMountedNode == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "dragMoveMountedNode is null"); + return; + } { AutoRSTransaction trans(surfaceNode->GetRSUIContext()); surfaceNode->SetPositionZ(GetZOrder()); surfaceNode->SetIsCrossNode(true); } { - AutoRSTransaction trans(screenSession->GetRSUIContext()); - screenSession->GetDisplayNode()->AddCrossScreenChild(surfaceNode, SUFFIX_INDEX, true); + AutoRSTransaction trans(dragMoveMountedNode->GetRSUIContext()); + dragMoveMountedNode->AddCrossScreenChild(surfaceNode, SUFFIX_INDEX, true); } cloneNodeCountDuringCross_.fetch_add(1); TLOGI(WmsLogTag::WMS_LAYOUT, "Add sub window to display:%{public}" PRIu64 " persistentId:%{public}d, " "cloneNodeCountDuringCross:%{public}d", displayId, GetPersistentId(), cloneNodeCountDuringCross_.load()); } else if (reason == SizeChangeReason::DRAG_END) { surfaceNode->SetPositionZ(moveDragController_->GetOriginalPositionZ()); - screenSession->GetDisplayNode()->RemoveCrossScreenChild(surfaceNode); + auto dragMoveMountedNode = GetWindowDragMoveMountedNode(displayId, this->GetZOrder()); + if (dragMoveMountedNode == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "dragMoveMountedNode is null"); + return; + } + dragMoveMountedNode->RemoveCrossScreenChild(surfaceNode); surfaceNode->SetIsCrossNode(false); cloneNodeCountDuringCross_.fetch_sub(1); TLOGI(WmsLogTag::WMS_LAYOUT, "Remove sub window from display:%{public}" PRIu64 " persistentId:%{public}d, " @@ -451,10 +456,15 @@ void SubSession::HandleCrossMoveToSurfaceNode(WSRect& globalRect) TLOGD(WmsLogTag::WMS_LAYOUT, "virtual screen, no need to add cross parent child"); continue; } + auto dragMoveMountedNode = GetWindowDragMoveMountedNode(displayId, this->GetZOrder()); + if (dragMoveMountedNode == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "dragMoveMountedNode is null"); + continue; + } movedSurfaceNode->SetPositionZ(GetZOrder()); { - AutoRSTransaction trans(screenSession->GetRSUIContext()); - screenSession->GetDisplayNode()->AddCrossScreenChild(movedSurfaceNode, SUFFIX_INDEX, true); + AutoRSTransaction trans(dragMoveMountedNode->GetRSUIContext()); + dragMoveMountedNode->AddCrossScreenChild(movedSurfaceNode, SUFFIX_INDEX, true); } cloneNodeCount_++; movedSurfaceNode->SetIsCrossNode(true); @@ -519,10 +529,15 @@ void SubSession::AddSurfaceNodeToScreen(DisplayId draggingOrMovingParentDisplayI TLOGD(WmsLogTag::WMS_LAYOUT, "virtual screen, no need to add cross parent child"); continue; } + auto dragMoveMountedNode = GetWindowDragMoveMountedNode(displayId, this->GetZOrder()); + if (dragMoveMountedNode == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "dragMoveMountedNode is null"); + continue; + } currSurfacedNode->SetPositionZ(GetZOrder()); { - AutoRSTransaction trans(screenSession->GetRSUIContext()); - screenSession->GetDisplayNode()->AddCrossScreenChild(currSurfacedNode, SUFFIX_INDEX, true); + AutoRSTransaction trans(dragMoveMountedNode->GetRSUIContext()); + dragMoveMountedNode->AddCrossScreenChild(currSurfacedNode, SUFFIX_INDEX, true); } cloneNodeCount_++; currSurfacedNode->SetIsCrossNode(true); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index e9ba28d36e..e7c548e665 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -167,6 +167,8 @@ using KioskModeChangeFunc = std::function& property)>; using NotifyRecoverStateChangeFunc = std::function; +using FindScenePanelRsNodeByZOrderFunc = std::function(DisplayId screenId, + uint32_t targetZOrder)>; class AppAnrListener : public IRemoteStub { public: @@ -235,6 +237,7 @@ public: void SetSCBFocusChangeListener(const NotifyDiffSCBAfterUpdateFocusFunc&& func); void SetCallingSessionIdSessionListenser(const ProcessCallingSessionIdChangeFunc& func); void SetDumpUITreeFunc(const DumpUITreeFunc& func); + void SetFindScenePanelRsNodeByZOrderFunc(FindScenePanelRsNodeByZOrderFunc&& func); const AppWindowSceneConfig& GetWindowSceneConfig() const; /* @@ -1207,9 +1210,9 @@ private: ProcessCloseTargetFloatWindowFunc closeTargetFloatWindowFunc_; SetForegroundWindowNumFunc setForegroundWindowNumFunc_; MinimizeByWindowIdFunc minimizeByWindowIdFunc_; - + FindScenePanelRsNodeByZOrderFunc FindScenePanelRsNodeByZOrderFunc_; AppWindowSceneConfig appWindowSceneConfig_; - + /* * Window Recover */ diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c48cdaca15..c589c60167 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2426,6 +2426,9 @@ sptr SceneSessionManager::CreateSceneSession(const SessionInfo& se sceneSession->RegisterGetFbPanelWindowIdFunc([this](uint32_t& windowId) { return this->GetFbPanelWindowId(windowId); }); + sceneSession->SetFindScenePanelRsNodeByZOrderFunc([this](uint64_t screenId, uint32_t targetZOrder) { + return this->FindScenePanelRsNodeByZOrderFunc_(screenId, targetZOrder); + }); DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED; GetAppDragResizeType(sessionInfo.bundleName_, dragResizeType); sceneSession->SetAppDragResizeType(dragResizeType); @@ -6945,6 +6948,11 @@ void SceneSessionManager::SetStatusBarDefaultVisibilityPerDisplay(DisplayId disp }, __func__); } +void SceneSessionManager::SetFindScenePanelRsNodeByZOrderFunc(FindScenePanelRsNodeByZOrderFunc&& func) +{ + FindScenePanelRsNodeByZOrderFunc_ = std::move(func); +} + bool SceneSessionManager::GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId) { return statusBarDefaultVisibilityPerDisplay_.count(displayId) != 0 ? diff --git a/window_scene/test/unittest/layout/main_session_layout_test.cpp b/window_scene/test/unittest/layout/main_session_layout_test.cpp index 721d8fc5cb..c7f19b3575 100644 --- a/window_scene/test/unittest/layout/main_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/main_session_layout_test.cpp @@ -144,29 +144,25 @@ HWTEST_F(MainSessionLayoutTest, HandleSubSessionSurfaceNodeByWindowAnchor, TestS sptr subSession = sptr::MakeSptr(info, nullptr); mainSession->subSession_.emplace_back(nullptr); mainSession->subSession_.emplace_back(subSession); - ScreenSessionConfig config = { - .screenId = 100, - .rsId = 101, - .name = "OpenHarmony", - }; - sptr screenSession = - sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); auto surfaceNode = CreateRSSurfaceNode(); ASSERT_NE(nullptr, surfaceNode); subSession->SetSurfaceNode(surfaceNode); + subSession->SetFindScenePanelRsNodeByZOrderFunc([this](uint64_t screenId, uint32_t targetZOrder) { + return CreateRSSurfaceNode(); + }); subSession->state_ = SessionState::STATE_FOREGROUND; subSession->windowAnchorInfo_.isAnchorEnabled_ = false; subSession->cloneNodeCountDuringCross_.store(0); - mainSession->HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG, screenSession); + mainSession->HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG, 0); EXPECT_EQ(subSession->cloneNodeCountDuringCross_, 0); subSession->windowAnchorInfo_.isAnchorEnabled_ = true; - mainSession->HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG, screenSession); + mainSession->HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG, 0); EXPECT_EQ(subSession->cloneNodeCountDuringCross_, 1); subSession->state_ = SessionState::STATE_BACKGROUND; - mainSession->HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG_END, screenSession); + mainSession->HandleSubSessionSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG_END, 0); EXPECT_EQ(subSession->cloneNodeCountDuringCross_, 1); } } // namespace diff --git a/window_scene/test/unittest/layout/scene_session_layout_test.cpp b/window_scene/test/unittest/layout/scene_session_layout_test.cpp index eac8ed51c9..ec49baf019 100644 --- a/window_scene/test/unittest/layout/scene_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/scene_session_layout_test.cpp @@ -44,6 +44,7 @@ public: void TearDown() override; private: + RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); sptr mockSessionStage_ = nullptr; }; @@ -58,6 +59,14 @@ void SceneSessionLayoutTest::SetUp() void SceneSessionLayoutTest::TearDown() {} +RSSurfaceNode::SharedPtr MainSessionLayoutTest::CreateRSSurfaceNode() +{ + struct RSSurfaceNodeConfig rsSurfaceNodeConfig; + rsSurfaceNodeConfig.SurfaceNodeName = "WindowSessionTestSurfaceNode"; + auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig); + return surfaceNode; +} + namespace { /** * @tc.name: UpdateRect01 @@ -1135,6 +1144,28 @@ HWTEST_F(SceneSessionLayoutTest, RegisterAppHookWindowInfoFunc, TestSize.Level1) sceneSession->RegisterAppHookWindowInfoFunc(nullptr); ASSERT_NE(sceneSession->getHookWindowInfoFunc_, nullptr); } + +/** + * @tc.name: GetWindowDragMoveMountedNode01 + * @tc.desc: GetWindowDragMoveMountedNode + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionLayoutTest, GetWindowDragMoveMountedNode01, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "GetWindowDragMoveMountedNode"; + info.bundleName_ = "GetWindowDragMoveMountedNode"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + auto rsNode = session->GetWindowDragMoveMountedNode(std::numeric_limits::max(), 0); + EXPECT_EQ(rsNode, nullptr); + sceneSession->SetFindScenePanelRsNodeByZOrderFunc([this](uint64_t screenId, uint32_t targetZOrder) { + return CreateRSSurfaceNode(); + }); + rsNode = session->GetWindowDragMoveMountedNode(0, 0); + EXPECT_NE(rsNode, nullptr); + +} + } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/layout/sub_session_layout_test.cpp b/window_scene/test/unittest/layout/sub_session_layout_test.cpp index 5d4a0b0c97..b3f01e510c 100644 --- a/window_scene/test/unittest/layout/sub_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/sub_session_layout_test.cpp @@ -70,15 +70,12 @@ HWTEST_F(SubSessionLayoutTest, HandleCrossSurfaceNodeByWindowAnchor, TestSize.Le info.bundleName_ = "HandleCrossSurfaceNodeByWindowAnchor"; sptr sceneSession = sptr::MakeSptr(info, nullptr); sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); - sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::UNDEFINED, nullptr); - ScreenSessionConfig config = { - .screenId = 100, - .rsId = 101, - .name = "OpenHarmony", - }; - sptr screenSession = - sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); - sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::UNDEFINED, screenSession); + sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::UNDEFINED, + std::numeric_limits::max()); + sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::UNDEFINED, 0); + sceneSession->SetFindScenePanelRsNodeByZOrderFunc([this](uint64_t screenId, uint32_t targetZOrder) { + return CreateRSSurfaceNode(); + }); struct RSSurfaceNodeConfig rsSurfaceNodeConfig; rsSurfaceNodeConfig.SurfaceNodeName = info.abilityName_; RSSurfaceNodeType rsSurfaceNodeType = RSSurfaceNodeType::DEFAULT; @@ -87,13 +84,13 @@ HWTEST_F(SubSessionLayoutTest, HandleCrossSurfaceNodeByWindowAnchor, TestSize.Le sceneSession->SetSurfaceNode(surfaceNode); sceneSession->cloneNodeCountDuringCross_.store(0); - sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG, screenSession); + sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG, 0); EXPECT_EQ(1, sceneSession->cloneNodeCountDuringCross_.load()); - sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG_MOVE, screenSession); + sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG_MOVE, 0); EXPECT_EQ(2, sceneSession->cloneNodeCountDuringCross_.load()); - sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG_END, screenSession); + sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::DRAG_END, 0); EXPECT_EQ(1, sceneSession->cloneNodeCountDuringCross_.load()); - sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::UNDEFINED, screenSession); + sceneSession->HandleCrossSurfaceNodeByWindowAnchor(SizeChangeReason::UNDEFINED, 0); EXPECT_EQ(1, sceneSession->cloneNodeCountDuringCross_.load()); } } // namespace -- Gitee From 525545d4bb4d1c79fd426194cdf346e1c4245553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Wed, 20 Aug 2025 16:14:05 +0800 Subject: [PATCH 096/241] chanege MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../session_manager/src/scene_session_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index fa1d71ae0a..13327b882b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6152,7 +6152,7 @@ void SceneSessionManager::PostBrightnessTask(const sptr& sceneSess DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness }; - taskScheduler_->AddExportTask("DisplayPowerMgr:RestoreBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:RestoreBrightness", std::move(task)); } } else { wptr weakSceneSession(sceneSession); @@ -6175,7 +6175,7 @@ void SceneSessionManager::PostBrightnessTask(const sptr& sceneSess } SetDisplayBrightness(brightness); }; - taskScheduler_->AddExportTask("DisplayPowerMgr:OverrideBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:OverrideBrightness", std::move(task)); } #endif } @@ -6206,7 +6206,7 @@ WSError SceneSessionManager::UpdateBrightness(int32_t persistentId) DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); SetDisplayBrightness(UNDEFINED_BRIGHTNESS); // UNDEFINED_BRIGHTNESS means system default brightness }; - taskScheduler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_RestoreBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_RestoreBrightness", std::move(task)); brightnessSessionId_ = INVALID_WINDOW_ID; } } else { @@ -6217,7 +6217,7 @@ WSError SceneSessionManager::UpdateBrightness(int32_t persistentId) static_cast(brightness * MAX_BRIGHTNESS)); SetDisplayBrightness(brightness); }; - taskScheduler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_OverrideBrightness", task); + taskScheduler_->AddExportTask("DisplayPowerMgr:UpdateBrightness_OverrideBrightness", std::move(task)); } brightnessSessionId_ = sceneSession->GetPersistentId(); } -- Gitee From b0537ccaf7ec4341fcd44a593d3ca5eefb357ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Wed, 20 Aug 2025 16:35:12 +0800 Subject: [PATCH 097/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8pad=E6=A8=A1=E5=BC=8F=E5=88=87=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E5=90=8E=EF=BC=8C=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=8F=98=E5=8C=96=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- wm/src/window_session_impl.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0a62e589d2..0ea8dd0675 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2336,15 +2336,17 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) bool decorVisible = mode == WindowMode::WINDOW_MODE_FLOATING || mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY || (mode == WindowMode::WINDOW_MODE_FULLSCREEN && !property_->IsLayoutFullScreen()); - TLOGD(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d", decorVisible); + if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)); + (property_->GetIsPcAppInPad() && isSubWindow)) && + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); } if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { decorVisible = false; } + TLOGD(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d", decorVisible); uiContent->UpdateDecorVisible(decorVisible, isDecorEnable); return; } @@ -2371,7 +2373,8 @@ void WindowSessionImpl::UpdateDecorEnable(bool needNotify, WindowMode mode) if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)); + (property_->GetIsPcAppInPad() && isSubWindow)) && + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); } TLOGI(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d, id: %{public}d", decorVisible, GetPersistentId()); uiContent->UpdateDecorVisible(decorVisible, IsDecorEnable()); -- Gitee From 3ba19f01159f8a6a9529110af5bbb2cc32b3f06f Mon Sep 17 00:00:00 2001 From: l30033162 Date: Wed, 20 Aug 2025 17:04:43 +0800 Subject: [PATCH 098/241] =?UTF-8?q?[bugfix]PC=E5=A4=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=87=E6=8D=A2=EF=BC=8COOBE=E7=95=8C=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30033162 --- .../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 8d822beac8..65d6ee24bf 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -8595,7 +8595,7 @@ void ScreenSessionManager::SetClient(const sptr& cl SetClientInner(); SwitchScbNodeHandle(userId, newScbPid, true); } - AddScbClientDeathRecipient(client, newScbPid); + AddScbClientDeathRecipient(client, IPCSkeleton::GetCallingPid()); static bool isNeedSwitchScreen = FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() || FoldScreenStateInternel::IsSingleDisplayFoldDevice(); -- Gitee From 353bfaefc9cc1d5be6bf94211fb7dd334ff935b1 Mon Sep 17 00:00:00 2001 From: chengzhen Date: Wed, 20 Aug 2025 17:41:41 +0800 Subject: [PATCH 099/241] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengzhen --- wm/src/window_session_impl.cpp | 6 +++--- wm/test/unittest/window_session_impl_test.cpp | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0a62e589d2..23b760198f 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2342,9 +2342,6 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || (property_->GetIsPcAppInPad() && isSubWindow)); } - if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { - decorVisible = false; - } uiContent->UpdateDecorVisible(decorVisible, isDecorEnable); return; } @@ -2373,6 +2370,9 @@ void WindowSessionImpl::UpdateDecorEnable(bool needNotify, WindowMode mode) decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || (property_->GetIsPcAppInPad() && isSubWindow)); } + if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { + decorVisible = false; + } TLOGI(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d, id: %{public}d", decorVisible, GetPersistentId()); uiContent->UpdateDecorVisible(decorVisible, IsDecorEnable()); uiContent->NotifyWindowMode(mode); diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 66bb15a4be..7450023962 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -600,10 +600,6 @@ HWTEST_F(WindowSessionImplTest, UpdateDecorEnable, TestSize.Level1) mode = WindowMode::WINDOW_MODE_UNDEFINED; window->UpdateDecorEnable(false, mode); ASSERT_EQ(window->property_->windowMode_, mode); - mode = WindowMode::WINDOW_MODE_FULLSCREEN; - window->property_->compatibleModeProperty_->SetDisableDecorFullscreen(true); - window->UpdateDecorEnable(false, mode); - ASSERT_EQ(window->property_->windowMode_, mode); GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDecorEnable end"; } -- Gitee From c5e5574fb334edd5c03c7a1eac2352b605f26156 Mon Sep 17 00:00:00 2001 From: chengzhen Date: Wed, 20 Aug 2025 17:51:31 +0800 Subject: [PATCH 100/241] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengzhen --- wm/test/unittest/window_session_impl_test.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 7450023962..6a4ff80435 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -600,6 +600,12 @@ HWTEST_F(WindowSessionImplTest, UpdateDecorEnable, TestSize.Level1) mode = WindowMode::WINDOW_MODE_UNDEFINED; window->UpdateDecorEnable(false, mode); ASSERT_EQ(window->property_->windowMode_, mode); + mode = WindowMode::WINDOW_MODE_FULLSCREEN; + sptr compatibleModeProperty = sptr::MakeSptr(); + ASSERT_NE(compatibleModeProperty, nullptr); + compatibleModeProperty->SetDisableDecorFullscreen(true); + window->property_->SetCompatibleModeProperty(compatibleModeProperty); + window->UpdateDecorEnable(true, mode); GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDecorEnable end"; } -- Gitee From 748bcaa92383a4f31ea108128ae171cec77a67ce Mon Sep 17 00:00:00 2001 From: "chengchao.zhou" Date: Wed, 20 Aug 2025 18:31:40 +0800 Subject: [PATCH 101/241] reset windowEffect in freeMultiWindow Signed-off-by: chengchao.zhou --- .../common/include/window_session_property.h | 1 + .../include/scene_session_manager.h | 3 +- .../src/scene_session_manager.cpp | 37 +++++++++++++------ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 28a309f506..eba574194c 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -688,6 +688,7 @@ struct FreeMultiWindowConfig : public Parcelable { WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; uint32_t maxMainFloatingWindowNumber_ = 0; DragResizeType defaultDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED; + AppWindowSceneConfig appWindowSceneConfig_; virtual bool Marshalling(Parcel& parcel) const override { diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 902af226c8..d6b734c7ff 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -817,7 +817,8 @@ private: void LoadWindowParameter(); void ConfigWindowSceneXml(); void ConfigWindowSceneXml(const WindowSceneConfig::ConfigItem& config); - void ConfigWindowEffect(const WindowSceneConfig::ConfigItem& effectConfig); + void ConfigWindowEffect(const WindowSceneConfig::ConfigItem& effectConfig, + AppWindowSceneConfig& AppWindowSceneConfig); void ConfigWindowImmersive(const WindowSceneConfig::ConfigItem& immersiveConfig); void ConfigKeyboardAnimation(const WindowSceneConfig::ConfigItem& animationConfig); void ConfigDefaultKeyboardAnimation(KeyboardSceneAnimationConfig& animationIn, diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1a104d886f..e8335b6e74 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -672,7 +672,7 @@ void SceneSessionManager::ConfigWindowSceneXml() const auto& config = WindowSceneConfig::GetConfig(); WindowSceneConfig::ConfigItem item = config["windowEffect"]; if (item.IsMap()) { - ConfigWindowEffect(item); + ConfigWindowEffect(item, appWindowSceneConfig_); } item = config["decor"]; @@ -827,6 +827,10 @@ void SceneSessionManager::ConfigFreeMultiWindow() systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_ = static_cast(static_cast(param)); } + item = freeMultiWindowConfig["windowEffect"]; + if (item.IsMap()) { + ConfigWindowEffect(item, systemConfig_.freeMultiWindowConfig_.appWindowSceneConfig_); + } } } @@ -837,6 +841,10 @@ void SceneSessionManager::LoadFreeMultiWindowConfig(bool enable) systemConfig_.defaultWindowMode_ = freeMultiWindowConfig.defaultWindowMode_; systemConfig_.decorWindowModeSupportType_ = freeMultiWindowConfig.decorWindowModeSupportType_; systemConfig_.isSystemDecorEnable_ = freeMultiWindowConfig.isSystemDecorEnable_; + appWindowSceneConfig_.focusedShadow_ = freeMultiWindowConfig.appWindowSceneConfig_.focusedShadow_; + appWindowSceneConfig_.unfocusedShadow_ = freeMultiWindowConfig.appWindowSceneConfig_.unfocusedShadow_; + appWindowSceneConfig_.focusedShadowDark_ = freeMultiWindowConfig.appWindowSceneConfig_.focusedShadowDark_; + appWindowSceneConfig_.unfocusedShadowDark_ = freeMultiWindowConfig.appWindowSceneConfig_.unfocusedShadowDark_; } else { const auto& config = WindowSceneConfig::GetConfig(); auto item = config["decor"]; @@ -850,6 +858,10 @@ void SceneSessionManager::LoadFreeMultiWindowConfig(bool enable) param == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { systemConfig_.defaultWindowMode_ = static_cast(static_cast(param)); } + item = config["windowEffect"]; + if (item.IsMap()) { + ConfigWindowEffect(item, appWindowSceneConfig_); + } } systemConfig_.freeMultiWindowEnable_ = enable; rsInterface_.SetFreeMultiWindowStatus(enable); @@ -997,15 +1009,16 @@ static inline bool IsAtomicServiceFreeInstall(const SessionInfo& sessionInfo) (sessionInfo.want->GetFlags() & AAFwk::Want::FLAG_INSTALL_ON_DEMAND) == AAFwk::Want::FLAG_INSTALL_ON_DEMAND; } -void SceneSessionManager::ConfigWindowEffect(const WindowSceneConfig::ConfigItem& effectConfig) +void SceneSessionManager::ConfigWindowEffect(const WindowSceneConfig::ConfigItem& effectConfig, + AppWindowSceneConfig& appWindowSceneConfig) { AppWindowSceneConfig config; // config corner radius WindowSceneConfig::ConfigItem item = effectConfig["appWindows"]["cornerRadius"]; if (item.IsMap()) { if (ConfigAppWindowCornerRadius(item["float"], config.floatCornerRadius_)) { - appWindowSceneConfig_ = config; // set default corner radius of window by system config + appWindowSceneConfig.floatCornerRadius_ = config.floatCornerRadius_; systemConfig_.defaultCornerRadius_ = config.floatCornerRadius_; } } @@ -1014,34 +1027,34 @@ void SceneSessionManager::ConfigWindowEffect(const WindowSceneConfig::ConfigItem item = effectConfig["appWindows"]["shadow"]["focused"]; if (item.IsMap()) { if (ConfigAppWindowShadow(item, config.focusedShadow_)) { - appWindowSceneConfig_.focusedShadow_ = config.focusedShadow_; + appWindowSceneConfig.focusedShadow_ = config.focusedShadow_; } } item = effectConfig["appWindows"]["shadow"]["unfocused"]; if (item.IsMap()) { if (ConfigAppWindowShadow(item, config.unfocusedShadow_)) { - appWindowSceneConfig_.unfocusedShadow_ = config.unfocusedShadow_; + appWindowSceneConfig.unfocusedShadow_ = config.unfocusedShadow_; } } - AddAlphaToColor(appWindowSceneConfig_.focusedShadow_.alpha_, appWindowSceneConfig_.focusedShadow_.color_); - AddAlphaToColor(appWindowSceneConfig_.unfocusedShadow_.alpha_, appWindowSceneConfig_.unfocusedShadow_.color_); + AddAlphaToColor(appWindowSceneConfig.focusedShadow_.alpha_, appWindowSceneConfig.focusedShadow_.color_); + AddAlphaToColor(appWindowSceneConfig.unfocusedShadow_.alpha_, appWindowSceneConfig.unfocusedShadow_.color_); // config shadow in dark mode item = effectConfig["appWindows"]["shadowDark"]["focused"]; if (item.IsMap()) { if (ConfigAppWindowShadow(item, config.focusedShadowDark_)) { - appWindowSceneConfig_.focusedShadowDark_ = config.focusedShadowDark_; + appWindowSceneConfig.focusedShadowDark_ = config.focusedShadowDark_; } } item = effectConfig["appWindows"]["shadowDark"]["unfocused"]; if (item.IsMap()) { if (ConfigAppWindowShadow(item, config.unfocusedShadowDark_)) { - appWindowSceneConfig_.unfocusedShadowDark_ = config.unfocusedShadowDark_; + appWindowSceneConfig.unfocusedShadowDark_ = config.unfocusedShadowDark_; } } - AddAlphaToColor(appWindowSceneConfig_.focusedShadowDark_.alpha_, appWindowSceneConfig_.focusedShadowDark_.color_); - AddAlphaToColor(appWindowSceneConfig_.unfocusedShadowDark_.alpha_, - appWindowSceneConfig_.unfocusedShadowDark_.color_); + AddAlphaToColor(appWindowSceneConfig.focusedShadowDark_.alpha_, appWindowSceneConfig.focusedShadowDark_.color_); + AddAlphaToColor(appWindowSceneConfig.unfocusedShadowDark_.alpha_, + appWindowSceneConfig.unfocusedShadowDark_.color_); TLOGI(WmsLogTag::WMS_ATTRIBUTE, "successfully"); } -- Gitee From a53f690329a191ade1b28a0d03e4b6f0b2afee76 Mon Sep 17 00:00:00 2001 From: jingbotao Date: Wed, 20 Aug 2025 19:12:45 +0800 Subject: [PATCH 102/241] =?UTF-8?q?=E8=B7=A8=E5=B1=8F=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E6=8C=82=E8=BD=BD=E8=8A=82=E7=82=B9=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jingbotao --- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 8 ++++---- .../session_manager/include/scene_session_manager.h | 4 ++-- .../session_manager/src/scene_session_manager.cpp | 4 ++-- .../test/unittest/layout/scene_session_layout_test.cpp | 1 - 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 9da9634237..9dcbc86aba 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -966,7 +966,7 @@ protected: bool isFollowParentLayout_ = false; NotifyWindowAnchorInfoChangeFunc onWindowAnchorInfoChangeFunc_ = nullptr; WindowAnchorInfo windowAnchorInfo_; - FindScenePanelRsNodeByZOrderFunc FindScenePanelRsNodeByZOrderFunc_; + FindScenePanelRsNodeByZOrderFunc findScenePanelRsNodeByZOrderFunc_; int32_t cloneNodeCount_ = 0; virtual void NotifySubSessionRectChangeByAnchor(const WSRect& parentRect, diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 29c000f25a..a3b76823e2 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4232,11 +4232,11 @@ WSError SceneSession::KeyFrameAnimateEnd() std::shared_ptr SceneSession::GetWindowDragMoveMountedNode(DisplayId displayId, uint32_t targetZOrder) { - if (!FindScenePanelRsNodeByZOrderFunc_) { - TLOGE(WmsLogTag::WMS_LAYOUT, "FindScenePanelRsNodeByZOrderFunc_ is null"); + if (!findScenePanelRsNodeByZOrderFunc_) { + TLOGE(WmsLogTag::WMS_LAYOUT, "findScenePanelRsNodeByZOrderFunc_ is null"); return nullptr; } - return FindScenePanelRsNodeByZOrderFunc_(displayId, targetZOrder); + return findScenePanelRsNodeByZOrderFunc_(displayId, targetZOrder); } /** @note @window.drag */ @@ -9263,6 +9263,6 @@ WSError SceneSession::SetFrameRectForPartialZoomInInner(const Rect& frameRect) void SceneSession::SetFindScenePanelRsNodeByZOrderFunc(FindScenePanelRsNodeByZOrderFunc&& func) { - FindScenePanelRsNodeByZOrderFunc_ = std::move(func); + findScenePanelRsNodeByZOrderFunc_ = std::move(func); } } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index e7c548e665..a025727313 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1210,9 +1210,9 @@ private: ProcessCloseTargetFloatWindowFunc closeTargetFloatWindowFunc_; SetForegroundWindowNumFunc setForegroundWindowNumFunc_; MinimizeByWindowIdFunc minimizeByWindowIdFunc_; - FindScenePanelRsNodeByZOrderFunc FindScenePanelRsNodeByZOrderFunc_; + FindScenePanelRsNodeByZOrderFunc findScenePanelRsNodeByZOrderFunc_; AppWindowSceneConfig appWindowSceneConfig_; - + /* * Window Recover */ diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c589c60167..563af44be0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2427,7 +2427,7 @@ sptr SceneSessionManager::CreateSceneSession(const SessionInfo& se return this->GetFbPanelWindowId(windowId); }); sceneSession->SetFindScenePanelRsNodeByZOrderFunc([this](uint64_t screenId, uint32_t targetZOrder) { - return this->FindScenePanelRsNodeByZOrderFunc_(screenId, targetZOrder); + return this->findScenePanelRsNodeByZOrderFunc_(screenId, targetZOrder); }); DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED; GetAppDragResizeType(sessionInfo.bundleName_, dragResizeType); @@ -6950,7 +6950,7 @@ void SceneSessionManager::SetStatusBarDefaultVisibilityPerDisplay(DisplayId disp void SceneSessionManager::SetFindScenePanelRsNodeByZOrderFunc(FindScenePanelRsNodeByZOrderFunc&& func) { - FindScenePanelRsNodeByZOrderFunc_ = std::move(func); + findScenePanelRsNodeByZOrderFunc_ = std::move(func); } bool SceneSessionManager::GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId) diff --git a/window_scene/test/unittest/layout/scene_session_layout_test.cpp b/window_scene/test/unittest/layout/scene_session_layout_test.cpp index ec49baf019..16b5822b0a 100644 --- a/window_scene/test/unittest/layout/scene_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/scene_session_layout_test.cpp @@ -1163,7 +1163,6 @@ HWTEST_F(SceneSessionLayoutTest, GetWindowDragMoveMountedNode01, TestSize.Level1 }); rsNode = session->GetWindowDragMoveMountedNode(0, 0); EXPECT_NE(rsNode, nullptr); - } } // namespace -- Gitee From 4176a082a899ee4469344f9c1ab55fea13cfc6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Wed, 20 Aug 2025 16:58:04 +0800 Subject: [PATCH 103/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=AD=90=E7=AA=97=E5=AE=89=E5=85=A8=E6=8E=A7=E4=BB=B6=E9=80=82?= =?UTF-8?q?=E9=85=8D=E7=BC=A9=E6=94=BE=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- interfaces/innerkits/wm/window_manager.h | 1 + utils/src/accessibility_window_info.cpp | 6 ++- .../session/host/include/scene_session.h | 2 +- .../session/host/src/scene_session.cpp | 8 +++- .../src/scene_session_manager.cpp | 1 + .../test/unittest/scene_session_test6.cpp | 40 +++++++++++++++++++ 6 files changed, 55 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index 1db684ff1f..340b8781b8 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -345,6 +345,7 @@ public: float scaleX_; float scaleY_; bool isCompatScaleMode_ { false }; + Rect scaleRect_; std::string bundleName_; std::vector touchHotAreas_; }; diff --git a/utils/src/accessibility_window_info.cpp b/utils/src/accessibility_window_info.cpp index 0baba01f63..0ca08ce8d9 100644 --- a/utils/src/accessibility_window_info.cpp +++ b/utils/src/accessibility_window_info.cpp @@ -31,6 +31,8 @@ bool AccessibilityWindowInfo::Marshalling(Parcel& parcel) const parcel.WriteInt32(windowRect_.posY_) && parcel.WriteBool(focused_) && parcel.WriteBool(isDecorEnable_) && parcel.WriteUint64(displayId_) && parcel.WriteUint32(layer_) && parcel.WriteFloat(scaleVal_) && parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) && parcel.WriteBool(isCompatScaleMode_) && + parcel.WriteUint32(scaleRect_.width_) && parcel.WriteUint32(scaleRect_.height_) && + parcel.WriteInt32(scaleRect_.posX_) && parcel.WriteInt32(scaleRect_.posY_) && parcel.WriteUint32(static_cast(mode_)) && parcel.WriteUint32(static_cast(type_)) && parcel.WriteString(bundleName_) && parcel.WriteUint32(touchHotAreas.size()); if (!res) { @@ -60,7 +62,9 @@ AccessibilityWindowInfo* AccessibilityWindowInfo::Unmarshalling(Parcel& parcel) parcel.ReadBool(info->isDecorEnable_) && parcel.ReadUint64(info->displayId_) && parcel.ReadUint32(info->layer_) && parcel.ReadFloat(info->scaleVal_) && parcel.ReadFloat(info->scaleX_) && parcel.ReadFloat(info->scaleY_) && - parcel.ReadBool(info->isCompatScaleMode_); + parcel.ReadBool(info->isCompatScaleMode_) && + parcel.ReadUint32(info->scaleRect_.width_) && parcel.ReadUint32(info->scaleRect_.height_) && + parcel.ReadInt32(info->scaleRect_.posX_) && parcel.ReadInt32(info->scaleRect_.posY_); if (!res) { delete info; return nullptr; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 7467904bd9..1c98f3032c 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -396,7 +396,7 @@ public: * Compatible Mode */ bool IsInCompatScaleStatus() const; - bool IsInCompatScaleMode() const; + bool IsInCompatScaleMode(); /* * PC Window diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1c129cf74c..53d76c675d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3677,8 +3677,14 @@ bool SceneSession::IsInCompatScaleStatus() const return false; } -bool SceneSession::IsInCompatScaleMode() const +bool SceneSession::IsInCompatScaleMode() { + if (WindowHelper::IsSubWindow(GetWindowType())) { + auto mainSession = GetSceneSessionById(GetMainSessionId()); + if (mainSession && GetCallingPid() == mainSession->GetCallingPid()) { + return mainSession->IsInCompatScaleMode(); + } + } auto property = GetSessionProperty(); return property->IsAdaptToProportionalScale() || property->IsAdaptToSimulationScale(); } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1a104d886f..1f42a7d080 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10936,6 +10936,7 @@ bool SceneSessionManager::FillWindowInfo(std::vectordisplayId_ = displayId; info->focused_ = sceneSession->GetPersistentId() == GetFocusedSessionId(displayId); info->windowRect_ = { wsRect.posX_, wsRect.posY_, wsRect.width_, wsRect.height_ }; + sceneSession->GetGlobalScaledRect(info->scaleRect_); infos.emplace_back(info); TLOGD(WmsLogTag::WMS_ATTRIBUTE, "wid: %{public}d, innerWid: %{public}d, nodeId: %{public}d" ", bundleName: %{public}s, displayId: %{public}" PRIu64 ", rect: %{public}s", diff --git a/window_scene/test/unittest/scene_session_test6.cpp b/window_scene/test/unittest/scene_session_test6.cpp index 8d5d0f627e..32752cd3da 100644 --- a/window_scene/test/unittest/scene_session_test6.cpp +++ b/window_scene/test/unittest/scene_session_test6.cpp @@ -593,6 +593,46 @@ HWTEST_F(SceneSessionTest6, IsInCompatScaleMode, TestSize.Level1) EXPECT_TRUE(session->IsInCompatScaleMode()); } +/** + * @tc.name: IsInCompatScaleMode_forSubWindow + * @tc.desc: IsInCompatScaleMode + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest6, IsInCompatScaleMode_forSubWindow, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "IsInCompatScaleMode_forSubWindow"; + info.bundleName_ = "IsInCompatScaleMode_forSubWindow"; + info.screenId_ = 0; + sptr subSession = sptr::MakeSptr(info, nullptr); + sptr mainSession = sptr::MakeSptr(info, nullptr); + EXPECT_FALSE(subSession->IsInCompatScaleMode()); + subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + EXPECT_FALSE(subSession->IsInCompatScaleMode()); + + sptr callBack = sptr::MakeSptr(); + subSession->specificCallback_ = callBack; + auto task = [&mainSession](int32_t persistentId) { return mainSession; }; + callBack->onGetSceneSessionByIdCallback_ = task; + subSession->SetCallingPid(1); + mainSession->SetCallingPid(2); + EXPECT_FALSE(subSession->IsInCompatScaleMode()); + + mainSession->SetCallingPid(1); + EXPECT_FALSE(subSession->IsInCompatScaleMode()); + + sptr compatibleModeProperty = sptr::MakeSptr(); + compatibleModeProperty->SetIsAdaptToProportionalScale(true); + mainSession->property_->SetCompatibleModeProperty(compatibleModeProperty); + EXPECT_TRUE(subSession->IsInCompatScaleMode()); + + compatibleModeProperty->SetIsAdaptToProportionalScale(false); + compatibleModeProperty->SetIsAdaptToSimulationScale(true); + EXPECT_TRUE(subSession->IsInCompatScaleMode()); + compatibleModeProperty->SetIsAdaptToProportionalScale(true); + EXPECT_TRUE(subSession->IsInCompatScaleMode()); +} + /** * @tc.name: GetSystemAvoidArea * @tc.desc: GetSystemAvoidArea function -- Gitee From fb8bbef7b536074728663d9e4b331b65dd6c60dd Mon Sep 17 00:00:00 2001 From: 17342015572 Date: Wed, 20 Aug 2025 11:20:00 +0000 Subject: [PATCH 104/241] =?UTF-8?q?=E5=8E=BB=E4=BD=BF=E8=83=BD=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E4=BC=98=E5=85=88=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=90=91?= =?UTF-8?q?RS=20commit=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 17342015572 Change-Id: Ibccab1b9acefc84c50a878e890695d6b13b7afed --- window_scene/session/host/src/scene_session.cpp | 6 ++++-- .../test/unittest/scene_session_lifecycle_test.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1c129cf74c..cbbb275623 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -444,9 +444,11 @@ WSError SceneSession::ForegroundTask(const sptr& property TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s foreground specific callback does not take effect, callback function null", where); } - if (session->isUIFirstEnabled_) { - session->SetSystemSceneForceUIFirst(false); + if (session->isUIFirstEnabled_ && leashWinSurfaceNode) { + leashWinSurfaceNode->SetForceUIFirst(false); session->isUIFirstEnabled_ = false; + TLOGNI(WmsLogTag::WMS_ANIMATION, "%{public}s %{public}" PRIu64 " forceUIFirst=false.", + leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId()); } return WSError::WS_OK; }, __func__); diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index aa90e8819a..77a95b7860 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -262,6 +262,20 @@ HWTEST_F(SceneSessionLifecycleTest, ForegroundTask01, TestSize.Level0) EXPECT_EQ(true, session->isUIFirstEnabled_); session->SetSessionState(SessionState::STATE_CONNECT); EXPECT_EQ(WSError::WS_OK, session->ForegroundTask(property)); + + session->isUIFirstEnabled_ = true; + EXPECT_EQ(true, session->isUIFirstEnabled_); + struct RSSurfaceNodeConfig config; + std::shared_ptr surfaceNode = RSSurfaceNode::Create(config); + EXPECT_NE(nullptr, surfaceNode); + session->SetLeashWinSurfaceNode(surfaceNode); + session->SetSessionState(SessionState::STATE_CONNECT); + EXPECT_EQ(WSError::WS_OK, session->ForegroundTask(property)); + + session->isUIFirstEnabled_ = false; + EXPECT_EQ(false, session->isUIFirstEnabled_); + session->SetSessionState(SessionState::STATE_CONNECT); + EXPECT_EQ(WSError::WS_OK, session->ForegroundTask(property)); } /** -- Gitee From 6cd460ee239886211970b0cbbfda0da98defec91 Mon Sep 17 00:00:00 2001 From: zhongqihong Date: Thu, 21 Aug 2025 08:53:51 +0800 Subject: [PATCH 105/241] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5win?= =?UTF-8?q?dow=5Fmanager=5Flite\window=5Fscene=5Fsession=5Fimpl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhongqihong --- wm/src/window_manager_lite.cpp | 6 +-- wm/src/window_scene_session_impl.cpp | 80 ++++++++++++++-------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index ea075a7415..75f62e1ae7 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -286,7 +286,7 @@ void WindowManagerLite::Impl::NotifyAccessibilityWindowInfo(const std::vector> cameraWindowChangeListeners; { @@ -708,7 +708,7 @@ WMError WindowManagerLite::UnregisterWindowModeChangedListener(const sptr& listener) { if (listener == nullptr) { - TLOGE(WmsLogTag::WMS_SYSTEM, "listener could not be null"); + TLOGE(WmsLogTag::WMS_PIP, "listener could not be null"); return WMError::WM_ERROR_NULLPTR; } @@ -736,7 +736,7 @@ WMError WindowManagerLite::RegisterCameraWindowChangedListener(const sptr& listener) { if (listener == nullptr) { - TLOGE(WmsLogTag::WMS_SYSTEM, "listener could not be null"); + TLOGE(WmsLogTag::WMS_PIP, "listener could not be null"); return WMError::WM_ERROR_NULLPTR; } diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 21bc75ad23..5fa3076f60 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -851,18 +851,6 @@ WMError WindowSceneSessionImpl::GetParentWindow(sptr& parentWindow) return WMError::WM_OK; } -void WindowSceneSessionImpl::InitSystemSessionDragEnable() -{ - if (WindowHelper::IsDialogWindow(GetType())) { - TLOGI(WmsLogTag::WMS_LAYOUT, "dialogWindow default draggable, should not init false, id: %{public}d", - GetPersistentId()); - return; - } - TLOGI(WmsLogTag::WMS_LAYOUT, "windId: %{public}d init dragEnable false", - GetPersistentId()); - property_->SetDragEnabled(false); -} - void WindowSceneSessionImpl::UpdateDefaultStatusBarColor() { SystemBarProperty statusBarProp = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); @@ -916,6 +904,18 @@ void WindowSceneSessionImpl::UpdateDefaultStatusBarColor() SetSpecificBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, statusBarProp); } +void WindowSceneSessionImpl::InitSystemSessionDragEnable() +{ + if (WindowHelper::IsDialogWindow(GetType())) { + TLOGI(WmsLogTag::WMS_LAYOUT, "dialogWindow default draggable, should not init false, id: %{public}d", + GetPersistentId()); + return; + } + TLOGI(WmsLogTag::WMS_LAYOUT, "windId: %{public}d init dragEnable false", + GetPersistentId()); + property_->SetDragEnabled(false); +} + void WindowSceneSessionImpl::RegisterSessionRecoverListener(bool isSpecificSession) { TLOGD(WmsLogTag::WMS_RECOVER, "Id=%{public}d, isSpecificSession=%{public}s", @@ -2128,10 +2128,10 @@ WMError WindowSceneSessionImpl::MoveTo(int32_t x, int32_t y, bool isMoveToGlobal return static_cast(ret); } -WMError WindowSceneSessionImpl::MoveWindowToGlobal(int32_t x, int32_t y, MoveConfiguration moveConfiguration) +WMError WindowSceneSessionImpl::MoveToAsync(int32_t x, int32_t y, MoveConfiguration moveConfiguration) { - TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d MoveTo %{public}d %{public}d", property_->GetPersistentId(), x, y); if (IsWindowSessionInvalid()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2140,29 +2140,7 @@ WMError WindowSceneSessionImpl::MoveWindowToGlobal(int32_t x, int32_t y, MoveCon GetWindowId(), GetWindowMode()); return WMError::WM_ERROR_INVALID_OP_IN_CUR_STATUS; } - - if (property_->GetWindowType() == WindowType::WINDOW_TYPE_PIP) { - TLOGW(WmsLogTag::WMS_LAYOUT, "Unsupported operation for pip window"); - return WMError::WM_ERROR_INVALID_OPERATION; - } - const auto& windowRect = GetRect(); - const auto& requestRect = GetRequestRect(); - Rect newRect = { x, y, requestRect.width_, requestRect.height_ }; // must keep x/y - TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, state: %{public}d, type: %{public}d, mode: %{public}d, requestRect: " - "%{public}s, windowRect: %{public}s, newRect: %{public}s", - property_->GetPersistentId(), state_, GetType(), GetWindowMode(), requestRect.ToString().c_str(), - windowRect.ToString().c_str(), newRect.ToString().c_str()); - - property_->SetRequestRect(newRect); - - CheckMoveConfiguration(moveConfiguration); - WSRect wsRect = { newRect.posX_, newRect.posY_, newRect.width_, newRect.height_ }; - auto hostSession = GetHostSession(); - RectAnimationConfig rectAnimationConfig = moveConfiguration.rectAnimationConfig; - SizeChangeReason reason = rectAnimationConfig.duration > 0 ? SizeChangeReason::MOVE_WITH_ANIMATION : - SizeChangeReason::MOVE; - CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); - auto ret = hostSession->UpdateSessionRect(wsRect, reason, false, true, moveConfiguration, rectAnimationConfig); + auto ret = MoveTo(x, y, false, moveConfiguration); if (state_ == WindowState::STATE_SHOWN) { layoutCallback_->ResetMoveToLock(); auto startTime = std::chrono::duration_cast( @@ -2179,10 +2157,10 @@ WMError WindowSceneSessionImpl::MoveWindowToGlobal(int32_t x, int32_t y, MoveCon return static_cast(ret); } -WMError WindowSceneSessionImpl::MoveToAsync(int32_t x, int32_t y, MoveConfiguration moveConfiguration) +WMError WindowSceneSessionImpl::MoveWindowToGlobal(int32_t x, int32_t y, MoveConfiguration moveConfiguration) { + TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d MoveTo %{public}d %{public}d", property_->GetPersistentId(), x, y); if (IsWindowSessionInvalid()) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2191,7 +2169,29 @@ WMError WindowSceneSessionImpl::MoveToAsync(int32_t x, int32_t y, MoveConfigurat GetWindowId(), GetWindowMode()); return WMError::WM_ERROR_INVALID_OP_IN_CUR_STATUS; } - auto ret = MoveTo(x, y, false, moveConfiguration); + + if (property_->GetWindowType() == WindowType::WINDOW_TYPE_PIP) { + TLOGW(WmsLogTag::WMS_LAYOUT, "Unsupported operation for pip window"); + return WMError::WM_ERROR_INVALID_OPERATION; + } + const auto& windowRect = GetRect(); + const auto& requestRect = GetRequestRect(); + Rect newRect = { x, y, requestRect.width_, requestRect.height_ }; // must keep x/y + TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, state: %{public}d, type: %{public}d, mode: %{public}d, requestRect: " + "%{public}s, windowRect: %{public}s, newRect: %{public}s", + property_->GetPersistentId(), state_, GetType(), GetWindowMode(), requestRect.ToString().c_str(), + windowRect.ToString().c_str(), newRect.ToString().c_str()); + + property_->SetRequestRect(newRect); + + CheckMoveConfiguration(moveConfiguration); + WSRect wsRect = { newRect.posX_, newRect.posY_, newRect.width_, newRect.height_ }; + auto hostSession = GetHostSession(); + RectAnimationConfig rectAnimationConfig = moveConfiguration.rectAnimationConfig; + SizeChangeReason reason = rectAnimationConfig.duration > 0 ? SizeChangeReason::MOVE_WITH_ANIMATION : + SizeChangeReason::MOVE; + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); + auto ret = hostSession->UpdateSessionRect(wsRect, reason, false, true, moveConfiguration, rectAnimationConfig); if (state_ == WindowState::STATE_SHOWN) { layoutCallback_->ResetMoveToLock(); auto startTime = std::chrono::duration_cast( -- Gitee From 5a57d445dd64da69463fef375e4234d46f2b6fa4 Mon Sep 17 00:00:00 2001 From: l30033162 Date: Thu, 21 Aug 2025 10:15:46 +0800 Subject: [PATCH 106/241] =?UTF-8?q?PC=E5=A4=9A=E7=94=A8=E6=88=B7=E5=88=87?= =?UTF-8?q?=E6=8D=A2=EF=BC=8COOBE=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30033162 --- .../screen_session_manager/src/screen_session_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 65d6ee24bf..c83df88033 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -8315,7 +8315,6 @@ void ScreenSessionManager::SwitchUser() return; } auto userId = GetUserIdByCallingUid(); - auto newScbPid = IPCSkeleton::GetCallingPid(); currentUserIdForSettings_ = userId; if (g_isPcDevice && userSwitching_) { std::unique_lock lock(switchUserMutex_); @@ -8324,7 +8323,10 @@ void ScreenSessionManager::SwitchUser() userSwitching_ = false; } } - SwitchScbNodeHandle(userId, newScbPid, false); + { + std::lock_guard lock(oldScbPidsMutex_); + SwitchScbNodeHandle(userId, IPCSkeleton::GetCallingPid(), false); + } MockSessionManagerService::GetInstance().NotifyWMSConnected(userId, GetDefaultScreenId(), false); #endif } -- Gitee From 4ca74d8cdbc1e9dbdb22fe0ab091f37538369a36 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 21 Aug 2025 10:56:37 +0800 Subject: [PATCH 107/241] UpdateSuperFoldRefreshRate Signed-off-by: chaos --- .../include/screen_session_manager.h | 1 + .../src/screen_session_manager.cpp | 26 ++++++++++++++++- .../screen_session_manager_test2.cpp | 28 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) 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 5a158937f7..97469b7a85 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -507,6 +507,7 @@ private: void InitSecondaryDisplayPhysicalParams(); ScreenId GetPhyScreenId(ScreenId screenId); void UpdateCoordinationRefreshRate(uint32_t refreshRate); + void UpdateSuperFoldRefreshRate(sptr screenSession, uint32_t refreshRate); void GetInternalWidth(); void InitExtendScreenDensity(sptr session, ScreenProperty property); void InitExtendScreenProperty(ScreenId screenId, sptr session, ScreenProperty property); 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 a397138101..99eb7aa9b1 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1699,7 +1699,8 @@ void ScreenSessionManager::OnHgmRefreshRateChange(uint32_t refreshRate) screenSession->UpdateRefreshRate(refreshRate); NotifyDisplayChanged(screenSession->ConvertToDisplayInfo(), DisplayChangeEvent::UPDATE_REFRESHRATE); - UpdateCoordinationRefreshRate(refreshRate); + UpdateCoordinationRefreshRate(screenSession, refreshRate); + UpdateSuperFoldRefreshRate(refreshRate); std::map> screenSessionMap; { std::lock_guard lock(screenSessionMapMutex_); @@ -1721,6 +1722,29 @@ void ScreenSessionManager::OnHgmRefreshRateChange(uint32_t refreshRate) return; } +void ScreenSessionManager::UpdateSuperFoldRefreshRate(sptr screenSession, uint32_t refreshRate) +{ + if (!FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + TLOGD(WmsLogTag::DMS, "not super fold display device."); + return; + } + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screenSession is nullptr") + return; + } + sptr fakeScreenSession = screenSession->GetFakeScreenSession(); + if (fakeScreenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "fakeScreenSession is nullptr") + return; + } + fakeScreenSession->UpdateRefreshRate(refreshRate); + if (screenSession->GetScreenProperty().GetIsFakeInUse()) { + NotifyDisplayChanged(fakeScreenSession->ConvertToDisplayInfo(), DisplayChangeEvent::UPDATE_REFRESHRATE); + TLOGE(WmsLogTag::DMS, "notify success") + } +} + + bool ScreenSessionManager::IsPhysicalScreenAndInUse(sptr screenSession) const { if (!screenSession) { 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 2312ab03eb..fa62d4ba9a 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -964,6 +964,34 @@ HWTEST_F(ScreenSessionManagerTest, SetScreenPrivacyWindowTagSwitch002, TestSize. EXPECT_EQ(ret, DMError::DM_OK); } +/** + * @tc.name: UpdateSuperFoldRefreshRate + * @tc.desc: UpdateSuperFoldRefreshRate test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, UpdateSuperFoldRefreshRate, TestSize.Level1) +{ + if (!FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + GTEST_SKIP(); + } + g_errLog.clear(); + uint32_t tempRefreshRate = 60; + sptr screenSession = nullptr; + ssm_->UpdateSuperFoldRefreshRate(screenSession, tempRefreshRate); + EXPECT_TRUE(g_errLog.find("screenSession is nullptr") != std::string::npos); + + + ScreenId screenId = 1050; + DMRect area{0, 0, 600, 800}; + screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); + + sptr fakescreenSession = nullptr; + screenSession->SetFakeScreenSession(fakescreenSession); + ssm_->UpdateSuperFoldRefreshRate(screenSession, tempRefreshRate); + EXPECT_TRUE(g_errLog.find("fakeScreenSession is nullptr") != std::string::npos); + g_errLog.clear(); +} + /** * @tc.name: OnVerticalChangeBoundsWhenSwitchUser * @tc.desc: OnVerticalChangeBoundsWhenSwitchUser test -- Gitee From 21482a13bfd9f6dd906ecfc198c921247010ecfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Thu, 21 Aug 2025 11:25:53 +0800 Subject: [PATCH 108/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8pad=E6=A8=A1=E5=BC=8F=E5=88=87=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E5=90=8E=EF=BC=8C=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=8F=98=E5=8C=96=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- window_scene/test/unittest/session_test.cpp | 3 +++ wm/src/window_session_impl.cpp | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 3cd93ebabf..4c845aa02e 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -188,7 +188,10 @@ HWTEST_F(WindowSessionTest, SetActive01, TestSize.Level1) HWTEST_F(WindowSessionTest, SetCompatibleModeProperty, TestSize.Level1) { sptr compatibleModeProperty = sptr::MakeSptr(); + ASSERT_EQ(session_->GetSessionProperty()->GetDragEnabled(), true); + compatibleModeProperty->SetDisableDragResize(true); ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); + ASSERT_EQ(session_->GetSessionProperty()->GetDragEnabled(), false); } /** diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0ea8dd0675..f98454e802 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2336,17 +2336,16 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) bool decorVisible = mode == WindowMode::WINDOW_MODE_FLOATING || mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY || (mode == WindowMode::WINDOW_MODE_FULLSCREEN && !property_->IsLayoutFullScreen()); - + TLOGD(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d", decorVisible); + if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)) && - !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); + (property_->GetIsPcAppInPad() && isSubWindow)); } if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { decorVisible = false; } - TLOGD(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d", decorVisible); uiContent->UpdateDecorVisible(decorVisible, isDecorEnable); return; } @@ -2373,8 +2372,7 @@ void WindowSessionImpl::UpdateDecorEnable(bool needNotify, WindowMode mode) if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)) && - !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); + (property_->GetIsPcAppInPad() && isSubWindow)); } TLOGI(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d, id: %{public}d", decorVisible, GetPersistentId()); uiContent->UpdateDecorVisible(decorVisible, IsDecorEnable()); -- Gitee From 735b28691ce51dbd2dec3551219d6e43a27eec7d Mon Sep 17 00:00:00 2001 From: l30033162 Date: Thu, 21 Aug 2025 11:26:30 +0800 Subject: [PATCH 109/241] =?UTF-8?q?PC=E5=A4=9A=E7=94=A8=E6=88=B7=E5=88=87?= =?UTF-8?q?=E6=8D=A2=EF=BC=8COOBE=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30033162 --- .../src/screen_session_manager.cpp | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 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 c83df88033..03c7844a63 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -8324,8 +8324,8 @@ void ScreenSessionManager::SwitchUser() } } { - std::lock_guard lock(oldScbPidsMutex_); - SwitchScbNodeHandle(userId, IPCSkeleton::GetCallingPid(), false); + std::lock_guard lock(oldScbPidsMutex_); + SwitchScbNodeHandle(userId, IPCSkeleton::GetCallingPid(), false); } MockSessionManagerService::GetInstance().NotifyWMSConnected(userId, GetDefaultScreenId(), false); #endif @@ -8581,21 +8581,20 @@ void ScreenSessionManager::SetClient(const sptr& cl } } { - std::unique_lock lock(oldScbPidsMutex_); - SetClientProxy(client); - auto userId = GetUserIdByCallingUid(); - auto newScbPid = IPCSkeleton::GetCallingPid(); + std::unique_lock lock(oldScbPidsMutex_); + SetClientProxy(client); + auto userId = GetUserIdByCallingUid(); + auto newScbPid = IPCSkeleton::GetCallingPid(); - std::ostringstream oss; - oss << "set client userId: " << userId - << " clientName: " << SysCapUtil::GetClientName(); - TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str()); - screenEventTracker_.RecordEvent(oss.str()); - currentUserIdForSettings_ = userId; - MockSessionManagerService::GetInstance().NotifyWMSConnected(userId, GetDefaultScreenId(), true); - NotifyClientProxyUpdateFoldDisplayMode(GetFoldDisplayMode()); - SetClientInner(); - SwitchScbNodeHandle(userId, newScbPid, true); + std::ostringstream oss; + oss << "set client userId: " << userId << " clientName: " << SysCapUtil::GetClientName(); + TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str()); + screenEventTracker_.RecordEvent(oss.str()); + currentUserIdForSettings_ = userId; + MockSessionManagerService::GetInstance().NotifyWMSConnected(userId, GetDefaultScreenId(), true); + NotifyClientProxyUpdateFoldDisplayMode(GetFoldDisplayMode()); + SetClientInner(); + SwitchScbNodeHandle(userId, newScbPid, true); } AddScbClientDeathRecipient(client, IPCSkeleton::GetCallingPid()); -- Gitee From acef5a87118770dee86918054827a79c15070106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Thu, 21 Aug 2025 11:27:09 +0800 Subject: [PATCH 110/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8pad=E6=A8=A1=E5=BC=8F=E5=88=87=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E5=90=8E=EF=BC=8C=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=8F=98=E5=8C=96=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- wm/src/window_session_impl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index f98454e802..0a62e589d2 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2337,7 +2337,6 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY || (mode == WindowMode::WINDOW_MODE_FULLSCREEN && !property_->IsLayoutFullScreen()); TLOGD(WmsLogTag::WMS_DECOR, "decorVisible:%{public}d", decorVisible); - if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || -- Gitee From ed0d7bacb1eb6f56504ae45f58a527863c64ede8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Wed, 20 Aug 2025 19:51:27 +0800 Subject: [PATCH 111/241] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- interfaces/innerkits/wm/window.h | 2 +- .../window_runtime/window_napi/js_window.cpp | 6 +- .../window_stage_napi/js_window_stage.cpp | 2 +- previewer/include/window.h | 2 +- wm/include/window_scene_session_impl.h | 1 - wm/include/window_session_impl.h | 2 +- wm/src/window_scene_session_impl.cpp | 55 ++------ wm/src/window_session_impl.cpp | 22 ++- .../window_scene_session_impl_test5.cpp | 125 ------------------ .../unittest/window_session_impl_test4.cpp | 18 +-- 10 files changed, 39 insertions(+), 196 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 3575de6218..8ed30ff621 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -2869,7 +2869,7 @@ public: * * @return True means pcAppInpad and pad window., false means the opposite. */ - virtual bool IsPadAndNotFreeMutiWindowCompatibleMode() const { return false; } + virtual bool IsPadAndNotFreeMultiWindowCompatibleMode() const { return false; } /** * @brief Judge whether SceneBoard is enabled. diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 403b12afb4..e7ba6b077b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4349,7 +4349,7 @@ napi_value JsWindow::OnSetWindowTopmost(napi_env env, napi_callback_info info) TLOGE(WmsLogTag::WMS_HIERARCHY, "windowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } - if (windowToken_->IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (windowToken_->IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_HIERARCHY, "This is PcAppInPad, not support"); return NapiGetUndefined(env); } @@ -7593,7 +7593,7 @@ napi_value JsWindow::OnSetDecorButtonStyle(napi_env env, napi_callback_info info return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][setDecorButtonStyle]msg: window is nullptr"); } - if (windowToken_->IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (windowToken_->IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_DECOR, "This is PcAppInPad, not support"); return NapiGetUndefined(env); } @@ -7636,7 +7636,7 @@ napi_value JsWindow::OnGetDecorButtonStyle(napi_env env, napi_callback_info info return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "[window][getDecorButtonStyle]msg: window is nullptr"); } - if (windowToken_->IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (windowToken_->IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_DECOR, "This is PcAppInPad, not support"); return NapiGetUndefined(env); } diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 780ce46020..bbf6d9c41c 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -624,7 +624,7 @@ napi_value JsWindowStage::OnSetWindowModal(napi_env env, napi_callback_info info "[window][setWindowModal]msg: invalid main window")); return NapiGetUndefined(env); } - if (window->IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (window->IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_MAIN, "This is PcAppInPad, not support"); return NapiGetUndefined(env); } diff --git a/previewer/include/window.h b/previewer/include/window.h index 15364944f9..8d23c8ea8b 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -457,7 +457,7 @@ public: virtual bool IsPadWindow() const { return false; } virtual bool IsPcOrFreeMultiWindowCapabilityEnabled() const { return false; } virtual bool IsPcOrPadFreeMultiWindowMode() const { return false; } - virtual bool IsPadAndNotFreeMutiWindowCompatibleMode() const { return false; } + virtual bool IsPadAndNotFreeMultiWindowCompatibleMode() const { return false; } virtual bool IsSceneBoardEnabled() const { return false; } virtual bool GetCompatibleModeInPc() const { return false; } virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) = 0; diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 16a6b36097..d9282b801f 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -217,7 +217,6 @@ public: WSError NotifyCompatibleModePropertyChange(const sptr property) override; void HookDecorButtonStyleInCompatibleMode(uint32_t contentColor); WSError PcAppInPadNormalClose() override; - void HandleWindowLimitsInCompatibleMode(WindowSizeLimits& windowSizeLimits); /* * Free Multi Window diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 6f578ce4f9..7672f2d3c8 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -147,7 +147,7 @@ public: bool IsPadWindow() const override; bool IsPcOrFreeMultiWindowCapabilityEnabled() const override; bool IsPcOrPadFreeMultiWindowMode() const override; - bool IsPadAndNotFreeMutiWindowCompatibleMode() const override; + bool IsPadAndNotFreeMultiWindowCompatibleMode() const override; bool IsSceneBoardEnabled() const override; bool GetCompatibleModeInPc() const override; void HookCompatibleModeAvoidAreaNotify() override; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 705e9b9b56..eff9c3da64 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -614,8 +614,8 @@ WMError WindowSceneSessionImpl::Create(const std::shared_ptrGetPcAppInpadSpecificSystemBarInvisible()); - if (WindowHelper::IsMainWindow(GetType()) && IsPadAndNotFreeMutiWindowCompatibleMode() && + if (WindowHelper::IsMainWindow(GetType()) && IsPadAndNotFreeMultiWindowCompatibleMode() && property_->GetPcAppInpadSpecificSystemBarInvisible()) { SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); UpdateSpecificSystemBarEnabled(false, false, statusProperty); @@ -693,7 +693,7 @@ WMError WindowSceneSessionImpl::SetPcAppInpadOrientationLandscape() { TLOGI(WmsLogTag::WMS_COMPAT, "isPcAppInpadOrientationLandscape: %{public}d", property_->GetPcAppInpadOrientationLandscape()); - if (WindowHelper::IsMainWindow(GetType()) && IsPadAndNotFreeMutiWindowCompatibleMode() && + if (WindowHelper::IsMainWindow(GetType()) && IsPadAndNotFreeMultiWindowCompatibleMode() && property_->GetPcAppInpadOrientationLandscape()) { SetRequestedOrientation(Orientation::HORIZONTAL, false); return WMError::WM_OK; @@ -797,7 +797,7 @@ WMError WindowSceneSessionImpl::SetParentWindow(int32_t newParentWindowId) } auto oldParentWindow = GetWindowWithId(oldParentWindowId); if (oldParentWindow == nullptr) { - TLOGE(WmsLogTag::WMS_SUB, "winId: %{public}d find not old parent window By Id: %{public}d", + TLOGE(WmsLogTag::WMS_SUB, "winId: %{public}d can not find old parent window By Id: %{public}d", subWindowId, oldParentWindowId); return WMError::WM_ERROR_INVALID_PARENT; } @@ -808,7 +808,7 @@ WMError WindowSceneSessionImpl::SetParentWindow(int32_t newParentWindowId) } auto newParentWindow = GetWindowWithId(newParentWindowId); if (newParentWindow == nullptr) { - TLOGE(WmsLogTag::WMS_SUB, "winId: %{public}d find not new parent window By Id: %{public}d", + TLOGE(WmsLogTag::WMS_SUB, "winId: %{public}d can not find new parent window By Id: %{public}d", subWindowId, newParentWindowId); return WMError::WM_ERROR_INVALID_PARENT; } @@ -1228,31 +1228,6 @@ static void GetWindowSizeLimits(std::shared_ptr ability windowSizeLimits.minWindowHeight : abilityInfo->minWindowHeight; } -void WindowSceneSessionImpl::HandleWindowLimitsInCompatibleMode(WindowSizeLimits& windowSizeLimits) -{ - if (!property_->IsWindowLimitDisabled()) { - return; - } - windowSizeLimits.maxWindowWidth = windowSystemConfig_.maxFloatingWindowSize_; - windowSizeLimits.maxWindowHeight = windowSystemConfig_.maxFloatingWindowSize_; - if (WindowHelper::IsMainWindow(GetType())) { - windowSizeLimits.minWindowWidth = windowSystemConfig_.miniWidthOfMainWindow_; - windowSizeLimits.minWindowHeight = windowSystemConfig_.miniHeightOfMainWindow_; - } else if (WindowHelper::IsSubWindow(GetType())) { - windowSizeLimits.minWindowWidth = windowSystemConfig_.miniWidthOfSubWindow_; - windowSizeLimits.minWindowHeight = windowSystemConfig_.miniHeightOfSubWindow_; - } else if (WindowHelper::IsDialogWindow(GetType())) { - windowSizeLimits.minWindowWidth = windowSystemConfig_.miniWidthOfDialogWindow_; - windowSizeLimits.minWindowHeight = windowSystemConfig_.miniHeightOfDialogWindow_; - } else { - windowSizeLimits.minWindowWidth = MIN_FLOATING_WIDTH; - windowSizeLimits.minWindowHeight = MIN_FLOATING_HEIGHT; - } - TLOGI(WmsLogTag::WMS_COMPAT, "maxWidth: %{public}u, minWidth: %{public}u, maxHeight: %{public}u, " - "minHeight: %{public}u", windowSizeLimits.maxWindowWidth, windowSizeLimits.minWindowWidth, - windowSizeLimits.maxWindowHeight, windowSizeLimits.minWindowHeight); -} - std::vector WindowSceneSessionImpl::ExtractSupportWindowModeFromMetaData( const std::shared_ptr& abilityInfo) { @@ -1300,9 +1275,6 @@ void WindowSceneSessionImpl::GetConfigurationFromAbilityInfo() if (abilityInfo != nullptr) { WindowSizeLimits windowSizeLimits = property_->GetWindowSizeLimits(); GetWindowSizeLimits(abilityInfo, windowSizeLimits); - if (property_->IsWindowLimitDisabled()) { - HandleWindowLimitsInCompatibleMode(windowSizeLimits); - } property_->SetConfigWindowLimitsVP({ windowSizeLimits.maxWindowWidth, windowSizeLimits.maxWindowHeight, windowSizeLimits.minWindowWidth, windowSizeLimits.minWindowHeight, @@ -2052,10 +2024,10 @@ WMError WindowSceneSessionImpl::Destroy(bool needNotifyServer, bool needClearLis } DestroySubWindow(); - { + { std::unique_lock lock(windowSessionMutex_); windowSessionMap_.erase(property_->GetWindowName()); - } + } { std::lock_guard lock(hostSessionMutex_); hostSession_ = nullptr; @@ -2970,7 +2942,7 @@ WMError WindowSceneSessionImpl::SetTitleAndDockHoverShown( TLOGE(WmsLogTag::WMS_LAYOUT_PC, "window is not main window"); return WMError::WM_ERROR_INVALID_CALLING; } - if (IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "This is PcAppInPad, not supported"); return WMError::WM_OK; } @@ -3558,7 +3530,7 @@ WMError WindowSceneSessionImpl::Recover(uint32_t reason) TLOGE(WmsLogTag::WMS_LAYOUT_PC, "session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } - if (IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "The device is not supported"); return WMError::WM_OK; } @@ -3609,7 +3581,7 @@ WMError WindowSceneSessionImpl::SetWindowRectAutoSave(bool enabled, bool isSaveB return WMError::WM_ERROR_INVALID_WINDOW; } - if (IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_MAIN, "This is PcAppInPad, not supported"); return WMError::WM_OK; } @@ -3682,7 +3654,7 @@ WMError WindowSceneSessionImpl::SetSupportedWindowModes( return WMError::WM_ERROR_INVALID_WINDOW; } - if (IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_LAYOUT_PC, "This is PcAppInpad, not supported"); return WMError::WM_OK; } @@ -5671,7 +5643,8 @@ WMError WindowSceneSessionImpl::GetWindowLimits(WindowLimits& windowLimits) void WindowSceneSessionImpl::UpdateNewSize() { if (GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING || property_->IsWindowLimitDisabled()) { - TLOGI(WmsLogTag::WMS_LAYOUT, "Fullscreen couldnot update new size, Id: %{public}u", GetWindowId()); + TLOGI(WmsLogTag::WMS_LAYOUT, "fullscreen of compatible mode could not update new size, Id: %{public}u", + GetPersistentId()); return; } bool needResize = false; @@ -5953,7 +5926,7 @@ WMError WindowSceneSessionImpl::SetFollowParentMultiScreenPolicy(bool enabled) if (IsWindowSessionInvalid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - if (IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_SUB, "This is PcAppInpad, not Suppored"); return WMError::WM_OK; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0a62e589d2..4a2437911d 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -350,7 +350,7 @@ bool WindowSessionImpl::IsPcOrPadFreeMultiWindowMode() const return windowSystemConfig_.IsPcWindow() || IsFreeMultiWindowMode(); } -bool WindowSessionImpl::IsPadAndNotFreeMutiWindowCompatibleMode() const +bool WindowSessionImpl::IsPadAndNotFreeMultiWindowCompatibleMode() const { return property_->GetPcAppInpadCompatibleMode() && !IsFreeMultiWindowMode(); @@ -369,8 +369,7 @@ bool WindowSessionImpl::GetCompatibleModeInPc() const bool WindowSessionImpl::IsAdaptToCompatibleImmersive() const { - auto property = GetPropertyByContext(); - return property->IsAdaptToImmersive(); + return property_->IsAdaptToImmersive(); } bool WindowSessionImpl::IsAdaptToSimulationScale() const @@ -954,7 +953,6 @@ void WindowSessionImpl::RemoveSubWindow(int32_t parentPersistentId) std::lock_guard lock(subWindowSessionMutex_); auto subIter = subWindowSessionMap_.find(parentPersistentId); if (subIter == subWindowSessionMap_.end()) { - TLOGW(WmsLogTag::WMS_SUB, "find parentPersistentId: %{public}d failed", parentPersistentId); return; } auto& subWindows = subIter->second; @@ -2723,7 +2721,7 @@ WMError WindowSessionImpl::SetWindowDelayRaiseEnabled(bool isEnabled) if (IsWindowSessionInvalid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - if (IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_FOCUS, "The is PcAppInPad, not supported"); return WMError::WM_OK; } @@ -2926,16 +2924,14 @@ void WindowSessionImpl::SetRequestedOrientation(Orientation orientation, bool ne if (!isNeededForciblySetOrientation(orientation)) { return; } + if (property_->IsSupportRotateFullScreen()) { + TLOGI(WmsLogTag::WMS_COMPAT, "compatible request horizontal orientation %{public}u", orientation); + property_->SetIsLayoutFullScreen(IsHorizontalOrientation(orientation)); + } if (needAnimation) { NotifyPreferredOrientationChange(orientation); SetUserRequestedOrientation(orientation); } - // when compatible mode disable fullscreen and request orientation, will enter into immersive mode - if (property_->IsFullScreenDisabled() && IsHorizontalOrientation(orientation)) { - TLOGI(WmsLogTag::WMS_COMPAT, "compatible request horizontal orientation %{public}u", orientation); - property_->SetIsLayoutFullScreen(true); - } - // the orientation of the invalid type is only applied to pageRotation. if (orientation == Orientation::INVALID) { Orientation requestedOrientation = ConvertInvalidOrientation(); property_->SetRequestedOrientation(requestedOrientation, needAnimation); @@ -3421,7 +3417,7 @@ WMError WindowSessionImpl::SetWindowTitleMoveEnabled(bool enable) if (IsWindowSessionInvalid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - if (IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_DECOR, "The is PcAppInPad, not supported"); return WMError::WM_OK; } @@ -3452,7 +3448,7 @@ WMError WindowSessionImpl::SetSubWindowModal(bool isModal, ModalityType modality TLOGE(WmsLogTag::WMS_SUB, "called by invalid window type, type:%{public}d", GetType()); return WMError::WM_ERROR_INVALID_CALLING; } - if (modalityType == ModalityType::APPLICATION_MODALITY && IsPadAndNotFreeMutiWindowCompatibleMode()) { + if (modalityType == ModalityType::APPLICATION_MODALITY && IsPadAndNotFreeMultiWindowCompatibleMode()) { TLOGE(WmsLogTag::WMS_SUB, "This is PcAppInPad, not support"); return WMError::WM_OK; } diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index 31187be9f8..9a5a1021c0 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -1820,131 +1820,6 @@ HWTEST_F(WindowSceneSessionImplTest5, StopMoveWindow, Function | SmallTest | Tes ASSERT_EQ(WmErrorCode::WM_OK, window->StopMoveWindow()); } -/** - * @tc.name: HandleWindowLimitsInCompatibleMode01 - * @tc.desc: HandleWindowLimitsInCompatibleMode - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest5, HandleWindowLimitsInCompatibleMode01, Function | SmallTest | Level2) -{ - sptr option = sptr::MakeSptr(); - sptr window = sptr::MakeSptr(option); - window->property_->SetPersistentId(1); - SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - window->hostSession_ = session; - sptr compatibleModeProperty = sptr::MakeSptr(); - compatibleModeProperty->SetDisableWindowLimit(true); - window->property_->SetCompatibleModeProperty(compatibleModeProperty); - window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - WindowSizeLimits windowSizeLimits = {0, 0, 0, 0}; - window->HandleWindowLimitsInCompatibleMode(windowSizeLimits); - EXPECT_EQ(windowSizeLimits.maxWindowWidth, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.maxWindowHeight, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.minWindowWidth, window->windowSystemConfig_.miniWidthOfMainWindow_); - EXPECT_EQ(windowSizeLimits.minWindowHeight, window->windowSystemConfig_.miniHeightOfMainWindow_); -} - -/** - * @tc.name: HandleWindowLimitsInCompatibleMode02 - * @tc.desc: HandleWindowLimitsInCompatibleMode - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest5, HandleWindowLimitsInCompatibleMode02, Function | SmallTest | Level2) -{ - sptr option = sptr::MakeSptr(); - sptr window = sptr::MakeSptr(option); - window->property_->SetPersistentId(1); - SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - window->hostSession_ = session; - sptr compatibleModeProperty = sptr::MakeSptr(); - compatibleModeProperty->SetDisableWindowLimit(true); - window->property_->SetCompatibleModeProperty(compatibleModeProperty); - window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); - WindowSizeLimits windowSizeLimits = {0, 0, 0, 0}; - window->HandleWindowLimitsInCompatibleMode(windowSizeLimits); - EXPECT_EQ(windowSizeLimits.maxWindowWidth, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.maxWindowHeight, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.minWindowWidth, window->windowSystemConfig_.miniWidthOfSubWindow_); - EXPECT_EQ(windowSizeLimits.minWindowHeight, window->windowSystemConfig_.miniHeightOfSubWindow_); -} - -/** - * @tc.name: HandleWindowLimitsInCompatibleMode03 - * @tc.desc: HandleWindowLimitsInCompatibleMode - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest5, HandleWindowLimitsInCompatibleMode03, Function | SmallTest | Level2) -{ - sptr option = sptr::MakeSptr(); - sptr window = sptr::MakeSptr(option); - window->property_->SetPersistentId(1); - SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - window->hostSession_ = session; - sptr compatibleModeProperty = sptr::MakeSptr(); - compatibleModeProperty->SetDisableWindowLimit(true); - window->property_->SetCompatibleModeProperty(compatibleModeProperty); - window->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); - WindowSizeLimits windowSizeLimits = {0, 0, 0, 0}; - window->HandleWindowLimitsInCompatibleMode(windowSizeLimits); - EXPECT_EQ(windowSizeLimits.maxWindowWidth, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.maxWindowHeight, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.minWindowWidth, window->windowSystemConfig_.miniWidthOfDialogWindow_); - EXPECT_EQ(windowSizeLimits.minWindowHeight, window->windowSystemConfig_.miniHeightOfDialogWindow_); -} - -/** - * @tc.name: HandleWindowLimitsInCompatibleMode04 - * @tc.desc: HandleWindowLimitsInCompatibleMode - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest5, HandleWindowLimitsInCompatibleMode04, Function | SmallTest | Level2) -{ - sptr option = sptr::MakeSptr(); - sptr window = sptr::MakeSptr(option); - window->property_->SetPersistentId(1); - SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - window->hostSession_ = session; - sptr compatibleModeProperty = sptr::MakeSptr(); - compatibleModeProperty->SetDisableWindowLimit(true); - window->property_->SetCompatibleModeProperty(compatibleModeProperty); - window->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); - WindowSizeLimits windowSizeLimits = {0, 0, 0, 0}; - window->HandleWindowLimitsInCompatibleMode(windowSizeLimits); - EXPECT_EQ(windowSizeLimits.maxWindowWidth, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.maxWindowHeight, window->windowSystemConfig_.maxFloatingWindowSize_); - EXPECT_EQ(windowSizeLimits.minWindowWidth, MIN_FLOATING_WIDTH); - EXPECT_EQ(windowSizeLimits.minWindowHeight, MIN_FLOATING_HEIGHT); -} - -/** - * @tc.name: HandleWindowLimitsInCompatibleMode05 - * @tc.desc: HandleWindowLimitsInCompatibleMode - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest5, HandleWindowLimitsInCompatibleMode05, Function | SmallTest | Level2) -{ - sptr option = sptr::MakeSptr(); - sptr window = sptr::MakeSptr(option); - window->property_->SetPersistentId(1); - SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; - sptr session = sptr::MakeSptr(sessionInfo); - window->hostSession_ = session; - sptr compatibleModeProperty = sptr::MakeSptr(); - compatibleModeProperty->SetDisableWindowLimit(true); - window->property_->SetCompatibleModeProperty(compatibleModeProperty); - window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - WindowSizeLimits windowSizeLimits = {0, 0, 0, 0}; - window->HandleWindowLimitsInCompatibleMode(windowSizeLimits); - EXPECT_EQ(windowSizeLimits.maxWindowWidth, 0); - EXPECT_EQ(windowSizeLimits.maxWindowHeight, 0); - EXPECT_EQ(windowSizeLimits.minWindowWidth, 0); - EXPECT_EQ(windowSizeLimits.minWindowHeight, 0); -} - /** * @tc.name: IsDecorEnable1 * @tc.desc: IsDecorEnable1 diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index 118a6eb549..5fc2c8c435 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -486,15 +486,15 @@ HWTEST_F(WindowSessionImplTest4, IsPcWindow, TestSize.Level1) } /** - * @tc.name: IsPadAndNotFreeMutiWindowCompatibleMode - * @tc.desc: IsPadAndNotFreeMutiWindowCompatibleMode + * @tc.name: IsPadAndNotFreeMultiWindowCompatibleMode + * @tc.desc: IsPadAndNotFreeMultiWindowCompatibleMode * @tc.type: FUNC */ -HWTEST_F(WindowSessionImplTest4, IsPadAndNotFreeMutiWindowCompatibleMode, TestSize.Level1) +HWTEST_F(WindowSessionImplTest4, IsPadAndNotFreeMultiWindowCompatibleMode, TestSize.Level1) { - GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPadAndNotFreeMutiWindowCompatibleMode start"; + GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPadAndNotFreeMultiWindowCompatibleMode start"; sptr option = sptr::MakeSptr(); - option->SetWindowName("IsPadAndNotFreeMutiWindowCompatibleMode"); + option->SetWindowName("IsPadAndNotFreeMultiWindowCompatibleMode"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); sptr window = sptr::MakeSptr(option); window->property_->SetPersistentId(1); @@ -504,13 +504,13 @@ HWTEST_F(WindowSessionImplTest4, IsPadAndNotFreeMutiWindowCompatibleMode, TestSi window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; window->property_->SetPcAppInpadCompatibleMode(true); window->windowSystemConfig_.freeMultiWindowEnable_ = false; - EXPECT_EQ(true, window->IsPadAndNotFreeMutiWindowCompatibleMode()); + EXPECT_EQ(true, window->IsPadAndNotFreeMultiWindowCompatibleMode()); window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; window->property_->SetPcAppInpadCompatibleMode(true); window->windowSystemConfig_.freeMultiWindowEnable_ = true; - window->windowSystemConfig_.isSystemDecorEnable_ = true; - EXPECT_EQ(false, window->IsPadAndNotFreeMutiWindowCompatibleMode()); - GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPadAndNotFreeMutiWindowCompatibleMode end"; + window->windowSystemConfig_.freeMultiWindowSupport_ = true; + EXPECT_EQ(false, window->IsPadAndNotFreeMultiWindowCompatibleMode()); + GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPadAndNotFreeMultiWindowCompatibleMode end"; } /** -- Gitee From 8ccbc249913a1c5fc813bed6f338737cf4bb412b Mon Sep 17 00:00:00 2001 From: LHHHYYY Date: Thu, 21 Aug 2025 14:42:05 +0800 Subject: [PATCH 112/241] =?UTF-8?q?SCB=E5=AD=90=E7=AA=97=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E7=88=B6=E7=AA=97=E6=8A=AC=E5=8D=87=E8=BF=87=E6=BB=A4=E4=BB=85?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LHHHYYY --- 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 6ffc701025..6828e6637c 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2437,7 +2437,7 @@ WSError Session::HandleSubWindowClick(int32_t action, int32_t sourceType, bool i GetPersistentId(), raiseEnabled, isPointDown, isPointDown); if (raiseEnabled && isPointDown && !isModal) { RaiseToAppTopForPointDown(); - } else if (parentSession && !isPointMove) { + } else if (parentSession && isPointDown) { // sub window is forbidden to raise to top after click, but its parent should raise parentSession->NotifyClick(!IsScbCoreEnabled()); } -- Gitee From 1151b78d45f4adfa212bad47e522b34321f8b13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Thu, 21 Aug 2025 14:44:32 +0800 Subject: [PATCH 113/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8pad=E6=A8=A1=E5=BC=8F=E5=88=87=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E5=90=8E=EF=BC=8C=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=8F=98=E5=8C=96=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- window_scene/session/host/src/session.cpp | 4 ++-- window_scene/test/unittest/session_test.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 7b35ae437e..f13afff318 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3341,12 +3341,12 @@ WSError Session::SetAppSupportPhoneInPc(bool isSupportPhone) WSError Session::SetCompatibleModeProperty(const sptr compatibleModeProperty) { auto property = GetSessionProperty(); - if (property == nullptr) { + if (property == nullptr || compatibleModeProperty == nullptr) { TLOGE(WmsLogTag::WMS_COMPAT, "id: %{public}d property is nullptr", persistentId_); return WSError::WS_ERROR_NULLPTR; } property->SetCompatibleModeProperty(compatibleModeProperty); - if (compatibleModeProperty && compatibleModeProperty->IsDragResizeDisabled()) { + if (compatibleModeProperty->IsDragResizeDisabled()) { property->SetDragEnabled(false); } if (!sessionStage_) { diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 4c845aa02e..033dd4afaa 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -187,7 +187,10 @@ HWTEST_F(WindowSessionTest, SetActive01, TestSize.Level1) */ HWTEST_F(WindowSessionTest, SetCompatibleModeProperty, TestSize.Level1) { - sptr compatibleModeProperty = sptr::MakeSptr(); + sptr compatibleModeProperty = nullptr; + ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); + compatibleModeProperty = sptr::MakeSptr(); + EXPECT_NE(nullptr, session_->GetSessionProperty()); ASSERT_EQ(session_->GetSessionProperty()->GetDragEnabled(), true); compatibleModeProperty->SetDisableDragResize(true); ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); -- Gitee From 1a3d44894857ec0642baf4033bc76b7c19db917b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Thu, 21 Aug 2025 15:49:02 +0800 Subject: [PATCH 114/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=BA=94=E7=94=A8pad=E6=A8=A1=E5=BC=8F=E5=88=87=E8=87=AA?= =?UTF-8?q?=E7=94=B1=E5=A4=9A=E7=AA=97=E5=90=8E=EF=BC=8C=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=8F=98=E5=8C=96=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- window_scene/test/unittest/session_test.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 033dd4afaa..c992c4e24e 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -187,10 +187,12 @@ HWTEST_F(WindowSessionTest, SetActive01, TestSize.Level1) */ HWTEST_F(WindowSessionTest, SetCompatibleModeProperty, TestSize.Level1) { + EXPECT_NE(nullptr, session_->GetSessionProperty()); sptr compatibleModeProperty = nullptr; - ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); + ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); compatibleModeProperty = sptr::MakeSptr(); - EXPECT_NE(nullptr, session_->GetSessionProperty()); + session_->sessionStage_ = mockSessionStage_; + ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); ASSERT_EQ(session_->GetSessionProperty()->GetDragEnabled(), true); compatibleModeProperty->SetDisableDragResize(true); ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); -- Gitee From 4eeda2aa61d47ebb1e1e3c37ad7d7cecd31ef74c Mon Sep 17 00:00:00 2001 From: meikun Date: Thu, 21 Aug 2025 16:29:35 +0800 Subject: [PATCH 115/241] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun --- previewer/include/window_option.h | 1 + wm/src/window_scene_session_impl.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/previewer/include/window_option.h b/previewer/include/window_option.h index a1ed304df2..204c9495af 100644 --- a/previewer/include/window_option.h +++ b/previewer/include/window_option.h @@ -283,6 +283,7 @@ public: /** * @brief Get sub window outline enabled * + * @return is sub window outline enabled */ bool IsSubWindowOutlineEnabled() const; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 117d76fb87..8ce50c81b3 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -3276,7 +3276,7 @@ bool WindowSceneSessionImpl::IsDecorEnable() const bool isSubWindow = WindowHelper::IsSubWindow(windowType); bool isDialogWindow = WindowHelper::IsDialogWindow(windowType); bool isValidWindow = isMainWindow || - ((isSubWindow || isDialogWindow) && property_->IsDecorEnable()); + ((isSubWindow || isDialogWindow || IsSubWindowMaximizeSupported()) && property_->IsDecorEnable()); bool isWindowModeSupported = WindowHelper::IsWindowModeSupported( windowSystemConfig_.decorWindowModeSupportType_, GetWindowMode()); if (windowSystemConfig_.freeMultiWindowSupport_) { @@ -3287,6 +3287,9 @@ bool WindowSceneSessionImpl::IsDecorEnable() const if ((isSubWindow || isDialogWindow) && property_->GetIsPcAppInPad() && property_->IsDecorEnable()) { enable = true; } + if (IsSubWindowMaximizeSupported() && property_->IsDecorEnable()) { + enable = true; + } TLOGD(WmsLogTag::WMS_DECOR, "get decor enable %{public}d", enable); return enable; } -- Gitee From 431d1afa1ee9957ed546a95f1db5e9f60b61486f Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 21 Aug 2025 11:54:37 +0800 Subject: [PATCH 116/241] fix1 Signed-off-by: chaos --- .../screen_session_manager/src/screen_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 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 99eb7aa9b1..b8abb69da9 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1699,8 +1699,8 @@ void ScreenSessionManager::OnHgmRefreshRateChange(uint32_t refreshRate) screenSession->UpdateRefreshRate(refreshRate); NotifyDisplayChanged(screenSession->ConvertToDisplayInfo(), DisplayChangeEvent::UPDATE_REFRESHRATE); - UpdateCoordinationRefreshRate(screenSession, refreshRate); - UpdateSuperFoldRefreshRate(refreshRate); + UpdateCoordinationRefreshRate(refreshRate); + UpdateSuperFoldRefreshRate(screenSession, refreshRate); std::map> screenSessionMap; { std::lock_guard lock(screenSessionMapMutex_); -- Gitee From 01b756b38049e3cdb6a1bf6b374e1dca2798c87f Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 21 Aug 2025 17:22:37 +0800 Subject: [PATCH 117/241] fix2 Signed-off-by: chaos --- .../screen_session_manager/src/screen_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 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 b8abb69da9..411b9742a7 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1729,18 +1729,18 @@ void ScreenSessionManager::UpdateSuperFoldRefreshRate(sptr screen return; } if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "screenSession is nullptr") + TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); return; } sptr fakeScreenSession = screenSession->GetFakeScreenSession(); if (fakeScreenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "fakeScreenSession is nullptr") + TLOGE(WmsLogTag::DMS, "fakeScreenSession is nullptr"); return; } fakeScreenSession->UpdateRefreshRate(refreshRate); if (screenSession->GetScreenProperty().GetIsFakeInUse()) { NotifyDisplayChanged(fakeScreenSession->ConvertToDisplayInfo(), DisplayChangeEvent::UPDATE_REFRESHRATE); - TLOGE(WmsLogTag::DMS, "notify success") + TLOGE(WmsLogTag::DMS, "notify success"); } } -- Gitee From 870d9fda2575c2e22ca8a3898648eaf8b989a88b Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Mon, 18 Aug 2025 20:31:21 +0800 Subject: [PATCH 118/241] =?UTF-8?q?=E6=88=AA=E5=9B=BE=E5=BD=A2=E6=80=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laiganlu --- window_scene/session/host/include/session.h | 2 +- .../session/host/include/ws_snapshot_helper.h | 22 +++++++++- window_scene/session/host/src/session.cpp | 26 +++--------- .../session/host/src/ws_snapshot_helper.cpp | 41 +++++++++++++++++-- .../src/scene_session_manager.cpp | 3 ++ .../window_pattern_snapshot_test.cpp | 11 +---- 6 files changed, 69 insertions(+), 36 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index e5d8b434d1..1b85e0e8f8 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -736,7 +736,7 @@ public: void InitSnapshotCapacity(); SnapshotStatus GetWindowStatus() const; SnapshotStatus GetSessionSnapshotStatus(BackgroundReason reason = BackgroundReason::DEFAULT) const; - DisplayOrientation GetWindowOrientation() const; + uint32_t GetWindowOrientation() const; uint32_t GetLastOrientation() const; bool HasSnapshotFreeMultiWindow(); bool HasSnapshot(SnapshotStatus key); diff --git a/window_scene/session/host/include/ws_snapshot_helper.h b/window_scene/session/host/include/ws_snapshot_helper.h index f3b9a23165..8110b041bd 100644 --- a/window_scene/session/host/include/ws_snapshot_helper.h +++ b/window_scene/session/host/include/ws_snapshot_helper.h @@ -44,11 +44,16 @@ constexpr SnapshotStatus maxCapacity = { SCREEN_COUNT, ORIENTATION_COUNT }; class WSSnapshotHelper { public: - WSSnapshotHelper() = default; - ~WSSnapshotHelper() = default; + static WSSnapshotHelper* GetInstance(); static uint32_t GetScreenStatus(); static uint32_t GetScreenStatus(FoldStatus foldStatus); static DisplayOrientation GetDisplayOrientation(int32_t rotation); + static void SetWindowScreenStatus(uint32_t screenStatus); + static void SetWindowScreenStatus(FoldStatus foldStatus); + static void SetWindowOrientationStatus(uint32_t orientationStatus); + static void SetWindowOrientationStatus(Rotation rotation); + static SnapshotStatus GetWindowStatus(); + static uint32_t GetRotation(); static inline uint32_t GetOrientation(int32_t rotation) { if (rotation == LANDSCAPE_ANGLE || rotation == LANDSCAPE_INVERTED_ANGLE) { @@ -65,6 +70,19 @@ public: } 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_; }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 6ffc701025..0d86c6f751 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2889,10 +2889,7 @@ SnapshotStatus Session::GetWindowStatus() const if (!SupportSnapshotAllSessionStatus()) { return defaultStatus; } - uint32_t snapshotScreen = WSSnapshotHelper::GetScreenStatus(); - auto windowOrientation = GetWindowOrientation(); - uint32_t orientation = WSSnapshotHelper::GetOrientation(windowOrientation); - return std::make_pair(snapshotScreen, orientation); + return WSSnapshotHelper::GetWindowStatus(); } SnapshotStatus Session::GetSessionSnapshotStatus(BackgroundReason reason) const @@ -2913,25 +2910,12 @@ SnapshotStatus Session::GetSessionSnapshotStatus(BackgroundReason reason) const return std::make_pair(snapshotScreen, orientation); } -DisplayOrientation Session::GetWindowOrientation() const +uint32_t Session::GetWindowOrientation() const { if (!SupportSnapshotAllSessionStatus()) { - return DisplayOrientation::PORTRAIT; - } - DisplayId displayId = GetScreenId(); - auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId); - if (!screenSession) { - TLOGE(WmsLogTag::WMS_PATTERN, "screenSession is nullptr, id:%{public}d", persistentId_); - return DisplayOrientation::PORTRAIT; - } - auto screenProperty = screenSession->GetScreenProperty(); - DisplayOrientation displayOrientation = screenProperty.GetDisplayOrientation(); - auto windowOrientation = static_cast(displayOrientation); - auto snapshotScreen = WSSnapshotHelper::GetScreenStatus(); - if (snapshotScreen == SCREEN_UNKNOWN) { - windowOrientation = (windowOrientation + SECONDARY_EXPAND_OFFSET) % ROTATION_COUNT; - } - return static_cast(windowOrientation); + return 0; + } + return WSSnapshotHelper::GetRotation(); } uint32_t Session::GetLastOrientation() const diff --git a/window_scene/session/host/src/ws_snapshot_helper.cpp b/window_scene/session/host/src/ws_snapshot_helper.cpp index dd8c3eb10d..33696c4f49 100644 --- a/window_scene/session/host/src/ws_snapshot_helper.cpp +++ b/window_scene/session/host/src/ws_snapshot_helper.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ -#include "screen_session_manager_client/include/screen_session_manager_client.h" #include "session/host/include/ws_snapshot_helper.h" namespace OHOS::Rosen { @@ -26,10 +25,15 @@ const std::unordered_map ROTATION_TO_DISPLAYORIENTA }; } +WSSnapshotHelper* WSSnapshotHelper::GetInstance() +{ + static WSSnapshotHelper instance; + return &instance; +} + uint32_t WSSnapshotHelper::GetScreenStatus() { - FoldStatus foldStatus = ScreenSessionManagerClient::GetInstance().GetFoldStatus(); - return GetScreenStatus(foldStatus); + return GetInstance()->windowStatus_.first; } // LCOV_EXCL_START @@ -53,5 +57,36 @@ DisplayOrientation WSSnapshotHelper::GetDisplayOrientation(int32_t rotation) } return DisplayOrientation::PORTRAIT; } + +void WSSnapshotHelper::SetWindowScreenStatus(uint32_t screenStatus) +{ + GetInstance()->windowStatus_.first = screenStatus; +} + +void WSSnapshotHelper::SetWindowScreenStatus(FoldStatus foldStatus) +{ + SetWindowScreenStatus(GetScreenStatus(foldStatus)); +} + +void WSSnapshotHelper::SetWindowOrientationStatus(uint32_t orientationStatus) +{ + GetInstance()->windowStatus_.second = orientationStatus; +} + +void WSSnapshotHelper::SetWindowOrientationStatus(Rotation rotation) +{ + GetInstance()->windowRotation_ = rotation; + SetWindowOrientationStatus(GetOrientation(rotation)); +} + +SnapshotStatus WSSnapshotHelper::GetWindowStatus() +{ + return GetInstance()->windowStatus_; +} + +uint32_t WSSnapshotHelper::GetRotation() +{ + return static_cast(GetInstance()->windowRotation_); +} // LCOV_EXCL_STOP } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1a104d886f..d8722bee8d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -71,6 +71,7 @@ #include "session/host/include/session_change_recorder.h" #include "session/host/include/session_utils.h" #include "session/host/include/sub_session.h" +#include "session/host/include/ws_snapshot_helper.h" #include "session_helper.h" #include "session_manager_agent_controller.h" #include "singleton_container.h" @@ -12210,6 +12211,7 @@ void SceneSessionManager::ProcessUpdateRotationChange(DisplayId defaultDisplayId sceneSession->SetRotation(displayInfo->GetRotation()); sceneSession->UpdateOrientation(); } + WSSnapshotHelper::SetWindowOrientationStatus(displayInfo->GetRotation()); UpdateDisplayRegion(displayInfo); return WSError::WS_OK; }, "ProcessUpdateRotationChange" + std::to_string(defaultDisplayId)); @@ -15336,6 +15338,7 @@ WMError SceneSessionManager::MakeScreenFoldData(const std::vector& screenFoldData.currentScreenFoldStatusDuration_ = std::stoi(screenFoldInfo[2]); // 2: current duration screenFoldData.postureAngle_ = std::atof(screenFoldInfo[3].c_str()); // 3: posture angle (type: float) screenFoldData.screenRotation_ = std::stoi(screenFoldInfo[4]); // 4: screen rotation + WSSnapshotHelper::SetWindowScreenStatus(static_cast(screenFoldData.nextScreenFoldStatus_)); if (!screenFoldData.GetTypeCThermalWithUtil()) { TLOGI(WmsLogTag::DMS, "Error: fail to get typeC thermal."); return WMError::WM_DO_NOTHING; 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 c94e1bd2cc..d1dd2693b4 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 @@ -752,21 +752,14 @@ HWTEST_F(WindowPatternSnapshotTest, GetWindowOrientation, TestSize.Level1) info.screenId_ = 0; sptr sceneSession = sptr::MakeSptr(info, nullptr); auto ret = sceneSession->GetWindowOrientation(); - EXPECT_EQ(ret, DisplayOrientation::PORTRAIT); + EXPECT_EQ(ret, 0); sceneSession->capacity_ = maxCapacity; - ScreenId screenId = 0; - sptr screenSession = nullptr; - screenSession = new ScreenSession(0, ScreenProperty(), 0); - ASSERT_NE(screenSession, nullptr); - ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession); - sceneSession->GetWindowOrientation(); - ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); session_->capacity_ = maxCapacity; ret = session_->GetWindowOrientation(); - EXPECT_EQ(ret, DisplayOrientation::PORTRAIT); + EXPECT_EQ(ret, WSSnapshotHelper::GetRotation()); } /** -- Gitee From f2f9cd393961a486f0658d36a30dac0f9ed5aa80 Mon Sep 17 00:00:00 2001 From: zhangweihua Date: Thu, 14 Aug 2025 17:35:04 +0800 Subject: [PATCH 119/241] bug fix Signed-off-by: zhangweihua --- dm/test/unittest/screen_test.cpp | 6 +----- window_scene/screen_session_manager/BUILD.gn | 2 ++ .../sensor_fold_state_manager/sensor_fold_state_manager.h | 1 - .../screen_session_manager/include/screen_session_manager.h | 3 +++ .../sensor_fold_state_manager/sensor_fold_state_manager.cpp | 6 +++--- .../screen_session_manager/src/screen_session_manager.cpp | 6 ++++++ .../src/screen_session_manager_client.cpp | 1 - 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dm/test/unittest/screen_test.cpp b/dm/test/unittest/screen_test.cpp index b30d78970c..d761e970bb 100644 --- a/dm/test/unittest/screen_test.cpp +++ b/dm/test/unittest/screen_test.cpp @@ -39,26 +39,22 @@ public: virtual void SetUp() override; virtual void TearDown() override; - static sptr defaultDisplay_; static ScreenId defaultScreenId_; static sptr screen_; }; -sptr ScreenTest::defaultDisplay_ = nullptr; ScreenId ScreenTest::defaultScreenId_ = SCREEN_ID_INVALID; sptr ScreenTest::screen_ = nullptr; bool g_isPcDevice = ScreenSceneConfig::GetExternalScreenDefaultMode() == "none"; void ScreenTest::SetUpTestCase() { - defaultDisplay_ = DisplayManager::GetInstance().GetDefaultDisplay(); - defaultScreenId_ = static_cast(defaultDisplay_->GetId()); + defaultScreenId_ = DisplayManager::GetInstance().GetDefaultDisplayId(); screen_ = ScreenManager::GetInstance().GetScreenById(defaultScreenId_); usleep(SLEEP_TIME_IN_US); } void ScreenTest::TearDownTestCase() { - defaultDisplay_ = nullptr; screen_ = nullptr; } diff --git a/window_scene/screen_session_manager/BUILD.gn b/window_scene/screen_session_manager/BUILD.gn index 4c7311cbc7..d2f89128ab 100644 --- a/window_scene/screen_session_manager/BUILD.gn +++ b/window_scene/screen_session_manager/BUILD.gn @@ -61,6 +61,7 @@ ohos_shared_library("screen_session_manager") { sources = [ "../../dm/src/zidl/display_manager_agent_proxy.cpp", "../screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp", + "../session_manager/src/ffrt_queue_helper.cpp", "src/connection/screen_cast_connection.cpp", "src/connection/screen_session_ability_connection.cpp", "src/connection/screen_snapshot_picker_connection.cpp", @@ -125,6 +126,7 @@ ohos_shared_library("screen_session_manager") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hicollie:libhicollie", diff --git a/window_scene/screen_session_manager/include/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.h b/window_scene/screen_session_manager/include/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.h index 9393c864c9..e41c088fc8 100644 --- a/window_scene/screen_session_manager/include/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.h +++ b/window_scene/screen_session_manager/include/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.h @@ -66,7 +66,6 @@ private: void ProcessNotifyFoldStatusChange(FoldStatus currentStatus, FoldStatus nextStatus, const std::vector& angles, sptr foldScreenPolicy); - std::shared_ptr taskScheduler_ = nullptr; }; } // namespace OHOS::Rosen #endif //OHOS_ROSEN_SMALL_DEVICE_SCREEN_SENSOR_MANAGER_H \ No newline at end of file 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 25da9bc115..8b5c495c1b 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -31,6 +31,7 @@ #include "session_display_power_controller.h" #include "wm_single_instance.h" #include "screen_edid_parse.h" +#include "session_manager/include/ffrt_queue_helper.h" #include "agent_death_recipient.h" #include "screen.h" @@ -480,6 +481,7 @@ public: bool SetScreenOffset(ScreenId screenId, float offsetX, float offsetY); bool SynchronizePowerStatus(ScreenPowerState state) override; std::shared_ptr GetPowerTaskScheduler() const; + std::shared_ptr GetFfrtQueueHelper() const; bool GetCancelSuspendStatus() const; protected: @@ -655,6 +657,7 @@ private: RSInterfaces& rsInterface_; std::shared_ptr taskScheduler_; std::shared_ptr screenPowerTaskScheduler_; + std::shared_ptr ffrtQueueHelper_ = nullptr; /* * multi user diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp index 1e63af8bd4..e62a03a5c2 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp @@ -121,9 +121,9 @@ void SensorFoldStateManager::HandleSensorChange(FoldStatus nextState, const std: } manager->ProcessNotifyFoldStatusChange(currentState, newState, angles, policy); }; - taskScheduler_ = ScreenSessionManager::GetInstance().GetPowerTaskScheduler(); - if (taskScheduler_ != nullptr) { - taskScheduler_->PostAsyncTask(task, "secondaryFoldStatusChange"); + auto ffrtQueueHelper = ScreenSessionManager::GetInstance().GetFfrtQueueHelper(); + if (ffrtQueueHelper != nullptr) { + ffrtQueueHelper->SubmitTask(task); } } 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 1d68aef0c9..36a22b3a63 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -223,6 +223,7 @@ ScreenSessionManager::ScreenSessionManager() screenOnDelay_ = CV_WAIT_SCREENON_MS; taskScheduler_ = std::make_shared(SCREEN_SESSION_MANAGER_THREAD); screenPowerTaskScheduler_ = std::make_shared(SCREEN_SESSION_MANAGER_SCREEN_POWER_THREAD); + ffrtQueueHelper_ = std::make_shared(); screenCutoutController_ = new (std::nothrow) ScreenCutoutController(); if (!screenCutoutController_) { TLOGE(WmsLogTag::DMS, "screenCutoutController_ is nullptr"); @@ -10942,6 +10943,11 @@ std::shared_ptr ScreenSessionManager::GetPowerTaskScheduler() con return screenPowerTaskScheduler_; } +std::shared_ptr ScreenSessionManager::GetFfrtQueueHelper() const +{ + return ffrtQueueHelper_; +} + bool ScreenSessionManager::GetCancelSuspendStatus() const { if (!sessionDisplayPowerController_) { 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 2737592886..3e027f78cc 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 @@ -1005,7 +1005,6 @@ bool ScreenSessionManagerClient::HandleScreenDisconnection(SessionOption option) TLOGE(WmsLogTag::DMS, "screenSession is null"); return false; } - screenSession->DestroyScreenScene(); NotifyScreenDisconnect(screenSession); { std::lock_guard lock(screenSessionMapMutex_); -- Gitee From f77c73411ec1c41c91c3497e643162ca90a43f52 Mon Sep 17 00:00:00 2001 From: meikun Date: Thu, 21 Aug 2025 19:31:54 +0800 Subject: [PATCH 120/241] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun --- wm/include/window_scene_session_impl.h | 1 + wm/include/window_session_impl.h | 1 - wm/src/window_scene_session_impl.cpp | 19 +++++++++++++++++++ wm/src/window_session_impl.cpp | 1 - 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 16a6b36097..0d45394317 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -415,6 +415,7 @@ private: * Window Layout */ void CheckMoveConfiguration(MoveConfiguration& moveConfiguration); + void UpdateEnableDragWhenSwitchMultiWindow(bool enable); WMError GetAppHookWindowInfoFromServer(HookWindowInfo& hookWindowInfo) override; /* diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 6f578ce4f9..18c5e4027a 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -473,7 +473,6 @@ public: WMError UnregisterWindowStatusDidChangeListener(const sptr& listener) override; WSError NotifyLayoutFinishAfterWindowModeChange(WindowMode mode) override { return WSError::WS_OK; } WMError UpdateWindowModeForUITest(int32_t updateMode) override { return WMError::WM_OK; } - void UpdateEnableDragWhenSwitchMultiWindow(bool enable); WSError NotifyAppHookWindowInfoUpdated() override { return WSError::WS_DO_NOTHING; } void SetNotifySizeChangeFlag(bool flag); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 8ce50c81b3..fe7aadaf18 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -5492,6 +5492,25 @@ void WindowSceneSessionImpl::UpdateSupportWindowModesWhenSwitchFreeMultiWindow() UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); } +void WindowSceneSessionImpl::UpdateEnableDragWhenSwitchMultiWindow(bool enable) +{ + if (hasSetEnableDrag_.load() || property_->IsDragResizeDisabled()) { + TLOGI(WmsLogTag::WMS_LAYOUT, "EnableDrag is already set, id: %{public}d", GetPersistentId()); + return; + } + auto isSystemWindow = WindowHelper::IsSystemWindow(property_->GetWindowType()); + bool isDialog = WindowHelper::IsDialogWindow(property_->GetWindowType()); + bool isSystemCalling = property_->GetSystemCalling(); + TLOGI(WmsLogTag::WMS_LAYOUT, "windId: %{public}d, isSystemWindow: %{public}d, isDialog: %{public}d, " + "isSystemCalling: %{public}d", GetPersistentId(), isSystemWindow, isDialog, isSystemCalling); + if (!enable || (isSystemWindow && !isDialog && !isSystemCalling)) { + property_->SetDragEnabled(false); + } else { + property_->SetDragEnabled(true); + } + UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED); +} + WSError WindowSceneSessionImpl::SwitchFreeMultiWindow(bool enable) { if (IsWindowSessionInvalid()) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0a62e589d2..eed743a973 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -8082,7 +8082,6 @@ void WindowSessionImpl::SwitchSubWindow(bool freeMultiWindowEnable, int32_t pare subWindowSession->SetFreeMultiWindowMode(freeMultiWindowEnable); subWindowSession->UpdateTitleButtonVisibility(); subWindowSession->UpdateDecorEnable(true); - subWindowSession->UpdateEnableDragWhenSwitchMultiWindow(freeMultiWindowEnable); subWindowSession->SwitchSubWindow(freeMultiWindowEnable, subWindowSession->GetPersistentId()); } } -- Gitee From db2a20e6e5dd10fdd7b1ff5bac20afbf2d1b4587 Mon Sep 17 00:00:00 2001 From: meikun Date: Thu, 21 Aug 2025 19:35:24 +0800 Subject: [PATCH 121/241] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun --- .../window_scene_session_impl_test5.cpp | 31 +++++++++++++++++++ .../unittest/window_session_impl_test5.cpp | 31 ------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index 31187be9f8..db60966a1d 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -2095,6 +2095,37 @@ HWTEST_F(WindowSceneSessionImplTest5, SetFrameRectForPartialZoomIn02, Function | EXPECT_EQ(WMError::WM_OK, window->SetFrameRectForPartialZoomIn(frameRect)); } +/** + * @tc.name: UpdateEnableDragWhenSwitchMultiWindow + * @tc.desc: UpdateEnableDragWhenSwitchMultiWindow + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, UpdateEnableDragWhenSwitchMultiWindow, Function | SmallTest | Level2) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("UpdateEnableDragWhenSwitchMultiWindow"); + option->SetWindowType(WindowType::WINDOW_TYPE_MAGNIFICATION); + sptr window = sptr::MakeSptr(option); + window->hasSetEnableDrag_.store(true); + window->UpdateEnableDragWhenSwitchMultiWindow(false); + EXPECT_EQ(true, window->property_->dragEnabled_); + + window->hasSetEnableDrag_.store(false); + window->UpdateEnableDragWhenSwitchMultiWindow(false); + EXPECT_EQ(false, window->property_->dragEnabled_); + + window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; + sptr property = sptr::MakeSptr(); + property->disableDragResize_ = true; + window->property_->compatibleModeProperty_ = property; + window->UpdateEnableDragWhenSwitchMultiWindow(true); + EXPECT_EQ(false, window->property_->dragEnabled_); + + property->disableDragResize_ = false; + window->UpdateEnableDragWhenSwitchMultiWindow(true); + EXPECT_EQ(true, window->property_->dragEnabled_); +} + /** * @tc.name: GetConfigurationFromAbilityInfo * @tc.desc: GetConfigurationFromAbilityInfo diff --git a/wm/test/unittest/window_session_impl_test5.cpp b/wm/test/unittest/window_session_impl_test5.cpp index 7d438515fa..b19ea601b1 100644 --- a/wm/test/unittest/window_session_impl_test5.cpp +++ b/wm/test/unittest/window_session_impl_test5.cpp @@ -1896,37 +1896,6 @@ HWTEST_F(WindowSessionImplTest5, OnPointDown, TestSize.Level1) EXPECT_TRUE(window->OnPointDown(0, 0, 0)); } -/** - * @tc.name: UpdateEnableDragWhenSwitchMultiWindow - * @tc.desc: UpdateEnableDragWhenSwitchMultiWindow - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest5, UpdateEnableDragWhenSwitchMultiWindow, Function | SmallTest | Level2) -{ - sptr option = sptr::MakeSptr(); - option->SetWindowName("UpdateEnableDragWhenSwitchMultiWindow"); - option->SetWindowType(WindowType::WINDOW_TYPE_MAGNIFICATION); - sptr window = sptr::MakeSptr(option); - window->hasSetEnableDrag_.store(true); - window->UpdateEnableDragWhenSwitchMultiWindow(false); - EXPECT_EQ(true, window->property_->dragEnabled_); - - window->hasSetEnableDrag_.store(false); - window->UpdateEnableDragWhenSwitchMultiWindow(false); - EXPECT_EQ(false, window->property_->dragEnabled_); - - window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; - sptr property = sptr::MakeSptr(); - property->disableDragResize_ = true; - window->property_->compatibleModeProperty_ = property; - window->UpdateEnableDragWhenSwitchMultiWindow(true); - EXPECT_EQ(false, window->property_->dragEnabled_); - - property->disableDragResize_ = false; - window->UpdateEnableDragWhenSwitchMultiWindow(true); - EXPECT_EQ(true, window->property_->dragEnabled_); -} - /** * @tc.name: SwitchSubWindow * @tc.desc: SwitchSubWindow -- Gitee From 0fbe63b39b6c5081f0ee2cd0a6a372a7eb8c67cd Mon Sep 17 00:00:00 2001 From: meikun Date: Thu, 21 Aug 2025 19:47:08 +0800 Subject: [PATCH 122/241] =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun --- wm/src/window_session_impl.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index eed743a973..9418529e08 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -8087,25 +8087,6 @@ void WindowSessionImpl::SwitchSubWindow(bool freeMultiWindowEnable, int32_t pare } } -void WindowSessionImpl::UpdateEnableDragWhenSwitchMultiWindow(bool enable) -{ - if (hasSetEnableDrag_.load() || property_->IsDragResizeDisabled()) { - TLOGI(WmsLogTag::WMS_LAYOUT, "EnableDrag is already set, id: %{public}d", GetPersistentId()); - return; - } - auto isSystemWindow = WindowHelper::IsSystemWindow(property_->GetWindowType()); - bool isDialog = WindowHelper::IsDialogWindow(property_->GetWindowType()); - bool isSystemCalling = property_->GetSystemCalling(); - TLOGI(WmsLogTag::WMS_LAYOUT, "windId: %{public}d, isSystemWindow: %{public}d, isDialog: %{public}d, " - "isSystemCalling: %{public}d", GetPersistentId(), isSystemWindow, isDialog, isSystemCalling); - if (!enable || (isSystemWindow && !isDialog && !isSystemCalling)) { - property_->SetDragEnabled(false); - } else { - property_->SetDragEnabled(true); - } - UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED); -} - void WindowSessionImpl::SetNotifySizeChangeFlag(bool flag) { if (flag) { -- Gitee From 375d3696b0a66f39c909059323a7691628a2cab0 Mon Sep 17 00:00:00 2001 From: LHHHYYY Date: Thu, 21 Aug 2025 19:45:38 +0800 Subject: [PATCH 123/241] =?UTF-8?q?=E6=96=B0=E5=A2=9EUT=E7=94=A8=E4=BE=8BS?= =?UTF-8?q?essionSpecificWindowTest.HandleSubWindowClick08?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LHHHYYY --- .../unittest/session_specific_window_test.cpp | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/window_scene/test/unittest/session_specific_window_test.cpp b/window_scene/test/unittest/session_specific_window_test.cpp index 01f51daa74..d9a1eab8c1 100644 --- a/window_scene/test/unittest/session_specific_window_test.cpp +++ b/window_scene/test/unittest/session_specific_window_test.cpp @@ -715,6 +715,49 @@ HWTEST_F(SessionSpecificWindowTest, HandleSubWindowClick07, Function | SmallTest MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, false); EXPECT_EQ(hasNotifyManagerToRequestFocus, true); } + +/** + * @tc.name: HandleSubWindowClick08 + * @tc.desc: HandleSubWindowClick + * @tc.type: FUNC + */ +HWTEST_F(SessionSpecificWindowTest, HandleSubWindowClick08, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + + SessionInfo info; + info.abilityName_ = "testSession1"; + info.moduleName_ = "testSession2"; + info.bundleName_ = "testSession3"; + sptr parentSession = sptr::MakeSptr(info); + + bool hasNotifyManagerToRaise = false; + parentSession->SetClickListener([&hasNotifyManagerToRaise](bool requestFocus, bool isClick) { + hasNotifyManagerToRaise = true; + }); + + session_->property_->SetRaiseEnabled(false); + hasNotifyManagerToRaise = false; + session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, + MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, false); + EXPECT_EQ(hasNotifyManagerToRaise, false); + + session_->SetParentSession(parentSession); + hasNotifyManagerToRaise = false; + session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_MOVE, + MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, false); + EXPECT_EQ(hasNotifyManagerToRaise, false); + + hasNotifyManagerToRaise = false; + session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, + MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, false); + EXPECT_EQ(hasNotifyManagerToRaise, true); + + hasNotifyManagerToRaise = false; + session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_DOWN, + MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, false); + EXPECT_EQ(hasNotifyManagerToRaise, true); +} } // namespace } // namespace Rosen } // namespace OHOS -- Gitee From dd14386c7c5282d9b864d059ce29ce724a24b203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Thu, 21 Aug 2025 18:57:05 +0800 Subject: [PATCH 124/241] =?UTF-8?q?TDD=E9=BB=84=E8=93=9D=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- interfaces/innerkits/wm/window.h | 6 ++---- .../napi/window_runtime/window_napi/js_window.cpp | 2 +- previewer/include/window_impl.h | 3 +-- previewer/src/window_impl.cpp | 2 +- .../common/include/window_session_property.h | 8 +++++--- .../test/dms_unittest/screen_session_test.cpp | 2 +- window_scene/test/mock/mock_session.h | 5 +---- wm/include/window_extension_session_impl.h | 2 +- wm/include/window_impl.h | 3 +-- wm/include/window_scene_session_impl.h | 6 ++---- wm/src/window_extension_session_impl.cpp | 3 +-- wm/src/window_impl.cpp | 2 +- wm/src/window_scene.cpp | 7 +++---- wm/src/window_scene_session_impl.cpp | 13 ++++--------- wm/src/window_session_impl.cpp | 2 +- 15 files changed, 26 insertions(+), 40 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index fe67e9d0fd..d53acd4e11 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1560,8 +1560,7 @@ public: * @param height * @return WMError */ - virtual WMError Resize(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig = {}) { return WMError::WM_OK; } + virtual WMError Resize(uint32_t width, uint32_t height) { return WMError::WM_OK; } /** * @brief resize the window instance (w,h) @@ -1570,8 +1569,7 @@ public: * @param height * @return WMError */ - virtual WMError ResizeAsync(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig = {}) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + virtual WMError ResizeAsync(uint32_t width, uint32_t height) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } /** * @brief set the window gravity diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 6f236931a8..6d756e431a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2252,7 +2252,7 @@ static void SetResizeWindowWithAnimationAsyncTask(NapiAsyncTask::ExecuteCallback *errCodePtr = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; return; } - *errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(window->ResizeAsync(rect.width_, rect.height_, rectAnimationConfig)); + *errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(window->ResizeAsync(rect.width_, rect.height_)); TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s end, window [%{public}u, %{public}s] err=%{public}d", where, window->GetWindowId(), window->GetWindowName().c_str(), *errCodePtr); }; diff --git a/previewer/include/window_impl.h b/previewer/include/window_impl.h index c7133b26e5..1d3fce87ef 100644 --- a/previewer/include/window_impl.h +++ b/previewer/include/window_impl.h @@ -111,8 +111,7 @@ public: virtual WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits, bool waitDetach) override; virtual WMError MoveTo(int32_t x, int32_t y, bool isMoveToGlobal = false, MoveConfiguration moveConfiguration = {}) override; - virtual WMError Resize(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig = {}) override; + virtual WMError Resize(uint32_t width, uint32_t height) override; virtual WMError SetWindowGravity(WindowGravity gravity, uint32_t percent) override; virtual WMError SetKeepScreenOn(bool keepScreenOn) override; virtual bool IsKeepScreenOn() const override; diff --git a/previewer/src/window_impl.cpp b/previewer/src/window_impl.cpp index fd0fc0ba7d..6349e43ae3 100644 --- a/previewer/src/window_impl.cpp +++ b/previewer/src/window_impl.cpp @@ -585,7 +585,7 @@ WMError WindowImpl::MoveTo(int32_t x, int32_t y, bool isMoveToGlobal, MoveConfig return WMError::WM_OK; } -WMError WindowImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig) +WMError WindowImpl::Resize(uint32_t width, uint32_t height) { return WMError::WM_OK; } diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index cf8fa9dbbf..909caa4f55 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -803,9 +803,11 @@ struct SystemSessionConfig : public Parcelable { return false; } - if (!parcel.WriteUint32(miniWidthOfMainWindow_) || !parcel.WriteUint32(miniHeightOfMainWindow_) || - !parcel.WriteUint32(miniWidthOfSubWindow_) || !parcel.WriteUint32(miniHeightOfSubWindow_) || - !parcel.WriteUint32(miniWidthOfDialogWindow_) || !parcel.WriteUint32(miniHeightOfDialogWindow_)) { + bool parcelWriteFail = !parcel.WriteUint32(miniWidthOfMainWindow_) || + !parcel.WriteUint32(miniHeightOfMainWindow_) || !parcel.WriteUint32(miniWidthOfSubWindow_) || + !parcel.WriteUint32(miniHeightOfSubWindow_) || !parcel.WriteUint32(miniWidthOfDialogWindow_) || + !parcel.WriteUint32(miniHeightOfDialogWindow_); + if (parcelWriteFail) { return false; } diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 2eaaa790fe..acc8a4e761 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -1110,7 +1110,7 @@ HWTEST_F(ScreenSessionTest, Resize002, TestSize.Level1) ASSERT_NE(nullptr, screenSession); uint32_t width = 1000; uint32_t height = 1000; - screenSession->Resize(width, height, false); + screenSession->Resize(width, height); GTEST_LOG_(INFO) << "Resize002 end"; } diff --git a/window_scene/test/mock/mock_session.h b/window_scene/test/mock/mock_session.h index 6cb8ae627e..054e746dba 100644 --- a/window_scene/test/mock/mock_session.h +++ b/window_scene/test/mock/mock_session.h @@ -67,10 +67,7 @@ public: WSPropertyChangeAction action)); MOCK_METHOD1(TransferExtensionData, int32_t(const AAFwk::WantParams& wantParams)); MOCK_METHOD(WSError, ProcessPointDownSession, (int32_t x, int32_t y), (override)); - void SetMockLayoutController(const sptr& layoutController) - { - layoutController_ = layoutController; - } + MOCK_CONST_METHOD2(ConvertGlobalRectToRelative, WSRect(const WSRect& globalRect, DisplayId targetDisplayId)); }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index d2d038c737..6845aaf2b6 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -42,7 +42,7 @@ public: bool isModuleAbilityHookEnd = false) override; WMError MoveTo(int32_t x, int32_t y, bool isMoveToGlobal = false, MoveConfiguration moveConfiguration = {}) override; - WMError Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig = {}) override; + WMError Resize(uint32_t width, uint32_t height) override; WMError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override; WMError TransferExtensionData(const AAFwk::WantParams& wantParams) override; WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override; diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index f9a3295f69..0c4f0abdbf 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -194,8 +194,7 @@ public: virtual WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits, bool waitDetach) override; virtual WMError MoveTo(int32_t x, int32_t y, bool isMoveToGlobal = false, MoveConfiguration moveConfiguration = {}) override; - virtual WMError Resize(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig = {}) override; + virtual WMError Resize(uint32_t width, uint32_t height) override; float GetVirtualPixelRatio() override; virtual WMError SetWindowGravity(WindowGravity gravity, uint32_t percent) override; virtual WMError SetKeepScreenOn(bool keepScreenOn) override; diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 9f039e2218..9c232d45c4 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -57,10 +57,8 @@ public: WMError MoveWindowToGlobal(int32_t x, int32_t y, MoveConfiguration moveConfiguration = {}) override; WMError MoveWindowToGlobalDisplay(int32_t x, int32_t y, MoveConfiguration moveConfiguration = {}) override; WMError GetGlobalScaledRect(Rect& globalScaledRect) override; - WMError Resize(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig = {}) override; - WMError ResizeAsync(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig = {}) override; + WMError Resize(uint32_t width, uint32_t height) override; + WMError ResizeAsync(uint32_t width, uint32_t height) override; WMError SetWindowAnchorInfo(const WindowAnchorInfo& windowAnchorInfo) override; WMError SetFollowParentWindowLayoutEnabled(bool isFollow) override; WSError NotifyLayoutFinishAfterWindowModeChange(WindowMode mode) override; diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index f17292e5b9..5711276058 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -335,8 +335,7 @@ WMError WindowExtensionSessionImpl::MoveTo(int32_t x, int32_t y, return static_cast(error); } -WMError WindowExtensionSessionImpl::Resize(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig) +WMError WindowExtensionSessionImpl::Resize(uint32_t width, uint32_t height) { WLOGFD("Id:%{public}d wh %{public}u %{public}u", property_->GetPersistentId(), width, height); if (IsWindowSessionInvalid()) { diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 72ed14ee17..6fbb6eed9a 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -2020,7 +2020,7 @@ WMError WindowImpl::MoveTo(int32_t x, int32_t y, bool isMoveToGlobal, MoveConfig return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_RECT); } -WMError WindowImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig) +WMError WindowImpl::Resize(uint32_t width, uint32_t height) { WLOGFD("id:%{public}d Resize %{public}u %{public}u", property_->GetWindowId(), width, height); diff --git a/wm/src/window_scene.cpp b/wm/src/window_scene.cpp index 145d3d7cb0..d7529c7056 100644 --- a/wm/src/window_scene.cpp +++ b/wm/src/window_scene.cpp @@ -100,10 +100,9 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptrSetBundleName(context->GetBundleName()); std::string moduleName = context->GetHapModuleInfo() ? context->GetHapModuleInfo()->moduleName : ""; - if (!moduleName.empty()) { - isModuleAbilityHookEnd = - SingletonContainer::Get().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); - } + TLOGI(WmsLogTag::WMS_MAIN, "set isModuleAbiltityHookEnd"); + isModuleAbilityHookEnd = + SingletonContainer::Get().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); } auto mainWindow = SingletonContainer::Get() .CreateWindow(option, context, iSession, identityToken, isModuleAbilityHookEnd); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 41f3868a07..0573a7e9ed 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2397,7 +2397,7 @@ WMError WindowSceneSessionImpl::CheckAndModifyWindowRect(uint32_t& width, uint32 } /** @note @window.layout */ -WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig) +WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height) { auto reason = SizeChangeReason::RESIZE; if (isResizedByLimit_) { @@ -2431,21 +2431,16 @@ WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height, const Re windowRect.ToString().c_str(), newRect.ToString().c_str()); property_->SetRequestRect(newRect); - property_->SetRectAnimationConfig(rectAnimationConfig); WSRect wsRect = { newRect.posX_, newRect.posY_, newRect.width_, newRect.height_ }; auto hostSession = GetHostSession(); - if (rectAnimationConfig.duration > 0 && reason == SizeChangeReason::RESIZE) { - reason = SizeChangeReason::RESIZE_WITH_ANIMATION; - } CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); - auto ret = hostSession->UpdateSessionRect(wsRect, reason, false, false, {}, rectAnimationConfig); + auto ret = hostSession->UpdateSessionRect(wsRect, reason); return static_cast(ret); } -WMError WindowSceneSessionImpl::ResizeAsync(uint32_t width, uint32_t height, - const RectAnimationConfig& rectAnimationConfig) +WMError WindowSceneSessionImpl::ResizeAsync(uint32_t width, uint32_t height) { if (IsWindowSessionInvalid()) { TLOGE(WmsLogTag::WMS_LAYOUT, "Session is invalid"); @@ -2457,7 +2452,7 @@ WMError WindowSceneSessionImpl::ResizeAsync(uint32_t width, uint32_t height, GetWindowId(), GetWindowMode()); return WMError::WM_ERROR_INVALID_OP_IN_CUR_STATUS; } - auto ret = Resize(width, height, rectAnimationConfig); + auto ret = Resize(width, height); if (state_ == WindowState::STATE_SHOWN) { layoutCallback_->ResetResizeLock(); auto startTime = std::chrono::duration_cast( diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index b299f1c93a..b44849998f 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2163,7 +2163,7 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, voi return initUIContentRet; } if (auto uiContent = GetUIContentSharedPtr()) { - TLOGI(WmsLogTag::WMS_LAYOUT, "id:%{public}d, posX:%{public}d, posY:%{public}d, " + TLOGI(WmsLogTag::WMS_LAYOUT, "single hand, id:%{public}d, posX:%{public}d, posY:%{public}d, " "scaleX:%{public}f, scaleY:%{public}f", GetPersistentId(), singleHandTransform_.posX, singleHandTransform_.posY, singleHandTransform_.scaleX, singleHandTransform_.scaleY); -- Gitee From 97830b49d0b7b10508d4900ae303b212accc3977 Mon Sep 17 00:00:00 2001 From: tanliang Date: Wed, 20 Aug 2025 19:53:20 +0800 Subject: [PATCH 125/241] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=98=B2=E7=AA=A5=E7=AE=A1=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanliang --- interfaces/innerkits/wm/window_manager.h | 3 ++ interfaces/innerkits/wm/wm_common.h | 1 + .../session/host/include/scene_session.h | 2 +- .../session/host/src/scene_session.cpp | 20 +++++-- .../include/scene_session_manager.h | 2 + .../src/scene_session_manager.cpp | 54 ++++++++++++------- .../zidl/scene_session_manager_lite_proxy.cpp | 3 +- .../zidl/scene_session_manager_lite_stub.cpp | 7 ++- .../unittest/scene_session_manager_test10.cpp | 47 ++++++++++++++++ .../test/unittest/scene_session_test.cpp | 41 ++++++++++++-- 10 files changed, 148 insertions(+), 32 deletions(-) diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index 1db684ff1f..9bbd0c1df3 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -365,6 +365,7 @@ struct AppUseControlInfo : public Parcelable { { return parcel.WriteString(bundleName_) && parcel.WriteInt32(appIndex_) && + parcel.WriteInt32(persistentId_) && parcel.WriteBool(isNeedControl_) && parcel.WriteBool(isControlRecentOnly_); } @@ -380,6 +381,7 @@ struct AppUseControlInfo : public Parcelable { auto info = new AppUseControlInfo(); if (!parcel.ReadString(info->bundleName_) || !parcel.ReadInt32(info->appIndex_) || + !parcel.ReadInt32(info->persistentId_) || !parcel.ReadBool(info->isNeedControl_) || !parcel.ReadBool(info->isControlRecentOnly_)) { delete info; @@ -390,6 +392,7 @@ struct AppUseControlInfo : public Parcelable { std::string bundleName_ = ""; int32_t appIndex_ = 0; + int32_t persistentId_ = INVALID_WINDOW_ID; // greater than 0 means control by id bool isNeedControl_ = false; bool isControlRecentOnly_ = false; }; diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index ec76b769c7..1cc0d3cde0 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -438,6 +438,7 @@ enum class ControlAppType : uint8_t { CONTROL_APP_TYPE_BEGIN = 0, APP_LOCK = 1, PARENT_CONTROL, + DLP_HIDE, PRIVACY_WINDOW, CONTROL_APP_TYPE_END, }; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 7467904bd9..1599a56627 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -618,7 +618,7 @@ public: void RegisterUpdateAppUseControlCallback(UpdateAppUseControlFunc&& func); void NotifyUpdateAppUseControl(ControlAppType type, const ControlInfo& controlInfo) override; void UpdatePrivacyModeControlInfo(); - bool HasSubSessionInPrivacyMode(); + bool HasChildSessionInPrivacyMode(); void SetVisibilityChangedDetectFunc(VisibilityChangedDetectFunc&& func); virtual void RegisterSessionLockStateChangeCallback(NotifySessionLockStateChangeCallback&& callback) {} virtual void NotifySessionLockStateChange(bool isLockedState) {} diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1c129cf74c..4215f737df 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1225,7 +1225,7 @@ void SceneSession::UpdatePrivacyModeControlInfo() { bool isPrivacyMode = false; auto property = GetSessionProperty(); - if ((property && property->GetPrivacyMode()) || HasSubSessionInPrivacyMode()) { + if ((property && property->GetPrivacyMode()) || HasChildSessionInPrivacyMode()) { isPrivacyMode = true; } if (!isPrivacyMode && appUseControlMap_.find(ControlAppType::PRIVACY_WINDOW) == appUseControlMap_.end()) { @@ -1236,7 +1236,7 @@ void SceneSession::UpdatePrivacyModeControlInfo() NotifyUpdateAppUseControl(ControlAppType::PRIVACY_WINDOW, controlInfo); } -bool SceneSession::HasSubSessionInPrivacyMode() +bool SceneSession::HasChildSessionInPrivacyMode() { for (const auto& subSession : GetSubSession()) { if (subSession == nullptr) { @@ -1247,7 +1247,21 @@ bool SceneSession::HasSubSessionInPrivacyMode() if (property && property->GetPrivacyMode()) { return true; } - if (subSession->HasSubSessionInPrivacyMode()) { + if (subSession->HasChildSessionInPrivacyMode()) { + return true; + } + } + for (const auto& dialogSession : GetDialogVector()) { + if (dialogSession == nullptr) { + TLOGW(WmsLogTag::WMS_LIFE, "dialogSession is nullptr"); + continue; + } + auto property = dialogSession->GetSessionProperty(); + if (property && property->GetPrivacyMode()) { + return true; + } + auto dialogSceneSession = GetSceneSessionById(dialogSession->GetPersistentId()); + if (dialogSceneSession && dialogSceneSession->HasChildSessionInPrivacyMode()) { return true; } } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 902af226c8..aa033a9a35 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -690,6 +690,8 @@ public: const std::string& bundleName, int32_t appIndex, std::vector>& mainSessions); WSError NotifyAppUseControlList( ControlAppType type, int32_t userId, const std::vector& controlList); + void NotifyAppUseControlListInner( + ControlAppType type, int32_t userId, const std::vector& controlList); void RegisterNotifyAppUseControlListCallback(NotifyAppUseControlListFunc&& func); WMError MinimizeMainSession(const std::string& bundleName, int32_t appIndex, int32_t userId); sptr RequestSceneSession(const SessionInfo& sessionInfo, diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1a104d886f..dac4123283 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -11312,28 +11312,46 @@ WSError SceneSessionManager::NotifyAppUseControlList( } } taskScheduler_->PostAsyncTask([this, type, userId, controlList] { - if (notifyAppUseControlListFunc_ != nullptr) { - notifyAppUseControlListFunc_(type, userId, controlList); - } + NotifyAppUseControlListInner(type, userId, controlList); + }, __func__); + return WSError::WS_OK; +} - std::vector> mainSessions; - for (const auto& appUseControlInfo : controlList) { - RefreshAllAppUseControlMap(appUseControlInfo, type); - GetMainSessionByBundleNameAndAppIndex(appUseControlInfo.bundleName_, appUseControlInfo.appIndex_, mainSessions); - if (mainSessions.empty()) { +void SceneSessionManager::NotifyAppUseControlListInner( + ControlAppType type, int32_t userId, const std::vector& controlList) +{ + std::vector> mainSessions; + std::vector controlByBundleList; + for (const auto& appUseControlInfo : controlList) { + if (appUseControlInfo.persistentId_ > INVALID_WINDOW_ID) { + // control by peristentId + TLOGI(WmsLogTag::WMS_MAIN, "control by id:%{public}d", appUseControlInfo.persistentId_); + auto iter = sceneSessionMap_.find(appUseControlInfo.persistentId_); + if (iter == sceneSessionMap_.end() || iter->second == nullptr) { + TLOGW(WmsLogTag::WMS_MAIN, "session not found, id:%{public}d", appUseControlInfo.persistentId_); continue; } - ControlInfo controlInfo = { - .isNeedControl = appUseControlInfo.isNeedControl_, - .isControlRecentOnly = appUseControlInfo.isControlRecentOnly_ - }; - for (const auto& session : mainSessions) { - session->NotifyUpdateAppUseControl(type, controlInfo); - } - mainSessions.clear(); + mainSessions.push_back(iter->second); + } else { + // control by bundleName and appIndex + RefreshAllAppUseControlMap(appUseControlInfo, type); + GetMainSessionByBundleNameAndAppIndex(appUseControlInfo.bundleName_, appUseControlInfo.appIndex_, mainSessions); } - }, __func__); - return WSError::WS_OK; + if (mainSessions.empty()) { + continue; + } + ControlInfo controlInfo = { + .isNeedControl = appUseControlInfo.isNeedControl_, + .isControlRecentOnly = appUseControlInfo.isControlRecentOnly_ + }; + for (const auto& session : mainSessions) { + session->NotifyUpdateAppUseControl(type, controlInfo); + } + mainSessions.clear(); + } + if (notifyAppUseControlListFunc_ != nullptr && controlByBundleList.size() > 0) { + notifyAppUseControlListFunc_(type, userId, controlByBundleList); + } } void SceneSessionManager::RefreshAllAppUseControlMap(const AppUseControlInfo& appUseControlInfo, ControlAppType type) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index 24c2412a3b..bae1f8a0d5 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -1588,8 +1588,7 @@ WSError SceneSessionManagerLiteProxy::NotifyAppUseControlList( } for (const auto& control : controlList) { - if (!data.WriteString(control.bundleName_) || !data.WriteInt32(control.appIndex_) || - !data.WriteBool(control.isNeedControl_) || !data.WriteBool(control.isControlRecentOnly_)) { + if (!data.WriteParcelable(&control)) { TLOGE(WmsLogTag::WMS_LIFE, "Write controlList failed"); return WSError::WS_ERROR_INVALID_PARAM; } diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index 3a9d4ff8de..9794d60a5e 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -1071,13 +1071,12 @@ int SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(MessageParcel& da std::vector controlList; controlList.resize(size); for (int32_t i = 0; i < size; i++) { - if (!data.ReadString(controlList[i].bundleName_) || - !data.ReadInt32(controlList[i].appIndex_) || - !data.ReadBool(controlList[i].isNeedControl_) || - !data.ReadBool(controlList[i].isControlRecentOnly_)) { + std::shared_ptr controlInfo(data.ReadParcelable()); + if (controlInfo == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "Read controlList failed"); return ERR_INVALID_DATA; } + controlList.push_back(*controlInfo); } WSError ret = NotifyAppUseControlList(type, userId, controlList); diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index d75fe03775..0e441b770b 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -1141,6 +1141,53 @@ HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlList, TestSize.Level1) ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList)); } +/** + * @tc.name: NotifyAppUseControlListInner + * @tc.desc: NotifyAppUseControlListInner + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlListInner, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + int32_t controlListSize = -1; + ssm->notifyAppUseControlListFunc_ = [&controlListSize] + (ControlAppType type, int32_t userId, const std::vector& controlList) { + controlListSize = controlList.size(); + }; + AppUseControlInfo controlById; + controlById.persistentId_ = 100; + std::vector controlList; + controlList.push_back(controlById); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + EXPECT_EQ(controlListSize, -1); + ssm_->sceneSessionMap_.emplace(100, nullptr); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + EXPECT_EQ(controlListSize, -1); + + sessionInfo sessionInfo; + sessionInfo.persistentId_ = 100; + sessionInfo.bundleName_ = "bundleName"; + sessionInfo.appIndex_ = 0; + sessionInfo.windowType_ = 1; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ssm_->sceneSessionMap_.emplace(100, sceneSession); + + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + EXPECT_EQ(controlListSize, -1); + + AppUseControlInfo controlByBundle; + controlByBundle.bundleName_ = "bundleName"; + controlByBundle.appIndex_ = 0; + controlList.push_back(controlByBundle); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + EXPECT_EQ(controlListSize, 1); + + ssm->notifyAppUseControlListFunc_ = nullptr; + controlListSize = -1; + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + EXPECT_EQ(controlListSize, -1); +} + /** * @tc.name: MinimizeMainSession * @tc.desc: test MinimizeMainSession diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index afca7ed333..e66515deb1 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -688,11 +688,11 @@ HWTEST_F(SceneSessionTest, UpdatePrivacyModeControlInfo02, Function | SmallTest } /** - * @tc.name: HasSubSessionInPrivacyMode - * @tc.desc: HasSubSessionInPrivacyMode + * @tc.name: HasChildSessionInPrivacyMode + * @tc.desc: HasChildSessionInPrivacyMode * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest, HasSubSessionInPrivacyMode, Function | SmallTest | Level3) +HWTEST_F(SceneSessionTest, HasChildSessionInPrivacyMode, Function | SmallTest | Level3) { SessionInfo info; info.bundleName_ = "testBundleName"; @@ -717,7 +717,40 @@ HWTEST_F(SceneSessionTest, HasSubSessionInPrivacyMode, Function | SmallTest | Le subSession->AddSubSession(subSession2); sceneSession->AddSubSession(subSession); - EXPECT_EQ(sceneSession->HasSubSessionInPrivacyMode(), true); + EXPECT_EQ(sceneSession->HasChildSessionInPrivacyMode(), true); +} + +/** + * @tc.name: HasChildSessionInPrivacyMode02 + * @tc.desc: HasChildSessionInPrivacyMode02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, HasChildSessionInPrivacyMode02, Function | SmallTest | Level3) +{ + SessionInfo info; + info.bundleName_ = "testBundleName"; + info.abilityName_ = "testAbilityName"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sceneSession->property_ = nullptr; + sptr dialogSessionCb = + sptr::MakeSptr(); + sptr dialogSession = sptr::MakeSptr(info, dialogSessionCb); + dialogSessionCb->onGetSceneSessionByIdCallback_ = [&dialogSession](int32_t id) { return dialogSession; }; + sceneSession->BindDialogToParentSession(dialogSession); + EXPECT_FALSE(sceneSession->HasChildSessionInPrivacyMode()); + sptr property = sptr::MakeSptr(); + property->SetPrivacyMode(false); + dialogSession->property_ = property; + EXPECT_FALSE(sceneSession->HasChildSessionInPrivacyMode()); + dialogSession->property_->SetPrivacyMode(true); + EXPECT_TRUE(sceneSession->HasChildSessionInPrivacyMode()); + + dialogSession->property_->SetPrivacyMode(false); + sptr dialogSession2 = sptr::MakeSptr(info, nullptr); + dialogSession2->property_ = sptr::MakeSptr(); + dialogSession2->property_->SetPrivacyMode(true); + dialogSession->BindDialogToParentSession(dialogSession2); + EXPECT_FALSE(sceneSession->HasChildSessionInPrivacyMode()); } /** -- Gitee From 4550e6e9cd0cd8f5d23eea1b78c4ff709b8dadd1 Mon Sep 17 00:00:00 2001 From: shenshensun Date: Wed, 20 Aug 2025 16:29:34 +0800 Subject: [PATCH 126/241] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E9=97=AE=E9=A2=98?= =?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: shenshensun --- window_scene/session/host/include/session.h | 1 + window_scene/session/host/src/session.cpp | 5 + .../include/scene_session_dirty_manager.h | 2 + .../src/scene_session_dirty_manager.cpp | 78 ++++++- .../scene_session_dirty_manager_test.cpp | 209 ++++++++++++++++++ 5 files changed, 285 insertions(+), 10 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index e5d8b434d1..a4fa5209e1 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -259,6 +259,7 @@ public: virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) { return WSError::WS_OK; } int32_t GetPersistentId() const; + int32_t GetCurrentRotation() const; void SetSurfaceNode(const std::shared_ptr& surfaceNode); std::shared_ptr GetSurfaceNode() const; std::optional GetSurfaceNodeId() const; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 6ffc701025..ad6fa5ce28 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -171,6 +171,11 @@ int32_t Session::GetPersistentId() const return persistentId_; } +int32_t Session::GetCurrentRotation() const +{ + return currentRotation_; +} + void Session::SetSurfaceNode(const std::shared_ptr& surfaceNode) { RSAdapterUtil::SetRSUIContext(surfaceNode, GetRSUIContext(), true); diff --git a/window_scene/session_manager/include/scene_session_dirty_manager.h b/window_scene/session_manager/include/scene_session_dirty_manager.h index 7ff5f35fb6..b5dd1fc975 100644 --- a/window_scene/session_manager/include/scene_session_dirty_manager.h +++ b/window_scene/session_manager/include/scene_session_dirty_manager.h @@ -80,6 +80,8 @@ private: SingleHandData GetSingleHandData(const sptr& sceneSession) const; void CalNotRotateTransform(const sptr& sceneSession, Matrix3f& transform, bool useUIExtension = false) const; + void CalSpecialNotRotateTransform(const sptr& sceneSession, ScreenProperty& screenProperty, + Matrix3f& transform, bool useUIExtension = false) const; void CalTransform(const sptr& sceneSession, Matrix3f& transform, const SingleHandData& singleHandData, bool useUIExtension = false) const; void UpdatePrivacyMode(const sptr& sceneSession, diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 4a60464c2e..3876d3c23e 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -15,6 +15,7 @@ #include "scene_session_dirty_manager.h" +#include #include #include "screen_session_manager_client/include/screen_session_manager_client.h" #include "session_manager/include/scene_session_manager.h" @@ -23,10 +24,11 @@ namespace OHOS::Rosen { namespace { -constexpr float DIRECTION0 = 0 ; -constexpr float DIRECTION90 = 90 ; -constexpr float DIRECTION180 = 180 ; -constexpr float DIRECTION270 = 270 ; +constexpr float DIRECTION0 = 0; +constexpr float DIRECTION90 = 90; +constexpr float DIRECTION180 = 180; +constexpr float DIRECTION270 = 270; +constexpr float DIRECTION360 = 360; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionDirtyManager"}; constexpr unsigned int POINTER_CHANGE_AREA_COUNT = 8; constexpr int POINTER_CHANGE_AREA_SIXTEEN = 16; @@ -177,6 +179,33 @@ void SceneSessionDirtyManager::CalNotRotateTransform(const sptr& s .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse(); } +inline float PositiveFmod(float x, float y) +{ + float result = std::fmod(x, y); + return result < 0 ? (result + y) : result; +} + +void SceneSessionDirtyManager::CalSpecialNotRotateTransform(const sptr& sceneSession, + ScreenProperty& screenProperty, Matrix3f& transform, bool useUIExtension) const +{ + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "sceneSession is nullptr"); + return; + } + + MMI::Direction displayRotation = + ConvertDegreeToMMIRotation(PositiveFmod(screenProperty.GetPhysicalRotation() - + screenProperty.GetScreenComponentRotation() - sceneSession->GetCurrentRotation(), DIRECTION360)); + float width = screenProperty.GetBounds().rect_.GetWidth(); + float height = screenProperty.GetBounds().rect_.GetHeight(); + Vector2f scale(sceneSession->GetScaleX(), sceneSession->GetScaleY()); + Vector2f offset = sceneSession->GetSessionGlobalPosition(useUIExtension); + float rotate = 0.0f; + Vector2f translate = CalRotationToTranslate(displayRotation, width, height, offset, rotate); + transform = transform.Translate(translate).Rotate(rotate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse(); +} + void SceneSessionDirtyManager::CalTransform(const sptr& sceneSession, Matrix3f& transform, const SingleHandData& singleHandData, bool useUIExtension) const { @@ -191,12 +220,41 @@ void SceneSessionDirtyManager::CalTransform(const sptr& sceneSessi transform = transform.Scale({singleHandData.scaleX, singleHandData.scaleY}, singleHandData.pivotX, singleHandData.pivotY); } - if (isRotate || !sceneSession->GetSessionInfo().isSystem_ || - static_cast(displayMode) == MMI::DisplayMode::FULL || - displayMode == FoldDisplayMode::GLOBAL_FULL || - (static_cast(displayMode) == MMI::DisplayMode::MAIN && - (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() || - FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()))) { + + auto sessionProperty = sceneSession->GetSessionProperty(); + if (sessionProperty == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "sessionProperty is nullptr"); + return; + } + auto displayId = sessionProperty->GetDisplayId(); + std::map screensProperties = + Rosen::ScreenSessionManagerClient::GetInstance().GetAllScreensProperties(); + if (screensProperties.find(displayId) == screensProperties.end()) { + TLOGE(WmsLogTag::WMS_EVENT, "screensProperties find displayId failed"); + return; + } + auto screenProperty = screensProperties[displayId]; + bool isRotateWindow = screenProperty.GetPhysicalRotation() - screenProperty.GetScreenComponentRotation() != + sceneSession->GetCurrentRotation(); + bool isSystem = sceneSession->GetSessionInfo().isSystem_; + bool displayModeIsFull = static_cast(displayMode) == MMI::DisplayMode::FULL; + bool displayModeIsGlobalFull = displayMode == FoldDisplayMode::GLOBAL_FULL; + bool displayModeIsMain = static_cast(displayMode) == MMI::DisplayMode::MAIN; + bool foldScreenStateInternel = FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice() || + FoldScreenStateInternel::IsSecondaryDisplayFoldDevice(); + TLOGD(WmsLogTag::WMS_EVENT, "wid:%{public}d, isRotate:%{public}d, isSystem:%{public}d," + " displayModeIsFull:%{public}d, displayModeIsGlobalFull:%{public}d, displayModeIsMain:%{public}d," + " foldScreenStateInternel:%{public}d, isRotateWindow:%{public}d", + sceneSession->GetWindowId(), isRotate, isSystem, displayModeIsFull, displayModeIsGlobalFull, + displayModeIsMain, foldScreenStateInternel, isRotateWindow); + + if (isRotate || !isSystem || displayModeIsFull || displayModeIsGlobalFull || + (displayModeIsMain && foldScreenStateInternel)) { + if (isRotateWindow && isSystem && ((displayModeIsMain && foldScreenStateInternel) || + (displayModeIsFull && FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()))) { + CalSpecialNotRotateTransform(sceneSession, screenProperty, transform, useUIExtension); + return; + } Vector2f scale(sceneSession->GetScaleX(), sceneSession->GetScaleY()); Vector2f translate = sceneSession->GetSessionGlobalPosition(useUIExtension); if (useUIExtension && UpdateModalExtensionInCompatStatus(sceneSession, transform)) { diff --git a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp index 991e384cac..4bca670ab9 100644 --- a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp @@ -871,6 +871,32 @@ HWTEST_F(SceneSessionDirtyManagerTest, CalNotRotateTransform2, TestSize.Level1) sceneSession->property_ = oriProperty; } +/** + * @tc.name: CalSpecialNotRotateTransformTest + * @tc.desc: CalSpecialNotRotateTransform + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest, CalSpecialNotRotateTransformTest, TestSize.Level1) +{ + g_logMsg.clear(); + LOG_SetCallback(MyLogCallback); + ScreenProperty screenProperty; + Matrix3f transform; + manager_->CalSpecialNotRotateTransform(nullptr, screenProperty, transform); + EXPECT_TRUE(g_logMsg.find("sceneSession is null") != std::string::npos); + + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "CalSpecialNotRotateTransformTest"; + sessionInfo.moduleName_ = "sessionInfo"; + Matrix3f testTransform = transform; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(sceneSession, nullptr); + manager_->CalSpecialNotRotateTransform(sceneSession, screenProperty, transform); + EXPECT_TRUE(g_logMsg.find("sceneSession is null") != std::string::npos); + EXPECT_NE(transform, testTransform); + LOG_SetCallback(nullptr); +} + /** * @tc.name: UpdateWindowFlags * @tc.desc: UpdateWindowFlags @@ -1017,6 +1043,189 @@ HWTEST_F(SceneSessionDirtyManagerTest, CalTransform_CompatMode, TestSize.Level1) .Inverse().Translate(translateOffset)); } +/** + * @tc.name: CalTransformSessionPropertyNullptr + * @tc.desc: CalTransform + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest, CalTransformSessionPropertyNullptr, TestSize.Level1) +{ + g_logMsg.clear(); + LOG_SetCallback(MyLogCallback); + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "CalTransformSessionPropertyNullptr"; + sessionInfo.moduleName_ = "CalTransformSessionPropertyNullptr"; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + Matrix3f transform; + SingleHandData testSingleHandData; + + auto oriProperty = sceneSession->GetSessionProperty(); + sceneSession->property_ = nullptr; + manager_->CalTransform(sceneSession, transform, testSingleHandData); + EXPECT_TRUE(g_logMsg.find("sessionProperty is null") != std::string::npos); + sceneSession->property_ = oriProperty; + LOG_SetCallback(nullptr); +} + +/** + * @tc.name: CalTransformTest_01 + * @tc.desc: CalTransform isRotate false + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest, CalTransformTest_01, TestSize.Level1) +{ + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "CalTransformTest_01"; + sessionInfo.moduleName_ = "CalTransformTest_01"; + sessionInfo.isRotable_ = false; + sessionInfo.isSystem_ = true; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + Vector2f scale(sceneSession->GetScaleX(), sceneSession->GetScaleY()); + Vector2f translate = sceneSession->GetSessionGlobalPosition(false); + Vector2f offset = sceneSession->GetSessionGlobalPosition(false); + Matrix3f transform; + SingleHandData testSingleHandData; + + auto screenId = 1001; + sceneSession->GetSessionProperty()->SetDisplayId(screenId); + ScreenSessionConfig config; + sptr screenSession = + sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + ASSERT_NE(screenSession, nullptr); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession); + ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::UNKNOWN); + manager_->CalTransform(sceneSession, transform, testSingleHandData); + ASSERT_EQ(transform, transform.Translate(translate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse()); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.erase(screenId); +} + +/** + * @tc.name: CalTransformTest_02 + * @tc.desc: CalTransform isRotate false isRotateWindow false + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest, CalTransformTest_02, TestSize.Level1) +{ + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "CalTransformTest_02"; + sessionInfo.moduleName_ = "CalTransformTest_02"; + sessionInfo.isRotable_ = false; + sessionInfo.isSystem_ = true; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + Vector2f scale(sceneSession->GetScaleX(), sceneSession->GetScaleY()); + Vector2f translate = sceneSession->GetSessionGlobalPosition(false); + Vector2f offset = sceneSession->GetSessionGlobalPosition(false); + Matrix3f transform; + SingleHandData testSingleHandData; + + auto screenId = 1001; + sceneSession->GetSessionProperty()->SetDisplayId(screenId); + ScreenSessionConfig config; + sptr screenSession = + sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + ASSERT_NE(screenSession, nullptr); + screenSession->GetScreenProperty().SetPhysicalRotation(180.0f); + screenSession->GetScreenProperty().SetScreenComponentRotation(90.0f); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession); + sceneSession->SetCurrentRotation(90); + ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::FULL); + manager_->CalTransform(sceneSession, transform, testSingleHandData); + ASSERT_EQ(transform, transform.Translate(translate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse()); + + ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::GLOBAL_FULL); + manager_->CalTransform(sceneSession, transform, testSingleHandData); + ASSERT_EQ(transform, transform.Translate(translate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse()); + + ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::MAIN); + manager_->CalTransform(sceneSession, transform, testSingleHandData); + ASSERT_EQ(transform, transform.Translate(translate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse()); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.erase(screenId); +} + +/** + * @tc.name: CalTransformTest_03 + * @tc.desc: CalTransform isRotate true isRotateWindow false + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest, CalTransformTest_03, TestSize.Level1) +{ + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "CalTransformTest_03"; + sessionInfo.moduleName_ = "CalTransformTest_03"; + sessionInfo.isRotable_ = true; + sessionInfo.isSystem_ = false; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + Vector2f scale(sceneSession->GetScaleX(), sceneSession->GetScaleY()); + Vector2f translate = sceneSession->GetSessionGlobalPosition(false); + Vector2f offset = sceneSession->GetSessionGlobalPosition(false); + Matrix3f transform; + SingleHandData testSingleHandData; + + auto screenId = 1001; + sceneSession->GetSessionProperty()->SetDisplayId(screenId); + ScreenSessionConfig config; + sptr screenSession = + sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + ASSERT_NE(screenSession, nullptr); + screenSession->GetScreenProperty().SetPhysicalRotation(180.0f); + screenSession->GetScreenProperty().SetScreenComponentRotation(90.0f); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession); + sceneSession->SetCurrentRotation(90); + ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::UNKNOWN); + manager_->CalTransform(sceneSession, transform, testSingleHandData); + ASSERT_EQ(transform, transform.Translate(translate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse()); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.erase(screenId); +} + +/** + * @tc.name: CalTransformTest_04 + * @tc.desc: CalTransform isRotate true isRotateWindow true + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest, CalTransformTest_04, TestSize.Level1) +{ + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "CalTransformTest_04"; + sessionInfo.moduleName_ = "CalTransformTest_04"; + sessionInfo.isRotable_ = true; + sessionInfo.isSystem_ = true; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + Vector2f scale(sceneSession->GetScaleX(), sceneSession->GetScaleY()); + Vector2f translate = sceneSession->GetSessionGlobalPosition(false); + Vector2f offset = sceneSession->GetSessionGlobalPosition(false); + Matrix3f transform; + SingleHandData testSingleHandData; + + auto screenId = 1001; + sceneSession->GetSessionProperty()->SetDisplayId(screenId); + ScreenSessionConfig config; + sptr screenSession = + sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + ASSERT_NE(screenSession, nullptr); + screenSession->GetScreenProperty().SetPhysicalRotation(180.0f); + screenSession->GetScreenProperty().SetScreenComponentRotation(90.0f); + + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession); + sceneSession->SetCurrentRotation(0); + ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::MAIN); + manager_->CalTransform(sceneSession, transform, testSingleHandData); + ASSERT_EQ(transform, transform.Translate(translate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse()); + + ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::FULL); + manager_->CalTransform(sceneSession, transform, testSingleHandData); + ASSERT_EQ(transform, transform.Translate(translate) + .Scale(scale, sceneSession->GetPivotX(), sceneSession->GetPivotY()).Inverse()); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.erase(screenId); +} + /** * @tc.name: UpdateModalExtensionInCompatStatus * @tc.desc: UpdateModalExtensionInCompatStatus -- Gitee From 30f3d98389f3c8b2605194164945394d277cd9f8 Mon Sep 17 00:00:00 2001 From: zhangweihua Date: Thu, 21 Aug 2025 22:15:35 +0800 Subject: [PATCH 127/241] bugfix Signed-off-by: zhangweihua --- ...dary_display_sensor_fold_state_manager.cpp | 12 ++++++-- ...display_sensor_fold_state_manager_test.cpp | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp index 181a48acbb..1e1f29588c 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp @@ -46,6 +46,7 @@ constexpr int32_t HALL_THRESHOLD = 1; constexpr int32_t HALL_FOLDED_THRESHOLD = 0; constexpr int32_t HALF_FOLD_VALUE = 3; constexpr int32_t REFLEXION_VALUE = 2; +constexpr float DEFAULT_ANGLE_VALUE = 5.0F; constexpr uint32_t FULL_WAIT_TIMES = 215; constexpr float ANGLE_DIFF_OF_SECONDARY_AB = 15.0F; @@ -61,15 +62,20 @@ void SecondaryDisplaySensorFoldStateManager::HandleAngleOrHallChange(const std:: TLOGE(WmsLogTag::DMS, "halls size is not right, halls size %{public}zu", halls.size()); return; } - bool isFoldScreenOn = PowerMgr::PowerMgrClient::GetInstance().IsFoldScreenOn(); + if ((std::fabs(angles[1] - DEFAULT_ANGLE_VALUE) < FLT_EPSILON && halls[1] == HALL_THRESHOLD) || + (std::fabs(angles[0] - DEFAULT_ANGLE_VALUE) < FLT_EPSILON && halls[0] == HALL_THRESHOLD)) { + TLOGI(WmsLogTag::DMS, "hall change but posture not change"); + return; + } + bool isScreenOn = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn(); { std::lock_guard lock(secondaryFoldStatusMutex_); - if (!isFoldScreenOn && curHallAB_ == halls[0] && curHallBC_ == halls[1]) { + if (!isScreenOn && curHallAB_ == halls[0] && curHallBC_ == halls[1]) { TLOGI(WmsLogTag::DMS, "hall value is not change in unPower"); return; } } - FoldStatus nextState = GetNextFoldState(angles, halls, isPostureRegistered, isFoldScreenOn); + FoldStatus nextState = GetNextFoldState(angles, halls, isPostureRegistered, isScreenOn); HandleSensorChange(nextState, angles, halls, foldScreenPolicy); if (angles.size() != ANGLES_AXIS_SIZE) { TLOGE(WmsLogTag::DMS, "angles size is not right, angles size %{public}zu", angles.size()); diff --git a/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp b/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp index 449a1b9f7c..726093d1ac 100644 --- a/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp +++ b/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp @@ -235,6 +235,36 @@ HWTEST_F(SecondaryDisplaySensorFoldStateManagerTest, HandleAngleOrHallChange07, FoldStatus::FOLD_STATE_EXPAND_WITH_SECOND_EXPAND); } +/** + * @tc.name: HandleAngleOrHallChange08 + * @tc.desc: test halls size + * @tc.type: FUNC + */ +HWTEST_F(SecondaryDisplaySensorFoldStateManagerTest, HandleAngleOrHallChange08, TestSize.Level1) +{ + if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + return; + } + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + std::vector angles = { 5, 5 }; + std::vector halls = { 0, 1 }; + SecondaryDisplaySensorFoldStateManager manager; + g_errLog.clear(); + manager.HandleAngleOrHallChange(angles, halls, nullptr, false); + EXPECT_TRUE(g_errLog.find("hall change but posture not change") != std::string::npos); + angles = { 5, 5 }; + halls = { 0, 0 }; + g_errLog.clear(); + manager.HandleAngleOrHallChange(angles, halls, nullptr, false); + EXPECT_FALSE(g_errLog.find("hall change but posture not change") != std::string::npos); + angles = { 4, 4 }; + halls = { 1, 1 }; + g_errLog.clear(); + manager.HandleAngleOrHallChange(angles, halls, nullptr, false); + EXPECT_FALSE(g_errLog.find("hall change but posture not change") != std::string::npos); +} + /** * @tc.name: UpdateSwitchScreenBoundaryForLargeFoldDeviceAB * @tc.desc: test function : UpdateSwitchScreenBoundaryForLargeFoldDeviceAB -- Gitee From 68d94b641ac133372cf4dd671126ca4ca023f630 Mon Sep 17 00:00:00 2001 From: qianli22 Date: Thu, 21 Aug 2025 22:43:34 +0800 Subject: [PATCH 128/241] =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=B8=A7=E6=A3=80?= =?UTF-8?q?=E8=A7=86=E6=84=8F=E8=A7=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qianli22 --- window_scene/session/host/include/scene_session.h | 1 + window_scene/session/host/src/scene_session.cpp | 14 ++++++++++---- wm/src/window_session_impl.cpp | 10 +++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 284930ed42..fdca5fa37a 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -1301,6 +1301,7 @@ private: void OnKeyFrameNextVsync(uint64_t count); bool KeyFrameNotifyFilter(const WSRect& rect, SizeChangeReason reason); bool KeyFrameRectAlmostSame(const WSRect& rect1, const WSRect& rect2); + std::mutex keyFrameMutex_; KeyFramePolicy keyFramePolicy_; std::shared_ptr keyFrameCloneNode_ = nullptr; bool keyFrameAnimating_ = false; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ed1c6d6368..3228cea316 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4067,6 +4067,7 @@ WSError SceneSession::UpdateKeyFrameCloneNode(std::shared_ptr& rsC void SceneSession::SetKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) { TLOGI(WmsLogTag::WMS_LAYOUT_PC, "in"); + std::lock_guard lock(keyFrameMutex_); bool running = keyFramePolicy_.running_; bool stopping = keyFramePolicy_.stopping_; keyFramePolicy_ = keyFramePolicy; @@ -4077,6 +4078,7 @@ void SceneSession::SetKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) WSError SceneSession::SetDragKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) { TLOGI(WmsLogTag::WMS_LAYOUT_PC, "in"); + std::lock_guard lock(keyFrameMutex_); bool running = keyFramePolicy_.running_; bool stopping = keyFramePolicy_.stopping_; keyFramePolicy_ = keyFramePolicy; @@ -4093,6 +4095,7 @@ void SceneSession::UpdateKeyFrameState(SizeChangeReason reason, const WSRect& re TLOGE(WmsLogTag::WMS_LAYOUT_PC, "no moveDragController or sessionStage"); return; } + std::lock_guard lock(keyFrameMutex_); if (reason == SizeChangeReason::DRAG_START && moveDragController_->GetStartDragFlag()) { TLOGD(WmsLogTag::WMS_LAYOUT_PC, "key frame start check"); if (!keyFramePolicy_.enabled() || GetAppDragResizeType() == DragResizeType::RESIZE_WHEN_DRAG_END) { @@ -4120,7 +4123,6 @@ void SceneSession::UpdateKeyFrameState(SizeChangeReason reason, const WSRect& re keyFrameCloneNode_->SetFrame(0, 0, rect.width_, rect.height_); RSTransactionAdapter::FlushImplicitTransaction(GetRSUIContext()); } else if (reason == SizeChangeReason::DRAG_END) { - TLOGI(WmsLogTag::WMS_LAYOUT_PC, "key frame stopping"); keyFramePolicy_.running_ = false; keyFramePolicy_.stopping_ = true; sessionStage_->SetKeyFramePolicy(keyFramePolicy_); @@ -4193,6 +4195,7 @@ void SceneSession::OnKeyFrameNextVsync(uint64_t count) bool SceneSession::KeyFrameNotifyFilter(const WSRect& rect, SizeChangeReason reason) { TLOGD(WmsLogTag::WMS_LAYOUT, "reason in: %{public}d", reason); + std::lock_guard lock(keyFrameMutex_); if (!keyFramePolicy_.running_) { TLOGD(WmsLogTag::WMS_LAYOUT, "skip filter for not running"); return false; @@ -8031,9 +8034,12 @@ bool SceneSession::NotifyServerToUpdateRect(const SessionUIParam& uiParam, SizeC TLOGD(WmsLogTag::WMS_PIPELINE, "skip recent, id:%{public}d", GetPersistentId()); return false; } - if (keyFramePolicy_.running_) { - TLOGI(WmsLogTag::WMS_PIPELINE, "skip for key frame running, id:%{public}d", GetPersistentId()); - return false; + { + std::lock_guard lock(keyFrameMutex_); + if (keyFramePolicy_.running_) { + TLOGI(WmsLogTag::WMS_PIPELINE, "skip for key frame running, id:%{public}d", GetPersistentId()); + return false; + } } if (uiParam.rect_.IsInvalid()) { TLOGW(WmsLogTag::WMS_PIPELINE, "id:%{public}d rect:%{public}s is invalid", diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 23b760198f..8376434c13 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2136,12 +2136,12 @@ WSError WindowSessionImpl::SetKeyFramePolicy(KeyFramePolicy& keyFramePolicy) WMError WindowSessionImpl::SetDragKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) { TLOGD(WmsLogTag::WMS_LAYOUT, "in"); - auto session = GetHostSession(); - if (session == nullptr) { - TLOGE(WmsLogTag::WMS_EVENT, "session is nullptr"); - return WMError::WM_ERROR_NULLPTR; + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; } - WSError errorCode = session->SetDragKeyFramePolicy(keyFramePolicy); + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); + WSError errorCode = hostSession->SetDragKeyFramePolicy(keyFramePolicy); TLOGI(WmsLogTag::WMS_LAYOUT, "Id: %{public}d, keyFramePolicy: %{public}s, errorCode: %{public}d", GetPersistentId(), keyFramePolicy.ToString().c_str(), static_cast(errorCode)); return static_cast(errorCode); -- Gitee From af945ec463eae18ab8b1addbdf0f8e43b9ee86d3 Mon Sep 17 00:00:00 2001 From: "chengchao.zhou" Date: Fri, 22 Aug 2025 09:44:11 +0800 Subject: [PATCH 129/241] add tdd Signed-off-by: chengchao.zhou --- .../unittest/scene_session_manager_test2.cpp | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/window_scene/test/unittest/scene_session_manager_test2.cpp b/window_scene/test/unittest/scene_session_manager_test2.cpp index 5ff75d6e25..3b12189cbe 100644 --- a/window_scene/test/unittest/scene_session_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_test2.cpp @@ -1392,6 +1392,184 @@ HWTEST_F(SceneSessionManagerTest2, ConfigFreeMultiWindowForDefaultDragResizeType ASSERT_EQ(ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_, DragResizeType::RESIZE_WHEN_DRAG_END); } +/** + * @tc.name: ConfigFreeMultiWindow + * @tc.desc: call ConfigFreeMultiWindow. + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest2, ConfigFreeMultiWindowTest, TestSize.Level1) +{ + ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED; + std::string xmlStr = + "" + "" + "" + "" + "" + "" + "" + "0" + "1" + "2" + "0.5" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" + "0" + "1" + "2" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" + "" + ""; + WindowSceneConfig::config_ = ReadConfig(xmlStr); + ssm_->ConfigFreeMultiWindow(); + // freeMultiWindow windowEffect + auto windowEffect = ssm_->systemConfig_.freeMultiWindowConfig_.appWindowSceneConfig_; + + ASSERT_FLOAT_EQ(windowEffect.focusedShadow_.alpha_, 0); + ASSERT_FLOAT_EQ(windowEffect.focusedShadow_.offsetX_, 1); + ASSERT_FLOAT_EQ(windowEffect.focusedShadow_.offsetY_, 2); + ASSERT_FLOAT_EQ(windowEffect.focusedShadow_.radius_, 0.5); + ASSERT_FLOAT_EQ(windowEffect.unfocusedShadow_.alpha_, 0); + ASSERT_FLOAT_EQ(windowEffect.unfocusedShadow_.offsetX_, 1); + ASSERT_FLOAT_EQ(windowEffect.unfocusedShadow_.offsetY_, 1); + ASSERT_FLOAT_EQ(windowEffect.unfocusedShadow_.radius_, 0.5); +} + +/** + * @tc.name: LoadFreeMultiWindowConfigTest + * @tc.desc: call LoadFreeMultiWindowConfig + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest2, LoadFreeMultiWindowConfigTest, TestSize.Level1) +{ + ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED; + std::string xmlStr = + "" + "" + "" + "" + "" + "" + "0" + "1" + "2" + "2" + "0" + "" + "" + "0" + "#000000" + "2" + "2" + "1" + "0" + "" + "" + "" + "" + "0" + "2" + "2" + "" + "" + "0" + "#000000" + "2" + "2" + "0" + "0.5" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "0" + "#000000" + "0" + "3" + "3" + "0.5" + "" + "" + "0" + "#000000" + "3" + "3" + "0" + "0.5" + "" + "" + "" + "" + "0" + "3" + "3" + "0.5" + "" + "" + "0" + "#000000" + "3" + "3" + "0" + "0.5" + "" + "" + "" + "" + "" + ""; + WindowSceneConfig::config_ = ReadConfig(xmlStr); + ssm_->ConfigFreeMultiWindow(); + ASSERT_EQ(ssm_->systemConfig_.freeMultiWindowSupport_, true); + // load windowEffect + ssm_->LoadFreeMultiWindowConfig(false); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetX_, 2); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetY_, 2); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 1); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.radius_, 0); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 1); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 2); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 2); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0); + + // load FreeMultiWindow windowEffect config + ssm_->LoadFreeMultiWindowConfig(true); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 0); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetX_, 3); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetY_, 3); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.radius_, 0.5); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 3); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 3); + ASSERT_FLOAT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5); +} + /** * @tc.name: Init * @tc.desc: SceneSesionManager init -- Gitee From 263edcb2c124f427221170364c67a013df60cc5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czhongzijie=E2=80=9D?= Date: Fri, 22 Aug 2025 10:01:59 +0800 Subject: [PATCH 130/241] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “zhongzijie” --- wm/src/window_scene_session_impl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 5e0159efef..c9033afaa2 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6054,6 +6054,13 @@ WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams WMError WindowSceneSessionImpl::AdjustKeyboardLayout(const KeyboardLayoutParams params) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "gravity: %{public}u, " + "landscapeAvoidHeight: %{public}d, portraitAvoidHeight: %{public}d, " + "LandscapeKeyboardRect: %{public}s, PortraitKeyboardRect: %{public}s, " + "LandscapePanelRect: %{public}s, PortraitPanelRect: %{public}s", + static_cast(params.gravity_), params.landscapeAvoidHeight_, params.portraitAvoidHeight_, + params.LandscapeKeyboardRect_.ToString().c_str(), params.PortraitKeyboardRect_.ToString().c_str(), + params.LandscapePanelRect_.ToString().c_str(), params.PortraitPanelRect_.ToString().c_str()); property_->SetKeyboardLayoutParams(params); auto ret = MoveAndResizeKeyboard(params); if (ret != WMError::WM_OK) { -- Gitee From 8d796be7151304b82d255cf813690024ba3b669f Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Fri, 22 Aug 2025 10:21:36 +0800 Subject: [PATCH 131/241] =?UTF-8?q?rdbStore=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laiganlu --- .../include/rdb/starting_window_rdb_manager.h | 1 - .../session_manager/src/rdb/starting_window_rdb_manager.cpp | 6 ------ window_scene/session_manager/src/scene_session_manager.cpp | 2 -- 3 files changed, 9 deletions(-) diff --git a/window_scene/session_manager/include/rdb/starting_window_rdb_manager.h b/window_scene/session_manager/include/rdb/starting_window_rdb_manager.h index 40ac71245c..f76e68ba01 100644 --- a/window_scene/session_manager/include/rdb/starting_window_rdb_manager.h +++ b/window_scene/session_manager/include/rdb/starting_window_rdb_manager.h @@ -60,7 +60,6 @@ public: std::string GetStartWindowValFromProfile(const AppExecFwk::AbilityInfo& abilityInfo, const std::shared_ptr& resourceMgr, const std::string& key, const std::string& defaultVal); - void ClearRdbStore(); private: std::shared_ptr GetRdbStore(); diff --git a/window_scene/session_manager/src/rdb/starting_window_rdb_manager.cpp b/window_scene/session_manager/src/rdb/starting_window_rdb_manager.cpp index af54c29ad9..bfe5b5cee4 100644 --- a/window_scene/session_manager/src/rdb/starting_window_rdb_manager.cpp +++ b/window_scene/session_manager/src/rdb/starting_window_rdb_manager.cpp @@ -116,12 +116,6 @@ StartingWindowRdbManager::StartingWindowRdbManager(const WmsRdbConfig& wmsRdbCon StartingWindowRdbManager::~StartingWindowRdbManager() { - ClearRdbStore(); -} - -void StartingWindowRdbManager::ClearRdbStore() -{ - std::lock_guard lock(rdbMutex_); rdbStore_ = nullptr; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7fda9275f5..f43feeb899 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3607,7 +3607,6 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrClearRdbStore(); auto sceneSessionInfo = SetAbilitySessionInfo(sceneSession); sceneSession->GetCloseAbilityWantAndClean(sceneSessionInfo->want); ResetSceneSessionInfoWant(sceneSessionInfo); @@ -5366,7 +5365,6 @@ void SceneSessionManager::UpdateAllStartingWindowRdb() auto batchInsertRes = startingWindowRdbMgr_->BatchInsert(outInsertNum, inputValues); TLOGNI(WmsLogTag::WMS_PATTERN, "res: %{public}d, bundles: %{public}zu, insert: %{public}" PRId64, batchInsertRes, bundleInfos.size(), outInsertNum); - startingWindowRdbMgr_->ClearRdbStore(); }; ffrtQueueHelper_->SubmitTask(loadTask); } -- Gitee From f3bbf7d80c6ad9893786c028d42521b0f11bd84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=95=AC=E6=9D=BE?= <18328528985@163.com> Date: Thu, 21 Aug 2025 20:53:12 +0800 Subject: [PATCH 132/241] =?UTF-8?q?=E9=BB=84=E8=93=9D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周敬松 <18328528985@163.com> --- .../js_fb_window_controller.cpp | 24 +++++++++---------- .../js_fb_window_manager.cpp | 4 ++++ .../common/include/session_permission.h | 2 +- window_scene/session/host/include/session.h | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/interfaces/kits/napi/floating_ball_napi/js_fb_window_controller.cpp b/interfaces/kits/napi/floating_ball_napi/js_fb_window_controller.cpp index e33cc2e71b..c978343593 100644 --- a/interfaces/kits/napi/floating_ball_napi/js_fb_window_controller.cpp +++ b/interfaces/kits/napi/floating_ball_napi/js_fb_window_controller.cpp @@ -363,40 +363,40 @@ napi_value JsFbController::CheckParams(napi_env env, const FbOption& option) { if (option.GetTemplate() < static_cast(FloatingBallTemplate::STATIC) || option.GetTemplate() >= static_cast(FloatingBallTemplate::END)) { - TLOGE(WmsLogTag::WMS_SYSTEM, "template %{public}d is invalid.", option.GetTemplate()); + TLOGE(WmsLogTag::WMS_SYSTEM, "Template %{public}d is invalid", option.GetTemplate()); napi_throw(env, AbilityRuntime::CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "template is invalid.")); + static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "Template is invalid.")); return nullptr; } if (option.GetTitle().length() < TITLE_MIN_LEN || option.GetTitle().length() > TITLE_MAX_LEN) { - TLOGE(WmsLogTag::WMS_SYSTEM, "title length Exceed the limit %{public}zu.", option.GetTitle().length()); + TLOGE(WmsLogTag::WMS_SYSTEM, "Title length Exceed the limit %{public}zu", option.GetTitle().length()); napi_throw(env, AbilityRuntime::CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "title length Exceed the limit")); + static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "Title length Exceed the limit")); return nullptr; } if (option.GetContent().length() > CONTENT_MAX_LEN) { - TLOGE(WmsLogTag::WMS_SYSTEM, "content length Exceed the limit %{public}zu.", option.GetContent().length()); + TLOGE(WmsLogTag::WMS_SYSTEM, "Content length Exceed the limit %{public}zu", option.GetContent().length()); napi_throw(env, AbilityRuntime::CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "content length Exceed the limit")); + static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "Content length Exceed the limit")); return nullptr; } if (option.GetIcon() != nullptr && option.GetIcon()->GetByteCount() > PIXEL_MAP_MAX_SIZE) { - TLOGE(WmsLogTag::WMS_SYSTEM, "icon size Exceed the limit %{public}d.", option.GetIcon()->GetByteCount()); + TLOGE(WmsLogTag::WMS_SYSTEM, "Icon size Exceed the limit %{public}d", option.GetIcon()->GetByteCount()); napi_throw(env, AbilityRuntime::CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "icon size Exceed the limit")); + static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "Icon size Exceed the limit")); return nullptr; } if (!option.GetBackgroundColor().empty() && !ColorParser::IsValidColorNoAlpha(option.GetBackgroundColor())) { - TLOGE(WmsLogTag::WMS_SYSTEM, "backgroundColor is invalid %{public}s.", option.GetBackgroundColor().c_str()); + TLOGE(WmsLogTag::WMS_SYSTEM, "BackgroundColor is invalid"); napi_throw(env, AbilityRuntime::CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "backgroundColor is invalid")); + static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "BackgroundColor is invalid")); return nullptr; } if (option.GetTemplate() == static_cast(FloatingBallTemplate::STATIC) && option.GetIcon() == nullptr) { - TLOGE(WmsLogTag::WMS_SYSTEM, "template %{public}u need icon.", option.GetTemplate()); + TLOGE(WmsLogTag::WMS_SYSTEM, "Template %{public}u need icon", option.GetTemplate()); napi_throw(env, AbilityRuntime::CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "current template need icon")); + static_cast(WmErrorCode::WM_ERROR_FB_PARAM_INVALID), "Current template need icon")); return nullptr; } return NapiGetUndefined(env); diff --git a/interfaces/kits/napi/floating_ball_napi/js_fb_window_manager.cpp b/interfaces/kits/napi/floating_ball_napi/js_fb_window_manager.cpp index c8dd74c7d2..cee8ae4ab9 100644 --- a/interfaces/kits/napi/floating_ball_napi/js_fb_window_manager.cpp +++ b/interfaces/kits/napi/floating_ball_napi/js_fb_window_manager.cpp @@ -94,6 +94,10 @@ napi_value JsFbWindowManager::NapiSendTask(napi_env env, void* contextPtr) *errCodePtr = WmErrorCode::WM_ERROR_FB_INTERNAL_ERROR; return; } + if (fbController == nullptr) { + *errCodePtr = WmErrorCode::WM_ERROR_FB_INTERNAL_ERROR; + return; + } fbController->UpdateMainWindow(mainWindow); }; NapiAsyncTask::CompleteCallback complete = diff --git a/window_scene/common/include/session_permission.h b/window_scene/common/include/session_permission.h index 303d9ea889..217171d731 100644 --- a/window_scene/common/include/session_permission.h +++ b/window_scene/common/include/session_permission.h @@ -28,8 +28,8 @@ constexpr const char* PERMISSION_CALLED_EXTENSION_ON_LOCK_SCREEN = "ohos.permiss constexpr const char* PERMISSION_WRITE_APP_LOCK = "ohos.permission.WRITE_APP_LOCK"; constexpr const char* PERMISSION_SET_ABILITY_INSTANCE_INFO = "ohos.permission.SET_ABILITY_INSTANCE_INFO"; constexpr const char* PERMISSION_VISIBLE_WINDOW_INFO = "ohos.permission.VISIBLE_WINDOW_INFO"; -constexpr const char* PERMISSION_FLOATING_BALL = "ohos.permission.USE_FLOAT_BALL"; constexpr const char* PERMISSION_WINDOW_TRANSPARENT = "ohos.permission.SET_WINDOW_TRANSPARENT"; +constexpr const char* PERMISSION_FLOATING_BALL = "ohos.permission.USE_FLOAT_BALL"; } class SessionPermission { public: diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index e5d8b434d1..11a4c0f42b 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -55,10 +55,10 @@ class RSTransaction; class Session; using NotifySessionRectChangeFunc = std::function; +using NotifySessionDisplayIdChangeFunc = std::function; using NotifyUpdateFloatingBallFunc = std::function; using NotifyStopFloatingBallFunc = std::function; using NotifyRestoreFloatingBallMainWindowFunc = std::function& want)>; -using NotifySessionDisplayIdChangeFunc = std::function; using NotifyPendingSessionActivationFunc = std::function; using NotifyBatchPendingSessionsActivationFunc = std::function>& info)>; using NotifyChangeSessionVisibilityWithStatusBarFunc = std::function; -- Gitee From de27d54bf91c06f2bb62dd22609dcd79e1587c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:17:00 +0000 Subject: [PATCH 133/241] update wm/src/window_scene_session_impl.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/src/window_scene_session_impl.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 518573c4a6..fd166dbcde 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2406,7 +2406,7 @@ WMError WindowSceneSessionImpl::CheckAndModifyWindowRect(uint32_t& width, uint32 } /** @note @window.layout */ -WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height) +WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig) { auto reason = SizeChangeReason::RESIZE; if (isResizedByLimit_) { @@ -2440,12 +2440,16 @@ WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height) windowRect.ToString().c_str(), newRect.ToString().c_str()); property_->SetRequestRect(newRect); + property_->SetRectAnimationConfig(rectAnimationConfig); WSRect wsRect = { newRect.posX_, newRect.posY_, newRect.width_, newRect.height_ }; auto hostSession = GetHostSession(); + if (rectAnimationConfig.duration > 0 && reason == SizeChangeReason::RESIZE) { + reason = SizeChangeReason::RESIZE_WITH_ANIMATION; + } CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); - auto ret = hostSession->UpdateSessionRect(wsRect, reason); + auto ret = hostSession->UpdateSessionRect(wsRect, reason, false, false, {}, rectAnimationConfig); return static_cast(ret); } @@ -2461,7 +2465,7 @@ WMError WindowSceneSessionImpl::ResizeAsync(uint32_t width, uint32_t height) GetWindowId(), GetWindowMode()); return WMError::WM_ERROR_INVALID_OP_IN_CUR_STATUS; } - auto ret = Resize(width, height); + auto ret = Resize(width, height, rectAnimationConfig); if (state_ == WindowState::STATE_SHOWN) { layoutCallback_->ResetResizeLock(); auto startTime = std::chrono::duration_cast( -- Gitee From 79fe5a534cd266cbdef6b37093c72acf86ba5a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:17:35 +0000 Subject: [PATCH 134/241] update wm/src/window_impl.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/src/window_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 6fbb6eed9a..72ed14ee17 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -2020,7 +2020,7 @@ WMError WindowImpl::MoveTo(int32_t x, int32_t y, bool isMoveToGlobal, MoveConfig return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_RECT); } -WMError WindowImpl::Resize(uint32_t width, uint32_t height) +WMError WindowImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig) { WLOGFD("id:%{public}d Resize %{public}u %{public}u", property_->GetWindowId(), width, height); -- Gitee From 34995e75ecd1f1ce08881221f6b00607a7ceca56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:18:17 +0000 Subject: [PATCH 135/241] update wm/src/window_extension_session_impl.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/src/window_extension_session_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 91be04e794..f85e966af2 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -335,7 +335,8 @@ WMError WindowExtensionSessionImpl::MoveTo(int32_t x, int32_t y, return static_cast(error); } -WMError WindowExtensionSessionImpl::Resize(uint32_t width, uint32_t height) +WMError WindowExtensionSessionImpl::Resize(uint32_t width, uint32_t height, + const RectAnimationConfig& rectAnimationConfig) { WLOGFD("Id:%{public}d wh %{public}u %{public}u", property_->GetPersistentId(), width, height); if (IsWindowSessionInvalid()) { -- Gitee From 7872df809fd37875e5bee6d53d6f83db8d87e6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:18:55 +0000 Subject: [PATCH 136/241] update wm/include/window_scene_session_impl.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/include/window_scene_session_impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index d5c5160654..a951a355ac 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -58,7 +58,8 @@ public: WMError MoveWindowToGlobal(int32_t x, int32_t y, MoveConfiguration moveConfiguration = {}) override; WMError MoveWindowToGlobalDisplay(int32_t x, int32_t y, MoveConfiguration moveConfiguration = {}) override; WMError GetGlobalScaledRect(Rect& globalScaledRect) override; - WMError Resize(uint32_t width, uint32_t height) override; + WMError Resize(uint32_t width, uint32_t height, + const RectAnimationConfig& rectAnimationConfig = {}) override; WMError ResizeAsync(uint32_t width, uint32_t height) override; WMError SetWindowAnchorInfo(const WindowAnchorInfo& windowAnchorInfo) override; WMError SetFollowParentWindowLayoutEnabled(bool isFollow) override; -- Gitee From bd892c4abbc8046383fc0a8298a9d3dbc308bb22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:19:38 +0000 Subject: [PATCH 137/241] update wm/include/window_impl.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/include/window_impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 0c4f0abdbf..f9a3295f69 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -194,7 +194,8 @@ public: virtual WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits, bool waitDetach) override; virtual WMError MoveTo(int32_t x, int32_t y, bool isMoveToGlobal = false, MoveConfiguration moveConfiguration = {}) override; - virtual WMError Resize(uint32_t width, uint32_t height) override; + virtual WMError Resize(uint32_t width, uint32_t height, + const RectAnimationConfig& rectAnimationConfig = {}) override; float GetVirtualPixelRatio() override; virtual WMError SetWindowGravity(WindowGravity gravity, uint32_t percent) override; virtual WMError SetKeepScreenOn(bool keepScreenOn) override; -- Gitee From d04b6d82b2c37bf76e65a4f5cceacc74ebd35e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:20:23 +0000 Subject: [PATCH 138/241] update interfaces/innerkits/wm/window.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- interfaces/innerkits/wm/window.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 19206d999a..e9b30562ff 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1561,7 +1561,8 @@ public: * @param height * @return WMError */ - virtual WMError Resize(uint32_t width, uint32_t height) { return WMError::WM_OK; } + virtual WMError Resize(uint32_t width, uint32_t height, + const RectAnimationConfig& rectAnimationConfig = {}) { return WMError::WM_OK; } /** * @brief resize the window instance (w,h) -- Gitee From 40115b741f1e7ff16168449270324fc924e1ac17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:21:02 +0000 Subject: [PATCH 139/241] update previewer/include/window_impl.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- previewer/include/window_impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/previewer/include/window_impl.h b/previewer/include/window_impl.h index 1d3fce87ef..c7133b26e5 100644 --- a/previewer/include/window_impl.h +++ b/previewer/include/window_impl.h @@ -111,7 +111,8 @@ public: virtual WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits, bool waitDetach) override; virtual WMError MoveTo(int32_t x, int32_t y, bool isMoveToGlobal = false, MoveConfiguration moveConfiguration = {}) override; - virtual WMError Resize(uint32_t width, uint32_t height) override; + virtual WMError Resize(uint32_t width, uint32_t height, + const RectAnimationConfig& rectAnimationConfig = {}) override; virtual WMError SetWindowGravity(WindowGravity gravity, uint32_t percent) override; virtual WMError SetKeepScreenOn(bool keepScreenOn) override; virtual bool IsKeepScreenOn() const override; -- Gitee From 958b0a73e6c8378fa7fc626b82b04cfc7c9d4236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:21:38 +0000 Subject: [PATCH 140/241] update previewer/src/window_impl.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- previewer/src/window_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/previewer/src/window_impl.cpp b/previewer/src/window_impl.cpp index 6349e43ae3..fd0fc0ba7d 100644 --- a/previewer/src/window_impl.cpp +++ b/previewer/src/window_impl.cpp @@ -585,7 +585,7 @@ WMError WindowImpl::MoveTo(int32_t x, int32_t y, bool isMoveToGlobal, MoveConfig return WMError::WM_OK; } -WMError WindowImpl::Resize(uint32_t width, uint32_t height) +WMError WindowImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig) { return WMError::WM_OK; } -- Gitee From 0a35d43ceb2a123d445e6d3e86b4d58cc62c4c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:22:21 +0000 Subject: [PATCH 141/241] update window_scene/test/dms_unittest/screen_session_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- window_scene/test/dms_unittest/screen_session_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 8ec39694bd..9d96691c34 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -1110,7 +1110,7 @@ HWTEST_F(ScreenSessionTest, Resize002, TestSize.Level1) ASSERT_NE(nullptr, screenSession); uint32_t width = 1000; uint32_t height = 1000; - screenSession->Resize(width, height); + screenSession->Resize(width, height, false); GTEST_LOG_(INFO) << "Resize002 end"; } -- Gitee From cf28cf2c4f5e27f8bbd6a7d5c8275a5ccd86bb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:22:59 +0000 Subject: [PATCH 142/241] update wm/include/window_extension_session_impl.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/include/window_extension_session_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index 7f52a1ea24..e133beaf0b 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -42,7 +42,7 @@ public: bool isModuleAbilityHookEnd = false) override; WMError MoveTo(int32_t x, int32_t y, bool isMoveToGlobal = false, MoveConfiguration moveConfiguration = {}) override; - WMError Resize(uint32_t width, uint32_t height) override; + WMError Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig = {}) override; WMError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override; WMError TransferExtensionData(const AAFwk::WantParams& wantParams) override; WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override; -- Gitee From 7d3510a825669cc54314e3c44861971954a7571a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Fri, 22 Aug 2025 11:23:01 +0800 Subject: [PATCH 143/241] =?UTF-8?q?pc=E5=BA=94=E7=94=A8=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- .../session/host/src/scene_session.cpp | 4 +++ .../unittest/scene_session_lifecycle_test.cpp | 35 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ed1c6d6368..fd4fd9db03 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -381,6 +381,10 @@ WSError SceneSession::Foreground( if (SessionPermission::VerifyCallingPermission("ohos.permission.CALLED_BELOW_LOCK_SCREEN")) { TLOGW(WmsLogTag::WMS_LIFE, "screen is locked, session %{public}d %{public}s permission verified", GetPersistentId(), sessionInfo_.bundleName_.c_str()); + } else if (SessionPermission::VerifyCallingPermission("ohos.permission.START_WINDOW_BELOW_LOCK_SCREEN")) { + TLOGW(WmsLogTag::WMS_LIFE, + "screen is locked, session %{public}d %{public}s start below lock screen permission verified", + GetPersistentId(), sessionInfo_.bundleName_.c_str()); } else { TLOGW(WmsLogTag::WMS_LIFE, "failed: screen is locked, session %{public}d %{public}s show without ShowWhenLocked flag", diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 77a95b7860..62c11efa45 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -23,6 +23,7 @@ #include "session/host/include/sub_session.h" #include "session/host/include/system_session.h" #include "session/host/include/main_session.h" +#include "screen_session_manager_client.h" #include "wm_common.h" #include "mock/mock_session_stage.h" #include "input_event.h" @@ -240,6 +241,40 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground06, TestSize.Level0) EXPECT_EQ(WSError::WS_OK, session->Foreground(property, false)); } +/** + * @tc.name: Foreground07 + * @tc.desc: Foreground07 function + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionLifecycleTest, Foreground07, TestSize.Level0) +{ + SessionInfo info; + info.abilityName_ = "Foreground07"; + info.bundleName_ = "Foreground07"; + + sptr session = sptr::MakeSptr(info, nullptr); + EXPECT_NE(session, nullptr); + sptr property = sptr::MakeSptr(); + session->property_ = property; + session->property_->SetDisplayId(ScreenSessionManagerClient::GetInstance().GetDefaultScreenId()); + session->SetIsActivatedAfterScreenLocked(true); + + GetStateFromManagerFunc func = [](const ManagerState key) { + switch (key) { + case ManagerState::MANAGER_STATE_SCREEN_LOCKED: + return true; + break; + default: + return false; + break; + } + }; + session->SetGetStateFromManagerListener(func); + MockAccesstokenKit::MockAccessTokenKitRet(-1); + EXPECT_EQ(WSError::WS_OK, session->Foreground(property, false)); + MockAccesstokenKit::MockAccessTokenKitRet(0); +} + /** * @tc.name: ForegroundTask01 * @tc.desc: ForegroundTask function -- Gitee From 184dd0f53bbf67b926d1557e7831de48a2c071ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 03:27:39 +0000 Subject: [PATCH 144/241] update window_scene/test/unittest/layout/scene_session_layout_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- window_scene/test/unittest/layout/scene_session_layout_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/layout/scene_session_layout_test.cpp b/window_scene/test/unittest/layout/scene_session_layout_test.cpp index 387dcd965c..94167894c7 100644 --- a/window_scene/test/unittest/layout/scene_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/scene_session_layout_test.cpp @@ -1161,7 +1161,7 @@ HWTEST_F(SceneSessionLayoutTest, GetWindowDragMoveMountedNode01, TestSize.Level1 sceneSession->SetFindScenePanelRsNodeByZOrderFunc([this](uint64_t screenId, uint32_t targetZOrder) { return CreateRSSurfaceNode(); }); - rsNode = session->GetWindowDragMoveMountedNode(0, 0); + rsNode = sceneSession->GetWindowDragMoveMountedNode(0, 0); EXPECT_NE(rsNode, nullptr); } -- Gitee From 40ceb2397ddc496f238f759f4e9c9c0d6b728f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Fri, 22 Aug 2025 11:33:25 +0800 Subject: [PATCH 145/241] =?UTF-8?q?pc=E5=BA=94=E7=94=A8=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- window_scene/test/unittest/scene_session_lifecycle_test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 62c11efa45..82b20d5b70 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -251,7 +251,6 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground07, TestSize.Level0) SessionInfo info; info.abilityName_ = "Foreground07"; info.bundleName_ = "Foreground07"; - sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); sptr property = sptr::MakeSptr(); @@ -271,7 +270,7 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground07, TestSize.Level0) }; session->SetGetStateFromManagerListener(func); MockAccesstokenKit::MockAccessTokenKitRet(-1); - EXPECT_EQ(WSError::WS_OK, session->Foreground(property, false)); + EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->Foreground(property, false)); MockAccesstokenKit::MockAccessTokenKitRet(0); } -- Gitee From 38d49c6052b02a0eec5d07955d95fbbea2765df1 Mon Sep 17 00:00:00 2001 From: xxx Date: Fri, 22 Aug 2025 03:37:02 +0000 Subject: [PATCH 146/241] update window_scene/session_manager/include/session_manager_agent_controller.h. Signed-off-by: xxx --- .../session_manager/include/session_manager_agent_controller.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/include/session_manager_agent_controller.h b/window_scene/session_manager/include/session_manager_agent_controller.h index f8e983690f..b409fa8db3 100644 --- a/window_scene/session_manager/include/session_manager_agent_controller.h +++ b/window_scene/session_manager/include/session_manager_agent_controller.h @@ -68,7 +68,7 @@ private: std::map>> windowManagerPidAgentMap_; std::map, std::pair> windowManagerAgentPairMap_; std::mutex windowManagerAgentPidMapMutex_; - WindowManagementMode windowManagementMode_; + WindowManagementMode windowManagementMode_ { WindowManagementMode::UNDEFINED }; }; } } -- Gitee From af93874641721c23d38f6db0163c2abda03d6229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Fri, 22 Aug 2025 06:10:29 +0000 Subject: [PATCH 147/241] update wm/src/window_scene_session_impl.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index fd166dbcde..71ce1a4ab8 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2465,7 +2465,7 @@ WMError WindowSceneSessionImpl::ResizeAsync(uint32_t width, uint32_t height) GetWindowId(), GetWindowMode()); return WMError::WM_ERROR_INVALID_OP_IN_CUR_STATUS; } - auto ret = Resize(width, height, rectAnimationConfig); + auto ret = Resize(width, height); if (state_ == WindowState::STATE_SHOWN) { layoutCallback_->ResetResizeLock(); auto startTime = std::chrono::duration_cast( -- Gitee From 37bd8e3d1bed977a7bac7849c6268116c2cf965c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czhongzijie=E2=80=9D?= Date: Fri, 22 Aug 2025 14:14:47 +0800 Subject: [PATCH 148/241] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “zhongzijie” --- wm/src/window_scene_session_impl.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index c9033afaa2..b5827974ae 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6055,12 +6055,16 @@ WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams WMError WindowSceneSessionImpl::AdjustKeyboardLayout(const KeyboardLayoutParams params) { TLOGI(WmsLogTag::WMS_KEYBOARD, "gravity: %{public}u, " - "landscapeAvoidHeight: %{public}d, portraitAvoidHeight: %{public}d, " - "LandscapeKeyboardRect: %{public}s, PortraitKeyboardRect: %{public}s, " - "LandscapePanelRect: %{public}s, PortraitPanelRect: %{public}s", - static_cast(params.gravity_), params.landscapeAvoidHeight_, params.portraitAvoidHeight_, - params.LandscapeKeyboardRect_.ToString().c_str(), params.PortraitKeyboardRect_.ToString().c_str(), - params.LandscapePanelRect_.ToString().c_str(), params.PortraitPanelRect_.ToString().c_str()); + "land: avoid=%{public}d, kbd=%{public}s, panel=%{public}s, " + "port: avoid=%{public}d, kbd=%{public}s, panel=%{public}s", + static_cast(params.gravity_), + params.landscapeAvoidHeight_, + params.LandscapeKeyboardRect_.ToString().c_str(), + params.LandscapePanelRect_.ToString().c_str(), + params.portraitAvoidHeight_, + params.PortraitKeyboardRect_.ToString().c_str(), + params.PortraitPanelRect_.ToString().c_str() + ); property_->SetKeyboardLayoutParams(params); auto ret = MoveAndResizeKeyboard(params); if (ret != WMError::WM_OK) { -- Gitee From a8bc561ef2e0c1586a0add504bbac47fd079d73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czhongzijie=E2=80=9D?= Date: Fri, 22 Aug 2025 14:19:52 +0800 Subject: [PATCH 149/241] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “zhongzijie” --- wm/src/window_scene_session_impl.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index b5827974ae..65a855522d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6054,17 +6054,13 @@ WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams WMError WindowSceneSessionImpl::AdjustKeyboardLayout(const KeyboardLayoutParams params) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "gravity: %{public}u, " - "land: avoid=%{public}d, kbd=%{public}s, panel=%{public}s, " - "port: avoid=%{public}d, kbd=%{public}s, panel=%{public}s", - static_cast(params.gravity_), - params.landscapeAvoidHeight_, - params.LandscapeKeyboardRect_.ToString().c_str(), - params.LandscapePanelRect_.ToString().c_str(), - params.portraitAvoidHeight_, - params.PortraitKeyboardRect_.ToString().c_str(), - params.PortraitPanelRect_.ToString().c_str() - ); + TLOGI(WmsLogTag::WMS_KEYBOARD, "g: %{public}u, " + "LAvoid: %{public}d, PAvoid: %{public}d, " + "LRect: %{public}s, PRect: %{public}s, " + "LPRect: %{public}s, PPRect: %{public}s", + static_cast(params.gravity_), params.landscapeAvoidHeight_, params.portraitAvoidHeight_, + params.LandscapeKeyboardRect_.ToString().c_str(), params.PortraitKeyboardRect_.ToString().c_str(), + params.LandscapePanelRect_.ToString().c_str(), params.PortraitPanelRect_.ToString().c_str()); property_->SetKeyboardLayoutParams(params); auto ret = MoveAndResizeKeyboard(params); if (ret != WMError::WM_OK) { -- Gitee From cd677af8fe821d832f0aa402bd7362709ac75ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czhongzijie=E2=80=9D?= Date: Fri, 22 Aug 2025 14:37:48 +0800 Subject: [PATCH 150/241] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “zhongzijie” --- wm/src/window_scene_session_impl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 65a855522d..8c2477c851 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6055,12 +6055,12 @@ WMError WindowSceneSessionImpl::MoveAndResizeKeyboard(const KeyboardLayoutParams WMError WindowSceneSessionImpl::AdjustKeyboardLayout(const KeyboardLayoutParams params) { TLOGI(WmsLogTag::WMS_KEYBOARD, "g: %{public}u, " - "LAvoid: %{public}d, PAvoid: %{public}d, " - "LRect: %{public}s, PRect: %{public}s, " - "LPRect: %{public}s, PPRect: %{public}s", - static_cast(params.gravity_), params.landscapeAvoidHeight_, params.portraitAvoidHeight_, - params.LandscapeKeyboardRect_.ToString().c_str(), params.PortraitKeyboardRect_.ToString().c_str(), - params.LandscapePanelRect_.ToString().c_str(), params.PortraitPanelRect_.ToString().c_str()); + "LAvoid: %{public}d, PAvoid: %{public}d, " + "LRect: %{public}s, PRect: %{public}s, " + "LPRect: %{public}s, PPRect: %{public}s", + static_cast(params.gravity_), params.landscapeAvoidHeight_, params.portraitAvoidHeight_, + params.LandscapeKeyboardRect_.ToString().c_str(), params.PortraitKeyboardRect_.ToString().c_str(), + params.LandscapePanelRect_.ToString().c_str(), params.PortraitPanelRect_.ToString().c_str()); property_->SetKeyboardLayoutParams(params); auto ret = MoveAndResizeKeyboard(params); if (ret != WMError::WM_OK) { -- Gitee From c0815cea23a1e506f515e0a4d69fb493bcc944eb Mon Sep 17 00:00:00 2001 From: lly920173971 <920173971@qq.com> Date: Fri, 22 Aug 2025 15:14:28 +0800 Subject: [PATCH 151/241] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lly920173971 <920173971@qq.com> --- .../src/zidl/scene_session_manager_proxy.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 cae8eb38fa..5c7161cbc3 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 @@ -3567,7 +3567,11 @@ WMError SceneSessionManagerProxy::MinimizeByWindowId(const std::vector& TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed"); return WMError::WM_ERROR_IPC_FAILED; } - return static_cast(reply.ReadInt32()); + int32_t ret = 0; + if (!reply.ReadInt32(ret)) { + return WMError::WM_ERROR_IPC_FAILED; + } + return static_cast(ret); } WMError SceneSessionManagerProxy::SetForegroundWindowNum(uint32_t windowNum) @@ -3598,7 +3602,7 @@ WMError SceneSessionManagerProxy::SetForegroundWindowNum(uint32_t windowNum) WSError SceneSessionManagerProxy::UseImplicitAnimation(int32_t hostWindowId, bool useImplicit) { - TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::GetHostWindowRect"); + TLOGD(WmsLogTag::WMS_UIEXT, "Run SceneSessionManagerProxy::UseImplicitAnimation"); MessageParcel data; MessageParcel reply; MessageOption option; -- Gitee From 1577d84681215a49bc969c71d9769b0a4bbc3302 Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Fri, 22 Aug 2025 15:17:31 +0800 Subject: [PATCH 152/241] =?UTF-8?q?=E9=94=81=E5=B1=8F=E4=B9=8B=E4=B8=8A?= =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peng fafu --- window_scene/session_manager/src/scene_session_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 95fc5f2edc..f327452f0b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -273,6 +273,7 @@ bool IsUIExtCanShowOnLockScreen(const AppExecFwk::ElementName& element, uint32_t std::make_tuple("com.ohos.sceneboard", "ThemeChargingAbility", "engineservice"), std::make_tuple("com.ohos.commondialog", "FoldStatusAbility", "phone_commondialog"), std::make_tuple("com.ohos.commondialog", "SecondaryReflexionAbility", "phone_commondialog"), + std::make_tuple("com.huawei.hmos.clock", "ScreenLockCoverExtensionAbility", "entry"), }; if (extensionAbilityTypeWhitelist.find(extensionAbilityType) != extensionAbilityTypeWhitelist.end()) { -- Gitee From 0456b178c50eed464906c855ca0900332e7c8a10 Mon Sep 17 00:00:00 2001 From: yecong2332 Date: Fri, 22 Aug 2025 15:28:22 +0800 Subject: [PATCH 153/241] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=A1=B5=E8=B7=9F?= =?UTF-8?q?=E9=9A=8F=E5=BA=94=E7=94=A8=E6=B7=B1=E6=B5=85=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yecong2332 --- window_scene/interfaces/include/ws_common.h | 2 + .../session/host/include/scene_session.h | 5 + .../host/include/zidl/session_interface.h | 1 + .../include/zidl/session_ipc_interface_code.h | 1 + .../session/host/include/zidl/session_proxy.h | 1 + .../session/host/include/zidl/session_stub.h | 1 + .../session/host/src/scene_session.cpp | 21 ++ window_scene/session/host/src/session.cpp | 2 - .../session/host/src/zidl/session_proxy.cpp | 30 +++ .../session/host/src/zidl/session_stub.cpp | 18 ++ .../include/scene_session_manager.h | 32 ++- .../src/scene_session_manager.cpp | 184 +++++++++++++++--- .../test/unittest/scene_session_test.cpp | 33 ++++ .../test/unittest/session_proxy_test.cpp | 41 ++++ .../test/unittest/session_stub_test.cpp | 22 +++ wm/include/window_scene_session_impl.h | 2 + wm/include/window_session_impl.h | 2 + wm/src/window_scene_session_impl.cpp | 50 +++++ .../window_scene_session_impl_test5.cpp | 52 +++++ 19 files changed, 469 insertions(+), 31 deletions(-) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index a361507cdf..54244f6283 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -49,6 +49,8 @@ constexpr int32_t INVALID_SESSION_ID = 0; constexpr int32_t DEFAULT_REQUEST_FROM_SCB_ID = -1; constexpr int32_t WINDOW_SUPPORT_MODE_MAX_SIZE = 4; constexpr int32_t DEFAULT_SCALE_RATIO = 100; +constexpr uint32_t COLOR_WHITE = 0xffffffff; +constexpr uint32_t COLOR_BLACK = 0xff000000; const std::string WINDOW_SCREEN_LOCK_PREFIX = "windowLock_"; const std::string VIEW_SCREEN_LOCK_PREFIX = "viewLock_"; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 12c3c33a7c..696a9924e3 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -857,6 +857,8 @@ public: WMError NotifySubSessionAcrossDisplaysChange(bool isAcrossDisplays); WMError NotifyFollowedParentWindowAcrossDisplaysChange(bool isAcrossDisplays); void NotifySessionAcrossDisplaysChange(const sptr& sceneSession, bool isAcrossDisplays); + WMError OnUpdateColorMode(const std::string& colorMode, bool hasDarkRes) override; + std::string GetAbilityColorMode() const; /* * Window Pattern @@ -1394,6 +1396,9 @@ private: bool isAncoForFloatingWindow_ = false; bool subWindowOutlineEnabled_ = false; std::atomic_bool isRegisterAcrossDisplaysChanged_ = false; + std::string colorMode_; + bool hasDarkRes_ = false; + mutable std::mutex colorModeMutex_; NotifySetWindowShadowsFunc onSetWindowShadowsFunc_; UpdateScreenshotAppEventRegisteredFunc updateScreenshotAppEventRegisteredFunc_; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index db962ffb0b..87c0544812 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -492,6 +492,7 @@ public: virtual WSError UpdateRotationChangeRegistered(int32_t persistentId, bool isRegister) { return WSError::WS_OK; } virtual WMError UpdateScreenshotAppEventRegistered(int32_t persistentId, bool isRegister) { return WMError::WM_OK; } virtual WMError UpdateAcrossDisplaysChangeRegistered(bool isRegister) { return WMError::WM_OK; } + virtual WMError OnUpdateColorMode(const std::string& colorMode, bool hasDarkRes) { return WMError::WM_OK; } virtual WMError IsMainWindowFullScreenAcrossDisplays(bool& isAcrossDisplays) { return WMError::WM_OK; } virtual WSError GetIsHighlighted(bool& isHighlighted) { return WSError::WS_OK; } diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index 5e8f00697c..78c45862df 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -61,6 +61,7 @@ enum class SessionInterfaceCode { TRANS_ID_ADJUST_KEYBOARD_LAYOUT, TRANS_ID_LAYOUT_FULL_SCREEN_CHANGE, TRANS_ID_DEFAULT_DENSITY_ENABLED, + TRANS_ID_UPDATE_COLOR_MODE, TRANS_ID_GET_FORCE_LANDSCAPE_CONFIG, TRANS_ID_GET_HOOK_WINDOW_INFO, TRANS_ID_GET_STATUSBAR_HEIGHT, diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 4277499205..1ec2231d8d 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -50,6 +50,7 @@ public: WSError SyncSessionEvent(SessionEvent event) override; WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) override; WSError OnDefaultDensityEnabled(bool isDefaultDensityEnabled) override; + WMError OnUpdateColorMode(const std::string& colorMode, bool hasDarkRes) override; WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, bool isDockHoverShown = true) override; WSError OnRestoreMainWindow() override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 8e882ee5fc..d63c8079cd 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -79,6 +79,7 @@ private: int HandleUpdatePropertyByAction(MessageParcel& data, MessageParcel& reply); int HandleLayoutFullScreenChange(MessageParcel& data, MessageParcel& reply); int HandleDefaultDensityEnabled(MessageParcel& data, MessageParcel& reply); + int HandleUpdateColorMode(MessageParcel& data, MessageParcel& reply); int HandleTitleAndDockHoverShowChange(MessageParcel& data, MessageParcel& reply); int HandleRestoreMainWindow(MessageParcel& data, MessageParcel& reply); int HandleGetAppForceLandscapeConfig(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 5780fcda64..c7f02283f2 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -7226,6 +7226,27 @@ WSError SceneSession::OnDefaultDensityEnabled(bool isDefaultDensityEnabled) return WSError::WS_OK; } +WMError SceneSession::OnUpdateColorMode(const std::string& colorMode, bool hasDarkRes) +{ + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d, colorMode: %{public}s, hasDarkRes: %{public}u", + GetPersistentId(), colorMode.c_str(), hasDarkRes); + std::lock_guard lock(colorModeMutex_); + colorMode_ = colorMode; + hasDarkRes_ = hasDarkRes; + return WMError::WM_OK; +} + +std::string SceneSession::GetAbilityColorMode() const +{ + std::lock_guard lock(colorModeMutex_); + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d, colorMode: %{public}s, hasDarkRes: %{public}u", + GetPersistentId(), colorMode_.c_str(), hasDarkRes_); + if (colorMode_ == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK && !hasDarkRes_) { + return AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO; + } + return colorMode_; +} + /** @note @Window.Layout */ WMError SceneSession::UpdateWindowModeForUITest(int32_t updateMode) { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 6ffc701025..426769bcea 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -53,8 +53,6 @@ constexpr float INNER_BORDER_VP = 5.0f; constexpr float OUTSIDE_BORDER_VP = 4.0f; constexpr float INNER_ANGLE_VP = 16.0f; constexpr uint32_t MAX_LIFE_CYCLE_TASK_IN_QUEUE = 15; -constexpr uint32_t COLOR_WHITE = 0xffffffff; -constexpr uint32_t COLOR_BLACK = 0xff000000; constexpr int64_t LIFE_CYCLE_TASK_EXPIRED_TIME_LIMIT = 350; static bool g_enableForceUIFirst = system::GetParameter("window.forceUIFirst.enabled", "1") == "1"; constexpr int64_t STATE_DETECT_DELAYTIME = 3 * 1000; diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 650b67d7f2..5378b0d241 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -905,6 +905,36 @@ WSError SessionProxy::OnDefaultDensityEnabled(bool isDefaultDensityEnabled) return static_cast(ret); } +WMError SessionProxy::OnUpdateColorMode(const std::string& colorMode, bool hasDarkRes) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (!data.WriteString(colorMode)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write colorMode failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (!data.WriteBool(hasDarkRes)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write hasDarkRes failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_COLOR_MODE), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + return WMError::WM_OK; +} + WSError SessionProxy::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown) { MessageParcel data; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 87e37480e4..db49aa8677 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -225,6 +225,8 @@ int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleLayoutFullScreenChange(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_DEFAULT_DENSITY_ENABLED): return HandleDefaultDensityEnabled(data, reply); + case static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_COLOR_MODE): + return HandleUpdateColorMode(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_TITLE_AND_DOCK_HOVER_SHOW_CHANGE): return HandleTitleAndDockHoverShowChange(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_GET_FORCE_LANDSCAPE_CONFIG): @@ -590,6 +592,22 @@ int SessionStub::HandleLayoutFullScreenChange(MessageParcel& data, MessageParcel return ERR_NONE; } +int SessionStub::HandleUpdateColorMode(MessageParcel& data, MessageParcel& reply) +{ + std::string colorMode; + if (!data.ReadString(colorMode)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read colorMode failed."); + return ERR_INVALID_DATA; + } + bool hasDarkRes = false; + if (!data.ReadBool(hasDarkRes)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read hasDarkRes failed."); + return ERR_INVALID_DATA; + } + OnUpdateColorMode(colorMode, hasDarkRes); + return ERR_NONE; +} + int SessionStub::HandleDefaultDensityEnabled(MessageParcel& data, MessageParcel& reply) { bool isDefaultDensityEnabled = false; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8b4c5cd786..15b080a9d5 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -40,6 +40,7 @@ #include "include/core/SkRegion.h" #include "interfaces/include/ws_common.h" #include "mission_snapshot.h" +#include "res_common.h" #include "scb_session_handler.h" #include "scene_session_converter.h" #include "screen_fold_data.h" @@ -72,6 +73,7 @@ class LauncherService; namespace OHOS::Global::Resource { class ResourceManager; +enum ColorMode; } // namespace OHOS::Global::Resource namespace OHOS::Rosen { @@ -789,6 +791,10 @@ public: WMError SetStartWindowBackgroundColor(const std::string& moduleName, const std::string& abilityName, uint32_t color, int32_t uid) override; void ConfigSupportSnapshotAllSessionStatus(); + void InsertProcessMap(const SessionInfo& sessionInfo, const int32_t persistentId); + WSError DeleteProcessMap(const SessionInfo& sessionInfo, const int32_t persistentId); + WSError FindProcessMap(const SessionInfo& sessionInfo, int32_t& persistentId); + int32_t FindCallerPersistentId(int32_t persistentId); void ConfigSupportPreloadStartingWindow(); /* @@ -1015,7 +1021,8 @@ private: const sptr& sceneSession); sptr GetBundleManager(); - std::shared_ptr GetResourceManager(const AppExecFwk::AbilityInfo& abilityInfo); + std::shared_ptr GetResourceManager(const AppExecFwk::AbilityInfo& abilityInfo, + Global::Resource::ColorMode colorMode = Global::Resource::ColorMode::COLOR_MODE_NOT_SET); bool CheckIsRemote(const std::string& deviceId); bool GetLocalDeviceId(std::string& localDeviceId); @@ -1663,32 +1670,45 @@ private: /* * Window Pattern */ + std::mutex processMapMutex_; + std::unordered_map> processCompareMap_; + std::shared_mutex startingWindowFollowAppSetMutex_; + std::unordered_set startingWindowFollowAppSet_; std::unordered_set emptyStartupResource_; std::atomic delayRemoveSnapshot_ = false; void InitStartingWindowRdb(const std::string& rdbPath); - bool GetStartingWindowInfoFromCache(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo); + bool GetStartingWindowInfoFromCache(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo, + bool isDark); uint32_t UpdateCachedColorToAppSet(const std::string& bundleName, const std::string& moduleName, const std::string& abilityName, StartingWindowInfo& startingWindowInfo); - bool GetStartingWindowInfoFromRdb(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo); + bool GetStartingWindowInfoFromRdb(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo, + bool darkMode); + bool GetStartWindowColorFollowApp(const SessionInfo& sessionInfo); bool GetPathInfoFromResource(const std::shared_ptr resourceMgr, bool hapPathEmpty, uint32_t resourceId, std::string& path); - bool GetStartupPageFromResource(const AppExecFwk::AbilityInfo& abilityInfo, StartingWindowInfo& startingWindowInfo); + bool CheckStartWindowColorFollowApp(const AppExecFwk::AbilityInfo& abilityInfo, + const std::shared_ptr& resourceMgr); + bool GetStartupPageFromResource(const AppExecFwk::AbilityInfo& abilityInfo, StartingWindowInfo& startingWindowInfo, + bool appColorModeChanged = false, + Global::Resource::ColorMode colorMode = Global::Resource::ColorMode::COLOR_MODE_NOT_SET); void GetBundleStartingWindowInfos(bool isDark, const AppExecFwk::BundleInfo& bundleInfo, std::vector>& outValues); void CacheStartingWindowInfo(const std::string& bundleName, const std::string& moduleName, - const std::string& abilityName, const StartingWindowInfo& startingWindowInfo); + const std::string& abilityName, const StartingWindowInfo& startingWindowInfo, bool isDark); void PreLoadStartingWindow(sptr sceneSession); bool CheckAndGetPreLoadResourceId(const StartingWindowInfo& startingWindowInfo, uint32_t& resId); std::unique_ptr startingWindowRdbMgr_; std::unique_ptr snapshotLruCache_; std::size_t snapshotCapacity_ = 0; bool GetIconFromDesk(const SessionInfo& sessionInfo, std::string& startupPagePath) const; - bool GetIsDarkFromConfiguration(); + bool GetIsDarkFromConfiguration(const std::string& appColorMode); bool needCloseSync_ = false; std::function closeSyncFunc_ = nullptr; WMError SetImageForRecent(uint32_t imgResourceId, ImageFit imageFit, int32_t persistentId) override; void UpdateAllStartingWindowRdb(); bool needUpdateRdb_ = true; + std::string GetSessionColorMode(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo); + int32_t GetOriginalPersistentId(const std::set& sessionSet, int32_t persistentId); }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 46143f8f5a..e0c88031dd 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -114,6 +114,7 @@ const std::string DM_PKG_NAME = "ohos.distributedhardware.devicemanager"; constexpr int32_t NON_ANONYMIZE_LENGTH = 6; const std::string EMPTY_DEVICE_ID = ""; const std::string STARTWINDOW_TYPE = "startWindowType"; +const std::string STARTWINDOW_COLOR_MODE_TYPE = "startWindowColorModeType"; const int32_t MAX_NUMBER_OF_DISTRIBUTED_SESSIONS = 20; constexpr int WINDOW_NAME_MAX_WIDTH = 21; @@ -2787,6 +2788,7 @@ void SceneSessionManager::InitSceneSession(sptr& sceneSession, con if (sessionLockedStateCacheSet_.find(key) != sessionLockedStateCacheSet_.end()) { sceneSession->NotifySessionLockStateChange(true); } + InsertProcessMap(sessionInfo, sceneSession->GetPersistentId()); } void SceneSessionManager::InitFbWindow(const sptr& sceneSession, @@ -3607,6 +3609,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrGetSessionInfo(), persistentId); startingWindowRdbMgr_->ClearRdbStore(); auto sceneSessionInfo = SetAbilitySessionInfo(sceneSession); sceneSession->GetCloseAbilityWantAndClean(sceneSessionInfo->want); @@ -5147,7 +5150,7 @@ sptr SceneSessionManager::GetBundleManager() } std::shared_ptr SceneSessionManager::GetResourceManager( - const AppExecFwk::AbilityInfo& abilityInfo) + const AppExecFwk::AbilityInfo& abilityInfo, Global::Resource::ColorMode colorMode) { auto context = rootSceneContextWeak_.lock(); if (!context) { @@ -5165,6 +5168,10 @@ std::shared_ptr SceneSessionManager::GetResou return nullptr; } resourceMgr->GetResConfig(*resConfig); + if (colorMode != Global::Resource::ColorMode::COLOR_MODE_NOT_SET) { + resConfig->SetColorMode(colorMode); + TLOGI(WmsLogTag::WMS_PATTERN, "resConfig colorMode: %{public}d", colorMode); + } resourceMgr = Global::Resource::CreateResourceManager( abilityInfo.bundleName, abilityInfo.moduleName, "", {}, *resConfig); if (!resourceMgr) { @@ -5209,14 +5216,31 @@ bool SceneSessionManager::GetPathInfoFromResource(const std::shared_ptr& resourceMgr) +{ + const std::string followSystemMode = "FOLLOW_SYSTEM"; + const std::string followAPPMode = "FOLLOW_APPLICATION"; + std::string colorModeType = startingWindowRdbMgr_->GetStartWindowValFromProfile( + abilityInfo, resourceMgr, STARTWINDOW_COLOR_MODE_TYPE, followSystemMode); + if (colorModeType == followAPPMode) { + TLOGI(WmsLogTag::WMS_PATTERN, "follow app: %{public}s", abilityInfo.bundleName.c_str()); + std::string key = abilityInfo.bundleName + '_' + abilityInfo.moduleName + '_' + abilityInfo.name; + std::unique_lock lock(startingWindowFollowAppSetMutex_); + startingWindowFollowAppSet_.insert(key); + return true; + } + return false; +} + bool SceneSessionManager::GetStartupPageFromResource(const AppExecFwk::AbilityInfo& abilityInfo, - StartingWindowInfo& startingWindowInfo) + StartingWindowInfo& startingWindowInfo, bool appColorModeChanged, Global::Resource::ColorMode colorMode) { const std::map START_WINDOW_KEY_AND_DEFAULT_MAP = { {STARTWINDOW_TYPE, "REQUIRED_SHOW"}, }; - auto resourceMgr = GetResourceManager(abilityInfo); + auto resourceMgr = GetResourceManager(abilityInfo, Global::Resource::ColorMode::COLOR_MODE_NOT_SET); if (!resourceMgr) { TLOGE(WmsLogTag::WMS_PATTERN, "resourceMgr is nullptr."); return false; @@ -5225,6 +5249,13 @@ bool SceneSessionManager::GetStartupPageFromResource(const AppExecFwk::AbilityIn if (hapPathEmpty) { TLOGD(WmsLogTag::WMS_PATTERN, "hapPath empty:%{public}s", abilityInfo.bundleName.c_str()); } + if (CheckStartWindowColorFollowApp(abilityInfo, resourceMgr) && appColorModeChanged) { + resourceMgr = GetResourceManager(abilityInfo, colorMode); + if (!resourceMgr) { + TLOGE(WmsLogTag::WMS_PATTERN, "resourceMgr is nullptr."); + return false; + } + } const auto startWindowType = START_WINDOW_KEY_AND_DEFAULT_MAP.find(STARTWINDOW_TYPE); if (startWindowType != START_WINDOW_KEY_AND_DEFAULT_MAP.end()) { @@ -5265,8 +5296,14 @@ bool SceneSessionManager::GetStartupPageFromResource(const AppExecFwk::AbilityIn return true; } -bool SceneSessionManager::GetIsDarkFromConfiguration() +bool SceneSessionManager::GetIsDarkFromConfiguration(const std::string& appColorMode) { + if (appColorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK) { + return true; + } + if (appColorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT) { + return false; + } std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); if (appContext == nullptr) { TLOGE(WmsLogTag::WMS_PATTERN, "app context is nullptr"); @@ -5358,7 +5395,7 @@ void SceneSessionManager::UpdateAllStartingWindowRdb() return; } std::vector> inputValues; - bool isDark = GetIsDarkFromConfiguration(); + bool isDark = GetIsDarkFromConfiguration(std::string(AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO)); for (const auto& bundleInfo : bundleInfos) { GetBundleStartingWindowInfos(isDark, bundleInfo, inputValues); } @@ -5371,6 +5408,100 @@ void SceneSessionManager::UpdateAllStartingWindowRdb() ffrtQueueHelper_->SubmitTask(loadTask); } +void SceneSessionManager::InsertProcessMap(const SessionInfo& sessionInfo, const int32_t persistentId) +{ + std::string compareInfo = + sessionInfo.bundleName_ + "_" + sessionInfo.appInstanceKey_ + "_" + std::to_string(sessionInfo.appIndex_); + TLOGI(WmsLogTag::WMS_PATTERN, "%{public}s, %{public}d", compareInfo.c_str(), persistentId); + std::lock_guard lock(processMapMutex_); + processCompareMap_[compareInfo].insert(persistentId); +} + +WSError SceneSessionManager::DeleteProcessMap(const SessionInfo& sessionInfo, const int32_t persistentId) +{ + std::string compareInfo = + sessionInfo.bundleName_ + "_" + sessionInfo.appInstanceKey_ + "_" + std::to_string(sessionInfo.appIndex_); + std::lock_guard lock(processMapMutex_); + auto it = processCompareMap_.find(compareInfo); + if (it == processCompareMap_.end()) { + return WSError::WS_DO_NOTHING; + } + auto& vals = it->second; + vals.erase(persistentId); + TLOGI(WmsLogTag::WMS_PATTERN, "%{public}s, %{public}d", compareInfo.c_str(), persistentId); + if (vals.empty()) { + processCompareMap_.erase(it); + TLOGI(WmsLogTag::WMS_PATTERN, "deleteALL: %{public}s", compareInfo.c_str()); + } + return WSError::WS_OK; +} + +int32_t SceneSessionManager::FindCallerPersistentId(int32_t persistentId) +{ + auto session = GetSceneSession(persistentId); + if (session == nullptr) { + return INVALID_SESSION_ID; + } + auto callerId = session->GetSessionInfo().callerPersistentId_; + TLOGI(WmsLogTag::WMS_PATTERN, "id: %{public}d, CallerId: %{public}d", persistentId, callerId); + return callerId; +} + +int32_t SceneSessionManager::GetOriginalPersistentId(const std::set& sessionSet, int32_t persistentId) +{ + auto resId = persistentId; + auto callerId = FindCallerPersistentId(persistentId); + std::unordered_set uniqueSet = { persistentId }; + while ((callerId != INVALID_SESSION_ID) && + (sessionSet.count(callerId) > 0) && (uniqueSet.count(callerId) == 0)) { + resId = callerId; + uniqueSet.insert(callerId); + callerId = FindCallerPersistentId(callerId); + } + return resId; +} + +WSError SceneSessionManager::FindProcessMap(const SessionInfo& sessionInfo, int32_t& persistentId) +{ + std::string compareInfo = + sessionInfo.bundleName_ + "_" + sessionInfo.appInstanceKey_ + "_" + std::to_string(sessionInfo.appIndex_); + std::lock_guard lock(processMapMutex_); + auto it = processCompareMap_.find(compareInfo); + if (it != processCompareMap_.end() && !it->second.empty()) { + persistentId = GetOriginalPersistentId(it->second, *it->second.begin()); + TLOGI(WmsLogTag::WMS_PATTERN, "find %{public}d", persistentId); + return WSError::WS_OK; + } + TLOGD(WmsLogTag::WMS_PATTERN, "find nothing %{public}s", compareInfo.c_str()); + return WSError::WS_DO_NOTHING; +} + +std::string SceneSessionManager::GetSessionColorMode(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo) +{ + int32_t sameProcessId = 0; + if (FindProcessMap(sessionInfo, sameProcessId) != WSError::WS_OK) { + return AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO; + } + auto session = GetSceneSession(sameProcessId); + if (session == nullptr) { + TLOGD(WmsLogTag::WMS_PATTERN, "session: %{public}d, nullptr", sameProcessId); + return AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO; + } + auto colorMode = session->GetAbilityColorMode(); + return colorMode; +} + +bool SceneSessionManager::GetStartWindowColorFollowApp(const SessionInfo& sessionInfo) +{ + std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' + sessionInfo.abilityName_; + std::shared_lock lock(startingWindowFollowAppSetMutex_); + if (startingWindowFollowAppSet_.count(key) != 0) { + TLOGI(WmsLogTag::WMS_PATTERN, "follow app: %{public}s", key.c_str()); + return true; + } + return false; +} + void SceneSessionManager::GetStartupPage(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo) { if (GetIconFromDesk(sessionInfo, startingWindowInfo.iconPathEarlyVersion_)) { @@ -5382,12 +5513,17 @@ void SceneSessionManager::GetStartupPage(const SessionInfo& sessionInfo, Startin return; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetStartupPage"); - if (GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo)) { + bool colorFollowApp = GetStartWindowColorFollowApp(sessionInfo); + bool isAppDark = GetIsDarkFromConfiguration(GetSessionColorMode(sessionInfo, startingWindowInfo)); + bool isSystemDark = GetIsDarkFromConfiguration(std::string(AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO)); + bool isDark = colorFollowApp ? isAppDark : isSystemDark; + if (GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo, isDark)) { return; } - if (GetStartingWindowInfoFromRdb(sessionInfo, startingWindowInfo)) { + startingWindowInfo.backgroundColorEarlyVersion_ = isDark ? COLOR_BLACK : COLOR_WHITE; + if (GetStartingWindowInfoFromRdb(sessionInfo, startingWindowInfo, isDark)) { CacheStartingWindowInfo( - sessionInfo.bundleName_, sessionInfo.moduleName_, sessionInfo.abilityName_, startingWindowInfo); + sessionInfo.bundleName_, sessionInfo.moduleName_, sessionInfo.abilityName_, startingWindowInfo, isDark); uint32_t updateRes = UpdateCachedColorToAppSet( sessionInfo.bundleName_, sessionInfo.moduleName_, sessionInfo.abilityName_, startingWindowInfo); TLOGI(WmsLogTag::WMS_PATTERN, "updateRes %{public}u, %{public}x", @@ -5402,15 +5538,16 @@ void SceneSessionManager::GetStartupPage(const SessionInfo& sessionInfo, Startin TLOGE(WmsLogTag::WMS_PATTERN, "Get ability info from BMS failed!"); return; } - if (GetStartupPageFromResource(abilityInfo, startingWindowInfo)) { + auto appColorMode = isAppDark ? Global::Resource::ColorMode::DARK : Global::Resource::ColorMode::LIGHT; + if (GetStartupPageFromResource(abilityInfo, startingWindowInfo, isAppDark != isSystemDark, appColorMode)) { CacheStartingWindowInfo( - sessionInfo.bundleName_, sessionInfo.moduleName_, sessionInfo.abilityName_, startingWindowInfo); + sessionInfo.bundleName_, sessionInfo.moduleName_, sessionInfo.abilityName_, startingWindowInfo, isDark); if (startingWindowRdbMgr_ != nullptr) { StartingWindowRdbItemKey itemKey = { .bundleName = sessionInfo.bundleName_, .moduleName = sessionInfo.moduleName_, .abilityName = sessionInfo.abilityName_, - .darkMode = GetIsDarkFromConfiguration(), + .darkMode = isDark, }; if (!startingWindowRdbMgr_->InsertData(itemKey, startingWindowInfo)) { TLOGW(WmsLogTag::WMS_PATTERN, "rdb insert faild"); @@ -5427,7 +5564,7 @@ void SceneSessionManager::GetStartupPage(const SessionInfo& sessionInfo, Startin } bool SceneSessionManager::GetStartingWindowInfoFromCache( - const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo) + const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo, bool isDark) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetStartingWindowInfoFromCache"); std::shared_lock lock(startingWindowMapMutex_); @@ -5435,21 +5572,21 @@ bool SceneSessionManager::GetStartingWindowInfoFromCache( if (iter == startingWindowMap_.end()) { return false; } - auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_; + auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_ + std::to_string(isDark); const auto& infoMap = iter->second; auto infoMapIter = infoMap.find(key); if (infoMapIter == infoMap.end()) { return false; } startingWindowInfo = infoMapIter->second; - TLOGW(WmsLogTag::WMS_PATTERN, "%{public}x, %{public}s, %{public}x, %{public}s", + TLOGW(WmsLogTag::WMS_PATTERN, "%{public}x, %{public}s, %{public}x, %{public}s, %{public}d", startingWindowInfo.backgroundColorEarlyVersion_, startingWindowInfo.iconPathEarlyVersion_.c_str(), - startingWindowInfo.backgroundColor_, startingWindowInfo.iconPath_.c_str()); + startingWindowInfo.backgroundColor_, startingWindowInfo.iconPath_.c_str(), isDark); return true; } bool SceneSessionManager::GetStartingWindowInfoFromRdb( - const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo) + const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo, bool darkMode) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetStartingWindowInfoFromRdb"); if (startingWindowRdbMgr_ == nullptr) { @@ -5460,7 +5597,7 @@ bool SceneSessionManager::GetStartingWindowInfoFromRdb( .bundleName = sessionInfo.bundleName_, .moduleName = sessionInfo.moduleName_, .abilityName = sessionInfo.abilityName_, - .darkMode = GetIsDarkFromConfiguration(), + .darkMode = darkMode, }; bool res = startingWindowRdbMgr_->QueryData(itemKey, startingWindowInfo); TLOGW(WmsLogTag::WMS_PATTERN, "%{public}x, %{public}s, %{public}x, %{public}s, %{public}d", @@ -5509,10 +5646,10 @@ uint32_t SceneSessionManager::UpdateCachedColorToAppSet(const std::string& bundl } void SceneSessionManager::CacheStartingWindowInfo(const std::string& bundleName, const std::string& moduleName, - const std::string& abilityName, const StartingWindowInfo& startingWindowInfo) + const std::string& abilityName, const StartingWindowInfo& startingWindowInfo, bool isDark) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:CacheStartingWindowInfo"); - auto key = moduleName + abilityName; + auto key = moduleName + abilityName + std::to_string(isDark); std::unique_lock lock(startingWindowMapMutex_); auto iter = startingWindowMap_.find(bundleName); if (iter != startingWindowMap_.end()) { @@ -5534,7 +5671,7 @@ std::shared_ptr SceneSessionManager::GetPreLoadStartingWindow(c std::shared_lock lock(preLoadstartingWindowMapMutex_); preLoadMap = preLoadStartingWindowMap_; } - std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' +sessionInfo.abilityName_; + std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' + sessionInfo.abilityName_; auto iter = preLoadMap.find(key); if (iter == preLoadMap.end()) { TLOGI(WmsLogTag::WMS_PATTERN, "%{public}s not found", key.c_str()); @@ -5545,7 +5682,7 @@ std::shared_ptr SceneSessionManager::GetPreLoadStartingWindow(c void SceneSessionManager::RemovePreLoadStartingWindowFromMap(const SessionInfo& sessionInfo) { - std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' +sessionInfo.abilityName_; + std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' + sessionInfo.abilityName_; std::unique_lock lock(preLoadstartingWindowMapMutex_); auto iter = preLoadStartingWindowMap_.find(key); if (iter != preLoadStartingWindowMap_.end()) { @@ -5596,7 +5733,7 @@ void SceneSessionManager::PreLoadStartingWindow(sptr sceneSession) TLOGNE(WmsLogTag::WMS_PATTERN, "%{public}s pixelMap is nullptr", where); return; } - std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' +sessionInfo.abilityName_; + std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' + sessionInfo.abilityName_; { std::unique_lock lock(preLoadstartingWindowMapMutex_); preLoadStartingWindowMap_[key] = pixelMap; @@ -5656,7 +5793,8 @@ void SceneSessionManager::OnBundleUpdated(const std::string& bundleName, int use bundleInfo, currentUserId_); if (ret == 0) { std::vector> inputValues; - GetBundleStartingWindowInfos(GetIsDarkFromConfiguration() ,bundleInfo, inputValues); + GetBundleStartingWindowInfos(GetIsDarkFromConfiguration(std::string(AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO)), + bundleInfo, inputValues); int64_t outInsertNum = -1; auto batchInsertRes = startingWindowRdbMgr_->BatchInsert(outInsertNum, inputValues); TLOGNI(WmsLogTag::WMS_PATTERN, "res:%{public}d, insert num:%{public}" PRId64, batchInsertRes, outInsertNum); diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index afca7ed333..225541e4c0 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -773,6 +773,39 @@ HWTEST_F(SceneSessionTest, UpdateAcrossDisplaysChangeRegistered01, TestSize.Leve EXPECT_NE(ret, WMError::WM_OK); } +/** + * @tc.name: ColorMode01 + * @tc.desc: Test OnUpdateColorMode And GetAbilityColorMode + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, ColorMode01, TestSize.Level0) +{ + SessionInfo info; + info.abilityName_ = "test"; + info.bundleName_ = "test"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + std::string colorMode = "dark"; + bool hasDarkRes = true; + auto ret = sceneSession->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_NE(WMError::WM_OK, ret); + + std::string resMode = sceneSession->GetAbilityColorMode(); + EXPECT_NE("dark", resMode); + + hasDarkRes = false; + ret = sceneSession->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_NE(WMError::WM_OK, ret); + resMode = sceneSession->GetAbilityColorMode(); + EXPECT_NE("auto", resMode); + + colorMode = "light"; + ret = sceneSession->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_NE(WMError::WM_OK, ret); + resMode = sceneSession->GetAbilityColorMode(); + EXPECT_NE("light", resMode); +} + /** * @tc.name: IsMainWindowFullScreenAcrossDisplays * @tc.desc: IsMainWindowFullScreenAcrossDisplays01 diff --git a/window_scene/test/unittest/session_proxy_test.cpp b/window_scene/test/unittest/session_proxy_test.cpp index 7b9ce9238c..393eef5244 100755 --- a/window_scene/test/unittest/session_proxy_test.cpp +++ b/window_scene/test/unittest/session_proxy_test.cpp @@ -1612,6 +1612,47 @@ HWTEST_F(SessionProxyTest, IsMainWindowFullScreenAcrossDisplays, Function | Smal MockMessageParcel::ClearAllErrorFlag(); } +/** + * @tc.name: OnUpdateColorMode + * @tc.desc: OnUpdateColorMode test + * @tc.type: FUNC + */ +HWTEST_F(SessionProxyTest, OnUpdateColorMode, Function | SmallTest | Level2) +{ + std::string colorMode = "DARK"; + bool hasDarkRes = true; + auto sProxy = sptr::MakeSptr(nullptr); + ASSERT_NE(sProxy, nullptr); + auto ret = sProxy->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); + + sptr remoteMocker = sptr::MakeSptr(); + sProxy = sptr::MakeSptr(remoteMocker); + ASSERT_NE(sProxy, nullptr); + ret = sProxy->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_EQ(ret, WMError::WM_OK); + + remoteMocker->SetRequestResult(ERR_INVALID_DATA); + ret = sProxy->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); + remoteMocker->SetRequestResult(ERR_NONE); + + MockMessageParcel::SetWriteBoolErrorFlag(true); + ret = sProxy->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); + + MockMessageParcel::SetWriteStringErrorFlag(true); + ret = sProxy->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); + + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + ret = sProxy->OnUpdateColorMode(colorMode, hasDarkRes); + EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); + MockMessageParcel::SetWriteBoolErrorFlag(false); + MockMessageParcel::SetWriteStringErrorFlag(false); + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); +} + /** * @tc.name: GetTargetOrientationConfigInfo * @tc.desc: GetTargetOrientationConfigInfo test diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 4010887e4a..cf565667cb 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -1202,6 +1202,28 @@ HWTEST_F(SessionStubTest, HandleIsMainWindowFullScreenAcrossDisplays, Function | EXPECT_EQ(0, sessionStub->ProcessRemoteRequest(code, data, reply, option)); } +/** + * @tc.name: HandleUpdateColorMode + * @tc.desc: sessionStub HandleUpdateColorMode + * @tc.type: FUNC + */ +HWTEST_F(SessionStubTest, HandleUpdateColorMode, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteString("DARK"); + data.WriteBool(true); + sptr sessionStub = sptr::MakeSptr(); + ASSERT_NE(nullptr, sessionStub); + auto result = sessionStub->HandleUpdateColorMode(data, reply); + EXPECT_EQ(result, ERR_NONE); + + data.WriteInterfaceToken(SessionStub::GetDescriptor()); + uint32_t code = static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_COLOR_MODE); + EXPECT_EQ(0, sessionStub->ProcessRemoteRequest(code, data, reply, option)); +} + /** * @tc.name: HandleNotifyKeyboardWillShowRegistered * @tc.desc: sessionStub HandleNotifyKeyboardWillShowRegistered diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 16a6b36097..6597e36370 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -449,6 +449,8 @@ private: /* * Window Property */ + void RecoverSessionProperty(); + WMError UpdateColorMode(const std::shared_ptr& configuration = nullptr); void InitSystemSessionDragEnable(); bool IsSystemDensityChanged(const sptr& displayInfo); bool IsDefaultDensityEnabled(); diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 6f578ce4f9..d101e9da2a 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -816,6 +816,8 @@ protected: /* * Window Property */ + std::string colorMode_; + bool hasDarkRes_; std::unordered_set containerColorList_; float lastSystemDensity_ = UNDEFINED_DENSITY; static std::atomic defaultDensityEnabledGlobalConfig_; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 246f0c0d4b..01372aedb0 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -403,6 +403,14 @@ WMError WindowSceneSessionImpl::CreateSystemWindow(WindowType type) return WMError::WM_OK; } +void WindowSceneSessionImpl::RecoverSessionProperty() +{ + // recover colorMode + if (auto hostSession = GetHostSession()) { + hostSession->OnUpdateColorMode(colorMode_, hasDarkRes_); + } +} + WMError WindowSceneSessionImpl::RecoverAndConnectSpecificSession() { TLOGI(WmsLogTag::WMS_RECOVER, "windowName=%{public}s, windowMode=%{public}u, windowType=%{public}u, " @@ -660,6 +668,7 @@ WMError WindowSceneSessionImpl::Create(const std::shared_ptrUpdateConfiguration(configuration); + UpdateColorMode(); } else { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "uiContent null, scene win=%{public}u, display=%{public}" PRIu64, GetWindowId(), GetDisplayId()); @@ -4310,6 +4321,44 @@ void WindowSceneSessionImpl::UpdateConfiguration(const std::shared_ptr& configuration) +{ + std::string colorMode; + if (configuration != nullptr) { + colorMode = configuration->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); + } + auto appContext = AbilityRuntime::Context::GetApplicationContext(); + if (appContext == nullptr) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d app context is null", GetPersistentId()); + return WMError::WM_ERROR_NULLPTR; + } + if (colorMode.empty()) { + std::shared_ptr config = appContext->GetConfiguration(); + if (config == nullptr) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "config is null, winId: %{public}d", GetPersistentId()); + return WMError::WM_ERROR_NULLPTR; + } + colorMode = config->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); + } + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d, colorMode: %{public}s", GetPersistentId(), colorMode.c_str()); + if (colorMode_ == colorMode) { + return WMError::WM_DO_NOTHING; + } + colorMode_ = colorMode; + bool hasDarkRes = false; + appContext->AppHasDarkRes(hasDarkRes); + hasDarkRes_ = hasDarkRes; + + if (auto hostSession = GetHostSession()) { + hostSession->OnUpdateColorMode(colorMode, hasDarkRes); + } else { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d hostSession is null", GetPersistentId()); + } + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d, colorMode: %{public}s, hasDarkRes: %{public}u", + GetPersistentId(), colorMode.c_str(), hasDarkRes); + return WMError::WM_OK; +} + void WindowSceneSessionImpl::UpdateConfigurationForSpecified( const std::shared_ptr& configuration, const std::shared_ptr& resourceManager) @@ -4374,6 +4423,7 @@ void WindowSceneSessionImpl::UpdateConfigurationSync(const std::shared_ptrUpdateConfigurationSyncForAll(configuration); + UpdateColorMode(); } else { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "uiContent null, scene win=%{public}u, display=%{public}" PRIu64, GetWindowId(), GetDisplayId()); diff --git a/wm/test/unittest/window_scene_session_impl_test5.cpp b/wm/test/unittest/window_scene_session_impl_test5.cpp index 31187be9f8..5cb3644076 100644 --- a/wm/test/unittest/window_scene_session_impl_test5.cpp +++ b/wm/test/unittest/window_scene_session_impl_test5.cpp @@ -507,6 +507,58 @@ HWTEST_F(WindowSceneSessionImplTest5, IsMainWindowFullScreenAcrossDisplays01, Te EXPECT_EQ(WMError::WM_OK, ret); } +/** + * @tc.name: RecoverSessionProperty + * @tc.desc: RecoverSessionProperty + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, RecoverSessionProperty, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(1); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + window->RecoverSessionProperty(); +} + +/** + * @tc.name: UpdateColorMode + * @tc.desc: UpdateColorMode + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest5, UpdateColorMode, TestSize.Level1) +{ + std::shared_ptr configuration; + sptr option = sptr::MakeSptr(); + sptr window = sptr::MakeSptr(option); + window->hostSession_ = nullptr; + auto ret = window->UpdateColorMode(configuration); + EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret); + + AbilityRuntime::ApplicationContext::applicationContext_ = std::make_shared(); + ret = window->UpdateColorMode(configuration); + EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret); + + AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_ = + std::make_shared(); + ret = window->UpdateColorMode(configuration); + configuration = std::make_shared(); + configuration->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, "dark"); + window->property_->SetPersistentId(1); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + ret = window->UpdateColorMode(configuration); + EXPECT_EQ(WMError::WM_OK, ret); + + ret = window->UpdateColorMode(configuration); + EXPECT_EQ(WMError::WM_OK, ret); +} + /** * @tc.name: SwitchFreeMultiWindow01 * @tc.desc: SwitchFreeMultiWindow -- Gitee From 7607b4fe54b3064d58a5e0a6323b7f68cd3dec50 Mon Sep 17 00:00:00 2001 From: hubijie Date: Thu, 21 Aug 2025 16:19:05 +0800 Subject: [PATCH 154/241] support uiextension create sub window which in system scene Signed-off-by: hubijie --- interfaces/innerkits/wm/wm_common.h | 1 + utils/include/string_util.h | 20 ++++++ .../common/include/window_session_property.h | 9 +++ .../common/src/window_session_property.cpp | 4 ++ .../js_scene_session_manager.cpp | 31 ++++++++ .../js_scene_session_manager.h | 2 + .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 25 +++++++ .../unittest/scene_session_manager_test12.cpp | 71 +++++++++++++++++++ wm/src/window_scene_session_impl.cpp | 2 +- 10 files changed, 165 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index ec76b769c7..7f035bdaf3 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -165,6 +165,7 @@ enum class WindowType : uint32_t { SYSTEM_SUB_WINDOW_BASE = 2500, WINDOW_TYPE_SYSTEM_SUB_WINDOW = SYSTEM_SUB_WINDOW_BASE, + WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW, SYSTEM_SUB_WINDOW_END, SYSTEM_WINDOW_END = SYSTEM_SUB_WINDOW_END, diff --git a/utils/include/string_util.h b/utils/include/string_util.h index 96c5eb161b..75cf6fa038 100644 --- a/utils/include/string_util.h +++ b/utils/include/string_util.h @@ -16,6 +16,7 @@ #ifndef WM_STRING_UTIL_H #define WM_STRING_UTIL_H +#incldue #include namespace OHOS { @@ -23,6 +24,25 @@ namespace Rosen { class StringUtil { public: static std::string Trim(std::string s); + + static inline bool ConvertStringToInt32(const std::string& str, int32_t& num) + { + auto res = std::from_chars(str.data(), str.data() + str.size(), num); + if (res.ec != std::errc()) { + return false; + } + return true; + } + + static inline bool ConvertStringToBool(const std::string& str) + { + std::string tmp = str; + std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower); + if (tmp == "true" || tmp == "1") { + return true; + } + return false; + } }; } // Rosen } // OHOS diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 4a5dc4d6f5..5b3abdfd51 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -27,6 +27,8 @@ #include #include "pixel_map.h" #include "floating_ball_template_info.h" +#include "string_util.h" +#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { @@ -801,6 +803,8 @@ struct SystemSessionConfig : public Parcelable { bool supportPreloadStartingWindow_ = false; bool supportCreateFloatWindow_ = false; float defaultCornerRadius_ = 0.0f; // default corner radius of window set by system config + bool supportUIExtensionSubWindow_ = false; + using ConvertSystemConfigFunc = void(SystemSessionConfig::*)(SystemSessionConfig& systemConfig, const std::string& configItem); virtual bool Marshalling(Parcel& parcel) const override { @@ -945,6 +949,11 @@ struct SystemSessionConfig : public Parcelable { { return IsPcWindow() || (IsPadWindow() && IsFreeMultiWindowMode()); } + + void ConvertSupportUIExtensionSubWindow(SystemSessionConfig& systemConfig, const std::string& itemValue) + { + systemConfig.supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); + } }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index c7010cc992..70bfe2ee54 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -1589,6 +1589,10 @@ void WindowSessionProperty::CopyFrom(const sptr& property isPcAppInpadOrientationLandscape_ = property->isPcAppInpadOrientationLandscape_; isPcAppInpadCompatibleMode_ = property->isPcAppInpadCompatibleMode_; ancoRealBundleName_ = property->ancoRealBundleName_; + { + std::lock_guard lock(missionInfoMutex_); + missionInfo_ = property->missionInfo_; + } } bool WindowSessionProperty::Write(Parcel& parcel, WSPropertyChangeAction action) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index be06d1d20e..e9dff81a97 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -326,6 +326,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::SetPiPSettingSwitchStatus); BindNativeFunction(env, exportObj, "UpdateSystemDecorEnable", moduleName, JsSceneSessionManager::UpdateSystemDecorEnable); + BindNativeFunction(env, exportObj, "applyFeatureConfig", moduleName, + JsSceneSessionManager::ApplyFeatureConfig); return NapiGetUndefined(env); } @@ -1455,6 +1457,35 @@ napi_value JsSceneSessionManager::SetSupportFunctionType(napi_env env, napi_call return (me != nullptr) ? me->OnSetSupportFunctionType(env, info) : nullptr; } +napi_value JsSceneSessionManager::ApplyFeatureConfig(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_MAIN, "[NAPI]"); + JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnApplyFeatureConfig(env, info) : nullptr; +} + +napi_value JsSceneSessionManager::OnApplyFeatureConfig(napi_env env, napi_callback_info info) +{ + size_t argc = ARGC_ONE; + napi_value argv[ARGC_ONE] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < ARGC_ONE) { + TLOGE(WmsLogTag::WMS_MAIN, "Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + std::unordered_map configMap; + if (!ConvertStringMapFromJs(env, argv[ARG_INDEX_ZERO], configMap)) { + TLOGE(WmsLogTag::WMS_MAIN, "Failed to convert parameter to configMap"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + SceneSessionManager::GetInstance().ApplyFeatureConfig(configMap); + return NapiGetUndefined(env); +} + bool JsSceneSessionManager::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSessionManager::IsCallbackRegistered[%s]", type.c_str()); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h index bf82225a4b..8e0172a96c 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h @@ -135,6 +135,7 @@ public: static napi_value GetApplicationInfo(napi_env env, napi_callback_info info); static napi_value SetUIEffectControllerAliveInUI(napi_env env, napi_callback_info info); static napi_value SupportCreateFloatWindow(napi_env env, napi_callback_info info); + static napi_value ApplyFeatureConfig(napi_env env, napi_callback_info info); /* * PC Window @@ -257,6 +258,7 @@ private: napi_value OnSupportZLevel(napi_env env, napi_callback_info info); napi_value OnSetSupportFunctionType(napi_env env, napi_callback_info info); napi_value OnUpdateRecentMainSessionInfos(napi_env env, napi_callback_info info); + napi_value OnApplyFeatureConfig(napi_env env, napi_callback_info info); /* * PC Window diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8b4c5cd786..feb38f1c54 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -239,6 +239,7 @@ public: void SetDumpUITreeFunc(const DumpUITreeFunc& func); void SetFindScenePanelRsNodeByZOrderFunc(FindScenePanelRsNodeByZOrderFunc&& func); const AppWindowSceneConfig& GetWindowSceneConfig() const; + void ApplyFeatureConfig(const std::unordered_map& configMap); /* * Window Recover diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 46143f8f5a..b0f0f56f9c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -196,6 +196,10 @@ const std::unordered_set LAYOUT_INFO_WHITELIST = { "SCBStatusBar" }; +const std::unordered_map convertConfigMap = { + {"supportUIExtensionSubWindow", &SystemSessionConfig::ConvertSupportUIExtensionSubWindow}, +}; + const std::chrono::milliseconds WAIT_TIME(3 * 1000); // 3 * 1000 wait for 3s std::string GetCurrentTime() @@ -3743,6 +3747,10 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetSubWindowLevel(parentProperty->GetSubWindowLevel() + 1); + if (WindowHelper::IsSystemWindow(parentSession->GetWindowType()) && property->GetIsUIExtFirstSubWindow() && + systemConfig_.supportUIExtensionSubWindow_) { + property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + } } auto initClientDisplayId = UpdateSpecificSessionClientDisplayId(property); bool shouldBlock = false; @@ -10846,6 +10854,23 @@ static void FillUnreliableWindowInfo(const sptr& sceneSession, TLOGD(WmsLogTag::WMS_MAIN, "wid=%{public}d", info->windowId_); } +void SceneSessionManager::ApplyFeatureConfig(const std::unordered_map& configMap) +{ + auto task = [this, where = __func__, configMap] { + for (const auto& [configName, configValue] : configMap ) { + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s, configEntry is %{public}s: %{public}s", + where, configName.c_str(), configValue.c_str()); + auto convertIter = convertConfigMap.find(configName); + if (convertIter != convertConfigMap.end()) { + auto convertFunc = convertIter->second; + (this->systemConfig_.*convertFunc)(systemConfig_, value); + } + } + return WMError::WM_OK; + }; + taskScheduler_->PostSyncTask(task, "ApplyFeatureConfig"); +} + WMError SceneSessionManager::GetUnreliableWindowInfo(int32_t windowId, std::vector>& infos) { diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index c1776be98d..08762034b3 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -631,6 +631,77 @@ HWTEST_F(SceneSessionManagerTest12, CreateAndConnectSpecificSession03, TestSize. EXPECT_EQ(WSError::WS_DO_NOTHING, res); } +/** + * @tc.name: CreateAndConnectSpecificSession + * @tc.desc: CreateAndConnectSpecificSession + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, CreateAndConnectSpecificSession04, TestSize.Level1) +{ + sptr sessionStage; + sptr eventChannel; + std::shared_ptr node = nullptr; + sptr property = sptr::MakeSptr(); + sptr session; + SystemSessionConfig systemConfig; + sptr token; + int32_t id = 0; + ASSERT_NE(ssm_, nullptr); + + SessionInfo info; + info.abilityName_ = "test1"; + info.bundleName_ = "test2"; + sptr parentSession = sptr::MakeSptr(info, nullptr); + parentSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); + ssm_->sceneSessionMap_.insert({ parentSession->GetPersistentId(), parentSession }); + + // Create UI_EXTENSION_SUB_WINDOW success + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + property->SetParentPersistentId(parentSession->GetPersistentId()); + property->SetIsUIExtFirstSubWindow(true); + ssm_->systemConfig_.supportUIExtensionSubWindow_ = true; + ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, + systemConfig, token); + EXPECT_EQ(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + + // Create UI_EXTENSION_SUB_WINDOW failed + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + ssm_->systemConfig_.supportUIExtensionSubWindow_ = false; + ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, + systemConfig, token); + EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + + // Create UI_EXTENSION_SUB_WINDOW failed + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + property->SetIsUIExtFirstSubWindow(false); + ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, + systemConfig, token); + EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + + // Create UI_EXTENSION_SUB_WINDOW failed + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + parentSession->GetSessionProperty()->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, + systemConfig, token); + EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); +} + +/** + * @tc.name: ApplyFeatureConfig + * @tc.desc: ApplyFeatureConfig + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, ApplyFeatureConfig, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + std::unordered_map configMap = { + {"testKey", "testVal"}, + {"supportUIExtensionSubWindow", "true"} + }; + ssm_->ApplyFeatureConfig(configMap); + EXPECT_TRUE(ssm_->systemConfig_.supportUIExtensionSubWindow_); +} + /** * @tc.name: SetCreateKeyboardSessionListener * @tc.desc: SetCreateKeyboardSessionListener diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 117d76fb87..d94364ef8a 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -663,7 +663,7 @@ WMError WindowSceneSessionImpl::Create(const std::shared_ptrGetWindowName().c_str(), property_->GetPersistentId(), state_, GetWindowMode(), isEnableDefaultDensityWhenCreate_, property_->GetDisplayId()); -- Gitee From 507c6b4f129dbe0f71b5c9f11effc00bbbd8a98a Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Fri, 22 Aug 2025 16:46:19 +0800 Subject: [PATCH 155/241] =?UTF-8?q?CheckSubSessionStartedByExtension?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peng fafu --- .../include/scene_session_manager.h | 6 +- .../src/scene_session_manager.cpp | 63 ++++++++-------- .../test/mock/mock_ability_manager_client.cpp | 4 ++ .../scene_session_manager_extension_test.cpp | 72 ++++++++++++------- 4 files changed, 82 insertions(+), 63 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8b4c5cd786..4efe87cfae 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1117,8 +1117,10 @@ private: * UIExtension */ void DestroyUIServiceExtensionSubWindow(const sptr& sceneSession); - WSError CheckSubSessionStartedByExtensionAndSetDisplayId(const sptr& token, - const sptr& property, const sptr& sessionStage); + WSError CheckSubSessionStartedByExtension(const sptr& token, + const sptr& property); + void SetExtensionSubSessionDisplayId(const sptr& property, + const sptr& sessionStage); void ReportSubWindowCreationFailure(const int32_t& pid, const std::string& abilityName, const std::string& parentBundleName, const std::string& hostBundleName); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 46143f8f5a..ea40ef5173 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3765,10 +3765,11 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { - WSError err = CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage); + WSError err = CheckSubSessionStartedByExtension(token, property); if (err != WSError::WS_OK) { return err; } + SetExtensionSubSessionDisplayId(property, sessionStage); } // WINDOW_TYPE_SYSTEM_ALARM_WINDOW has been deprecated, will be deleted after 5 versions. if (property->GetWindowType() == WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW) { @@ -3844,8 +3845,8 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrPostSyncTask(task, "CreateAndConnectSpecificSession"); } -WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(const sptr& token, - const sptr& property, const sptr& sessionStage) +WSError SceneSessionManager::CheckSubSessionStartedByExtension(const sptr& token, + const sptr& property) { sptr extensionParentSession = GetSceneSession(property->GetParentPersistentId()); if (extensionParentSession == nullptr) { @@ -3855,10 +3856,9 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co } auto pid = IPCSkeleton::GetCallingRealPid(); auto parentPid = extensionParentSession->GetCallingPid(); - WSError result = WSError::WS_ERROR_INVALID_WINDOW; if (pid == parentPid) { // Determine Whether to create a sub window in the same process. TLOGI(WmsLogTag::WMS_UIEXT, "pid == parentPid"); - result = WSError::WS_OK; + return WSError::WS_OK; } AAFwk::UIExtensionSessionInfo info; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info); @@ -3867,41 +3867,36 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co // Check the parent ids are the same in cross-process scenarios. if (parentId == property->GetParentPersistentId()) { TLOGD(WmsLogTag::WMS_UIEXT, "parentId == property->GetParentPersistentId(parentId:%{public}d)", parentId); - result = WSError::WS_OK; + return WSError::WS_OK; } } if (SessionPermission::IsSystemCalling()) { // Fallback strategy. TLOGD(WmsLogTag::WMS_UIEXT, "is system app"); - result = WSError::WS_OK; - } - if (property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { - AAFwk::UIExtensionHostInfo hostInfo; - AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); - const auto& sessionInfo = extensionParentSession->GetSessionInfo(); - auto hostBundleName = extensionParentSession->IsAnco()? - SessionUtils::GetBundleNameBySessionName(hostInfo.sessionName) : hostInfo.elementName_.GetBundleName(); - if (sessionInfo.bundleName_ != hostBundleName && - sessionInfo.bundleName_ != info.hostElementName.GetBundleName()) { - TLOGE(WmsLogTag::WMS_UIEXT, "The hostWindow is not this parentwindow ! parentwindow bundleName: %{public}s," - " hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), hostBundleName.c_str()); - ReportSubWindowCreationFailure(pid, info.elementName.GetAbilityName(), sessionInfo.bundleName_, - hostBundleName); - return WSError::WS_ERROR_INVALID_WINDOW; - } - result = WSError::WS_OK; + return WSError::WS_OK; } - if (result == WSError::WS_OK) { - sptr parentProperty = extensionParentSession->GetSessionProperty(); - if (sessionStage && property->GetIsUIExtFirstSubWindow()) { - sessionStage->UpdateDisplayId(extensionParentSession->GetClientDisplayId() == VIRTUAL_DISPLAY_ID - ? VIRTUAL_DISPLAY_ID - : parentProperty->GetDisplayId()); - property->SetDisplayId(parentProperty->GetDisplayId()); - } - } else { - TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: persistentId %{public}d", property->GetPersistentId()); + + TLOGE(WmsLogTag::WMS_UIEXT, + "can't create sub window: persistentId:%{public}d, parentPersistentId:%{public}d, hostWindowId:%{public}d", + property->GetPersistentId(), property->GetParentPersistentId(), info.hostWindowId); + return WSError::WS_ERROR_INVALID_WINDOW; +} + +void SceneSessionManager::SetExtensionSubSessionDisplayId(const sptr& property, + const sptr& sessionStage) +{ + sptr extensionParentSession = GetSceneSession(property->GetParentPersistentId()); + if (extensionParentSession == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "extensionParentSession is invalid with %{public}d", + property->GetParentPersistentId()); + return; + } + sptr parentProperty = extensionParentSession->GetSessionProperty(); + if (sessionStage && property->GetIsUIExtFirstSubWindow()) { + sessionStage->UpdateDisplayId(extensionParentSession->GetClientDisplayId() == VIRTUAL_DISPLAY_ID + ? VIRTUAL_DISPLAY_ID + : parentProperty->GetDisplayId()); + property->SetDisplayId(parentProperty->GetDisplayId()); } - return result; } void SceneSessionManager::ReportSubWindowCreationFailure(const int32_t& pid, const std::string& abilityName, diff --git a/window_scene/test/mock/mock_ability_manager_client.cpp b/window_scene/test/mock/mock_ability_manager_client.cpp index 49b034207f..ef97c9822d 100644 --- a/window_scene/test/mock/mock_ability_manager_client.cpp +++ b/window_scene/test/mock/mock_ability_manager_client.cpp @@ -36,6 +36,8 @@ void MockAbilityManagerClient::SetUIExtensionSessionInfo(const UIExtensionSessio { g_uiExtensionSessionInfo = std::make_shared(); g_uiExtensionSessionInfo->hostElementName.SetBundleName(sessionInfo.hostElementName.GetBundleName()); + g_uiExtensionSessionInfo->persistentId = sessionInfo.persistentId; + g_uiExtensionSessionInfo->hostWindowId = sessionInfo.hostWindowId; } ErrCode AbilityManagerClient::GetUIExtensionRootHostInfo(const sptr token, @@ -52,6 +54,8 @@ ErrCode AbilityManagerClient::GetUIExtensionSessionInfo(const sptrhostElementName.GetBundleName()); + sessionInfo.persistentId = g_uiExtensionSessionInfo->persistentId; + sessionInfo.hostWindowId = g_uiExtensionSessionInfo->hostWindowId; } 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 41a643c1a5..fc42082f2d 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 @@ -72,69 +72,87 @@ void SceneSessionManagerExtensionTest::TearDown() namespace { /** - * @tc.name: CheckSubSessionStartedByExtensionAndSetDisplayId01 + * @tc.name: SetExtensionSubSessionDisplayId * @tc.desc: normal test * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerExtensionTest, CheckSubSessionStartedByExtensionAndSetDisplayId01, TestSize.Level1) +HWTEST_F(SceneSessionManagerExtensionTest, SetExtensionSubSessionDisplayId, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); SessionInfo info; + info.bundleName_ = BUNDLE_NAME; sptr callback = ssm_->CreateSpecificSessionCallback(); sptr parentSession = sptr::MakeSptr(info, callback); + parentSession->property_->SetPersistentId(1); + parentSession->persistentId_ = 1; ssm_->sceneSessionMap_.insert({ parentSession->GetPersistentId(), parentSession }); sptr token; + constexpr DisplayId displayId = 0; sptr property = sptr::MakeSptr(); sptr sessionStage = sptr::MakeSptr(); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), - WSError::WS_ERROR_NULLPTR); + property->SetParentPersistentId(100000); + property->SetDisplayId(100); + ssm_->SetExtensionSubSessionDisplayId(property, sessionStage); + EXPECT_NE(property->GetDisplayId(), displayId); + property->SetParentPersistentId(parentSession->GetPersistentId()); - constexpr DisplayId displayId = 0; - parentSession->GetSessionProperty()->SetDisplayId(displayId); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, nullptr), WSError::WS_OK); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), WSError::WS_OK); + ssm_->SetExtensionSubSessionDisplayId(property, nullptr); + EXPECT_NE(property->GetDisplayId(), displayId); + + property->SetIsUIExtFirstSubWindow(false); + ssm_->SetExtensionSubSessionDisplayId(property, sessionStage); + EXPECT_NE(property->GetDisplayId(), displayId); + property->SetIsUIExtFirstSubWindow(true); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), WSError::WS_OK); + ssm_->SetExtensionSubSessionDisplayId(property, sessionStage); EXPECT_EQ(property->GetDisplayId(), displayId); } /** - * @tc.name: CheckSubSessionStartedByExtensionAndSetDisplayId02 - * @tc.desc: test compare host bundleName and parent bundleName + * @tc.name: CheckSubSessionStartedByExtension + * @tc.desc: test CheckSubSessionStartedByExtension * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerExtensionTest, CheckSubSessionStartedByExtensionAndSetDisplayId02, TestSize.Level1) +HWTEST_F(SceneSessionManagerExtensionTest, CheckSubSessionStartedByExtension, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); SessionInfo info; info.bundleName_ = BUNDLE_NAME; sptr callback = ssm_->CreateSpecificSessionCallback(); sptr parentSession = sptr::MakeSptr(info, callback); + parentSession->property_->SetPersistentId(1); + parentSession->persistentId_ = 1; ssm_->sceneSessionMap_.insert({ parentSession->GetPersistentId(), parentSession }); sptr token; sptr property = sptr::MakeSptr(); - sptr sessionStage = sptr::MakeSptr(); + property->SetParentPersistentId(100000); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_ERROR_NULLPTR); property->SetParentPersistentId(parentSession->GetPersistentId()); - property->SetIsUIExtensionAbilityProcess(true); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), WSError::WS_OK); - MockUIExtSessionPermission::SetIsStartedByUIExtensionFlag(true); - AAFwk::UIExtensionHostInfo hostInfo; - hostInfo.elementName_.SetBundleName(BUNDLE_NAME); - AAFwk::MockAbilityManagerClient::SetUIExtensionRootHostInfo(hostInfo); + 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)); + AAFwk::UIExtensionSessionInfo extensionSessionInfo; extensionSessionInfo.hostElementName.SetBundleName(BUNDLE_NAME); + extensionSessionInfo.persistentId = property->GetParentPersistentId(); + extensionSessionInfo.hostWindowId = property->GetParentPersistentId(); + AAFwk::MockAbilityManagerClient::SetUIExtensionSessionInfo(extensionSessionInfo); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_OK); + MockUIExtSessionPermission::SetIsSystemCallingFlag(false); + extensionSessionInfo.hostWindowId = property->GetParentPersistentId() + 1; AAFwk::MockAbilityManagerClient::SetUIExtensionSessionInfo(extensionSessionInfo); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), WSError::WS_OK); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_ERROR_INVALID_WINDOW); + extensionSessionInfo.hostWindowId = INVALID_SESSION_ID; + AAFwk::MockAbilityManagerClient::SetUIExtensionSessionInfo(extensionSessionInfo); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_ERROR_INVALID_WINDOW); + extensionSessionInfo.persistentId = INVALID_SESSION_ID; + AAFwk::MockAbilityManagerClient::SetUIExtensionSessionInfo(extensionSessionInfo); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_ERROR_INVALID_WINDOW); - hostInfo.elementName_.SetBundleName(BUNDLE_NAME_TEST); - AAFwk::MockAbilityManagerClient::SetUIExtensionRootHostInfo(hostInfo); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), WSError::WS_OK); + MockUIExtSessionPermission::SetIsSystemCallingFlag(true); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtension(token, property), WSError::WS_OK); - extensionSessionInfo.hostElementName.SetBundleName(BUNDLE_NAME_TEST); - AAFwk::MockAbilityManagerClient::SetUIExtensionSessionInfo(extensionSessionInfo); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), - WSError::WS_ERROR_INVALID_WINDOW); MockUIExtSessionPermission::ClearAllFlag(); AAFwk::MockAbilityManagerClient::ClearAll(); } -- Gitee From c2046f585505c5e58bc9fa9a38b0cc6e8b1e1e8c Mon Sep 17 00:00:00 2001 From: Yyongkang Date: Wed, 20 Aug 2025 20:30:58 +0800 Subject: [PATCH 156/241] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yyongkang --- wm/include/window_session_impl.h | 1 + wm/src/window_adapter.cpp | 14 ++-- wm/src/window_session_impl.cpp | 138 ++++++++++++++++--------------- 3 files changed, 81 insertions(+), 72 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 6f578ce4f9..8c32f95da1 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -803,6 +803,7 @@ protected: bool supportEnterWaterfallMode_ { false }; std::atomic_bool isFullScreenWaterfallMode_ { false }; std::atomic_bool isValidWaterfallMode_ { false }; + bool isFirstNotifyAcrossDisplays_ = true; bool isAcrossDisplays_ = false; WMError NotifyAcrossDisplaysChange(bool isAcrossDisplays); void NotifyWaterfallModeChange(bool isWaterfallMode); diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 7af0715572..43ff070c62 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -1318,30 +1318,30 @@ WMError WindowAdapter::CreateUIEffectController(const sptrCreateUIEffectController(controllerClient, controller, controllerId); } -WMError WindowAdapter::AddSessionBlackList( - const std::unordered_set& bundleNames, const std::unordered_set& privacyWindowTags) +WMError WindowAdapter::GetPiPSettingSwitchStatus(bool& switchStatus) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); auto wmsProxy = GetWindowManagerServiceProxy(); CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); - return wmsProxy->AddSessionBlackList(bundleNames, privacyWindowTags); + return wmsProxy->GetPiPSettingSwitchStatus(switchStatus); } -WMError WindowAdapter::RemoveSessionBlackList( +WMError WindowAdapter::AddSessionBlackList( const std::unordered_set& bundleNames, const std::unordered_set& privacyWindowTags) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); auto wmsProxy = GetWindowManagerServiceProxy(); CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); - return wmsProxy->RemoveSessionBlackList(bundleNames, privacyWindowTags); + return wmsProxy->AddSessionBlackList(bundleNames, privacyWindowTags); } -WMError WindowAdapter::GetPiPSettingSwitchStatus(bool& switchStatus) +WMError WindowAdapter::RemoveSessionBlackList( + const std::unordered_set& bundleNames, const std::unordered_set& privacyWindowTags) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); auto wmsProxy = GetWindowManagerServiceProxy(); CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); - return wmsProxy->GetPiPSettingSwitchStatus(switchStatus); + return wmsProxy->RemoveSessionBlackList(bundleNames, privacyWindowTags); } } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0a62e589d2..82a4bd77cf 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1095,8 +1095,6 @@ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reaso "[name:%{public}s, id:%{public}d], clientDisplayId: %{public}" PRIu64, rect.ToString().c_str(), preRect.ToString().c_str(), wmReason, GetWindowName().c_str(), GetPersistentId(), property_->GetDisplayId()); - TLOGD(WmsLogTag::WMS_LAYOUT, "hasRSTransaction:%{public}d, duration:%{public}d" PRIu64, - config.rsTransaction_ != nullptr, config.animationDuration_); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "WindowSessionImpl::UpdateRect id: %d [%d, %d, %u, %u] reason: %u hasRSTransaction: %u", GetPersistentId(), wmRect.posX_, wmRect.posY_, wmRect.width_, wmRect.height_, wmReason, config.rsTransaction_ != nullptr); @@ -3027,14 +3025,14 @@ std::string WindowSessionImpl::GetContentInfo(BackupAndRestoreType type) WMError WindowSessionImpl::SetRestoredRouterStack(const std::string& routerStack) { - TLOGD(WmsLogTag::WMS_LIFE, "in"); + TLOGD(WmsLogTag::WMS_LIFE, "Set restored router stack."); restoredRouterStack_ = routerStack; return WMError::WM_OK; } std::string WindowSessionImpl::GetRestoredRouterStack() { - TLOGD(WmsLogTag::WMS_LIFE, "in"); + TLOGD(WmsLogTag::WMS_LIFE, "Get restored router stack."); return std::move(restoredRouterStack_); } @@ -4188,7 +4186,7 @@ EnableIfSame(state)); crossAxisState_ = state; AAFwk::Want want; @@ -4261,8 +4259,9 @@ std::vector> WindowSessionImpl::GetWaterfallM WMError WindowSessionImpl::NotifyAcrossDisplaysChange(bool isAcrossDisplays) { - static bool isFirstNotify = true; - if (!isFirstNotify && isAcrossDisplays_ == isAcrossDisplays) { + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId:%{public}u,isFirst:%{public}u,last:%{public}u,curr:%{public}u", + GetWindowId(), isFirstNotifyAcrossDisplays_, isAcrossDisplays_, isAcrossDisplays); + if (!isFirstNotifyAcrossDisplays_ && isAcrossDisplays_ == isAcrossDisplays) { return WMError::WM_DO_NOTHING; } std::lock_guard lock(acrossDisplaysChangeListenerMutex_); @@ -4272,7 +4271,7 @@ WMError WindowSessionImpl::NotifyAcrossDisplaysChange(bool isAcrossDisplays) listener->OnAcrossDisplaysChanged(isAcrossDisplays); } } - isFirstNotify = false; + isFirstNotifyAcrossDisplays_ = false; isAcrossDisplays_ = isAcrossDisplays; return WMError::WM_OK; } @@ -4655,7 +4654,7 @@ CrossAxisState WindowSessionImpl::GetCrossAxisState() if (hostSession->GetCrossAxisState(state) != WSError::WS_OK) { return CrossAxisState::STATE_INVALID; } - TLOGI(WmsLogTag::WMS_LAYOUT, "window id is %{public}d, state is %{public}d", GetPersistentId(), + TLOGI(WmsLogTag::WMS_LAYOUT_PC, "window id is %{public}d, state is %{public}u", GetPersistentId(), static_cast(state)); return state; } @@ -4736,6 +4735,9 @@ WMError WindowSessionImpl::SetWindowContainerModalColor(const std::string& activ if (!SessionPermission::IsSystemCalling()) { return WMError::WM_ERROR_NOT_SYSTEM_APP; } + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } if (!WindowHelper::IsMainWindow(GetType())) { return WMError::WM_ERROR_INVALID_CALLING; } @@ -4920,6 +4922,7 @@ static void RequestInputMethodCloseKeyboard(bool isNeedKeyboard, bool keepKeyboa { if (!isNeedKeyboard && !keepKeyboardFlag) { #ifdef IMF_ENABLE + TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify InputMethod framework close keyboard start."); if (MiscServices::InputMethodController::GetInstance()) { MiscServices::InputMethodController::GetInstance()->RequestHideInput(); TLOGD(WmsLogTag::WMS_KEYBOARD, "Notify InputMethod framework close keyboard end."); @@ -6256,18 +6259,6 @@ bool WindowSessionImpl::FilterKeyEvent(const std::shared_ptr& key return false; } -void WindowSessionImpl::NotifyConsumeResultToFloatWindow - (const std::shared_ptr& keyEvent, bool isConsumed) -{ - if ((keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_TAB || - keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_ENTER) && !GetWatchGestureConsumed() && - keyEvent->GetKeyAction() == MMI::KeyEvent::KEY_ACTION_DOWN) { - TLOGD(WmsLogTag::WMS_EVENT, "wid:%{public}d, keyCode:%{public}d, isConsumed:%{public}d", - GetWindowId(), keyEvent->GetKeyCode(), isConsumed); - NotifyWatchGestureConsumeResult(keyEvent->GetKeyCode(), isConsumed); - } -} - bool WindowSessionImpl::FilterPointerEvent(const std::shared_ptr& pointerEvent) { bool isFiltered = false; @@ -6304,6 +6295,18 @@ bool WindowSessionImpl::FilterPointerEvent(const std::shared_ptr& keyEvent, bool isConsumed) +{ + if ((keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_TAB || + keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_ENTER) && !GetWatchGestureConsumed() && + keyEvent->GetKeyAction() == MMI::KeyEvent::KEY_ACTION_DOWN) { + TLOGD(WmsLogTag::WMS_EVENT, "wid:%{public}u, keyCode:%{public}d, isConsumed:%{public}d", + GetWindowId(), keyEvent->GetKeyCode(), isConsumed); + NotifyWatchGestureConsumeResult(keyEvent->GetKeyCode(), isConsumed); + } +} + WMError WindowSessionImpl::HandleEscKeyEvent(const std::shared_ptr& keyEvent, bool& isConsumed) { if (keyEvent == nullptr) { @@ -6969,7 +6972,7 @@ WSError WindowSessionImpl::NotifyDialogStateChange(bool isForeground) void WindowSessionImpl::UpdatePiPRect(const Rect& rect, WindowSizeChangeReason reason) { if (IsWindowSessionInvalid()) { - WLOGFE("session is invalid"); + TLOGE(WmsLogTag::WMS_PIP, "session is invalid"); return; } auto hostSession = GetHostSession(); @@ -7029,7 +7032,8 @@ WMError WindowSessionImpl::UpdateFloatingBall(const FloatingBallTemplateBaseInfo } if (GetProperty()->GetFbTemplateInfo().template_ != fbTemplateBaseInfo.template_) { - TLOGE(WmsLogTag::WMS_SYSTEM, "Fb template type can't update"); + TLOGE(WmsLogTag::WMS_SYSTEM, "Fb template type can't update %{public}d, %{public}d", + GetProperty()->GetFbTemplateInfo().template_, fbTemplateBaseInfo.template_); return WMError::WM_ERROR_FB_UPDATE_TEMPLATE_TYPE_DENIED; } FloatingBallTemplateInfo fbTemplateInfo = FloatingBallTemplateInfo(fbTemplateBaseInfo, icon); @@ -7135,7 +7139,7 @@ void WindowSessionImpl::NotifyWindowStatusDidChange(WindowMode mode) auto windowStatus = GetWindowStatusInner(mode); auto lastStatus = lastStatusWhenNotifyWindowStatusDidChange_.load(); if (lastStatus == windowStatus) { - TLOGI(WmsLogTag::WMS_LAYOUT, "Duplicate windowStatus:%{public}u, id:%{public}d, windowMode:%{public}u", + TLOGD(WmsLogTag::WMS_LAYOUT, "Duplicate windowStatus:%{public}u, id:%{public}d, windowMode:%{public}u", windowStatus, GetPersistentId(), mode); return; } @@ -7666,6 +7670,10 @@ void WindowSessionImpl::SetCurrentTransform(const Transform& transform) std::lock_guard lock(currentTransformMutex_); currentTransform_ = transform; } + if (handler_ == nullptr) { + TLOGE(WmsLogTag::WMS_COMPAT, "handler is nullptr"); + return; + } handler_->PostTask([weakThis = wptr(this), transform, where = __func__] { auto window = weakThis.promote(); if (window == nullptr) { @@ -7721,15 +7729,15 @@ void WindowSessionImpl::GetExtensionConfig(AAFwk::WantParams& want) const GetRootHostWindowType() : GetType(); want.SetParam(Extension::ROOT_HOST_WINDOW_TYPE_FIELD, AAFwk::Integer::Box(static_cast(rootHostWindowType))); + bool isHostWindowDelayRaiseEnabled = IsWindowDelayRaiseEnabled(); + want.SetParam(Extension::HOST_WINDOW_DELAY_RAISE_STATE_FIELD, + AAFwk::Integer::Box(static_cast(isHostWindowDelayRaiseEnabled))); + SetCompatInfoInExtensionConfig(want); bool gestureBackEnable = true; GetGestureBackEnabled(gestureBackEnable); want.SetParam(Extension::GESTURE_BACK_ENABLED, AAFwk::Integer::Box(static_cast(gestureBackEnable))); want.SetParam(Extension::IMMERSIVE_MODE_ENABLED, AAFwk::Integer::Box(static_cast(GetImmersiveModeEnabledState()))); - bool isHostWindowDelayRaiseEnabled = IsWindowDelayRaiseEnabled(); - want.SetParam(Extension::HOST_WINDOW_DELAY_RAISE_STATE_FIELD, - AAFwk::Integer::Box(static_cast(isHostWindowDelayRaiseEnabled))); - SetCompatInfoInExtensionConfig(want); } WMError WindowSessionImpl::OnExtensionMessage(uint32_t code, int32_t persistentId, const AAFwk::Want& data) @@ -7870,17 +7878,6 @@ void WindowSessionImpl::UpdateSubWindowInfo(uint32_t subWindowLevel, } } -bool WindowSessionImpl::IsSubWindowMaximizeSupported() const -{ - if (!WindowHelper::IsSubWindow(GetType())) { - return false; - } - if (windowOption_ != nullptr) { - return windowOption_->GetSubWindowMaximizeSupported(); - } - return false; -} - bool WindowSessionImpl::IsFullScreenPcAppInPadMode() const { return property_->GetIsPcAppInPad() && GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN @@ -7898,6 +7895,17 @@ void WindowSessionImpl::NotifyClientWindowSize() } } +WSError WindowSessionImpl::SetCurrentRotation(int32_t currentRotation) +{ + TLOGI(WmsLogTag::WMS_ROTATION, "currentRotation: %{public}d", currentRotation); + if (currentRotation > FULL_CIRCLE_DEGREE || currentRotation < ZERO_CIRCLE_DEGREE) { + TLOGE(WmsLogTag::WMS_ROTATION, "currentRotation is invalid: %{public}d", currentRotation); + return WSError::WS_ERROR_INVALID_PARAM; + } + property_->EditSessionInfo().currentRotation_ = currentRotation; + return WSError::WS_OK; +} + WMError WindowSessionImpl::CheckMultiWindowRect(uint32_t& width, uint32_t& height) { const auto& requestRect = GetRequestRect(); @@ -7987,27 +7995,25 @@ void WindowSessionImpl::NotifyRotationChangeResultInner(const RotationChangeInfo }, __func__); } -WSError WindowSessionImpl::SetCurrentRotation(int32_t currentRotation) +bool WindowSessionImpl::IsSubWindowMaximizeSupported() const { - TLOGI(WmsLogTag::WMS_ROTATION, "currentRotation: %{public}d", currentRotation); - if (currentRotation > FULL_CIRCLE_DEGREE || currentRotation < ZERO_CIRCLE_DEGREE) { - TLOGE(WmsLogTag::WMS_ROTATION, "currentRotation is invalid: %{public}d", currentRotation); - return WSError::WS_ERROR_INVALID_PARAM; + if (!WindowHelper::IsSubWindow(GetType())) { + return false; } - property_->EditSessionInfo().currentRotation_ = currentRotation; - return WSError::WS_OK; + if (windowOption_ != nullptr) { + return windowOption_->GetSubWindowMaximizeSupported(); + } + return false; } -nlohmann::json WindowSessionImpl::SetContainerButtonStyle(const DecorButtonStyle& decorButtonStyle) +WMError WindowSessionImpl::SetIntentParam(const std::string& intentParam, + const std::function& loadPageCallback, bool isColdStart) { - nlohmann::json decorJson; - decorJson.emplace(BUTTON_BACKGROUND_CORNER_RADIUS, decorButtonStyle.buttonBackgroundCornerRadius); - decorJson.emplace(BUTTON_BACKGROUND_SIZE, decorButtonStyle.buttonBackgroundSize); - decorJson.emplace(BUTTON_ICON_SIZE, decorButtonStyle.buttonIconSize); - decorJson.emplace(CLOSE_BUTTON_RIGHT_MARGIN, decorButtonStyle.closeButtonRightMargin); - decorJson.emplace(BUTTON_COLOR_MODE, decorButtonStyle.colorMode); - decorJson.emplace(BUTTON_SPACING_BETWEEN, decorButtonStyle.spacingBetweenButtons); - return decorJson; + TLOGI(WmsLogTag::WMS_LIFE, "in"); + intentParam_ = intentParam; + loadPageCallback_ = loadPageCallback; + isIntentColdStart_ = isColdStart; + return WMError::WM_OK; } std::shared_ptr WindowSessionImpl::GetRSUIDirector() const @@ -8027,6 +8033,18 @@ std::shared_ptr WindowSessionImpl::GetRSUIContext() const return rsUIContext; } +nlohmann::json WindowSessionImpl::SetContainerButtonStyle(const DecorButtonStyle& decorButtonStyle) +{ + nlohmann::json decorJson; + decorJson.emplace(BUTTON_BACKGROUND_CORNER_RADIUS, decorButtonStyle.buttonBackgroundCornerRadius); + decorJson.emplace(BUTTON_BACKGROUND_SIZE, decorButtonStyle.buttonBackgroundSize); + decorJson.emplace(BUTTON_ICON_SIZE, decorButtonStyle.buttonIconSize); + decorJson.emplace(CLOSE_BUTTON_RIGHT_MARGIN, decorButtonStyle.closeButtonRightMargin); + decorJson.emplace(BUTTON_COLOR_MODE, decorButtonStyle.colorMode); + decorJson.emplace(BUTTON_SPACING_BETWEEN, decorButtonStyle.spacingBetweenButtons); + return decorJson; +} + bool WindowSessionImpl::IsAnco() const { return property_->GetCollaboratorType() == static_cast(CollaboratorType::RESERVE_TYPE); @@ -8050,16 +8068,6 @@ void WindowSessionImpl::SetNavDestinationInfo(const std::string& navDestinationI navDestinationInfo_ = navDestinationInfo; } -WMError WindowSessionImpl::SetIntentParam(const std::string& intentParam, - const std::function& loadPageCallback, bool isColdStart) -{ - TLOGI(WmsLogTag::WMS_LIFE, "in"); - intentParam_ = intentParam; - loadPageCallback_ = loadPageCallback; - isIntentColdStart_ = isColdStart; - return WMError::WM_OK; -} - WMError WindowSessionImpl::GetPiPSettingSwitchStatus(bool& switchStatus) const { if (IsWindowSessionInvalid()) { -- Gitee From a217dc1029b59fa34ae93b089330bdac437602c3 Mon Sep 17 00:00:00 2001 From: yecong2332 Date: Fri, 22 Aug 2025 16:54:05 +0800 Subject: [PATCH 157/241] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yecong2332 --- .../window_pattern_starting_window_test.cpp | 168 ++++++++++++++++-- 1 file changed, 157 insertions(+), 11 deletions(-) diff --git a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp index 9e44236f61..0b7a77dcba 100644 --- a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp +++ b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp @@ -53,6 +53,7 @@ public: private: void InitTestStartingWindowRdb(); + void CreateSession(SessionInfo sessionInfo, int32_t persistentId); }; sptr WindowPatternStartingWindowTest::ssm_ = nullptr; @@ -86,6 +87,14 @@ void WindowPatternStartingWindowTest::InitTestStartingWindowRdb() ssm_->startingWindowRdbMgr_ = std::make_unique(config); } +void WindowPatternStartingWindowTest::CreateSession(SessionInfo sessionInfo, int32_t persistentId) +{ + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(sceneSession, nullptr); + ssm_->sceneSessionMap_.insert({ persistentId, sceneSession }); + ASSERT_NE(ssm_->GetSceneSession(persistentId), nullptr); +} + namespace { /** * @tc.name: GetStartupPage01 @@ -178,16 +187,17 @@ HWTEST_F(WindowPatternStartingWindowTest, GetStartingWindowInfoFromCache, TestSi sessionInfo.abilityName_ = "abilityName"; sessionInfo.bundleName_ = "bundleName"; StartingWindowInfo startingWindowInfo; - auto res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); - ASSERT_EQ(res, false); - auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_; + bool isDark = false; + auto res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo, isDark); + EXPECT_EQ(res, false); + auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_ + std::to_string(isDark); std::map startingWindowInfoMap{ { key, startingWindowInfo } }; ssm_->startingWindowMap_.insert({ sessionInfo.bundleName_, startingWindowInfoMap }); - res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); - ASSERT_EQ(res, true); + res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo, isDark); + EXPECT_EQ(res, true); sessionInfo.moduleName_ = "invalidModuleName"; - res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); - ASSERT_EQ(res, false); + res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo, isDark); + EXPECT_EQ(res, false); } /** @@ -208,14 +218,15 @@ HWTEST_F(WindowPatternStartingWindowTest, GetStartingWindowInfoFromRdb, TestSize sessionInfo.abilityName_ = itemKey.abilityName = "abilityName"; sessionInfo.bundleName_ = itemKey.bundleName = "bundleName"; itemKey.darkMode = false; - auto res = ssm_->GetStartingWindowInfoFromRdb(sessionInfo, outInfo); + bool isDark = false; + auto res = ssm_->GetStartingWindowInfoFromRdb(sessionInfo, outInfo, isDark); EXPECT_EQ(res, false); bool insertRes = ssm_->startingWindowRdbMgr_->InsertData(itemKey, outInfo); EXPECT_EQ(insertRes, true); - res = ssm_->GetStartingWindowInfoFromRdb(sessionInfo, outInfo); + res = ssm_->GetStartingWindowInfoFromRdb(sessionInfo, outInfo, isDark); EXPECT_EQ(res, true); ssm_->startingWindowRdbMgr_ = nullptr; - res = ssm_->GetStartingWindowInfoFromRdb(sessionInfo, outInfo); + res = ssm_->GetStartingWindowInfoFromRdb(sessionInfo, outInfo, isDark); EXPECT_EQ(res, false); } @@ -511,7 +522,14 @@ HWTEST_F(WindowPatternStartingWindowTest, NotifyPreLoadStartingWindowFinished, T HWTEST_F(WindowPatternStartingWindowTest, GetIsDarkFromConfiguration, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); - bool isDark = ssm_->GetIsDarkFromConfiguration(); + std::string autoColorMode = AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO; + bool isDark = ssm_->GetIsDarkFromConfiguration(autoColorMode); + EXPECT_EQ(false, isDark); + std::string darkColorMode = AppExecFwk::ConfigurationInner::COLOR_MODE_DARK; + isDark = ssm_->GetIsDarkFromConfiguration(darkColorMode); + EXPECT_EQ(true, isDark); + std::string lightColorMode = AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT; + isDark = ssm_->GetIsDarkFromConfiguration(lightColorMode); EXPECT_EQ(false, isDark); } @@ -529,6 +547,134 @@ HWTEST_F(WindowPatternStartingWindowTest, UpdateAllStartingWindowRdb, TestSize.L usleep(WAIT_SLEEP_TIME); EXPECT_TRUE(g_logMsg.find("GetBundleInfosV9 error") != std::string::npos); } + +/** + * @tc.name: UpdateProcessMap + * @tc.desc: UpdateProcessMap + * @tc.type: FUNC + */ +HWTEST_F(WindowPatternStartingWindowTest, UpdateProcessMap, TestSize.Level0) +{ + ASSERT_NE(ssm_, nullptr); + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "bundleName_"; + sessionInfo.moduleName_ = "moduleName_"; + sessionInfo.abilityName_ = "abilityName_"; + sessionInfo.appInstanceKey_ = "instanceKey"; + sessionInfo.appIndex_ = 0; + int32_t persistentId0 = 1; + auto res = ssm_->FindProcessMap(sessionInfo, persistentId0); + EXPECT_EQ(res, WSError::WS_DO_NOTHING); + + ssm_->InsertProcessMap(sessionInfo, persistentId0); + int32_t persistentIdRes; + res = ssm_->FindProcessMap(sessionInfo, persistentIdRes); + EXPECT_EQ(res, WSError::WS_OK); + EXPECT_EQ(persistentIdRes, persistentId0); + int32_t persistentId1 = 2; + ssm_->InsertProcessMap(sessionInfo, persistentId1); + res = ssm_->DeleteProcessMap(sessionInfo, persistentId0); + EXPECT_EQ(res, WSError::WS_OK); + + res = ssm_->FindProcessMap(sessionInfo, persistentIdRes); + EXPECT_EQ(res, WSError::WS_OK); + EXPECT_EQ(persistentIdRes, persistentId1); + + res = ssm_->DeleteProcessMap(sessionInfo, persistentId1); + EXPECT_EQ(res, WSError::WS_OK); +} + +/** + * @tc.name: UpdateProcessMap + * @tc.desc: UpdateProcessMap + * @tc.type: FUNC + */ +HWTEST_F(WindowPatternStartingWindowTest, GetSessionColorMode, TestSize.Level0) +{ + ASSERT_NE(ssm_, nullptr); + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "bundleName_"; + sessionInfo.moduleName_ = "moduleName_"; + sessionInfo.abilityName_ = "abilityName_"; + sessionInfo.appInstanceKey_ = "instanceKey"; + sessionInfo.appIndex_ = 0; + int32_t persistentId = 1000; + + StartingWindowInfo startingWindowInfo; + auto res = ssm_->GetSessionColorMode(sessionInfo, startingWindowInfo); + EXPECT_EQ(res, AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO); + + ssm_->InsertProcessMap(sessionInfo, persistentId); + res = ssm_->GetSessionColorMode(sessionInfo, startingWindowInfo); + EXPECT_EQ(res, AppExecFwk::ConfigurationInner::COLOR_MODE_AUTO); + + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(sceneSession, nullptr); + ssm_->sceneSessionMap_.insert({ persistentId, sceneSession }); + ASSERT_NE(ssm_->GetSceneSession(persistentId), nullptr); + + sceneSession->OnUpdateColorMode(AppExecFwk::ConfigurationInner::COLOR_MODE_DARK, true); + res = ssm_->GetSessionColorMode(sessionInfo, startingWindowInfo); + EXPECT_EQ(res, AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); +} + +/** + * @tc.name: GetOriginalPersistentId + * @tc.desc: GetOriginalPersistentId + * @tc.type: FUNC + */ +HWTEST_F(WindowPatternStartingWindowTest, GetOriginalPersistentId, TestSize.Level0) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->sceneSessionMap_.clear(); + SessionInfo sessionInfo; + int32_t persistentId = 1000; + int32_t callerIdA = 1001; + int32_t callerIdB = 1002; + sessionInfo.callerPersistentId_ = callerIdA; + + std::set sessionSet = { persistentId }; + auto res = ssm_->GetOriginalPersistentId(sessionSet, persistentId); + EXPECT_EQ(res, persistentId); + + CreateSession(sessionInfo, persistentId); + res = ssm_->GetOriginalPersistentId(sessionSet, persistentId); + EXPECT_EQ(res, persistentId); + + SessionInfo callerA; + callerA.callerPersistentId_ = callerIdB; + SessionInfo callerB; + callerB.callerPersistentId_ = callerIdA; + CreateSession(callerA, callerIdA); + CreateSession(callerB, callerIdB); + sessionSet.insert(callerIdA); + sessionSet.insert(callerIdB); + + res = ssm_->GetOriginalPersistentId(sessionSet, persistentId); + EXPECT_EQ(res, callerIdB); +} + +/** + * @tc.name: GetStartWindowColorFollowApp + * @tc.desc: GetStartWindowColorFollowApp + * @tc.type: FUNC + */ +HWTEST_F(WindowPatternStartingWindowTest, GetStartWindowColorFollowApp, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->startingWindowFollowAppSet_.clear(); + SessionInfo sessionInfo; + sessionInfo.moduleName_ = "moduleName"; + sessionInfo.abilityName_ = "abilityName"; + sessionInfo.bundleName_ = "bundleName"; + auto res = ssm_->GetStartWindowColorFollowApp(sessionInfo); + EXPECT_EQ(res, false); + std::string key = sessionInfo.bundleName_ + '_' + sessionInfo.moduleName_ + '_' + sessionInfo.abilityName_; + startingWindowFollowAppSet_.insert(key); + auto res = ssm_->GetStartWindowColorFollowApp(sessionInfo); + ssm_->startingWindowFollowAppSet_.clear(); + EXPECT_EQ(res, true); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 97cfce82982d2e1f990b118d46a7b2aa3a4cd2eb Mon Sep 17 00:00:00 2001 From: qianli22 Date: Fri, 22 Aug 2025 17:28:11 +0800 Subject: [PATCH 158/241] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=9D=E5=A4=96?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qianli22 --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 3228cea316..4be2eb8ef4 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4077,7 +4077,7 @@ void SceneSession::SetKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) WSError SceneSession::SetDragKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) { - TLOGI(WmsLogTag::WMS_LAYOUT_PC, "in"); + TLOGI(WmsLogTag::WMS_LAYOUT, "in"); std::lock_guard lock(keyFrameMutex_); bool running = keyFramePolicy_.running_; bool stopping = keyFramePolicy_.stopping_; -- Gitee From 2856ede8752fd94a8e2a8449408f7c680fb4c55a Mon Sep 17 00:00:00 2001 From: l30067243 Date: Fri, 22 Aug 2025 17:32:53 +0800 Subject: [PATCH 159/241] rollback Signed-off-by: l30067243 --- window_scene/session/host/src/scene_session.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ed1c6d6368..776a3f3eab 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -431,7 +431,6 @@ WSError SceneSession::ForegroundTask(const sptr& property auto leashWinSurfaceNode = session->GetLeashWinSurfaceNode(); if (leashWinSurfaceNode && sessionProperty) { bool lastPrivacyMode = sessionProperty->GetPrivacyMode() || sessionProperty->GetSystemPrivacyMode(); - AutoRSTransaction trans(session->GetRSUIContext()); leashWinSurfaceNode->SetSecurityLayer(lastPrivacyMode); } session->MarkAvoidAreaAsDirty(); -- Gitee From d0f6fd94e3996b458e808fec2bc56653e45e8602 Mon Sep 17 00:00:00 2001 From: chaos Date: Fri, 22 Aug 2025 17:44:11 +0800 Subject: [PATCH 160/241] fix Signed-off-by: chaos --- .../screen_session_manager/src/screen_session_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 411b9742a7..7197a05bec 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1744,7 +1744,6 @@ void ScreenSessionManager::UpdateSuperFoldRefreshRate(sptr screen } } - bool ScreenSessionManager::IsPhysicalScreenAndInUse(sptr screenSession) const { if (!screenSession) { -- Gitee From 925a88380692e3392ba509f716187f5981863313 Mon Sep 17 00:00:00 2001 From: MirMort Date: Fri, 22 Aug 2025 17:47:28 +0800 Subject: [PATCH 161/241] =?UTF-8?q?=E9=80=BB=E8=BE=91=E7=9B=B8=E6=9C=BArot?= =?UTF-8?q?ation=E6=96=B9=E5=90=91=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MirMort --- interfaces/innerkits/dm/dm_common.h | 1 + .../include/screen_session_manager.h | 10 +- .../src/screen_cutout_controller.cpp | 1 + .../src/screen_session_manager.cpp | 214 ++++++++++++++---- .../screen_session_manager_client_proxy.h | 2 + .../src/screen_session_manager_client.cpp | 3 +- .../screen_session_manager_client_proxy.cpp | 47 +++- .../screen_session_manager_client_stub.cpp | 6 + .../session/screen/include/screen_property.h | 2 +- .../session/screen/include/screen_session.h | 16 +- .../session/screen/src/screen_property.cpp | 9 +- .../session/screen/src/screen_session.cpp | 54 ++++- window_scene/test/dms_unittest/BUILD.gn | 2 + .../dms_unittest/screen_property_test.cpp | 30 +++ ...reen_session_manager_client_proxy_test.cpp | 97 ++++++++ ...creen_session_manager_client_stub_test.cpp | 3 + .../screen_session_manager_test2.cpp | 214 +++++++++++++++++- .../test/dms_unittest/screen_session_test.cpp | 63 +++++- 18 files changed, 697 insertions(+), 77 deletions(-) diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index f0ba02b523..1137cadb88 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -708,6 +708,7 @@ struct SessionOption { bool isExtend_; std::string innerName_; ScreenId screenId_; + std::unordered_map rotationCorrectionMap_; }; /** 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 52c4e1629d..9523ae7db9 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -300,7 +300,7 @@ public: void SetIsOuterOnlyMode(bool isOuterOnlyMode); bool GetIsOuterOnlyModeBeforePowerOff(); void SetIsOuterOnlyModeBeforePowerOff(bool isOuterOnlyModeBeforePowerOff); - void OnVerticalChangeBoundsWhenSwitchUser(sptr screenSession); + void OnVerticalChangeBoundsWhenSwitchUser(sptr& screenSession, FoldDisplayMode oldScbDisplayMode); bool SetScreenPower(ScreenPowerStatus status, PowerStateChangeReason reason); void SetScreenPowerForFold(ScreenPowerStatus status); @@ -490,6 +490,8 @@ public: std::shared_ptr GetFfrtQueueHelper() const; bool GetCancelSuspendStatus() const; void RemoveScreenCastInfo(ScreenId screenId); + Rotation GetConfigCorrectionByDisplayMode(FoldDisplayMode displayMode); + Rotation RemoveRotationCorrection(Rotation rotation); protected: ScreenSessionManager(); @@ -857,11 +859,17 @@ private: void SetScreenCastInfo(ScreenId screenId, ScreenId castScreenId, ScreenCombination screenCombination); void ChangeMirrorScreenConfig(const sptr& group, const DMRect& mainScreenRegion, sptr& screen); + void InitRotationCorrectionMap(std::string displayModeCorrectionConfig); + void SwapScreenWeightAndHeight(sptr& screenSession); + Rotation GetOldDisplayModeRotation(FoldDisplayMode oldDisplayMode, Rotation rotation); + void HandleScreenRotationAndBoundsWhenSetClient(sptr& screenSession); LowTempMode lowTemp_ {LowTempMode::UNKNOWN}; std::mutex lowTempMutex_; std::mutex pcModeSwitchMutex_; std::atomic displayGroupNum_ { 1 }; + std::unordered_map rotationCorrectionMap_; + std::shared_mutex rotationCorrectionMutex_; // Fold Screen duringcall bool duringCallState_ = false; 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 f16f2d5cd8..257917ff8f 100644 --- a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp @@ -45,6 +45,7 @@ sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId, uint32_t width, uint32_t height, Rotation rotation) const { + rotation = ScreenSessionManager::GetInstance().RemoveRotationCorrection(rotation); std::vector boundaryRects; GetCutoutArea(displayId, width, height, rotation, boundaryRects); 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 7bfa8bdbe7..e7e76cec40 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -198,6 +198,11 @@ constexpr uint32_t SCREEN_DEFAULT_HEIGHT = 2232; constexpr int32_t SECONDARY_FULL_OFFSET = 1136; constexpr int32_t SECONDARY_FULL_STATUS_WIDTH = 2048; +const bool CORRECTION_ENABLE = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; +const std::string DISPLAYMODE_CORRECTION = system::GetParameter("const.dms.rotation_correction", ""); +constexpr uint32_t EXPECT_DISPLAY_MODE_CORRECTION_SIZE = 2; +constexpr int32_t PARAM_NUM_TEN = 10; + // based on the bundle_util // LCOV_EXCL_START inline int32_t GetUserIdByCallingUid() @@ -880,25 +885,23 @@ void ScreenSessionManager::FreeDisplayMirrorNodeInner(const sptr void ScreenSessionManager::SetScreenCorrection() { + ScreenRotation screenRotation = ScreenRotation::ROTATION_0; std::ostringstream oss; if (g_foldScreenFlag) { if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) { - auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_MAIN, - static_cast(ROTATION_90)); - oss << "main screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret; + screenRotation = static_cast(ROTATION_90); } else { - auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_FULL, - static_cast(g_screenRotationOffSet)); - oss << "full screenRotationOffSet: " << g_screenRotationOffSet << " ret value: " << ret; + screenRotation = static_cast(g_screenRotationOffSet); } } else { std::vector phyOffsets = FoldScreenStateInternel::GetPhyRotationOffset(); int32_t phyOffset = static_cast(std::stoi(phyOffsets[0])); - ScreenRotation correctRotation = ConvertOffsetToCorrectRotation(phyOffset); - auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_DEFAULT, correctRotation); - oss << "phyOffset: " << phyOffset << " correctRotation value: " << - static_cast(correctRotation) << " ret value: " << ret; + screenRotation = ConvertOffsetToCorrectRotation(phyOffset); } + auto rotationOffset = GetConfigCorrectionByDisplayMode(GetFoldDisplayMode()); + auto rotation = (static_cast(screenRotation) + static_cast(rotationOffset)) % ROTATION_MOD; + auto ret = rsInterface_.SetScreenCorrection(SCREEN_ID_DEFAULT, static_cast(rotation)); + oss << "screenRotation: " << static_cast(screenRotation) << " ret value: " << ret; TLOGW(WmsLogTag::DMS, "%{public}s", oss.str().c_str()); screenEventTracker_.RecordEvent(oss.str()); } @@ -1504,6 +1507,8 @@ void ScreenSessionManager::SetLapTopLidOpenStatus(bool isLapTopLidOpen) void ScreenSessionManager::HandleScreenConnectEvent(sptr screenSession, ScreenId screenId, ScreenEvent screenEvent) { + InitRotationCorrectionMap(DISPLAYMODE_CORRECTION); + screenSession->SetRotationCorrectionMap(rotationCorrectionMap_); bool phyMirrorEnable = IsDefaultMirrorMode(screenId); HandlePhysicalMirrorConnect(screenSession, phyMirrorEnable); auto clientProxy = GetClientProxy(); @@ -2738,7 +2743,7 @@ void ScreenSessionManager::InitScreenProperty(ScreenId screenId, RSScreenModeInf property.SetPhyBounds(screenBounds); property.SetBounds(screenBounds); property.SetAvailableArea({0, 0, screenMode.GetScreenWidth(), screenMode.GetScreenHeight()}); - property.SetPhysicalTouchBounds(); + property.SetPhysicalTouchBounds(GetConfigCorrectionByDisplayMode(GetFoldDisplayMode())); property.SetInputOffsetY(); property.SetCurrentOffScreenRendering(false); property.SetScreenRealWidth(property.GetBounds().rect_.GetWidth()); @@ -5853,6 +5858,8 @@ sptr ScreenSessionManager::InitVirtualScreen(ScreenId smsScreenId screenSession->SetRealHeight(option.height_); screenSession->SetScreenAreaWidth(option.width_); screenSession->SetScreenAreaHeight(option.height_); + InitRotationCorrectionMap(DISPLAYMODE_CORRECTION); + screenSession->SetRotationCorrectionMap(rotationCorrectionMap_); return screenSession; } @@ -8111,6 +8118,7 @@ void ScreenSessionManager::RefreshMirrorScreenRegion(ScreenId screenId) void ScreenSessionManager::NotifyDisplayModeChanged(FoldDisplayMode displayMode) { NotifyClientProxyUpdateFoldDisplayMode(displayMode); + SetScreenCorrection(); auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_MODE_CHANGED_LISTENER); TLOGI(WmsLogTag::DMS, "DisplayMode:%{public}d, agent size: %{public}u", displayMode, static_cast(agents.size())); @@ -8400,7 +8408,7 @@ void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector TLOGE(WmsLogTag::DMS, "old mode: %{public}u, cur mode: %{public}u", oldScbDisplayMode_, GetFoldDisplayMode()); if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { screenSession->UpdatePropertyByFoldControl(screenSession->GetScreenProperty()); - OnVerticalChangeBoundsWhenSwitchUser(screenSession); + OnVerticalChangeBoundsWhenSwitchUser(screenSession, oldScbDisplayMode_); screenSession->PropertyChange(screenSession->GetScreenProperty(), FoldDisplayMode::MAIN == GetFoldDisplayMode() ? ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING : ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND); @@ -8433,16 +8441,53 @@ void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector #endif } -void ScreenSessionManager::OnVerticalChangeBoundsWhenSwitchUser(sptr screenSession) +Rotation ScreenSessionManager::GetOldDisplayModeRotation(FoldDisplayMode oldDisplayMode, Rotation rotation) +{ + auto currentDisplayMode = GetFoldDisplayMode(); + if (currentDisplayMode == oldDisplayMode) { + return rotation; + } + auto oldRotationoffset = GetConfigCorrectionByDisplayMode(oldDisplayMode); + auto rotationoffset = GetConfigCorrectionByDisplayMode(GetFoldDisplayMode()); + return static_cast( + (static_cast(rotation) - static_cast(rotationoffset) + + static_cast(oldRotationoffset) + ROTATION_MOD) % ROTATION_MOD); +} + +void ScreenSessionManager::SwapScreenWeightAndHeight(sptr& screenSession) { if (screenSession == nullptr) { TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); return; } - auto rotation = screenSession->GetScreenProperty().GetRotation(); - if (std::fabs(rotation - SECONDARY_ROTATION_90) < FLT_EPSILON || - std::fabs(rotation - SECONDARY_ROTATION_270) < FLT_EPSILON ) { - const RRect& bounds = screenSession->GetScreenProperty().GetBounds(); + RRect bounds = screenSession->GetScreenProperty().GetBounds(); + auto lastWidth = bounds.rect_.GetWidth(); + auto lastHeight = bounds.rect_.GetHeight(); + RRect afterBounds = + RRect({ 0, bounds.rect_.GetTop(), lastHeight, lastWidth}, 0.0f, 0.0f); + screenSession->SetBounds(afterBounds); + TLOGI(WmsLogTag::DMS, "before width:%{public}f, height:%{public}f,after width:%{public}f, height:%{public}f", + lastWidth, lastHeight, afterBounds.rect_.GetWidth(), afterBounds.rect_.GetHeight()); +} + +void ScreenSessionManager::OnVerticalChangeBoundsWhenSwitchUser(sptr& screenSession, + FoldDisplayMode oldScbDisplayMode) +{ + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); + return; + } + auto bounds = screenSession->GetScreenProperty().GetBounds(); + auto rotation = screenSession->GetRotation(); + // set rotation to old displayMode + auto oldRotation = GetOldDisplayModeRotation(oldScbDisplayMode_, screenSession->GetRotation()); + screenSession->SetRotation(oldRotation); + screenSession->SetBounds(bounds); + auto correctionRotation = GetConfigCorrectionByDisplayMode(GetFoldDisplayMode()); + float rotationValue = (static_cast(rotation) - static_cast(correctionRotation) + + ROTATION_MOD) % ROTATION_MOD * SECONDARY_ROTATION_90; + if (std::fabs(rotationValue - SECONDARY_ROTATION_90) < FLT_EPSILON || + std::fabs(rotationValue - SECONDARY_ROTATION_270) < FLT_EPSILON ) { RRect afterBounds = RRect({ 0, bounds.rect_.GetTop(), bounds.rect_.GetHeight(), bounds.rect_.GetWidth()}, 0.0f, 0.0f); screenSession->SetBounds(afterBounds); @@ -8712,39 +8757,12 @@ int32_t ScreenSessionManager::GetCurrentUserId() void ScreenSessionManager::SetClientInner() { std::lock_guard lock(screenSessionMapMutex_); - for (const auto& iter : screenSessionMap_) { + for (auto& iter : screenSessionMap_) { if (!iter.second) { continue; } // In the rotating state, after scb restarts, the screen information needs to be reset. - float phyWidth = 0.0f; - float phyHeight = 0.0f; - bool isReset = true; - int boundaryOffset = 0; - GetCurrentScreenPhyBounds(phyWidth, phyHeight, isReset, iter.first); - auto localRotation = iter.second->GetRotation(); - if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { - FoldDisplayMode displayMode = GetFoldDisplayMode(); - if (displayMode == FoldDisplayMode::FULL) { - boundaryOffset = SECONDARY_FULL_OFFSET; - phyWidth = SECONDARY_FULL_STATUS_WIDTH; - } else if (displayMode == FoldDisplayMode::MAIN) { - phyWidth = MAIN_STATUS_DEFAULT_WIDTH; - phyHeight = SCREEN_DEFAULT_HEIGHT; - } - } - TLOGI(WmsLogTag::DMS, "phyWidth = :%{public}f, phyHeight = :%{public}f, localRotation = :%{public}u", - phyWidth, phyHeight, localRotation); - if (!FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { - bool isModeChanged = localRotation != Rotation::ROTATION_0; - if (isModeChanged && isReset) { - TLOGI(WmsLogTag::DMS, "screen(id:%{public}" PRIu64 ") current is not default mode, reset it", - iter.first); - SetRotation(iter.first, Rotation::ROTATION_0, false); - SetPhysicalRotationClientInner(iter.first, 0); - iter.second->SetDisplayBoundary(RectF(0, boundaryOffset, phyWidth, phyHeight), 0); - } - } + HandleScreenRotationAndBoundsWhenSetClient(iter.second); auto clientProxy = GetClientProxy(); if (!clientProxy) { TLOGE(WmsLogTag::DMS, "clientProxy is null"); @@ -8761,6 +8779,50 @@ void ScreenSessionManager::SetClientInner() } } +void ScreenSessionManager::HandleScreenRotationAndBoundsWhenSetClient(sptr& screenSession) +{ + float phyWidth = 0.0f; + float phyHeight = 0.0f; + bool isReset = true; + int boundaryOffset = 0; + ScreenId screenId = screenSession->GetScreenId(); + GetCurrentScreenPhyBounds(phyWidth, phyHeight, isReset, screenSession->GetScreenId()); + auto localRotation = screenSession->GetRotation(); + if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + FoldDisplayMode displayMode = GetFoldDisplayMode(); + if (displayMode == FoldDisplayMode::FULL) { + boundaryOffset = SECONDARY_FULL_OFFSET; + phyWidth = SECONDARY_FULL_STATUS_WIDTH; + } else if (displayMode == FoldDisplayMode::MAIN) { + phyWidth = MAIN_STATUS_DEFAULT_WIDTH; + phyHeight = SCREEN_DEFAULT_HEIGHT; + } + } + TLOGI(WmsLogTag::DMS, "phyWidth:%{public}f, phyHeight:%{public}f, localRotation:%{public}u", + phyWidth, phyHeight, localRotation); + if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + auto buouds = screenSession->GetScreenProperty().GetBounds(); + screenSession->SetRotation(Rotation::ROTATION_0); + TLOGI(WmsLogTag::DMS, "rotation:%{public}d", screenSession->GetRotation()); + screenSession->SetBounds(buouds); + auto rotationWithoutCorrection = RemoveRotationCorrection(localRotation); + if (rotationWithoutCorrection == Rotation::ROTATION_90 || rotationWithoutCorrection == Rotation::ROTATION_270) + { + SwapScreenWeightAndHeight(screenSession); + } + } else { + if (!FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + bool isModeChanged = localRotation != Rotation::ROTATION_0; + if (isModeChanged && isReset) { + TLOGI(WmsLogTag::DMS, "screen(id:%{public}" PRIu64 ") current is not default mode, reset it", screenId); + SetRotation(screenId, Rotation::ROTATION_0, false); + SetPhysicalRotationClientInner(screenId, 0); + screenSession->SetDisplayBoundary(RectF(0, boundaryOffset, phyWidth, phyHeight), 0); + } + } + } +} + void ScreenSessionManager::SetPhysicalRotationClientInner(ScreenId screenId, int rotation) { sptr screenSession = GetScreenSession(screenId); @@ -10386,6 +10448,7 @@ SessionOption ScreenSessionManager::GetSessionOption(sptr screenS .isExtend_ = screenSession->GetIsExtend(), .innerName_ = screenSession->GetInnerName(), .screenId_ = screenSession->GetScreenId(), + .rotationCorrectionMap_ = screenSession->GetRotationCorrectionMap(), }; return option; } @@ -10398,6 +10461,7 @@ SessionOption ScreenSessionManager::GetSessionOption(sptr screenS .isExtend_ = screenSession->GetIsExtend(), .innerName_ = screenSession->GetInnerName(), .screenId_ = screenId, + .rotationCorrectionMap_ = screenSession->GetRotationCorrectionMap(), }; return option; } @@ -11161,6 +11225,64 @@ bool ScreenSessionManager::SynchronizePowerStatus(ScreenPowerState state) return true; } +Rotation ScreenSessionManager::RemoveRotationCorrection(Rotation rotation) +{ + auto correctionRotation = GetConfigCorrectionByDisplayMode(GetFoldDisplayMode()); + return static_cast((static_cast(rotation) - + static_cast(correctionRotation) + ROTATION_MOD) % ROTATION_MOD); +} + +Rotation ScreenSessionManager::GetConfigCorrectionByDisplayMode(FoldDisplayMode displayMode) +{ + if (!CORRECTION_ENABLE) { + return Rotation::ROTATION_0; + } + InitRotationCorrectionMap(DISPLAYMODE_CORRECTION); + std::shared_lock lock(rotationCorrectionMutex_); + auto iter = rotationCorrectionMap_.find(displayMode); + if (iter == rotationCorrectionMap_.end()) { + return Rotation::ROTATION_0; + } + TLOGI(WmsLogTag::DMS, "offset:%{public}d", iter->second); + return static_cast(iter->second); +} + +void ScreenSessionManager::InitRotationCorrectionMap(std::string displayModeCorrectionConfig) +{ + if (!rotationCorrectionMap_.empty()) { + return; + } + std::unique_lock lock(rotationCorrectionMutex_); + rotationCorrectionMap_.clear(); + std::vector displayModeCorrections = {}; + bool splitSuccess = ScreenSettingHelper::SplitString(displayModeCorrections, displayModeCorrectionConfig, ';'); + if (!splitSuccess) { + TLOGE(WmsLogTag::DMS, "invalid config"); + return; + } + for (std::string displayModeCorrection : displayModeCorrections) { + std::vector corrections = {}; + splitSuccess = ScreenSettingHelper::SplitString(corrections, displayModeCorrection, ','); + uint32_t dataSize = corrections.size(); + if (!splitSuccess || dataSize != EXPECT_DISPLAY_MODE_CORRECTION_SIZE) { + TLOGE(WmsLogTag::DMS, "invalid mode config"); + continue; + } + if (!ScreenSettingHelper::IsNumber(corrections[0]) || + !ScreenSettingHelper::IsNumber(corrections[1])) { + TLOGE(WmsLogTag::DMS, "config not int:%{public}s,%{public}s", + corrections[0].c_str(), corrections[1].c_str()); + continue; + } + auto displayModeValue = + static_cast(strtoll(corrections[0].c_str(), nullptr, PARAM_NUM_TEN)); + auto offset = static_cast(strtoll(corrections[1].c_str(), nullptr, PARAM_NUM_TEN)); + FoldDisplayMode displayMode = static_cast(displayModeValue); + rotationCorrectionMap_.insert({displayMode, offset}); + TLOGI(WmsLogTag::DMS, "rotationCorrectionMap add:%{public}d-%{public}d", displayMode, offset); + } +} + std::shared_ptr ScreenSessionManager::GetPowerTaskScheduler() const { return screenPowerTaskScheduler_; diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h index 285ddf1215..f4794d2d5e 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h @@ -67,6 +67,8 @@ public: void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) override; private: static inline BrokerDelegator delegator_; + bool ScreenConnectWriteParam(SessionOption& SessionOption, + ScreenEvent screenEvent, MessageParcel& data); }; } // namespace OHOS::Rosen 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 3c533debf5..3d1fce0b1a 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 @@ -421,7 +421,7 @@ void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, screenSession->SetScreenComponentRotation(directionInfo.screenRotation_); screenSession->UpdateToInputManager(bounds, directionInfo.notifyRotation_, directionInfo.rotation_, foldDisplayMode); - screenSession->UpdateTouchBoundsAndOffset(); + screenSession->UpdateTouchBoundsAndOffset(foldDisplayMode); TLOGW(WmsLogTag::DMS, "superFoldStatus:%{public}d", currentstate_); if (currentstate_ != SuperFoldStatus::KEYBOARD) { screenSession->SetValidHeight(bounds.rect_.GetHeight()); @@ -1003,6 +1003,7 @@ bool ScreenSessionManagerClient::HandleScreenConnection(SessionOption option) screenSessionMap_[option.screenId_] = screenSession; extraScreenSessionMap_[option.screenId_] = screenSession; } + screenSession->SetRotationCorrectionMap(option.rotationCorrectionMap_); NotifyClientScreenConnect(screenSession); return true; } diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp index b022fa9905..e4e9828387 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp @@ -30,40 +30,63 @@ void ScreenSessionManagerClientProxy::OnScreenConnectionChanged(SessionOption Se MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); + if (!ScreenConnectWriteParam(SessionOption, screenEvent, data)) { + return; + } + if (remote->SendRequest( + static_cast(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CONNECTION_CHANGED), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::DMS, "SendRequest failed"); + return; + } +} + +bool ScreenSessionManagerClientProxy::ScreenConnectWriteParam(SessionOption& SessionOption, + ScreenEvent screenEvent, MessageParcel& data) +{ if (!data.WriteInterfaceToken(GetDescriptor())) { TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); - return; + return false; } if (!data.WriteUint64(SessionOption.rsId_)) { TLOGE(WmsLogTag::DMS, "Write rsId failed"); - return; + return false; } if (!data.WriteString(SessionOption.name_)) { TLOGE(WmsLogTag::DMS, "Write name failed"); - return; + return false; } if (!data.WriteBool(SessionOption.isExtend_)) { TLOGE(WmsLogTag::DMS, "Write isExtended failed"); - return; + return false; } if (!data.WriteString(SessionOption.innerName_)) { TLOGE(WmsLogTag::DMS, "Write innerName failed"); - return; + return false; } if (!data.WriteUint64(SessionOption.screenId_)) { TLOGE(WmsLogTag::DMS, "Write screenId failed"); - return; + return false; } if (!data.WriteUint8(static_cast(screenEvent))) { TLOGE(WmsLogTag::DMS, "Write screenEvent failed"); - return; + return false; } - if (remote->SendRequest( - static_cast(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CONNECTION_CHANGED), - data, reply, option) != ERR_NONE) { - TLOGE(WmsLogTag::DMS, "SendRequest failed"); - return; + if (!data.WriteUint64(static_cast(SessionOption.rotationCorrectionMap_.size()))) { + TLOGE(WmsLogTag::DMS, "Write size failed"); + return false; + } + for (auto& iter : SessionOption.rotationCorrectionMap_) { + if (!data.WriteUint32(static_cast(iter.first))) { + TLOGE(WmsLogTag::DMS, "Write displayMode failed"); + return false; + } + if (!data.WriteUint32(static_cast(iter.second))) { + TLOGE(WmsLogTag::DMS, "Write offset failed"); + return false; + } } + return true; } void ScreenSessionManagerClientProxy::SwitchUserCallback(std::vector oldScbPids, int32_t currentScbPid) diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp index a0fb451bb2..6acead3bc5 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp @@ -195,12 +195,18 @@ int ScreenSessionManagerClientStub::HandleOnScreenConnectionChanged(MessageParce auto innerName = data.ReadString(); auto screenId = static_cast(data.ReadUint64()); auto screenEvent = static_cast(data.ReadUint8()); + auto size = data.ReadUint64(); + std::unordered_map rotationCorrectionMap; + for (uint64_t i = 0; i < size; i++) { + rotationCorrectionMap.insert({static_cast(data.ReadUint32()), data.ReadUint32()}); + } SessionOption option = { .rsId_ = rsId, .name_ = name, .isExtend_ = isExtend, .innerName_ = innerName, .screenId_ = screenId, + .rotationCorrectionMap_ = rotationCorrectionMap }; OnScreenConnectionChanged(option, screenEvent); return ERR_NONE; diff --git a/window_scene/session/screen/include/screen_property.h b/window_scene/session/screen/include/screen_property.h index 5a452a5e0f..0f4ccde8a5 100644 --- a/window_scene/session/screen/include/screen_property.h +++ b/window_scene/session/screen/include/screen_property.h @@ -207,7 +207,7 @@ public: RRect GetPhysicalTouchBounds(); - void SetPhysicalTouchBounds(); + void SetPhysicalTouchBounds(Rotation rotationOffset); int32_t GetInputOffsetX(); diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 0d6c69e02e..dbb4b80795 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -156,10 +156,10 @@ public: void ReleaseDisplayNode(); Rotation CalcRotation(Orientation orientation, FoldDisplayMode foldDisplayMode) const; - DisplayOrientation CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const; - DisplayOrientation CalcDeviceOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const; + DisplayOrientation CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode); + DisplayOrientation CalcDeviceOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode); DisplayOrientation CalcDeviceOrientationWithBounds(Rotation rotation, - FoldDisplayMode foldDisplayMode, const RRect& bounds) const; + FoldDisplayMode foldDisplayMode, const RRect& bounds); void FillScreenInfo(sptr info) const; void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend = false, float positionX = 0, float positionY = 0); @@ -196,7 +196,7 @@ public: bool IsTouchEnabled(); void SetIsPhysicalMirrorSwitch(bool isPhysicalMirrorSwitch); bool GetIsPhysicalMirrorSwitch(); - void UpdateTouchBoundsAndOffset(); + void UpdateTouchBoundsAndOffset(FoldDisplayMode foldDisplayMode); void UpdateToInputManager(RRect bounds, int rotation, int deviceRotation, FoldDisplayMode foldDisplayMode); void UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode); void UpdatePropertyOnly(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode); @@ -358,6 +358,10 @@ public: bool GetIsAvailableAreaNeedNotify() const; uint64_t GetSessionId() const; + void SetRotationCorrectionMap(std::unordered_map& rotationCorrectionMap); + std::unordered_map GetRotationCorrectionMap(); + Rotation GetRotationCorrection(FoldDisplayMode foldDisplayMode); + /* * RS Client Multi Instance */ @@ -436,6 +440,10 @@ private: bool lastCloseHdrStatus_ = false; mutable std::shared_mutex modesMutex_; + void RemoveRotationCorrection(Rotation& rotation, FoldDisplayMode foldDisplayMode); + std::unordered_map rotationCorrectionMap_; + std::shared_mutex rotationCorrectionMutex_; + /* * RS Client Multi Instance */ diff --git a/window_scene/session/screen/src/screen_property.cpp b/window_scene/session/screen/src/screen_property.cpp index 5cea27fc41..8edb52dbf9 100644 --- a/window_scene/session/screen/src/screen_property.cpp +++ b/window_scene/session/screen/src/screen_property.cpp @@ -29,6 +29,7 @@ constexpr int32_t TRUNCATE_TWO_DECIMALS = 100; constexpr int32_t TRUNCATE_THREE_DECIMALS = 1000; constexpr float SECONDARY_ROTATION_90 = 90.0F; constexpr float SECONDARY_ROTATION_270 = 270.0F; +constexpr float SECONDARY_ROTATION_360 = 360.0F; constexpr int32_t SECONDARY_FULL_OFFSETY = 1136; constexpr int32_t FULL_STATUS_WIDTH = 2048; constexpr int32_t SCREEN_HEIGHT = 2232; @@ -617,14 +618,18 @@ RRect ScreenProperty::GetPhysicalTouchBounds() return physicalTouchBounds_; } -void ScreenProperty::SetPhysicalTouchBounds() +void ScreenProperty::SetPhysicalTouchBounds(Rotation rotationOffset) { if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { physicalTouchBounds_.rect_.width_ = bounds_.rect_.width_; physicalTouchBounds_.rect_.height_ = bounds_.rect_.height_; return; } - if (rotation_ == SECONDARY_ROTATION_90 || rotation_ == SECONDARY_ROTATION_270) { + float correctionValue = rotation_ - static_cast(rotationOffset) * SECONDARY_ROTATION_90 + + SECONDARY_ROTATION_360; + float correctionRotation = static_cast(static_cast(correctionValue) % 360); + if (std::fabs(correctionRotation - SECONDARY_ROTATION_90) < FLT_EPSILON || + std::fabs(correctionRotation - SECONDARY_ROTATION_270) < FLT_EPSILON) { physicalTouchBounds_.rect_.width_ = phyBounds_.rect_.width_; physicalTouchBounds_.rect_.height_ = phyBounds_.rect_.height_; } else { diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 029f0ecf61..882119cfab 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -697,7 +697,7 @@ ScreenProperty ScreenSession::UpdatePropertyByFoldControl(const ScreenProperty& property_.SetScreenAreaOffsetY(updatedProperty.GetScreenAreaOffsetY()); property_.SetScreenAreaHeight(updatedProperty.GetScreenAreaHeight()); } - UpdateTouchBoundsAndOffset(); + UpdateTouchBoundsAndOffset(foldDisplayMode); return property_; } @@ -987,9 +987,9 @@ void ScreenSession::SetSecurity(bool isSecurity) isSecurity_ = isSecurity; } -void ScreenSession::UpdateTouchBoundsAndOffset() +void ScreenSession::UpdateTouchBoundsAndOffset(FoldDisplayMode foldDisplayMode) { - property_.SetPhysicalTouchBounds(); + property_.SetPhysicalTouchBounds(GetRotationCorrection(foldDisplayMode)); property_.SetInputOffsetY(); if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { property_.SetValidHeight(property_.GetBounds().rect_.GetHeight()); @@ -1011,7 +1011,7 @@ void ScreenSession::UpdateToInputManager(RRect bounds, int rotation, int deviceR property_.SetRotation(static_cast(rotation)); property_.UpdateScreenRotation(targetRotation); property_.SetDisplayOrientation(displayOrientation); - UpdateTouchBoundsAndOffset(); + UpdateTouchBoundsAndOffset(foldDisplayMode); Rotation targetDeviceRotation = ConvertIntToRotation(deviceRotation); auto deviceOrientation = CalcDeviceOrientationWithBounds(targetDeviceRotation, foldDisplayMode, bounds); property_.UpdateDeviceRotation(targetDeviceRotation); @@ -1049,7 +1049,7 @@ void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, Fold property_.SetValidHeight(bounds.rect_.GetHeight()); property_.SetValidWidth(bounds.rect_.GetWidth()); } - UpdateTouchBoundsAndOffset(); + UpdateTouchBoundsAndOffset(foldDisplayMode); { std::shared_lock displayNodeLock(displayNodeMutex_); if (!displayNode_) { @@ -1351,8 +1351,9 @@ Rotation ScreenSession::CalcRotation(Orientation orientation, FoldDisplayMode fo } DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation, - FoldDisplayMode foldDisplayMode) const + FoldDisplayMode foldDisplayMode) { + RemoveRotationCorrection(rotation, foldDisplayMode); // vertical: phone(Plugin screen); horizontal: pad & external screen bool isVerticalScreen = property_.GetPhyWidth() < property_.GetPhyHeight(); if (g_screenScanType == SCAN_TYPE_VERTICAL) { @@ -1392,8 +1393,9 @@ DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation, } DisplayOrientation ScreenSession::CalcDeviceOrientation(Rotation rotation, - FoldDisplayMode foldDisplayMode) const + FoldDisplayMode foldDisplayMode) { + RemoveRotationCorrection(rotation, foldDisplayMode); if (foldDisplayMode == FoldDisplayMode::GLOBAL_FULL) { uint32_t temp = (static_cast(rotation) + SECONDARY_ROTATION_270) % SECONDARY_ROTATION_MOD; rotation = static_cast(temp); @@ -1424,8 +1426,9 @@ DisplayOrientation ScreenSession::CalcDeviceOrientation(Rotation rotation, } DisplayOrientation ScreenSession::CalcDeviceOrientationWithBounds(Rotation rotation, - FoldDisplayMode foldDisplayMode, const RRect& bounds) const + FoldDisplayMode foldDisplayMode, const RRect& bounds) { + RemoveRotationCorrection(rotation, foldDisplayMode); if (foldDisplayMode == FoldDisplayMode::GLOBAL_FULL) { uint32_t temp = (static_cast(rotation) + SECONDARY_ROTATION_270) % SECONDARY_ROTATION_MOD; rotation = static_cast(temp); @@ -2637,6 +2640,41 @@ std::shared_ptr ScreenSession::GetRSUIContext() const return rsUIContext; } +Rotation ScreenSession::GetRotationCorrection(FoldDisplayMode displayMode) +{ + auto rotationCorrectionMap = GetRotationCorrectionMap(); + int32_t rotationOffset = 0; + auto iter = rotationCorrectionMap.find(displayMode); + if (iter != rotationCorrectionMap.end()) { + rotationOffset = iter->second; + } + return static_cast(rotationOffset); +} + +void ScreenSession::RemoveRotationCorrection(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) % SECONDARY_ROTATION_MOD; + rotation = static_cast(rotationValue); + TLOGI(WmsLogTag::DMS, "rotation:%{public}u, rotationOffset:%{public}u", rotation, rotationOffset); +} + +void ScreenSession::SetRotationCorrectionMap(std::unordered_map& rotationCorrectionMap) +{ + std::unique_lock lock(rotationCorrectionMutex_); + rotationCorrectionMap_ = rotationCorrectionMap; +} + +std::unordered_map ScreenSession::GetRotationCorrectionMap() +{ + std::shared_lock lock(rotationCorrectionMutex_); + return rotationCorrectionMap_; +} + void ScreenSession::SetIsEnableCanvasRotation(bool isEnableCanvasRotation) { std::lock_guard lock(isEnableCanvasRotationMutex_); diff --git a/window_scene/test/dms_unittest/BUILD.gn b/window_scene/test/dms_unittest/BUILD.gn index 17347a04a6..cf98ce10e0 100644 --- a/window_scene/test/dms_unittest/BUILD.gn +++ b/window_scene/test/dms_unittest/BUILD.gn @@ -410,6 +410,8 @@ ohos_unittest("ws_screen_session_manager_client_proxy_test") { "screen_session_manager_client_proxy_test.cpp" ] + include_dirs = [ "../mock" ] + deps = [ ":ws_unittest_common" ] external_deps = test_external_deps } diff --git a/window_scene/test/dms_unittest/screen_property_test.cpp b/window_scene/test/dms_unittest/screen_property_test.cpp index 51e9488c6b..ca424ce58f 100644 --- a/window_scene/test/dms_unittest/screen_property_test.cpp +++ b/window_scene/test/dms_unittest/screen_property_test.cpp @@ -15,6 +15,7 @@ #include "screen_property.h" #include +#include "fold_screen_state_internel.h" // using namespace FRAME_TRACE; using namespace testing; @@ -940,6 +941,35 @@ HWTEST_F(ScreenPropertyTest, SetRotationAndScreenRotationOnly, Function | SmallT ASSERT_EQ(property->GetScreenRotation(), Rotation::ROTATION_270); GTEST_LOG_(INFO) << "ScreenPropertyTest: SetRotationAndScreenRotationOnly end"; } + +/** + * @tc.name: SetPhysicalTouchBounds + * @tc.desc: SetPhysicalTouchBounds + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, SetPhysicalTouchBounds, TestSize.Level1) +{ + if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + GTEST_SKIP(); + } + std::shared_ptr property = std::make_shared(); + property->physicalTouchBounds_.rect_.width_ = 100; + property->physicalTouchBounds_.rect_.height_ = 200; + property->rotation_ = 0.0f; + property->SetPhysicalTouchBounds(Rotation::ROTATION_0); + EXPECT_EQ(property->physicalTouchBounds_.rect_.width_, 200); + EXPECT_EQ(property->physicalTouchBounds_.rect_.height_, 100); + + property->rotation_ = 90.0f; + property->SetPhysicalTouchBounds(Rotation::ROTATION_0); + EXPECT_EQ(property->physicalTouchBounds_.rect_.width_, 100); + EXPECT_EQ(property->physicalTouchBounds_.rect_.height_, 200); + + property->rotation_ = 270.0f; + property->SetPhysicalTouchBounds(Rotation::ROTATION_0); + EXPECT_EQ(property->physicalTouchBounds_.rect_.width_, 100); + EXPECT_EQ(property->physicalTouchBounds_.rect_.height_, 200); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp index e30a32e42d..52752ddad1 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp @@ -18,6 +18,7 @@ #include "iremote_object_mocker.h" #include "mock/mock_message_parcel.h" #include "zidl/screen_session_manager_client_proxy.h" +#include "window_manager_hilog.h" using namespace testing; using namespace testing::ext; @@ -27,6 +28,14 @@ namespace Rosen { namespace { constexpr uint32_t SLEEP_TIME_IN_US = 100000; // 100ms } +namespace { + std::string logMsg; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char* tag, + const char* msg) + { + logMsg += msg; + } +} class ScreenSessionManagerClientProxyTest : public testing::Test { public: static void SetUpTestCase(); @@ -469,5 +478,93 @@ HWTEST_F(ScreenSessionManagerClientProxyTest, OnVirtualScreenDisconnected, TestS ssmProxy->OnVirtualScreenDisconnected(displayId); MockMessageParcel::ClearAllErrorFlag(); } + +/** + * @tc.name: OnScreenConnectionChangedMock + * @tc.desc: OnScreenConnectionChangedMock + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientProxyTest, OnScreenConnectionChangedMock, TestSize.Level1) +{ + ASSERT_TRUE(screenSessionManagerClientProxy_ != nullptr); + ScreenEvent screenEvent = ScreenEvent::CONNECTED; + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + SessionOption option = { + .rsId_ = 0, + .isExtend_ = false, + .screenId_ = 0, + .rotationCorrectionMap_ = rotationCorrectionMap, + }; + logMsg.clear(); + LOG_SetCallback(MyLogCallback); + // remote == nullptr + auto proxy = sptr::MakeSptr(nullptr); + proxy->OnScreenConnectionChanged(option, screenEvent); + // SendRequest failed + sptr remoteMocker = sptr::MakeSptr(); + proxy = sptr::MakeSptr(remoteMocker); + ASSERT_NE(proxy, nullptr); + remoteMocker->SetRequestResult(ERR_INVALID_DATA); + ret = proxy->OnScreenConnectionChanged(option, screenEvent); + remoteMocker->SetRequestResult(ERR_NONE); + // Pass all + ret = proxy->OnScreenConnectionChanged(option, screenEvent); + // write param failed + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + screenSessionManagerClientProxy_->OnScreenConnectionChanged(option, screenEvent); + EXPECT_TRUE(logMsg.find("WriteInterfaceToken failed") != std::string::npos); + logMsg.clear(); + MockMessageParcel::ClearAllErrorFlag(); +} + +/** + * @tc.name: ScreenConnectWriteParam + * @tc.desc: ScreenConnectWriteParam + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientProxyTest, ScreenConnectWriteParam, TestSize.Level1) +{ + MessageParcel data; + ScreenEvent screenEvent = ScreenEvent::CONNECTED; + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + SessionOption option = { + .rsId_ = 0, + .isExtend_ = false, + .screenId_ = 0, + .rotationCorrectionMap_ = rotationCorrectionMap + }; + sptr remoteMocker = sptr::MakeSptr(); + auto proxy = sptr::MakeSptr(remoteMocker); + + bool ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); + EXPECT_TRUE(ret); + + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); + EXPECT_FALSE(ret); + + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteUint64ErrorFlag(true); + ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); + EXPECT_FALSE(ret); + + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteStringErrorFlag(true); + ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); + EXPECT_FALSE(ret); + + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteBoolErrorFlag(true); + ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); + EXPECT_FALSE(ret); + + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteUint32ErrorFlag(true); + ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); + EXPECT_FALSE(ret); +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp index c4c9fded40..fda7e3442f 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp @@ -523,6 +523,9 @@ HWTEST_F(ScreenSessionManagerClientStubTest, HandleOnScreenConnectionChanged, Te std::string name; data.WriteString(name); data.WriteBool(false); + data.WriteUint64(1); + data.WriteUint32(1); + data.WriteUint32(2); int ret = screenSessionManagerClientStub_->HandleOnScreenConnectionChanged(data, reply); EXPECT_EQ(ret, 0); } 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 7df2ae9d6b..c80ce196fa 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -1047,7 +1047,7 @@ HWTEST_F(ScreenSessionManagerTest, OnVerticalChangeBoundsWhenSwitchUser, TestSiz constexpr float SECONDARY_ROTATION_90 = 90.0F; screenProperty.SetRotation(SECONDARY_ROTATION_90); RRect bounds = screenProperty.GetBounds(); - ssm_->OnVerticalChangeBoundsWhenSwitchUser(screenSession); + ssm_->OnVerticalChangeBoundsWhenSwitchUser(screenSession, FoldDisplayMode::UNKNOWN); RRect afterbounds = screenProperty.GetBounds(); EXPECT_EQ(bounds.rect_.GetHeight(), bounds.rect_.GetWidth()); } @@ -1544,6 +1544,218 @@ HWTEST_F(ScreenSessionManagerTest, SetDefaultScreenModeWhenCreateMirror, TestSiz #undef FOLD_ABILITY_ENABLE } +/** + * @tc.name: GetOldDisplayModeRotation + * @tc.desc: GetOldDisplayModeRotation + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetOldDisplayModeRotation, TestSize.Level1) +{ + bool CORRECTION_ENABLE = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; + auto foldController = sptr::MakeSptr(ssm_->displayInfoMutex_, + ssm_->screenPowerTaskScheduler_); + ASSERT_NE(foldController, nullptr); + DisplayPhysicalResolution physicalSize_full; + physicalSize_full.foldDisplayMode_ = FoldDisplayMode::FULL; + physicalSize_full.physicalWidth_ = 2048; + physicalSize_full.physicalHeight_ = 2232; + DisplayPhysicalResolution physicalSize_main; + physicalSize_main.foldDisplayMode_ = FoldDisplayMode::MAIN; + physicalSize_main.physicalWidth_ = 1008; + physicalSize_main.physicalHeight_ = 2232; + DisplayPhysicalResolution physicalSize_global_full; + physicalSize_global_full.foldDisplayMode_ = FoldDisplayMode::GLOBAL_FULL; + physicalSize_global_full.physicalWidth_ = 3184; + physicalSize_global_full.physicalHeight_ = 2232; + ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_full); + ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_main); + ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_global_full); + auto foldPolicy = foldController->GetFoldScreenPolicy(DisplayDeviceType::SECONDARY_DISPLAY_DEVICE); + ASSERT_NE(foldPolicy, nullptr); + foldPolicy->lastDisplayMode_ = FoldDisplayMode::MAIN; + foldController->foldScreenPolicy_ = foldPolicy; + ssm_->foldScreenController_ = foldController; + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::GLOBAL_FULL, 3}); + ssm_->rotationCorrectionMap_ = rotationCorrectionMap; + Rotation rotation = ssm_->GetOldDisplayModeRotation(FoldDisplayMode::MAIN, Rotation::ROTATION_0); + EXPECT_EQ(rotation, Rotation::ROTATION_0); + rotation = ssm_->GetOldDisplayModeRotation(FoldDisplayMode::GLOBAL_FULL, Rotation::ROTATION_0); + if (CORRECTION_ENABLE) { + EXPECT_EQ(rotation, Rotation::ROTATION_90); + } else { + EXPECT_EQ(rotation, Rotation::ROTATION_0); + } +} + +/** + * @tc.name: SwapScreenWeightAndHeight + * @tc.desc: SwapScreenWeightAndHeight + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SwapScreenWeightAndHeight, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + sptr screenSession = nullptr; + ssm_->SwapScreenWeightAndHeight(screenSession); + EXPECT_TRUE(g_errLog.find("screenSession is null") != std::string::npos); + screenSession = sptr::MakeSptr(); + ScreenProperty property; + RRect bounds; + bounds.rect_.width_ = 100; + bounds.rect_.height_ = 200; + property.SetBounds(bounds); + screenSession->SetScreenProperty(property); + ssm_->SwapScreenWeightAndHeight(screenSession); + auto afterBounds = screenSession->GetScreenProperty().GetBounds(); + EXPECT_EQ(afterBounds.rect_.width_, bounds.rect_.height_); + EXPECT_EQ(afterBounds.rect_.height_, bounds.rect_.width_); + g_errLog.clear(); +} + +/** + * @tc.name: HandleScreenRotationAndBoundsWhenSetClient + * @tc.desc: HandleScreenRotationAndBoundsWhenSetClient + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, HandleScreenRotationAndBoundsWhenSetClient, TestSize.Level1) +{ + auto foldController = sptr::MakeSptr(ssm_->displayInfoMutex_, + ssm_->screenPowerTaskScheduler_); + ASSERT_NE(foldController, nullptr); + DisplayPhysicalResolution physicalSize_full; + physicalSize_full.foldDisplayMode_ = FoldDisplayMode::FULL; + physicalSize_full.physicalWidth_ = 2048; + physicalSize_full.physicalHeight_ = 2232; + DisplayPhysicalResolution physicalSize_main; + physicalSize_main.foldDisplayMode_ = FoldDisplayMode::MAIN; + physicalSize_main.physicalWidth_ = 1008; + physicalSize_main.physicalHeight_ = 2232; + DisplayPhysicalResolution physicalSize_global_full; + physicalSize_global_full.foldDisplayMode_ = FoldDisplayMode::GLOBAL_FULL; + physicalSize_global_full.physicalWidth_ = 3184; + physicalSize_global_full.physicalHeight_ = 2232; + ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_full); + ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_main); + ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_global_full); + auto foldPolicy = foldController->GetFoldScreenPolicy(DisplayDeviceType::SECONDARY_DISPLAY_DEVICE); + ASSERT_NE(foldPolicy, nullptr); + foldPolicy->lastDisplayMode_ = FoldDisplayMode::GLOBAL_FULL; + foldController->foldScreenPolicy_ = foldPolicy; + ssm_->foldScreenController_ = foldController; + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::GLOBAL_FULL, 3}); + ssm_->rotationCorrectionMap_ = rotationCorrectionMap; + ScreenId id = 123; + sptr screenSession = sptr::MakeSptr(id, ScreenProperty(), 0); + if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + screenSession->SetRotation(Rotation::ROTATION_0); + ssm_->HandleScreenRotationAndBoundsWhenSetClient(screenSession); + EXPECT_EQ(screenSession->GetRotation(), Rotation::ROTATION_0); + screenSession->SetRotation(Rotation::ROTATION_180); + ssm_->HandleScreenRotationAndBoundsWhenSetClient(screenSession); + EXPECT_EQ(screenSession->GetRotation(), Rotation::ROTATION_0); + screenSession->SetRotation(Rotation::ROTATION_270); + ssm_->HandleScreenRotationAndBoundsWhenSetClient(screenSession); + EXPECT_EQ(screenSession->GetRotation(), Rotation::ROTATION_0); + } else { + screenSession->SetRotation(Rotation::ROTATION_270); + ssm_->HandleScreenRotationAndBoundsWhenSetClient(screenSession); + EXPECT_EQ(screenSession->GetRotation(), Rotation::ROTATION_270); + screenSession->SetRotation(Rotation::ROTATION_270); + foldPolicy->lastDisplayMode_ = FoldDisplayMode::UNKNOWN; + ssm_->HandleScreenRotationAndBoundsWhenSetClient(screenSession); + EXPECT_EQ(screenSession->GetRotation(), Rotation::ROTATION_270); + screenSession->SetRotation(Rotation::ROTATION_0); + ssm_->HandleScreenRotationAndBoundsWhenSetClient(screenSession); + EXPECT_EQ(screenSession->GetRotation(), Rotation::ROTATION_0); + } +} + +/** + * @tc.name: RemoveRotationCorrection + * @tc.desc: RemoveRotationCorrection + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, RemoveRotationCorrection, TestSize.Level1) +{ + auto afterRotation = ssm_->RemoveRotationCorrection(Rotation::ROTATION_270); + EXPECT_EQ(afterRotation, Rotation::ROTATION_270); +} + +/** + * @tc.name: GetConfigCorrectionByDisplayMode + * @tc.desc: GetConfigCorrectionByDisplayMode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetConfigCorrectionByDisplayMode, TestSize.Level1) +{ + ssm_->rotationCorrectionMap_.clear(); + bool correctionEnable = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; + if (correctionEnable) { + auto rotation = ssm_->GetConfigCorrectionByDisplayMode(FoldDisplayMode::MAIN); + EXPECT_EQ(rotation, Rotation::ROTATION_0); + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + ssm_->rotationCorrectionMap_ = rotationCorrectionMap; + rotation = ssm_->GetConfigCorrectionByDisplayMode(FoldDisplayMode::MAIN); + EXPECT_EQ(rotation, Rotation::ROTATION_270); + + } else { + auto rotation = ssm_->GetConfigCorrectionByDisplayMode(FoldDisplayMode::MAIN); + EXPECT_EQ(rotation, Rotation::ROTATION_0); + } +} + +/** + * @tc.name: InitRotationCorrectionMap + * @tc.desc: rotationCorrectionMap not null + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, InitRotationCorrectionMap01, TestSize.Level1) +{ + ssm_->rotationCorrectionMap_.clear(); + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + ssm_->rotationCorrectionMap_ = rotationCorrectionMap; + ssm_->InitRotationCorrectionMap(""); + EXPECT_TRUE(ssm_->rotationCorrectionMap_.find(FoldDisplayMode::MAIN) != ssm_->rotationCorrectionMap_.end()); + ssm_->rotationCorrectionMap_.clear(); + std::string config = "1,0;2,0;5,3;"; + ssm_->InitRotationCorrectionMap(config); + EXPECT_EQ(ssm_->rotationCorrectionMap_[FoldDisplayMode::GLOBAL_FULL], 3); +} + +/** + * @tc.name: InitRotationCorrectionMap + * @tc.desc: split failed + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, InitRotationCorrectionMap02, TestSize.Level1) +{ + ssm_->rotationCorrectionMap_.clear(); + ssm_->InitRotationCorrectionMap(""); + EXPECT_TRUE(ssm_->rotationCorrectionMap_.empty()); + ssm_->rotationCorrectionMap_.clear(); + std::string config = ";;"; + ssm_->InitRotationCorrectionMap(config); + EXPECT_TRUE(ssm_->rotationCorrectionMap_.empty()); +} + +/** + * @tc.name: InitRotationCorrectionMap + * @tc.desc: InitRotationCorrectionMap + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, InitRotationCorrectionMap03, TestSize.Level1) +{ + ssm_->rotationCorrectionMap_.clear(); + std::string config = "1,0,1;1,0;2,0;5,3;3,a;a,a"; + ssm_->InitRotationCorrectionMap(config); + EXPECT_EQ(ssm_->rotationCorrectionMap_[FoldDisplayMode::GLOBAL_FULL], 3); +} + /** * @tc.name: RecoverDefaultScreenModeInner * @tc.desc: RecoverDefaultScreenModeInner diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 9d96691c34..6b0e0289e8 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -3900,7 +3900,7 @@ HWTEST_F(ScreenSessionTest, UpdateTouchBoundsAndOffset, TestSize.Level1) ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); ASSERT_NE(screenSession, nullptr); - screenSession->UpdateTouchBoundsAndOffset(); + screenSession->UpdateTouchBoundsAndOffset(FoldDisplayMode::UNKNOWN); EXPECT_EQ(0, screenSession->property_.GetInputOffsetY()); GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateTouchBoundsAndOffset end"; } @@ -4516,6 +4516,67 @@ HWTEST_F(ScreenSessionTest, FreezeScreen, TestSize.Level2) g_errLog.clear(); } +/** + * @tc.name: GetRotationCorrection + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, GetRotationCorrection, TestSize.Level1) +{ + sptr session = sptr::MakeSptr(); + ASSERT_NE(session, nullptr); + Rotation rotation = session->GetRotationCorrection(FoldDisplayMode::MAIN); + EXPECT_EQ(rotation, Rotation::ROTATION_0); + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + session->SetRotationCorrectionMap(rotationCorrectionMap); + rotation = session->GetRotationCorrection(FoldDisplayMode::MAIN); + EXPECT_EQ(rotation, Rotation::ROTATION_270); + rotation = session->GetRotationCorrection(FoldDisplayMode::FULL); + EXPECT_EQ(rotation, Rotation::ROTATION_0); +} + +/** + * @tc.name: RemoveRotationCorrection + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, RemoveRotationCorrection, TestSize.Level1) +{ + sptr session = sptr::MakeSptr(); + ASSERT_NE(session, nullptr); + Rotation rotation = Rotation::ROTATION_270; + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + session->SetRotationCorrectionMap(rotationCorrectionMap); + session->RemoveRotationCorrection(rotation, FoldDisplayMode::MAIN); + EXPECT_EQ(rotation, Rotation::ROTATION_0); + + rotation = Rotation::ROTATION_270; + session->RemoveRotationCorrection(rotation, FoldDisplayMode::FULL); + EXPECT_EQ(rotation, Rotation::ROTATION_270); + + rotation = static_cast(100); + session->RemoveRotationCorrection(rotation, FoldDisplayMode::FULL); + EXPECT_EQ(rotation, rotation); +} + +/** + * @tc.name: SetRotationCorrectionMap + * @tc.desc: test set and get + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetRotationCorrectionMap, TestSize.Level1) +{ + sptr session = sptr::MakeSptr(); + ASSERT_NE(session, nullptr); + std::unordered_map rotationCorrectionMap; + rotationCorrectionMap.insert({FoldDisplayMode::MAIN, 3}); + session->SetRotationCorrectionMap(rotationCorrectionMap); + auto correctionMap = session->GetRotationCorrectionMap(); + EXPECT_EQ(correctionMap[FoldDisplayMode::MAIN], 3); +} + /** * @tc.name: GetScreenSnapshotWithAllWindows01 * @tc.desc: GetScreenSnapshotWithAllWindows01 Test -- Gitee From c9ccbe436155465a0debcd0a54d7c260b7a334af Mon Sep 17 00:00:00 2001 From: MirMort Date: Fri, 22 Aug 2025 17:48:55 +0800 Subject: [PATCH 162/241] add Signed-off-by: MirMort --- .../dms_unittest/screen_session_manager_client_proxy_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp index 52752ddad1..70fffeb01a 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp @@ -506,7 +506,7 @@ HWTEST_F(ScreenSessionManagerClientProxyTest, OnScreenConnectionChangedMock, Tes proxy = sptr::MakeSptr(remoteMocker); ASSERT_NE(proxy, nullptr); remoteMocker->SetRequestResult(ERR_INVALID_DATA); - ret = proxy->OnScreenConnectionChanged(option, screenEvent); + bool ret = proxy->OnScreenConnectionChanged(option, screenEvent); remoteMocker->SetRequestResult(ERR_NONE); // Pass all ret = proxy->OnScreenConnectionChanged(option, screenEvent); -- Gitee From 4ea1b419fb1e7350aa5cb120e191a2aaf80967dd Mon Sep 17 00:00:00 2001 From: MirMort Date: Fri, 22 Aug 2025 17:51:06 +0800 Subject: [PATCH 163/241] add Signed-off-by: MirMort --- .../dms_unittest/screen_session_manager_client_proxy_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp index 70fffeb01a..11b168d6a1 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp @@ -506,10 +506,10 @@ HWTEST_F(ScreenSessionManagerClientProxyTest, OnScreenConnectionChangedMock, Tes proxy = sptr::MakeSptr(remoteMocker); ASSERT_NE(proxy, nullptr); remoteMocker->SetRequestResult(ERR_INVALID_DATA); - bool ret = proxy->OnScreenConnectionChanged(option, screenEvent); + proxy->OnScreenConnectionChanged(option, screenEvent); remoteMocker->SetRequestResult(ERR_NONE); // Pass all - ret = proxy->OnScreenConnectionChanged(option, screenEvent); + proxy->OnScreenConnectionChanged(option, screenEvent); // write param failed MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); screenSessionManagerClientProxy_->OnScreenConnectionChanged(option, screenEvent); -- Gitee From 74991d3e0ea5b75270dd6a7ab45da560aa99c143 Mon Sep 17 00:00:00 2001 From: MirMort Date: Fri, 22 Aug 2025 18:06:58 +0800 Subject: [PATCH 164/241] add Signed-off-by: MirMort --- window_scene/session/screen/src/screen_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 882119cfab..4f04d8d8da 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -1094,7 +1094,7 @@ void ScreenSession::UpdatePropertyOnly(RRect bounds, int rotation, FoldDisplayMo property_.SetValidHeight(bounds.rect_.GetHeight()); property_.SetValidWidth(bounds.rect_.GetWidth()); } - UpdateTouchBoundsAndOffset(); + UpdateTouchBoundsAndOffset(foldDisplayMode); TLOGI(WmsLogTag::DMS, "bounds:[%{public}f %{public}f %{public}f %{public}f],\ rotation:%{public}d, displayOrientation:%{public}u", property_.GetBounds().rect_.GetLeft(), property_.GetBounds().rect_.GetTop(), -- Gitee From 27472e786ab369a644c349098bf307ed83b19204 Mon Sep 17 00:00:00 2001 From: zhangweihua Date: Fri, 22 Aug 2025 18:13:17 +0800 Subject: [PATCH 165/241] bugfix Signed-off-by: zhangweihua --- .../secondary_display_sensor_fold_state_manager.cpp | 5 +++-- .../secondary_display_sensor_fold_state_manager_test.cpp | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp index 1e1f29588c..2b0139bee5 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/secondary_display_sensor_fold_state_manager.cpp @@ -58,8 +58,9 @@ SecondaryDisplaySensorFoldStateManager::~SecondaryDisplaySensorFoldStateManager( void SecondaryDisplaySensorFoldStateManager::HandleAngleOrHallChange(const std::vector& angles, const std::vector& halls, sptr foldScreenPolicy, bool isPostureRegistered) { - if (halls.size() != HALLS_AXIS_SIZE) { - TLOGE(WmsLogTag::DMS, "halls size is not right, halls size %{public}zu", halls.size()); + if (halls.size() != HALLS_AXIS_SIZE || angles.size() != ANGLES_AXIS_SIZE) { + TLOGE(WmsLogTag::DMS, "halls size or angles is not right, size %{public}zu, %{public}zu", + halls.size(), angles.size()); return; } if ((std::fabs(angles[1] - DEFAULT_ANGLE_VALUE) < FLT_EPSILON && halls[1] == HALL_THRESHOLD) || diff --git a/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp b/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp index 726093d1ac..d91bde52b5 100644 --- a/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp +++ b/window_scene/test/dms_unittest/secondary_display_sensor_fold_state_manager_test.cpp @@ -247,18 +247,18 @@ HWTEST_F(SecondaryDisplaySensorFoldStateManagerTest, HandleAngleOrHallChange08, } g_errLog.clear(); LOG_SetCallback(MyLogCallback); - std::vector angles = { 5, 5 }; + std::vector angles = { 5, 5, 5 }; std::vector halls = { 0, 1 }; SecondaryDisplaySensorFoldStateManager manager; g_errLog.clear(); manager.HandleAngleOrHallChange(angles, halls, nullptr, false); EXPECT_TRUE(g_errLog.find("hall change but posture not change") != std::string::npos); - angles = { 5, 5 }; + angles = { 5, 5, 5 }; halls = { 0, 0 }; g_errLog.clear(); manager.HandleAngleOrHallChange(angles, halls, nullptr, false); EXPECT_FALSE(g_errLog.find("hall change but posture not change") != std::string::npos); - angles = { 4, 4 }; + angles = { 4, 4, 4 }; halls = { 1, 1 }; g_errLog.clear(); manager.HandleAngleOrHallChange(angles, halls, nullptr, false); -- Gitee From 4d38df60f8706948b1433e9b17c4c622d8918072 Mon Sep 17 00:00:00 2001 From: MirMort Date: Fri, 22 Aug 2025 18:33:45 +0800 Subject: [PATCH 166/241] add Signed-off-by: MirMort --- .../screen_session_manager_test2.cpp | 19 ++----------------- .../test/dms_unittest/screen_session_test.cpp | 1 - 2 files changed, 2 insertions(+), 18 deletions(-) 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 c80ce196fa..4dd15fe00d 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -40,6 +40,7 @@ constexpr uint32_t EXCEPTION_DPI = 10; constexpr uint32_t PC_MODE_DPI = 304; constexpr ScreenId SCREEN_ID_FULL = 0; constexpr ScreenId SCREEN_ID_MAIN = 5; +bool CORRECTION_ENABLE = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; } namespace { std::string g_errLog; @@ -1551,7 +1552,6 @@ HWTEST_F(ScreenSessionManagerTest, SetDefaultScreenModeWhenCreateMirror, TestSiz */ HWTEST_F(ScreenSessionManagerTest, GetOldDisplayModeRotation, TestSize.Level1) { - bool CORRECTION_ENABLE = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; auto foldController = sptr::MakeSptr(ssm_->displayInfoMutex_, ssm_->screenPowerTaskScheduler_); ASSERT_NE(foldController, nullptr); @@ -1624,22 +1624,7 @@ HWTEST_F(ScreenSessionManagerTest, HandleScreenRotationAndBoundsWhenSetClient, T auto foldController = sptr::MakeSptr(ssm_->displayInfoMutex_, ssm_->screenPowerTaskScheduler_); ASSERT_NE(foldController, nullptr); - DisplayPhysicalResolution physicalSize_full; - physicalSize_full.foldDisplayMode_ = FoldDisplayMode::FULL; - physicalSize_full.physicalWidth_ = 2048; - physicalSize_full.physicalHeight_ = 2232; - DisplayPhysicalResolution physicalSize_main; - physicalSize_main.foldDisplayMode_ = FoldDisplayMode::MAIN; - physicalSize_main.physicalWidth_ = 1008; - physicalSize_main.physicalHeight_ = 2232; - DisplayPhysicalResolution physicalSize_global_full; - physicalSize_global_full.foldDisplayMode_ = FoldDisplayMode::GLOBAL_FULL; - physicalSize_global_full.physicalWidth_ = 3184; - physicalSize_global_full.physicalHeight_ = 2232; - ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_full); - ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_main); - ScreenSceneConfig::displayPhysicalResolution_.emplace_back(physicalSize_global_full); - auto foldPolicy = foldController->GetFoldScreenPolicy(DisplayDeviceType::SECONDARY_DISPLAY_DEVICE); + auto foldPolicy = foldController->GetFoldScreenPolicy(DisplayDeviceType::SINGLE_DISPLAY_DEVICE); ASSERT_NE(foldPolicy, nullptr); foldPolicy->lastDisplayMode_ = FoldDisplayMode::GLOBAL_FULL; foldController->foldScreenPolicy_ = foldPolicy; diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 6b0e0289e8..207d7916f9 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -4558,7 +4558,6 @@ HWTEST_F(ScreenSessionTest, RemoveRotationCorrection, TestSize.Level1) rotation = static_cast(100); session->RemoveRotationCorrection(rotation, FoldDisplayMode::FULL); - EXPECT_EQ(rotation, rotation); } /** -- Gitee From 626de11fb4f66c1fd65b57c74f69bcd1ed93dd9a Mon Sep 17 00:00:00 2001 From: MirMort Date: Fri, 22 Aug 2025 19:01:54 +0800 Subject: [PATCH 167/241] add Signed-off-by: MirMort --- window_scene/test/dms_unittest/screen_session_manager_test2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4dd15fe00d..b3a957610e 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -40,7 +40,7 @@ constexpr uint32_t EXCEPTION_DPI = 10; constexpr uint32_t PC_MODE_DPI = 304; constexpr ScreenId SCREEN_ID_FULL = 0; constexpr ScreenId SCREEN_ID_MAIN = 5; -bool CORRECTION_ENABLE = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; +const bool CORRECTION_ENABLE = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; } namespace { std::string g_errLog; -- Gitee From 3f143b4db700b1aa75ec3c70d0340bef998be20e Mon Sep 17 00:00:00 2001 From: MirMort Date: Fri, 22 Aug 2025 20:53:03 +0800 Subject: [PATCH 168/241] add Signed-off-by: MirMort --- .../src/screen_session_manager.cpp | 20 +++++++++---------- .../screen_session_manager_client_stub.cpp | 18 +++++++++++++++-- .../test/dms_unittest/screen_session_test.cpp | 1 + 3 files changed, 26 insertions(+), 13 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 e7e76cec40..40aac04ff2 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -8464,7 +8464,7 @@ void ScreenSessionManager::SwapScreenWeightAndHeight(sptr& screen auto lastWidth = bounds.rect_.GetWidth(); auto lastHeight = bounds.rect_.GetHeight(); RRect afterBounds = - RRect({ 0, bounds.rect_.GetTop(), lastHeight, lastWidth}, 0.0f, 0.0f); + RRect({ 0, bounds.rect_.GetTop(), lastHeight, lastWidth}, 0.0f, 0.0f); screenSession->SetBounds(afterBounds); TLOGI(WmsLogTag::DMS, "before width:%{public}f, height:%{public}f,after width:%{public}f, height:%{public}f", lastWidth, lastHeight, afterBounds.rect_.GetWidth(), afterBounds.rect_.GetHeight()); @@ -8810,15 +8810,13 @@ void ScreenSessionManager::HandleScreenRotationAndBoundsWhenSetClient(sptrSetDisplayBoundary(RectF(0, boundaryOffset, phyWidth, phyHeight), 0); - } + } else if (!FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + bool isModeChanged = localRotation != Rotation::ROTATION_0; + if (isModeChanged && isReset) { + TLOGI(WmsLogTag::DMS, "screen(id:%{public}" PRIu64 ") current is not default mode, reset it", screenId); + SetRotation(screenId, Rotation::ROTATION_0, false); + SetPhysicalRotationClientInner(screenId, 0); + screenSession->SetDisplayBoundary(RectF(0, boundaryOffset, phyWidth, phyHeight), 0); } } } @@ -11260,7 +11258,7 @@ void ScreenSessionManager::InitRotationCorrectionMap(std::string displayModeCorr TLOGE(WmsLogTag::DMS, "invalid config"); return; } - for (std::string displayModeCorrection : displayModeCorrections) { + for (const std::string& displayModeCorrection : displayModeCorrections) { std::vector corrections = {}; splitSuccess = ScreenSettingHelper::SplitString(corrections, displayModeCorrection, ','); uint32_t dataSize = corrections.size(); diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp index 6acead3bc5..b06d2c1653 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp @@ -195,10 +195,24 @@ int ScreenSessionManagerClientStub::HandleOnScreenConnectionChanged(MessageParce auto innerName = data.ReadString(); auto screenId = static_cast(data.ReadUint64()); auto screenEvent = static_cast(data.ReadUint8()); - auto size = data.ReadUint64(); + uint64_t size = 0; + if (!data.ReadUint64(size)) { + TLOGE(WmsLogTag::DMS, "Failed to read size"); + return ERR_INVALID_DATA; + } std::unordered_map rotationCorrectionMap; for (uint64_t i = 0; i < size; i++) { - rotationCorrectionMap.insert({static_cast(data.ReadUint32()), data.ReadUint32()}); + uint32_t foldDisplayMode = 0; + if (!data.ReadUint32(foldDisplayMode)) { + TLOGE(WmsLogTag::DMS, "Failed to read foldDisplayMode"); + return ERR_INVALID_DATA; + } + uint32_t offset = 0; + if (!data.ReadUint32(offset)) { + TLOGE(WmsLogTag::DMS, "Failed to read offset"); + return ERR_INVALID_DATA; + } + rotationCorrectionMap.insert({static_cast(foldDisplayMode), offset}); } SessionOption option = { .rsId_ = rsId, diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 207d7916f9..545d230bc2 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -4558,6 +4558,7 @@ HWTEST_F(ScreenSessionTest, RemoveRotationCorrection, TestSize.Level1) rotation = static_cast(100); session->RemoveRotationCorrection(rotation, FoldDisplayMode::FULL); + EXPECT_EQ(static_cast(rotation), 100); } /** -- Gitee From 728345ecad87d59a7508c8977b3a2788c3be3546 Mon Sep 17 00:00:00 2001 From: chaos Date: Sat, 23 Aug 2025 09:33:11 +0800 Subject: [PATCH 169/241] fix Signed-off-by: chaos --- window_scene/test/dms_unittest/screen_session_manager_test2.cpp | 2 -- 1 file changed, 2 deletions(-) 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 fa62d4ba9a..f35599ebc8 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -980,11 +980,9 @@ HWTEST_F(ScreenSessionManagerTest, UpdateSuperFoldRefreshRate, TestSize.Level1) ssm_->UpdateSuperFoldRefreshRate(screenSession, tempRefreshRate); EXPECT_TRUE(g_errLog.find("screenSession is nullptr") != std::string::npos); - ScreenId screenId = 1050; DMRect area{0, 0, 600, 800}; screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); - sptr fakescreenSession = nullptr; screenSession->SetFakeScreenSession(fakescreenSession); ssm_->UpdateSuperFoldRefreshRate(screenSession, tempRefreshRate); -- Gitee From c8fd5b40c46d03d2887e53ce1ea568a90c90a024 Mon Sep 17 00:00:00 2001 From: shenshensun Date: Sat, 23 Aug 2025 10:59:04 +0800 Subject: [PATCH 170/241] Add deviceRotation and rotationCorrection Signed-off-by: shenshensun --- window_scene/session_manager/src/scene_input_manager.cpp | 9 ++++++++- .../event_distribution/scene_input_manager_test.cpp | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 47d60a919e..69ae5e1529 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -81,6 +81,9 @@ bool operator==(const MMI::DisplayInfo& a, const MMI::DisplayInfo& b) a.pointerActiveHeight != b.pointerActiveHeight) { return false; } + if (a.deviceRotation != b.deviceRotation || a.rotationCorrection != b.rotationCorrection) { + return false; + } return true; } @@ -289,6 +292,8 @@ void SceneInputManager::ConstructDisplayGroupInfos(std::map(screenProperty.GetDeviceRotation()); + int32_t rotationCorrection = static_cast(screenSession->GetRotationCorrection(displayMode)); MMI::DisplayInfo displayInfo = { .id = screenId, .x = screenProperty.GetX(), @@ -316,7 +321,9 @@ void SceneInputManager::ConstructDisplayGroupInfos(std::mapGetDisplayGroupId(); if (displayGroupMap.count(displayGroupId) == 0) { diff --git a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp index 3b4eda9c3a..db7391fa61 100644 --- a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp @@ -899,6 +899,8 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdateFordDisplayInfos, TestSize.Level1 displayInfo.offsetY = 1; displayInfo.pointerActiveWidth = 1; displayInfo.pointerActiveHeight = 1; + displayInfo.deviceRotation = MMI::Direction::DIRECTION90; + displayInfo.rotationCorrection = MMI::Direction::DIRECTION90; displayInfos.emplace_back(displayInfo); ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); ASSERT_FALSE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); @@ -958,6 +960,10 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdateFordDisplayInfos, TestSize.Level1 ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); displayInfos[0].screenArea = { 2, { 2, 2, 2, 2 } }; ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].deviceRotation = MMI::Direction::DIRECTION180; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); + displayInfos[0].rotationCorrection = MMI::Direction::DIRECTION180; + ASSERT_TRUE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); ASSERT_FALSE(SceneInputManager::GetInstance().CheckNeedUpdate(screenInfos, displayInfos, windowInfoList)); } } // namespace -- Gitee From 3577be6db0214150b45c705e6ab998be2c015501 Mon Sep 17 00:00:00 2001 From: w00893971 Date: Sat, 23 Aug 2025 14:43:31 +0800 Subject: [PATCH 171/241] esc do not transfer to back when UIExtension window Signed-off-by: w00893971 --- wm/src/window_session_impl.cpp | 5 +++-- wm/test/unittest/window_session_impl_test2.cpp | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 3cd57d19a7..b86a6efab9 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -6321,8 +6321,9 @@ WMError WindowSessionImpl::HandleEscKeyEvent(const std::shared_ptrHasFlag(MMI::InputEvent::EVENT_FLAG_KEYBOARD_ESCAPE); - if (!escToBackFlag) { - TLOGE(WmsLogTag::WMS_EVENT, "ESC no flag"); + // noflag do not handle; UEC do not handle because it is handled in the host window + if (!escToBackFlag || property_->GetWindowType() == WindowType::WINDOW_TYPE_UI_EXTENSION) { + TLOGE(WmsLogTag::WMS_EVENT, "ESC no flag or UIExtension window"); return WMError::WM_DO_NOTHING; } diff --git a/wm/test/unittest/window_session_impl_test2.cpp b/wm/test/unittest/window_session_impl_test2.cpp index 0a8bc08351..76c7ca9005 100644 --- a/wm/test/unittest/window_session_impl_test2.cpp +++ b/wm/test/unittest/window_session_impl_test2.cpp @@ -484,6 +484,7 @@ HWTEST_F(WindowSessionImplTest2, HandleEscKeyEvent001, TestSize.Level1) { auto window = GetTestWindowImpl("HandleEscKeyEvent001"); ASSERT_NE(window, nullptr); + ASSERT_NE(window->property_, nullptr); std::shared_ptr keyEvent = MMI::KeyEvent::Create(); ASSERT_NE(keyEvent, nullptr); @@ -498,6 +499,9 @@ HWTEST_F(WindowSessionImplTest2, HandleEscKeyEvent001, TestSize.Level1) EXPECT_EQ(true, keyEvent->HasFlag(MMI::InputEvent::EVENT_FLAG_KEYBOARD_ESCAPE)); WMError result = window->HandleEscKeyEvent(keyEvent, isConsumed); EXPECT_EQ(result, WMError::WM_OK); + + window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); + ASSERT_EQ(WMError::WM_DO_NOTHING, window->HandleEscKeyEvent(keyEvent, isConsumed)); window->Destroy(); } -- Gitee From e4e7c330873e7b939caee00bf88de323dd28beb5 Mon Sep 17 00:00:00 2001 From: Jane_Go <2243369153@qq.com> Date: Sat, 23 Aug 2025 16:27:19 +0800 Subject: [PATCH 172/241] cj display bugfix Signed-off-by: Jane_Go <2243369153@qq.com> --- .../kits/cj/display_runtime/cj_display_manager.cpp | 12 ++++++------ interfaces/kits/cj/display_runtime/display_utils.h | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/cj/display_runtime/cj_display_manager.cpp b/interfaces/kits/cj/display_runtime/cj_display_manager.cpp index 02d30e16dc..0480dd9b38 100644 --- a/interfaces/kits/cj/display_runtime/cj_display_manager.cpp +++ b/interfaces/kits/cj/display_runtime/cj_display_manager.cpp @@ -224,18 +224,18 @@ bool CJDisplayManager::IsCaptured() static void SetDisplayPhysicalResolutionObject(DisplayPhysicalResolution& resolution, RetStruct& ret) { - DisplayPhysicalResolution* dataPtr = static_cast(ret.data); - dataPtr[ret.len].foldDisplayMode_ = resolution.foldDisplayMode_; - dataPtr[ret.len].physicalWidth_ = resolution.physicalWidth_; - dataPtr[ret.len].physicalHeight_ = resolution.physicalHeight_; + CDisplayPhysicalResolution* dataPtr = static_cast(ret.data); + dataPtr[ret.len].foldDisplayMode = static_cast(resolution.foldDisplayMode_); + dataPtr[ret.len].physicalWidth = resolution.physicalWidth_; + dataPtr[ret.len].physicalHeight = resolution.physicalHeight_; ret.len++; } static void SetDisplayPhysicalResolutionArrayObject( std::vector& resolutionList, RetStruct& ret) { - DisplayPhysicalResolution* resolutions = - static_cast(malloc(sizeof(DisplayPhysicalResolution) * resolutionList.size())); + CDisplayPhysicalResolution* resolutions = + static_cast(malloc(sizeof(CDisplayPhysicalResolution) * resolutionList.size())); if (resolutions == nullptr) { TLOGE(WmsLogTag::DMS, "[SetDisplayPhysicalResolutionArrayObject] ERROR Failed to create display physical resolution list."); diff --git a/interfaces/kits/cj/display_runtime/display_utils.h b/interfaces/kits/cj/display_runtime/display_utils.h index c937e4dedd..d6952f0997 100644 --- a/interfaces/kits/cj/display_runtime/display_utils.h +++ b/interfaces/kits/cj/display_runtime/display_utils.h @@ -29,6 +29,12 @@ typedef struct { void* data; } RetStruct; +typedef struct { + uint32_t foldDisplayMode; + uint32_t physicalWidth; + uint32_t physicalHeight; +} CDisplayPhysicalResolution; + typedef struct { int32_t left; int32_t top; -- Gitee From 1ee6445688340a5017db57744d2cbf72a13a01a6 Mon Sep 17 00:00:00 2001 From: zrb <2454498733@qq.com> Date: Sat, 23 Aug 2025 20:32:33 +0800 Subject: [PATCH 173/241] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=8F=98?= =?UTF-8?q?=E9=80=8F=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zrb <2454498733@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2a77b5a9be..17d2e81d86 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6158,10 +6158,11 @@ void SceneSessionManager::UpdateForceHideState(const sptr& sceneSe bool forceHideFloatOld = !systemTopSceneSessionMap_.empty(); bool notifyAll = false; if (add) { - if (property->GetHideNonSystemFloatingWindows()) { + if (property->GetHideNonSystemFloatingWindows() && sceneSession->GetWindowMode() != WindowMode::WINDOW_MODE_PIP) { systemTopSceneSessionMap_.insert({ persistentId, sceneSession }); notifyAll = !forceHideFloatOld; - } else if ((property->IsFloatingWindowAppType() && !property->GetSystemCalling()) || + } else if ((property->IsFloatingWindowAppType() && !property->GetSystemCalling() && + sceneSession->GetWindowMode() != WindowMode::WINDOW_MODE_PIP) || sceneSession->GetIsAncoForFloatingWindow()) { nonSystemFloatSceneSessionMap_.insert({ persistentId, sceneSession }); if (forceHideFloatOld) { -- Gitee From 6f7da60ed9ab22d457cc3097b1b4d1bb4773b077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Sun, 24 Aug 2025 15:21:05 +0800 Subject: [PATCH 174/241] chaneg1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- window_scene/session/host/include/session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index ce30e29890..bf4151007d 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -827,7 +827,7 @@ protected: bool isActive_ = false; bool isSystemActive_ = false; WSRectF bounds_; - Rotation rotation_; + Rotation rotation_ { Rotation::ROTATION_0 }; float offsetX_ = 0.0f; float offsetY_ = 0.0f; std::atomic_bool isExitSplitOnBackground_ = false; -- Gitee From 900c18e611ad25a190d09a182dbfbed72cdca52a Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Mon, 25 Aug 2025 09:08:50 +0800 Subject: [PATCH 175/241] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=A1=B5=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=9B=B4=E6=96=B0=E6=97=A0ability=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laiganlu --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2a77b5a9be..0cd1bf48a6 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5337,6 +5337,10 @@ void SceneSessionManager::GetBundleStartingWindowInfos(bool isDark, const AppExe { for (const auto& moduleInfo : bundleInfo.hapModuleInfos) { for (const auto& abilityInfo : moduleInfo.abilityInfos) { + if (abilityInfo.startWindowId == 0 && abilityInfo.startWindowBackgroundId == 0) { + TLOGD(WmsLogTag::WMS_PATTERN, "not ability:%{public}s", abilityInfo.bundleName.c_str()); + continue; + } StartingWindowRdbItemKey itemKey = { .bundleName = abilityInfo.bundleName, .moduleName = abilityInfo.moduleName, -- Gitee From 2b6a61ade79c5bb5e8000a4573480fc9fc39adbb Mon Sep 17 00:00:00 2001 From: zrb <2454498733@qq.com> Date: Mon, 25 Aug 2025 09:30:33 +0800 Subject: [PATCH 176/241] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=8F=98?= =?UTF-8?q?=E9=80=8F=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zrb <2454498733@qq.com> --- .../unittest/scene_session_manager_test3.cpp | 38 +++++++++++++++++++ window_scene/test/unittest/session_test.cpp | 10 ++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test3.cpp b/window_scene/test/unittest/scene_session_manager_test3.cpp index f42cd7defe..313944928a 100644 --- a/window_scene/test/unittest/scene_session_manager_test3.cpp +++ b/window_scene/test/unittest/scene_session_manager_test3.cpp @@ -1173,6 +1173,44 @@ HWTEST_F(SceneSessionManagerTest3, HandleHideNonSystemFloatingWindows, TestSize. ASSERT_EQ(result, WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); } +/** + +@tc.name: UpdateForceHideState +@tc.desc: SceneSesionManager update Force Hide system state +@tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest3, UpdateForceHideState, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "UpdateForceHideState"; + info.bundleName_ = "UpdateForceHideState"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sptr property = sptr::MakeSptr(); + ssm_->systemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; + property->SetHideNonSystemFloatingWindows(true); + sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_PIP; + ssm_->systemTopSceneSessionMap_.clear(); + ssm_->UpdateForceHideState(sceneSession, property, true); + EXPECT_EQ(ssm_->systemTopSceneSessionMap_.size(), 0); + property->SetHideNonSystemFloatingWindows(true); + sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_FLOATING; + ssm_->systemTopSceneSessionMap_.clear(); + ssm_->UpdateForceHideState(sceneSession, property, true); + EXPECT_EQ(ssm_->systemTopSceneSessionMap_.size(), 1); + property->SetHideNonSystemFloatingWindows(false); + property->SetFloatingWindowAppType(true); + property->SetSystemCalling(false); + sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_PIP; + ssm_->systemTopSceneSessionMap_.clear(); + ssm_->UpdateForceHideState(sceneSession, property, true); + EXPECT_EQ(ssm_->systemTopSceneSessionMap_.size(), 0); + property->SetHideNonSystemFloatingWindows(false); + sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_FLOATING; + ssm_->systemTopSceneSessionMap_.clear(); + ssm_->UpdateForceHideState(sceneSession, property, true); + EXPECT_EQ(ssm_->systemTopSceneSessionMap_.size(), 0); +} + /** * @tc.name: UpdateBrightness01 * @tc.desc: SceneSesionManager update brightness diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index c992c4e24e..ec0eb7325b 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -189,14 +189,14 @@ HWTEST_F(WindowSessionTest, SetCompatibleModeProperty, TestSize.Level1) { EXPECT_NE(nullptr, session_->GetSessionProperty()); sptr compatibleModeProperty = nullptr; - ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); + EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); compatibleModeProperty = sptr::MakeSptr(); session_->sessionStage_ = mockSessionStage_; - ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); - ASSERT_EQ(session_->GetSessionProperty()->GetDragEnabled(), true); + EXPECT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); + EXPECT_EQ(session_->GetSessionProperty()->GetDragEnabled(), true); compatibleModeProperty->SetDisableDragResize(true); - ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); - ASSERT_EQ(session_->GetSessionProperty()->GetDragEnabled(), false); + EXPECT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); + EXPECT_EQ(session_->GetSessionProperty()->GetDragEnabled(), false); } /** -- Gitee From e0b4cf0755fdcd1dc5c600f7c224ee6eaea94086 Mon Sep 17 00:00:00 2001 From: zrb <2454498733@qq.com> Date: Mon, 25 Aug 2025 09:58:37 +0800 Subject: [PATCH 177/241] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=8F=98?= =?UTF-8?q?=E9=80=8F=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zrb <2454498733@qq.com> --- window_scene/test/unittest/session_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index ec0eb7325b..7077b12924 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -187,9 +187,10 @@ HWTEST_F(WindowSessionTest, SetActive01, TestSize.Level1) */ HWTEST_F(WindowSessionTest, SetCompatibleModeProperty, TestSize.Level1) { - EXPECT_NE(nullptr, session_->GetSessionProperty()); + EXPECT_NE(nullptr, session_->GetSessionProperty()); sptr compatibleModeProperty = nullptr; EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); + compatibleModeProperty = sptr::MakeSptr(); session_->sessionStage_ = mockSessionStage_; EXPECT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); -- Gitee From b19261dc6842937da6da3bd82790e3e6dca36e07 Mon Sep 17 00:00:00 2001 From: zrb <2454498733@qq.com> Date: Mon, 25 Aug 2025 10:00:21 +0800 Subject: [PATCH 178/241] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=8F=98?= =?UTF-8?q?=E9=80=8F=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zrb <2454498733@qq.com> --- window_scene/test/unittest/session_test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 7077b12924..ec0eb7325b 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -187,10 +187,9 @@ HWTEST_F(WindowSessionTest, SetActive01, TestSize.Level1) */ HWTEST_F(WindowSessionTest, SetCompatibleModeProperty, TestSize.Level1) { - EXPECT_NE(nullptr, session_->GetSessionProperty()); + EXPECT_NE(nullptr, session_->GetSessionProperty()); sptr compatibleModeProperty = nullptr; EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); - compatibleModeProperty = sptr::MakeSptr(); session_->sessionStage_ = mockSessionStage_; EXPECT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); -- Gitee From af44dcf2879344802cbeee5a30e9a32e10978cd9 Mon Sep 17 00:00:00 2001 From: zrb <2454498733@qq.com> Date: Mon, 25 Aug 2025 10:02:17 +0800 Subject: [PATCH 179/241] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=8F=98?= =?UTF-8?q?=E9=80=8F=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zrb <2454498733@qq.com> --- window_scene/test/unittest/session_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index ec0eb7325b..89768221ad 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -187,13 +187,13 @@ HWTEST_F(WindowSessionTest, SetActive01, TestSize.Level1) */ HWTEST_F(WindowSessionTest, SetCompatibleModeProperty, TestSize.Level1) { - EXPECT_NE(nullptr, session_->GetSessionProperty()); sptr compatibleModeProperty = nullptr; - EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeProperty(compatibleModeProperty)); - compatibleModeProperty = sptr::MakeSptr(); session_->sessionStage_ = mockSessionStage_; EXPECT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); EXPECT_EQ(session_->GetSessionProperty()->GetDragEnabled(), true); + compatibleModeProperty = sptr::MakeSptr(); + EXPECT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); + EXPECT_EQ(session_->GetSessionProperty()->GetDragEnabled(), true); compatibleModeProperty->SetDisableDragResize(true); EXPECT_EQ(WSError::WS_OK, session_->SetCompatibleModeProperty(compatibleModeProperty)); EXPECT_EQ(session_->GetSessionProperty()->GetDragEnabled(), false); -- Gitee From 62a0f9f5cbfaa9d9f5aa3e4b58144a71a4cea5af Mon Sep 17 00:00:00 2001 From: 17342015572 Date: Mon, 25 Aug 2025 02:45:21 +0000 Subject: [PATCH 180/241] Clean code style Signed-off-by: 17342015572 Change-Id: Id74ce4e6c7e22a028673aca305c30c44554cd9ff --- window_scene/session/host/src/scene_session.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 73eeed9730..712177e86f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -452,8 +452,6 @@ WSError SceneSession::ForegroundTask(const sptr& property if (session->isUIFirstEnabled_ && leashWinSurfaceNode) { leashWinSurfaceNode->SetForceUIFirst(false); session->isUIFirstEnabled_ = false; - TLOGNI(WmsLogTag::WMS_ANIMATION, "%{public}s %{public}" PRIu64 " forceUIFirst=false.", - leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId()); } return WSError::WS_OK; }, __func__); @@ -8462,7 +8460,7 @@ void SceneSession::SetWindowCornerRadiusCallback(NotifySetWindowCornerRadiusFunc } session->onSetWindowCornerRadiusFunc_ = std::move(func); auto property = session->GetSessionProperty(); - float cornerRadius = property->GetWindowCornerRadius(); + float cornerRadius = property ? property->GetWindowCornerRadius() : WINDOW_CORNER_RADIUS_INVALID; if (!MathHelper::LessNotEqual(cornerRadius, 0.0f)) { // Valid corner radius menas app has set corner radius of the window, need to update to scb. session->onSetWindowCornerRadiusFunc_(cornerRadius); -- Gitee From 5ed1d2d4926658a4a532ede4329c3abe3f23438f Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Mon, 25 Aug 2025 14:50:28 +0800 Subject: [PATCH 181/241] =?UTF-8?q?destroy=E6=97=B6=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E5=B0=86surfaceNode=5F=E7=BD=AE=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peng fafu --- wm/src/window_extension_session_impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index f85e966af2..5b13850c65 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -315,6 +315,7 @@ WMError WindowExtensionSessionImpl::Destroy(bool needNotifyServer, bool needClea SetUIExtensionDestroyComplete(); RemoveExtensionWindowStageFromSCB(property_->IsConstrainedModal()); dataHandler_->SetRemoteProxyObject(nullptr); + surfaceNode_ = nullptr; TLOGI(WmsLogTag::WMS_LIFE, "Destroyed success, id: %{public}d.", GetPersistentId()); return WMError::WM_OK; } -- Gitee From ad6e362d9f2d75636732e3cefb8c35352303f4f6 Mon Sep 17 00:00:00 2001 From: chuanstudy Date: Mon, 25 Aug 2025 07:07:54 +0000 Subject: [PATCH 182/241] fix get to release Signed-off-by: chuanstudy --- .../scene_session_manager_ani/src/ani_scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp index 1a034b41cf..502acf108a 100644 --- a/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/ani/scene_session_manager/scene_session_manager_ani/src/ani_scene_session_manager.cpp @@ -36,7 +36,7 @@ ani_status AniSceneSessionManager::Init(ani_env* env, ani_namespace nsp) return ret; } std::unique_ptr aniSceneSessionManager = std::make_unique(); - ret = env->Function_Call_Void(setObjFunc, aniSceneSessionManager.get()); + ret = env->Function_Call_Void(setObjFunc, aniSceneSessionManager.release()); if (ret != ANI_OK) { TLOGE(WmsLogTag::DEFAULT, "[ANI] find setSceneSessionManagerRef func fail %{public}u", ret); return ret; -- Gitee From f4c1b36181ee0df0231b9324cd021f73344a1a8e Mon Sep 17 00:00:00 2001 From: Lighter Date: Mon, 25 Aug 2025 09:13:57 +0000 Subject: [PATCH 183/241] update wm/src/window_session_impl.cpp. Signed-off-by: Lighter --- wm/src/window_session_impl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index e62d1d2dc7..28ee7f6291 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2336,7 +2336,8 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)); + (property_->GetIsPcAppInPad() && isSubWindow)) && + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); } uiContent->UpdateDecorVisible(decorVisible, isDecorEnable); return; @@ -2364,7 +2365,8 @@ void WindowSessionImpl::UpdateDecorEnable(bool needNotify, WindowMode mode) if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)); + (property_->GetIsPcAppInPad() && isSubWindow)) && + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); } if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { decorVisible = false; -- Gitee From 6be3e17eab50ad057de07ca71954c37134943f8c Mon Sep 17 00:00:00 2001 From: hubijie Date: Sat, 23 Aug 2025 10:47:07 +0800 Subject: [PATCH 184/241] support uiextension create sub window which in system scene Signed-off-by: hubijie --- utils/include/string_util.h | 2 +- window_scene/common/include/window_session_property.h | 11 +++-------- window_scene/common/src/window_session_property.cpp | 7 +++++++ .../session_manager/src/scene_session_manager.cpp | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/utils/include/string_util.h b/utils/include/string_util.h index 75cf6fa038..241044c432 100644 --- a/utils/include/string_util.h +++ b/utils/include/string_util.h @@ -16,7 +16,7 @@ #ifndef WM_STRING_UTIL_H #define WM_STRING_UTIL_H -#incldue +#include #include namespace OHOS { diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 5b3abdfd51..587276bf70 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -27,8 +27,6 @@ #include #include "pixel_map.h" #include "floating_ball_template_info.h" -#include "string_util.h" -#include "window_manager_hilog.h" namespace OHOS { namespace Rosen { @@ -804,7 +802,9 @@ struct SystemSessionConfig : public Parcelable { bool supportCreateFloatWindow_ = false; float defaultCornerRadius_ = 0.0f; // default corner radius of window set by system config bool supportUIExtensionSubWindow_ = false; - using ConvertSystemConfigFunc = void(SystemSessionConfig::*)(SystemSessionConfig& systemConfig, const std::string& configItem); + using ConvertSystemConfigFunc = void(SystemSessionConfig::*)(const std::string& configItem, + SystemSessionConfig& systemConfig); + void ConvertSupportUIExtensionSubWindow(const std::string& itemValue, SystemSessionConfig& systemConfig); virtual bool Marshalling(Parcel& parcel) const override { @@ -949,11 +949,6 @@ struct SystemSessionConfig : public Parcelable { { return IsPcWindow() || (IsPadWindow() && IsFreeMultiWindowMode()); } - - void ConvertSupportUIExtensionSubWindow(SystemSessionConfig& systemConfig, const std::string& itemValue) - { - systemConfig.supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); - } }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 70bfe2ee54..76c92662db 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -14,6 +14,7 @@ */ #include "common/include/window_session_property.h" +#include "string_util.h" #include "window_manager_hilog.h" #include "wm_common.h" #include "window_helper.h" @@ -2584,5 +2585,11 @@ void WindowSessionProperty::UnmarshallingShadowsInfo(Parcel& parcel, WindowSessi } property->SetWindowShadows(*shadowsInfo); } + +void SystemSessionConfig::ConvertSupportUIExtensionSubWindow(const std::string& itemValue, + SystemSessionConfig& systemConfig) +{ + systemConfig.supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); +} } // namespace Rosen } // namespace OHOS \ 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 b0f0f56f9c..5f42f92c77 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10856,14 +10856,14 @@ static void FillUnreliableWindowInfo(const sptr& sceneSession, void SceneSessionManager::ApplyFeatureConfig(const std::unordered_map& configMap) { - auto task = [this, where = __func__, configMap] { - for (const auto& [configName, configValue] : configMap ) { + auto task = [this, where = __func__, &configMap] { + for (const auto& [configName, configValue] : configMap) { TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s, configEntry is %{public}s: %{public}s", where, configName.c_str(), configValue.c_str()); auto convertIter = convertConfigMap.find(configName); if (convertIter != convertConfigMap.end()) { auto convertFunc = convertIter->second; - (this->systemConfig_.*convertFunc)(systemConfig_, value); + (this->systemConfig_.*convertFunc)(systemConfig_, configValue); } } return WMError::WM_OK; -- Gitee From 5c3af6c896daf16757555921faa06550b742bfcd Mon Sep 17 00:00:00 2001 From: Jiayi Zhu Date: Mon, 25 Aug 2025 18:03:34 +0800 Subject: [PATCH 185/241] switch user with multi screenNode, supports animate Signed-off-by: Jiayi Zhu --- .../include/display_manager_interface_code.h | 1 + .../js_screen_session_manager.cpp | 64 +++++ .../js_screen_session_manager.h | 4 + .../include/multi_screen_manager.h | 7 +- .../include/screen_session_manager.h | 27 +- .../zidl/screen_session_manager_interface.h | 3 +- .../zidl/screen_session_manager_proxy.h | 3 +- .../src/multi_screen_manager.cpp | 16 +- .../src/screen_session_manager.cpp | 267 +++++++++++++++++- .../src/zidl/screen_session_manager_proxy.cpp | 25 +- .../src/zidl/screen_session_manager_stub.cpp | 4 + .../include/screen_session_manager_client.h | 7 + .../screen_session_manager_client_interface.h | 2 + .../screen_session_manager_client_proxy.h | 1 + .../zidl/screen_session_manager_client_stub.h | 1 + .../src/screen_session_manager_client.cpp | 51 ++++ .../screen_session_manager_client_proxy.cpp | 21 ++ .../screen_session_manager_client_stub.cpp | 10 + ...reen_session_manager_client_proxy_test.cpp | 40 ++- ...creen_session_manager_client_stub_test.cpp | 16 ++ .../screen_session_manager_client_test.cpp | 61 ++++ .../screen_session_manager_proxy_test.cpp | 26 ++ .../screen_session_manager_stub_test.cpp | 18 ++ .../screen_session_manager_test2.cpp | 214 ++++++++++++++ window_scene/test/dms_unittest/test_client.h | 1 + 25 files changed, 856 insertions(+), 34 deletions(-) diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index 3b48394536..32ab3fe5a2 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -181,6 +181,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_SET_SCREEN_PRIVACY_WINDOW_TAG_SWITCH, TRANS_ID_SYNCHRONIZED_POWER_STATUS, TRANS_ID_NOTIFY_SCREEN_CONNECT_COMPLETION, + TRANS_ID_NOTIFY_SWITCH_USER_ANIMATION_FINISH, }; } #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H 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 caed713d0a..5dc9bbba1a 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 @@ -145,6 +145,10 @@ napi_value JsScreenSessionManager::Init(napi_env env, napi_value exportObj) BindNativeFunction(env, exportObj, "freezeScreen", moduleName, JsScreenSessionManager::FreezeScreen); BindNativeFunction(env, exportObj, "getScreenSnapshotWithAllWindows", moduleName, JsScreenSessionManager::GetScreenSnapshotWithAllWindows); + BindNativeFunction(env, exportObj, "notifySwitchUserAnimationFinish", moduleName, + JsScreenSessionManager::NotifySwitchUserAnimationFinish); + BindNativeFunction(env, exportObj, "registerSwitchUserAnimationNotification", moduleName, + JsScreenSessionManager::RegisterSwitchUserAnimationNotification); return NapiGetUndefined(env); } @@ -395,6 +399,20 @@ napi_value JsScreenSessionManager::GetScreenSnapshotWithAllWindows(napi_env env, return (me != nullptr) ? me->OnGetScreenSnapshotWithAllWindows(env, info) : nullptr; } +napi_value JsScreenSessionManager::NotifySwitchUserAnimationFinish(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::DMS, "[NAPI]NotifyScreenSwitchUserAnimateFinish"); + JsScreenSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnNotifySwitchUserAnimationFinish(env, info) : nullptr; +} + +napi_value JsScreenSessionManager::RegisterSwitchUserAnimationNotification(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::DMS, "[NAPI]RegisterSwitchUserAnimationNotification"); + JsScreenSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnRegisterSwitchUserAnimationNotification(env, info) : nullptr; +} + void JsScreenSessionManager::OnScreenConnected(const sptr& screenSession) { if (screenConnectionCallback_ == nullptr || screenSession == nullptr) { @@ -1318,4 +1336,50 @@ napi_value JsScreenSessionManager::OnGetScreenSnapshotWithAllWindows(napi_env en } return nativeData; } + +napi_value JsScreenSessionManager::OnNotifySwitchUserAnimationFinish(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::DMS, "[NAPI]notify switch user animate finish"); + size_t argc = ARGC_ONE; + napi_value argv[ARGC_ONE] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < ARGC_ONE) { + TLOGE(WmsLogTag::DMS, "[NAPI]Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + std::string description; + if (!ConvertFromJsValue(env, argv[0], description)) { + TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to description"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + ScreenSessionManagerClient::GetInstance().NotifySwitchUserAnimationFinish(description); + return NapiGetUndefined(env); +} + +napi_value JsScreenSessionManager::OnRegisterSwitchUserAnimationNotification(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::DMS, "[NAPI]register animate need notify"); + size_t argc = ARGC_ONE; + napi_value argv[ARGC_ONE] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < ARGC_ONE) { + TLOGE(WmsLogTag::DMS, "[NAPI]Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + std::string description; + if (!ConvertFromJsValue(env, argv[0], description)) { + TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to description"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + ScreenSessionManagerClient::GetInstance().RegisterSwitchUserAnimationNotification(description); + return NapiGetUndefined(env); +} } // namespace OHOS::Rosen diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h index e8cc6bf4e8..359b3d03cf 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h @@ -75,6 +75,8 @@ private: static napi_value GetFoldDisplayMode(napi_env env, napi_callback_info info); static napi_value FreezeScreen(napi_env env, napi_callback_info info); static napi_value GetScreenSnapshotWithAllWindows(napi_env env, napi_callback_info info); + static napi_value NotifySwitchUserAnimationFinish(napi_env env, napi_callback_info info); + static napi_value RegisterSwitchUserAnimationNotification(napi_env env, napi_callback_info info); napi_value OnRegisterCallback(napi_env env, const napi_callback_info info); napi_value OnUpdateScreenRotationProperty(napi_env env, const napi_callback_info info); @@ -110,6 +112,8 @@ private: napi_value OnGetFoldDisplayMode(napi_env env, napi_callback_info info); napi_value OnFreezeScreen(napi_env env, napi_callback_info info); napi_value OnGetScreenSnapshotWithAllWindows(napi_env env, napi_callback_info info); + napi_value OnNotifySwitchUserAnimationFinish(napi_env env, napi_callback_info info); + napi_value OnRegisterSwitchUserAnimationNotification(napi_env env, napi_callback_info info); std::shared_ptr screenConnectionCallback_; std::shared_ptr shutdownCallback_; diff --git a/window_scene/screen_session_manager/include/multi_screen_manager.h b/window_scene/screen_session_manager/include/multi_screen_manager.h index a9b40af3d8..22ec14db26 100644 --- a/window_scene/screen_session_manager/include/multi_screen_manager.h +++ b/window_scene/screen_session_manager/include/multi_screen_manager.h @@ -33,7 +33,7 @@ public: DMError UniqueSwitch(const std::vector& screenIds, std::vector& displayIds); DMError MirrorSwitch(const ScreenId mainScreenId, const std::vector& screenIds, DMRect mainScreenRegion, - ScreenId& screenGroupId); + ScreenId& screenGroupId, bool forceMirror = false); void MultiScreenModeChange(sptr mainSession, sptr secondarySession, const std::string& operateType); @@ -61,9 +61,10 @@ private: std::vector& physicalScreenIds, std::vector& virtualScreenIds); DMError VirtualScreenMirrorSwitch(const ScreenId mainScreenId, const std::vector& screenIds, - DMRect mainScreenRegion, ScreenId& screenGroupId); + DMRect mainScreenRegion, ScreenId& screenGroupId, bool forceMirror = false); - DMError PhysicalScreenMirrorSwitch(const std::vector& screenIds, DMRect mainScreenRegion); + DMError PhysicalScreenMirrorSwitch(const std::vector& screenIds, DMRect mainScreenRegion, + bool forceMirror = false); DMError PhysicalScreenUniqueSwitch(const std::vector& screenIds); 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 9523ae7db9..53243dd79a 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -130,7 +130,7 @@ public: virtual DMError DestroyVirtualScreen(ScreenId screenId) override; DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) override; virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) override; + ScreenId& screenGroupId, bool forceMirror = false) override; virtual DMError MakeMirrorForRecord(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) override; virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, @@ -206,7 +206,8 @@ public: std::map& removeChildResMap); bool CheckScreenInScreenGroup(sptr screen) const; - DMError SetMirror(ScreenId screenId, std::vector screens, DMRect mainScreenRegion); + DMError SetMirror(ScreenId screenId, std::vector screens, DMRect mainScreenRegion, + bool forceMirror = false); DMError StopScreens(const std::vector& screenIds, ScreenCombination stopCombination); void NotifyScreenConnected(sptr screenInfo); @@ -492,6 +493,7 @@ public: void RemoveScreenCastInfo(ScreenId screenId); Rotation GetConfigCorrectionByDisplayMode(FoldDisplayMode displayMode); Rotation RemoveRotationCorrection(Rotation rotation); + void NotifySwitchUserAnimationFinish() override; protected: ScreenSessionManager(); @@ -562,7 +564,7 @@ private: void MultiScreenModeChange(ScreenId mainScreenId, ScreenId secondaryScreenId, const std::string& operateType); void OperateModeChange(ScreenId mainScreenId, ScreenId secondaryScreenId, sptr& firstSession, sptr& secondarySession, const std::string& operateMode); - void SetClientInner(); + void SetClientInner(int32_t newUserId); void RecoverMultiScreenMode(sptr screenSession); void GetCurrentScreenPhyBounds(float& phyWidth, float& phyHeight, bool& isReset, const ScreenId& screenid); void SetPhysicalRotationClientInner(ScreenId screenId, int rotation); @@ -575,7 +577,7 @@ private: void NotifyCaptureStatusChanged(); void NotifyCaptureStatusChanged(bool IsCaptured); DMError DoMakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - DMRect mainScreenRegion, ScreenId& screenGroupId); + DMRect mainScreenRegion, ScreenId& screenGroupId, bool forceMirror = false); bool OnMakeExpand(std::vector screenId, std::vector startPoint); bool OnRemoteDied(const sptr& agent); std::string TransferTypeToString(ScreenType type) const; @@ -874,6 +876,23 @@ private: // Fold Screen duringcall bool duringCallState_ = false; + mutable std::recursive_mutex userDisplayNodeMapMutex_; + std::map>> userDisplayNodeMap_; + std::condition_variable switchUserDisplayNodeCV_; + std::mutex switchUserDisplayNodeMutex_; + bool animateFinishAllNotified_ = false; + + void AddOrUpdateUserDisplayNode(int32_t userId, ScreenId screenId, std::shared_ptr& displayNode); + void RemoveUserDisplayNode(int32_t userId, ScreenId screenId); + std::map> GetUserDisplayNodeMap(int32_t userId); + void SwitchUserDealUserDisplayNode(int32_t newUserId); + void AddUserDisplayNodeOnTree(int32_t userId); + void RemoveUserDisplayNodeFromTree(int32_t userId); + void SetUserDisplayNodePositionZ(int32_t userId, float positionZ); + void HandleNewUserDisplayNode(int32_t newUserId, bool coldBoot); + void WaitSwitchUserAnimateFinish(int32_t newUserId, bool isColdSwitch); + void MakeMirrorAfterSwitchUser(); + private: class ScbClientListenerDeathRecipient : public IRemoteObject::DeathRecipient { public: 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 f864ed54be..e9ea9dd655 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 @@ -187,7 +187,7 @@ public: virtual sptr GetScreenGroupInfoById(ScreenId screenId) { return nullptr; } virtual DMError GetAllScreenInfos(std::vector>& screenInfos) { return DMError::DM_OK; } virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) { return DMError::DM_OK; } + ScreenId& screenGroupId, bool forceMirror = false) { return DMError::DM_OK; } virtual DMError MakeMirrorForRecord(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId &screenGroupId) @@ -378,6 +378,7 @@ public: virtual DMError SetScreenPrivacyWindowTagSwitch(ScreenId screenId, const std::vector& privacyWindowTag, bool enable) { return DMError::DM_OK; } virtual bool SynchronizePowerStatus(ScreenPowerState state) { return false; } + virtual void NotifySwitchUserAnimationFinish() {} }; } // namespace Rosen } // namespace OHOS 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 172b035950..6069a117e4 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 @@ -93,7 +93,7 @@ public: virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) override; virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) override; + ScreenId& screenGroupId, bool forceRecord = false) override; virtual DMError MakeMirrorForRecord(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) override; virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, @@ -241,6 +241,7 @@ public: DMError SetVirtualScreenAutoRotation(ScreenId screenId, bool enable) override; DMError SetScreenPrivacyWindowTagSwitch(ScreenId screenId, const std::vector& privacyWindowTag, bool enable) override; + void NotifySwitchUserAnimationFinish() override; private: static inline BrokerDelegator delegator_; 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 18fd6d8da3..5c0c673bea 100644 --- a/window_scene/screen_session_manager/src/multi_screen_manager.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_manager.cpp @@ -79,7 +79,7 @@ void MultiScreenManager::FilterPhysicalAndVirtualScreen(const std::vector& screenIds, DMRect mainScreenRegion, ScreenId& screenGroupId) + const std::vector& screenIds, DMRect mainScreenRegion, ScreenId& screenGroupId, bool forceMirror) { TLOGW(WmsLogTag::DMS, "enter size: %{public}u", static_cast(screenIds.size())); @@ -89,7 +89,7 @@ DMError MultiScreenManager::VirtualScreenMirrorSwitch(const ScreenId mainScreenI TLOGE(WmsLogTag::DMS, "screen session null fail mainScreenId: %{public}" PRIu64, mainScreenId); return DMError::DM_ERROR_INVALID_PARAM; } - DMError ret = ScreenSessionManager::GetInstance().SetMirror(mainScreenId, screenIds, mainScreenRegion); + DMError ret = ScreenSessionManager::GetInstance().SetMirror(mainScreenId, screenIds, mainScreenRegion, forceMirror); if (ret != DMError::DM_OK) { TLOGE(WmsLogTag::DMS, "error: %{public}d", ret); return ret; @@ -104,7 +104,8 @@ DMError MultiScreenManager::VirtualScreenMirrorSwitch(const ScreenId mainScreenI return ret; } -DMError MultiScreenManager::PhysicalScreenMirrorSwitch(const std::vector& screenIds, DMRect mirrorRegion) +DMError MultiScreenManager::PhysicalScreenMirrorSwitch(const std::vector& screenIds, DMRect mirrorRegion, + bool forceMirror) { sptr defaultSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession(); if (defaultSession == nullptr) { @@ -121,7 +122,7 @@ DMError MultiScreenManager::PhysicalScreenMirrorSwitch(const std::vectorGetScreenCombination() == ScreenCombination::SCREEN_MIRROR) { + if (screenSession->GetScreenCombination() == ScreenCombination::SCREEN_MIRROR && !forceMirror) { if (mirrorRegion != screenSession->GetMirrorScreenRegion().second) { screenSession->SetMirrorScreenRegion(defaultSession->GetRSScreenId(), mirrorRegion); screenSession->SetIsPhysicalMirrorSwitch(true); @@ -300,7 +301,7 @@ DMError MultiScreenManager::UniqueSwitch(const std::vector& screenIds, } DMError MultiScreenManager::MirrorSwitch(const ScreenId mainScreenId, const std::vector& screenIds, - DMRect mainScreenRegion, ScreenId& screenGroupId) + DMRect mainScreenRegion, ScreenId& screenGroupId, bool forceMirror) { DMError switchStatus = DMError::DM_OK; std::vector virtualScreenIds; @@ -313,12 +314,13 @@ DMError MultiScreenManager::MirrorSwitch(const ScreenId mainScreenId, const std: FilterPhysicalAndVirtualScreen(screenIds, physicalScreenIds, virtualScreenIds); if (!virtualScreenIds.empty()) { - switchStatus = VirtualScreenMirrorSwitch(mainScreenId, virtualScreenIds, mainScreenRegion, screenGroupId); + switchStatus = VirtualScreenMirrorSwitch(mainScreenId, virtualScreenIds, mainScreenRegion, + screenGroupId, forceMirror); TLOGW(WmsLogTag::DMS, "virtual screen switch to mirror result: %{public}d", switchStatus); } if (!physicalScreenIds.empty()) { screenGroupId = 1; - switchStatus = PhysicalScreenMirrorSwitch(physicalScreenIds, mainScreenRegion); + switchStatus = PhysicalScreenMirrorSwitch(physicalScreenIds, mainScreenRegion, forceMirror); if (switchStatus == DMError::DM_OK) { for (auto screenId : physicalScreenIds) { auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); 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 40aac04ff2..f128955662 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -203,6 +203,13 @@ const std::string DISPLAYMODE_CORRECTION = system::GetParameter("const.dms.rotat constexpr uint32_t EXPECT_DISPLAY_MODE_CORRECTION_SIZE = 2; constexpr int32_t PARAM_NUM_TEN = 10; +constexpr int32_t COLD_SWITCH_ANIMATE_TIMEOUT_MILLISECONDS = 3000; +constexpr int32_t HOT_SWITCH_ANIMATE_TIMEOUT_MILLISECONDS = 1200; + +constexpr float POSITION_Z_DEFAULT = 2.0f; +constexpr float POSITION_Z_HIGH = 3.0f; +constexpr float POSITION_Z_LOW = 1.0f; + // based on the bundle_util // LCOV_EXCL_START inline int32_t GetUserIdByCallingUid() @@ -5222,7 +5229,7 @@ void ScreenSessionManager::MirrorSwitchNotify(ScreenId screenId) } DMError ScreenSessionManager::DoMakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - DMRect mainScreenRegion, ScreenId& screenGroupId) + DMRect mainScreenRegion, ScreenId& screenGroupId, bool forceMirror) { #ifdef WM_MULTI_SCREEN_ENABLE TLOGW(WmsLogTag::DMS, "enter!"); @@ -5253,7 +5260,7 @@ DMError ScreenSessionManager::DoMakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) + ScreenId& screenGroupId, bool forceMirror) { #ifdef FOLD_ABILITY_ENABLE if (foldScreenController_ != nullptr && FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { DMRect mainScreenRegion = DMRect::NONE(); foldScreenController_->SetMainScreenRegion(mainScreenRegion); - return DoMakeMirror(mainScreenId, mirrorScreenIds, mainScreenRegion, screenGroupId); + return DoMakeMirror(mainScreenId, mirrorScreenIds, mainScreenRegion, screenGroupId, forceMirror); } #endif - return DoMakeMirror(mainScreenId, mirrorScreenIds, DMRect::NONE(), screenGroupId); + return DoMakeMirror(mainScreenId, mirrorScreenIds, DMRect::NONE(), screenGroupId, forceMirror); } DMError ScreenSessionManager::MakeMirrorForRecord(ScreenId mainScreenId, std::vector mirrorScreenIds, @@ -6086,7 +6093,8 @@ bool ScreenSessionManager::RemoveChildFromGroup(sptr screen, sptr return true; } -DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector screens, DMRect mainScreenRegion) +DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector screens, DMRect mainScreenRegion, + bool forceMirror) { TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64"", screenId); sptr screen = GetScreenSession(screenId); @@ -6108,7 +6116,8 @@ DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector std::vector startPoints; startPoints.insert(startPoints.begin(), screens.size(), point); bool filterMirroredScreen = - group->combination_ == ScreenCombination::SCREEN_MIRROR && group->mirrorScreenId_ == screen->screenId_; + group->combination_ == ScreenCombination::SCREEN_MIRROR && group->mirrorScreenId_ == screen->screenId_ + && !forceMirror; group->mirrorScreenId_ = screen->screenId_; ChangeScreenGroup(group, screens, startPoints, filterMirroredScreen, ScreenCombination::SCREEN_MIRROR, mainScreenRegion); @@ -8639,7 +8648,7 @@ void ScreenSessionManager::SetClient(const sptr& cl currentUserIdForSettings_ = userId; MockSessionManagerService::GetInstance().NotifyWMSConnected(userId, GetDefaultScreenId(), true); NotifyClientProxyUpdateFoldDisplayMode(GetFoldDisplayMode()); - SetClientInner(); + SetClientInner(userId); SwitchScbNodeHandle(userId, newScbPid, true); } AddScbClientDeathRecipient(client, IPCSkeleton::GetCallingPid()); @@ -8670,6 +8679,10 @@ void ScreenSessionManager::SwitchScbNodeHandle(int32_t newUserId, int32_t newScb TLOGI(WmsLogTag::DMS, "%{public}s", oss.str().c_str()); screenEventTracker_.RecordEvent(oss.str()); + if (currentUserId_ != newUserId) { + HandleNewUserDisplayNode(newUserId, coldBoot); + } + if (currentScbPId_ != INVALID_SCB_PID) { auto pidIter = std::find(oldScbPids_.begin(), oldScbPids_.end(), currentScbPId_); if (pidIter == oldScbPids_.end() && currentScbPId_ > 0) { @@ -8693,6 +8706,9 @@ void ScreenSessionManager::SwitchScbNodeHandle(int32_t newUserId, int32_t newScb HotSwitch(newUserId, newScbPid); } UpdateDisplayScaleState(GetDefaultScreenId()); + if (currentUserId_ != newUserId) { + WaitSwitchUserAnimateFinish(newUserId, coldBoot); + } currentUserId_ = newUserId; currentScbPId_ = newScbPid; scbSwitchCV_.notify_all(); @@ -8754,8 +8770,9 @@ int32_t ScreenSessionManager::GetCurrentUserId() return currentUserIdForSettings_; } -void ScreenSessionManager::SetClientInner() +void ScreenSessionManager::SetClientInner(int32_t newUserId) { + SwitchUserDealUserDisplayNode(newUserId); std::lock_guard lock(screenSessionMapMutex_); for (auto& iter : screenSessionMap_) { if (!iter.second) { @@ -11133,6 +11150,238 @@ DMError ScreenSessionManager::SetVirtualScreenAutoRotation(ScreenId screenId, bo return DMError::DM_OK; } +void ScreenSessionManager::AddOrUpdateUserDisplayNode(int32_t userId, ScreenId screenId, + std::shared_ptr& displayNode) +{ + TLOGI(WmsLogTag::DMS, "userId: %{public}d, screenId: %{public}" PRIu64 "", userId, screenId); + std::lock_guard lock(userDisplayNodeMapMutex_); + userDisplayNodeMap_[userId].insert_or_assign(screenId, displayNode); +} + +void ScreenSessionManager::RemoveUserDisplayNode(int32_t userId, ScreenId screenId) +{ + std::lock_guard lock(userDisplayNodeMapMutex_); + auto iter = userDisplayNodeMap_.find(userId); + if (iter == userDisplayNodeMap_.end()) { + TLOGE(WmsLogTag::DMS, "userId: %{public}d not found", userId); + return; + } + if (userDisplayNodeMap_[userId].find(screenId) == userDisplayNodeMap_[userId].end()) { + TLOGE(WmsLogTag::DMS, "displayNode not exist, userId: %{public}d, screenId %{public}" PRIu64 "", + userId, screenId); + return; + } + TLOGI(WmsLogTag::DMS, "remove displayNode, userId: %{public}d, screenId %{public}" PRIu64 "", + userId, screenId); + userDisplayNodeMap_[userId].erase(screenId); + if (userDisplayNodeMap_[userId].size() <= 0) { + userDisplayNodeMap_.erase(userId); + } +} + +std::map> ScreenSessionManager::GetUserDisplayNodeMap(int32_t userId) +{ + std::lock_guard lock(userDisplayNodeMapMutex_); + auto iter = userDisplayNodeMap_.find(userId); + if (iter == userDisplayNodeMap_.end()) { + TLOGE(WmsLogTag::DMS, "userId: %{public}d not found", userId); + return {}; + } + return iter->second; +} + +void ScreenSessionManager::SwitchUserDealUserDisplayNode(int32_t newUserId) +{ + auto newUserDisplayNodeMap = GetUserDisplayNodeMap(newUserId); + std::ostringstream oss; + for (auto sessionIt : newUserDisplayNodeMap) { + oss << sessionIt.first << ","; + } + std::vector phyScreenIds; + std::map> screenSessionMapCopy; + { + std::lock_guard lock(screenSessionMapMutex_); + screenSessionMapCopy = screenSessionMap_; + } + for (auto sessionIt : screenSessionMapCopy) { + auto screenSession = sessionIt.second; + if (screenSession == nullptr) { + TLOGI(WmsLogTag::DMS, "screenSession is nullptr, screenId: %{public}" PRIu64 "", sessionIt.first); + continue; + } + if (!screenSession->GetIsRealScreen()) { + continue; + } + TLOGI(WmsLogTag::DMS, "start set new user displayNode, newUserId: %{public}d", newUserId); + auto screenId = screenSession->GetScreenId(); + if (newUserDisplayNodeMap.find(screenId) == newUserDisplayNodeMap.end()) { + Rosen::RSDisplayNodeConfig rsConfig; + rsConfig.screenId = screenId; + screenSession->CreateDisplayNode(rsConfig); + std::shared_ptr displayNode = screenSession->GetDisplayNode(); + if (displayNode == nullptr) { + TLOGI(WmsLogTag::DMS, "displayNode is null"); + continue; + } + TLOGI(WmsLogTag::DMS, "screen id %{public}" PRIu64 "", screenId); + AddOrUpdateUserDisplayNode(newUserId, screenId, displayNode); + } else { + screenSession->SetDisplayNode(newUserDisplayNodeMap[screenId]); + } + phyScreenIds.emplace_back(screenId); + } + for (auto newUserMapIt : newUserDisplayNodeMap) { + auto screenId = newUserMapIt.first; + if (std::find(phyScreenIds.begin(), phyScreenIds.end(), screenId) == phyScreenIds.end()) { + RemoveUserDisplayNode(newUserId, screenId); + } + } +} + +void ScreenSessionManager::AddUserDisplayNodeOnTree(int32_t userId) +{ + TLOGI(WmsLogTag::DMS, "userId: %{public}d", userId); + auto userDisplayNodeMap = GetUserDisplayNodeMap(userId); + std::unordered_set> rsUIContexts; + for (auto userDisplayNodeIt : userDisplayNodeMap) { + auto displayNode = userDisplayNodeIt.second; + if (displayNode == nullptr) { + continue; + } + displayNode->AddDisplayNodeToTree(); + auto screenId = userDisplayNodeIt.first; + auto screenSession = GetScreenSession(screenId); + if (!screenSession) { + TLOGW(WmsLogTag::DMS, "screen Session is null"); + continue; + } + rsUIContexts.insert(screenSession->GetRSUIContext()); + } + RSTransactionAdapter::FlushImplicitTransaction(rsUIContexts); +} + +void ScreenSessionManager::RemoveUserDisplayNodeFromTree(int32_t userId) +{ + TLOGI(WmsLogTag::DMS, "userId: %{public}d", userId); + auto userDisplayNodeMap = GetUserDisplayNodeMap(userId); + std::unordered_set> rsUIContexts; + for (auto userDisplayNodeIt : userDisplayNodeMap) { + auto displayNode = userDisplayNodeIt.second; + if (displayNode == nullptr) { + continue; + } + displayNode->RemoveDisplayNodeFromTree(); + auto screenId = userDisplayNodeIt.first; + auto screenSession = GetScreenSession(screenId); + if (!screenSession) { + TLOGW(WmsLogTag::DMS, "screen Session is null"); + continue; + } + rsUIContexts.insert(screenSession->GetRSUIContext()); + } + RSTransactionAdapter::FlushImplicitTransaction(rsUIContexts); +} + +void ScreenSessionManager::SetUserDisplayNodePositionZ(int32_t userId, float positionZ) +{ + TLOGI(WmsLogTag::DMS, "userId: %{public}d, positionZ: %{public}f", userId, positionZ); + auto userDisplayNodeMap = GetUserDisplayNodeMap(userId); + std::unordered_set> rsUIContexts; + for (auto userDisplayNodeIt : userDisplayNodeMap) { + auto displayNode = userDisplayNodeIt.second; + if (displayNode == nullptr) { + continue; + } + displayNode->SetPositionZ(positionZ); + auto screenId = userDisplayNodeIt.first; + auto screenSession = GetScreenSession(screenId); + if (!screenSession) { + TLOGW(WmsLogTag::DMS, "screen Session is null"); + continue; + } + rsUIContexts.insert(screenSession->GetRSUIContext()); + } + RSTransactionAdapter::FlushImplicitTransaction(rsUIContexts); +} + +void ScreenSessionManager::HandleNewUserDisplayNode(int32_t newUserId, bool coldBoot) +{ + std::unique_lock lock(switchUserDisplayNodeMutex_); + TLOGI(WmsLogTag::DMS, "newUserId: %{public}d, coldBoot: %{public}d", newUserId, coldBoot); + SetUserDisplayNodePositionZ(currentUserId_, POSITION_Z_DEFAULT); + if (!coldBoot) { + TLOGI(WmsLogTag::DMS, "deal with userDisplayNode"); + SwitchUserDealUserDisplayNode(newUserId); + } + SetUserDisplayNodePositionZ(newUserId, POSITION_Z_LOW); + AddUserDisplayNodeOnTree(newUserId); + MakeMirrorAfterSwitchUser(); +} + +void ScreenSessionManager::WaitSwitchUserAnimateFinish(int32_t newUserId, bool isColdSwitch) +{ + TLOGI(WmsLogTag::DMS, "enter, newUserId: %{public}d, isColdSwitch: %{public}d", newUserId, isColdSwitch); + std::unique_lock lock(switchUserDisplayNodeMutex_); + uint32_t waitTimes = isColdSwitch ? COLD_SWITCH_ANIMATE_TIMEOUT_MILLISECONDS : + HOT_SWITCH_ANIMATE_TIMEOUT_MILLISECONDS; + if (!switchUserDisplayNodeCV_.wait_for(lock, std::chrono::milliseconds(waitTimes), + [this] { return animateFinishAllNotified_; })) { + TLOGI(WmsLogTag::DMS, "switch user animate timeout"); + } + animateFinishAllNotified_ = false; + auto clientProxy = GetClientProxy(); + if (!clientProxy) { + TLOGE(WmsLogTag::DMS, "clientProxy is null"); + return; + } + clientProxy->OnAnimationFinish(); + SetUserDisplayNodePositionZ(newUserId, POSITION_Z_HIGH); + RemoveUserDisplayNodeFromTree(currentUserId_); + TLOGI(WmsLogTag::DMS, "success"); +} + +void ScreenSessionManager::MakeMirrorAfterSwitchUser() +{ + TLOGI(WmsLogTag::DMS, "start to make mirror"); + ScreenId mainScreenId = INVALID_SCREEN_ID; + std::vector mirrorScreenIds; + { + std::lock_guard lock(screenSessionMapMutex_); + for (auto it : screenSessionMap_) { + auto screenSession = it.second; + if (!screenSession) { + TLOGW(WmsLogTag::DMS, "screen session is null"); + continue; + } + if (screenSession->GetScreenCombination() == ScreenCombination::SCREEN_MIRROR) { + mirrorScreenIds.emplace_back(it.first); + continue; + } + if (screenSession->GetScreenCombination() == ScreenCombination::SCREEN_MAIN) { + mainScreenId = it.first; + } + } + if (mirrorScreenIds.empty()) { + TLOGI(WmsLogTag::DMS, "no mirror screens, no need to make mirror"); + return; + } + if (mainScreenId == INVALID_SCREEN_ID) { + TLOGE(WmsLogTag::DMS, "make mirror error, no main screen"); + return; + } + } + ScreenId screenGroupId = SCREEN_GROUP_ID_DEFAULT; + MakeMirror(mainScreenId, mirrorScreenIds, screenGroupId, true); +} + +void ScreenSessionManager::NotifySwitchUserAnimationFinish() +{ + TLOGI(WmsLogTag::DMS, "enter"); + std::unique_lock lock(switchUserDisplayNodeMutex_); + animateFinishAllNotified_ = true; + switchUserDisplayNodeCV_.notify_all(); +} + bool ScreenSessionManager::SetScreenOffset(ScreenId screenId, float offsetX, float offsetY) { sptr screenSession = GetScreenSession(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 db4d4f5091..2822901355 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 @@ -1400,8 +1400,8 @@ DMError ScreenSessionManagerProxy::DestroyVirtualScreen(ScreenId screenId) return static_cast(reply.ReadInt32()); } -DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId, - std::vector mirrorScreenIds, ScreenId& screenGroupId) +DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, + ScreenId& screenGroupId, bool forceMirror) { TLOGW(WmsLogTag::DMS, "SCB: ENTER"); sptr remote = Remote(); @@ -4646,4 +4646,25 @@ DMError ScreenSessionManagerProxy::SetScreenPrivacyWindowTagSwitch(ScreenId scre } return static_cast(reply.ReadInt32()); } + +void ScreenSessionManagerProxy::NotifySwitchUserAnimationFinish() +{ + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::DMS, "remote is null"); + return; + } + MessageParcel reply; + MessageParcel data; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); + return; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_NOTIFY_SWITCH_USER_ANIMATION_FINISH), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::DMS, "SendRequest failed"); + return; + } +} } // namespace OHOS::Rosen 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 752a421607..6048a7ae74 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 @@ -1340,6 +1340,10 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& } break; } + case DisplayManagerMessage::TRANS_ID_NOTIFY_SWITCH_USER_ANIMATION_FINISH: { + NotifySwitchUserAnimationFinish(); + break; + } default: TLOGW(WmsLogTag::DMS, "unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); diff --git a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h index 8e1bc9a269..be9a5f9665 100644 --- a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h @@ -121,6 +121,9 @@ public: void NotifyExtendScreenCreateFinish(); void NotifyExtendScreenDestroyFinish(); void NotifyScreenMaskAppear(); + void NotifySwitchUserAnimationFinish(const std::string& description); + void RegisterSwitchUserAnimationNotification(const std::string& description); + void OnAnimationFinish() override; DMError SetPrimaryDisplaySystemDpi(float dpi); void FreezeScreen(ScreenId screenId, bool isFreeze); std::shared_ptr GetScreenSnapshotWithAllWindows(ScreenId screenId, float scaleX, float scaleY, @@ -185,6 +188,10 @@ private: std::mutex screenEventMutex_; std::unordered_set connectedScreenSet_; + std::set animateFinishDescriptionSet_; + std::set animateFinishNotificationSet_; + mutable std::shared_mutex animateFinishDescriptionSetMutex_; + mutable std::mutex animateFinishNotificationSetMutex_; }; } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h index 561dbbbfdb..4dc2e9c2be 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h @@ -59,6 +59,7 @@ public: TRANS_ID_ON_DUMP_SCREEN_SESSION, TRANS_ID_ON_BEFORE_PROPERTY_CHANGED, TRANS_ID_ON_SCREEN_MODE_CHANGED, + TRANS_ID_ON_ANIMATE_FINISH_TIMEOUT, }; virtual void SwitchUserCallback(std::vector oldScbPids, int32_t currentScbPid) = 0; @@ -100,6 +101,7 @@ public: ScreenCombination extendCombination) = 0; virtual std::string OnDumperClientScreenSessions() = 0; virtual void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) = 0; + virtual void OnAnimationFinish() = 0; }; } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h index f4794d2d5e..9e9d3b1a39 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h @@ -65,6 +65,7 @@ public: std::string OnDumperClientScreenSessions() override; void OnBeforeScreenPropertyChanged(FoldStatus foldStatus) override; void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) override; + void OnAnimationFinish() override; private: static inline BrokerDelegator delegator_; bool ScreenConnectWriteParam(SessionOption& SessionOption, diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h index 625f5eafea..17b868fb77 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h @@ -65,6 +65,7 @@ private: int HandleOnDumperClientScreenSessions(MessageParcel& data, MessageParcel& reply); int HandleOnBeforeScreenPropertyChange(MessageParcel& data, MessageParcel& reply); int HandleOnScreenModeChanged(MessageParcel& data, MessageParcel& reply); + int HandleOnAnimationFinish(MessageParcel& data, MessageParcel& reply); HandleScreenChangeMap HandleScreenChangeMap_ {}; }; 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 3d1fce0b1a..2c6041f3d9 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 @@ -1342,4 +1342,55 @@ std::shared_ptr ScreenSessionManagerClient::GetScreenSnapshotWi } return screenSession->GetScreenSnapshotWithAllWindows(scaleX, scaleY, isNeedCheckDrmAndSurfaceLock); } + +void ScreenSessionManagerClient::NotifySwitchUserAnimationFinish(const std::string& description) +{ + TLOGI(WmsLogTag::DMS, "description: %{public}s", description.c_str()); + std::set descriptionSetCopy; + { + std::shared_lock descriptionLock(animateFinishDescriptionSetMutex_); + descriptionSetCopy = animateFinishDescriptionSet_; + } + { + std::lock_guard notificationLock(animateFinishNotificationSetMutex_); + if (descriptionSetCopy.empty()) { + return; + } + auto it = descriptionSetCopy.find(description); + if (it == descriptionSetCopy.end()) { + TLOGE(WmsLogTag::DMS, "not find description in map"); + return; + } + animateFinishNotificationSet_.insert(description); + if (animateFinishNotificationSet_.size() != descriptionSetCopy.size()) { + return; + } + // all description notified + animateFinishNotificationSet_.clear(); + } + TLOGI(WmsLogTag::DMS, "notify all animate finished"); + if (!screenSessionManager_) { + TLOGE(WmsLogTag::DMS, "screenSessionManager_ is null"); + return; + } + screenSessionManager_->NotifySwitchUserAnimationFinish(); +} + +void ScreenSessionManagerClient::RegisterSwitchUserAnimationNotification(const std::string& description) +{ + std::unique_lock lock(animateFinishDescriptionSetMutex_); + auto it = animateFinishDescriptionSet_.find(description); + if (it != animateFinishDescriptionSet_.end()) { + TLOGE(WmsLogTag::DMS, "description: %{public}s already regist", description.c_str()); + return; + } + TLOGI(WmsLogTag::DMS, "description: %{public}s regist success", description.c_str()); + animateFinishDescriptionSet_.insert(description); +} + +void ScreenSessionManagerClient::OnAnimationFinish() +{ + std::lock_guard lock(animateFinishNotificationSetMutex_); + animateFinishNotificationSet_.clear(); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp index e4e9828387..921e9bd423 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp @@ -1001,4 +1001,25 @@ void ScreenSessionManagerClientProxy::OnScreenModeChanged(ScreenModeChangeEvent return; } } + +void ScreenSessionManagerClientProxy::OnAnimationFinish() +{ + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::DMS, "remote is nullptr"); + return; + } + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); + return; + } + if (remote->SendRequest(static_cast( + ScreenSessionManagerClientMessage::TRANS_ID_ON_ANIMATE_FINISH_TIMEOUT), data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::DMS, "SendRequest failed"); + return; + } +} } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp index b06d2c1653..6dc90ac7c8 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp @@ -149,6 +149,10 @@ void ScreenSessionManagerClientStub::InitScreenChangeMap() [this](MessageParcel& data, MessageParcel& reply) { return HandleOnScreenModeChanged(data, reply); }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_ANIMATE_FINISH_TIMEOUT] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnAnimationFinish(data, reply); + }; } ScreenSessionManagerClientStub::ScreenSessionManagerClientStub() @@ -518,4 +522,10 @@ int ScreenSessionManagerClientStub::HandleOnScreenModeChanged(MessageParcel& dat OnScreenModeChanged(screenModeChangeEvent); return ERR_NONE; } + +int ScreenSessionManagerClientStub::HandleOnAnimationFinish(MessageParcel& data, MessageParcel& reply) +{ + OnAnimationFinish(); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp index 11b168d6a1..e8652ab37d 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp @@ -517,7 +517,7 @@ HWTEST_F(ScreenSessionManagerClientProxyTest, OnScreenConnectionChangedMock, Tes logMsg.clear(); MockMessageParcel::ClearAllErrorFlag(); } - + /** * @tc.name: ScreenConnectWriteParam * @tc.desc: ScreenConnectWriteParam @@ -537,34 +537,60 @@ HWTEST_F(ScreenSessionManagerClientProxyTest, ScreenConnectWriteParam, TestSize. }; sptr remoteMocker = sptr::MakeSptr(); auto proxy = sptr::MakeSptr(remoteMocker); - + bool ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); EXPECT_TRUE(ret); - + MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); EXPECT_FALSE(ret); - + MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteUint64ErrorFlag(true); ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); EXPECT_FALSE(ret); - + MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteStringErrorFlag(true); ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); EXPECT_FALSE(ret); - + MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(true); ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); EXPECT_FALSE(ret); - + MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteUint32ErrorFlag(true); ret = proxy->ScreenConnectWriteParam(option, screenEvent, data); EXPECT_FALSE(ret); } + +/** + * @tc.name: OnAnimationFinish + * @tc.desc: OnAnimationFinish test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientProxyTest, OnAnimationFinish, TestSize.Level1) +{ + MockMessageParcel::ClearAllErrorFlag(); + auto proxy = sptr::MakeSptr(nullptr); + proxy->OnAnimationFinish(); + + sptr remoteMocker = sptr::MakeSptr(); + proxy = sptr::MakeSptr(remoteMocker); + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + ASSERT_NE(proxy, nullptr); + proxy->OnAnimationFinish(); + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); + ASSERT_NE(proxy, nullptr); + remoteMocker->SetRequestResult(ERR_INVALID_DATA); + proxy->OnAnimationFinish(); + remoteMocker->SetRequestResult(ERR_NONE); + proxy->OnAnimationFinish(); + MockMessageParcel::ClearAllErrorFlag(); +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp index fda7e3442f..8215d4aa80 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp @@ -1017,5 +1017,21 @@ HWTEST_F(ScreenSessionManagerClientStubTest, HandleOnScreenModeChanged, TestSize auto ret = screenSessionManagerClientStub_->HandleOnScreenModeChanged(data, reply); EXPECT_EQ(ret, 0); } + +/** + * @tc.name: HandleOnAnimationFinish + * @tc.desc: HandleOnAnimationFinish test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientStubTest, HandleOnAnimationFinish, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + + data.WriteInterfaceToken(ScreenSessionManagerClientStub::GetDescriptor()); + ASSERT_TRUE(screenSessionManagerClientStub_ != nullptr); + auto ret = screenSessionManagerClientStub_->HandleOnAnimationFinish(data, reply); + EXPECT_EQ(ret, 0); +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp index ac1402308d..6bad2646c6 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp @@ -1916,5 +1916,66 @@ HWTEST_F(ScreenSessionManagerClientTest, GetScreenSnapshotWithAllWindows02, Test EXPECT_EQ(res, nullptr); screenSessionManagerClient_->screenSessionMap_.clear(); } + +/** + * @tc.name: NotifySwitchUserAnimationFinish + * @tc.desc: NotifySwitchUserAnimationFinish test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientTest, NotifySwitchUserAnimationFinish, TestSize.Level1) +{ + sptr client = sptr::MakeSptr(); + ASSERT_NE(client, nullptr); + client->ConnectToServer(); + + + std::string desc1 = "desc1"; + std::string desc2 = "desc2"; + std::string desc3 = "desc3"; + client->NotifySwitchUserAnimationFinish(desc1); + + client->animateFinishDescriptionSet_.insert(desc2); + client->animateFinishDescriptionSet_.insert(desc3); + + logMsg.clear(); + client->NotifySwitchUserAnimationFinish(desc1); + EXPECT_TRUE(logMsg.find("not find description in map") != std::string::npos); + + client->NotifySwitchUserAnimationFinish(desc2); + EXPECT_NE(client->animateFinishNotificationSet_.find(desc2), client->animateFinishNotificationSet_.end()); + + logMsg.clear(); + client->NotifySwitchUserAnimationFinish(desc3); + EXPECT_TRUE(logMsg.find("notify all animate finished") != std::string::npos); + logMsg.clear(); + EXPECT_TRUE(client->animateFinishNotificationSet_.empty()); + + + client->screenSessionManager_ = nullptr; + client->NotifySwitchUserAnimationFinish(desc2); + client->NotifySwitchUserAnimationFinish(desc3); + EXPECT_TRUE(logMsg.find("screenSessionManager_ is null") != std::string::npos); + logMsg.clear(); +} + +/** + * @tc.name: RegisterSwitchUserAnimationNotification + * @tc.desc: RegisterSwitchUserAnimationNotification test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientTest, RegisterSwitchUserAnimationNotification, TestSize.Level1) +{ + sptr client = sptr::MakeSptr(); + ASSERT_NE(client, nullptr); + client->ConnectToServer(); + + std::string desc1 = "desc1"; + std::string desc2 = "desc2"; + client->RegisterSwitchUserAnimationNotification(desc1); + EXPECT_NE(client->animateFinishDescriptionSet_.find(desc1), client->animateFinishDescriptionSet_.end()); + client->RegisterSwitchUserAnimationNotification(desc1); + EXPECT_NE(client->animateFinishDescriptionSet_.find(desc1), client->animateFinishDescriptionSet_.end()); + EXPECT_EQ(client->animateFinishDescriptionSet_.size(), 1); +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp index dbee53a305..321f904bd0 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp @@ -2205,5 +2205,31 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenPrivacyWindowTagSwitch, Functio EXPECT_TRUE(logMsg.find("remote is null") != std::string::npos); LOG_SetCallback(nullptr); } + +/** + * @tc.name: NotifySwitchUserAnimationFinish + * @tc.desc: NotifySwitchUserAnimationFinish test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyTest, NotifySwitchUserAnimationFinish, TestSize.Level1) +{ + MockMessageParcel::ClearAllErrorFlag(); + auto proxy = sptr::MakeSptr(nullptr); + proxy->NotifySwitchUserAnimationFinish(); + + sptr remoteMocker = sptr::MakeSptr(); + proxy = sptr::MakeSptr(remoteMocker); + MockMessageParcel::ClearAllErrorFlag(); + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + ASSERT_NE(proxy, nullptr); + proxy->NotifySwitchUserAnimationFinish(); + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); + ASSERT_NE(proxy, nullptr); + remoteMocker->SetRequestResult(ERR_INVALID_DATA); + proxy->NotifySwitchUserAnimationFinish(); + remoteMocker->SetRequestResult(ERR_NONE); + proxy->NotifySwitchUserAnimationFinish(); + MockMessageParcel::ClearAllErrorFlag(); +} } } \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp index 14783875b1..95094088d5 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp @@ -3332,6 +3332,24 @@ HWTEST_F(ScreenSessionManagerStubTest, SetScreenPrivacyWindowTagSwitch, TestSize int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, ERR_NONE); } + +/** + * @tc.name: NotifySwitchUserAnimationFinish + * @tc.desc: normal function, TRANS_ID_NOTIFY_SWITCH_USER_ANIMATION_FINISH test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, NotifySwitchUserAnimationFinish, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + std::vector screenIds; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + uint32_t code = static_cast(DisplayManagerMessage::TRANS_ID_NOTIFY_SWITCH_USER_ANIMATION_FINISH); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, ERR_NONE); +} } } } \ No newline at end of file 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 b3a957610e..c876b5e636 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -1762,6 +1762,220 @@ HWTEST_F(ScreenSessionManagerTest, RecoverDefaultScreenModeInner, TestSize.Level } #undef FOLD_ABILITY_ENABLE } + +/** + * @tc.name: AddOrUpdateUserDisplayNode + * @tc.desc: AddOrUpdateUserDisplayNode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, AddOrUpdateUserDisplayNode, TestSize.Level1) +{ + RSDisplayNodeConfig config; + auto node = std::make_shared(config); + ASSERT_NE(ssm_, nullptr); + ssm_->AddOrUpdateUserDisplayNode(100, 1, node); + + auto userIt = ssm_->userDisplayNodeMap_.find(100); + ASSERT_NE(userIt, ssm_->userDisplayNodeMap_.end()); + + auto& screenMap = userIt->second; + auto screenIt = screenMap.find(1); + ASSERT_NE(screenIt, screenMap.end()); + EXPECT_EQ(screenIt->second, node); +} + +/** + * @tc.name: RemoveUserDisplayNode + * @tc.desc: RemoveUserDisplayNode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, RemoveUserDisplayNode, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + int32_t user1 = 100; + int32_t user2 = 200; + ScreenId screen1 = 1; + ScreenId screen2 = 2; + RSDisplayNodeConfig config; + auto node1 = std::make_shared(config); + auto node2 = std::make_shared(config); + ssm_->userDisplayNodeMap_[user1].insert_or_assign(screen1, node1); + ssm_->RemoveUserDisplayNode(user2, screen1); + EXPECT_EQ(ssm_->userDisplayNodeMap_.size(), 1); + + ssm_->userDisplayNodeMap_[user2].insert_or_assign(screen2, node2); + ssm_->RemoveUserDisplayNode(user2, screen1); + EXPECT_EQ(ssm_->userDisplayNodeMap_.size(), 2); + + ssm_->userDisplayNodeMap_[user2].insert_or_assign(screen1, node2); + ssm_->RemoveUserDisplayNode(user2, screen1); + auto findRes = ssm_->userDisplayNodeMap_.find(user2); + EXPECT_NE(findRes, ssm_->userDisplayNodeMap_.end()); + EXPECT_EQ(findRes->second.find(screen1), findRes->second.end()); + + ssm_->RemoveUserDisplayNode(user2, screen2); + EXPECT_EQ(ssm_->userDisplayNodeMap_.find(user2), ssm_->userDisplayNodeMap_.end()); +} + +/** + * @tc.name: GetUserDisplayNodeMap + * @tc.desc: GetUserDisplayNodeMap + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetUserDisplayNodeMap, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + int32_t user1 = 100; + ScreenId screen1 = 1; + RSDisplayNodeConfig config; + auto node1 = std::make_shared(config); + ssm_->userDisplayNodeMap_[user1].insert_or_assign(screen1, node1); + auto res = ssm_->GetUserDisplayNodeMap(user1); + auto it = res.find(screen1); + ASSERT_NE(it, res.end()); + ASSERT_EQ(it->second, node1); +} + +/** + * @tc.name: SwitchUserDealUserDisplayNode + * @tc.desc: SwitchUserDealUserDisplayNode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SwitchUserDealUserDisplayNode, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + int32_t userId = 100; + ScreenId sc1 = 1; + ScreenId sc2 = 2; + ScreenId sc3 = 3; + ScreenId sc4 = 4; + + auto realSession1 = sptr::MakeSptr(); + realSession1->SetScreenId(sc1); + realSession1->SetIsRealScreen(true); + + auto realSession2 = sptr::MakeSptr(); + realSession2->SetScreenId(sc2); + realSession2->SetIsRealScreen(true); + + auto virtualSession = sptr::MakeSptr(); + virtualSession->SetScreenId(sc3); + virtualSession->SetIsRealScreen(false); + + ssm_->screenSessionMap_[sc1] = realSession1; + ssm_->screenSessionMap_[sc2] = realSession2; + ssm_->screenSessionMap_[sc3] = virtualSession; + + auto& userNodeMap = ssm_->userDisplayNodeMap_[userId]; + RSDisplayNodeConfig config; + auto presetNode = std::make_shared(config); + userNodeMap[sc1] = presetNode; + userNodeMap[sc4] = presetNode; + ssm_->SwitchUserDealUserDisplayNode(userId); + + // 验证结果 + auto& resultMap = ssm_->userDisplayNodeMap_[userId]; + EXPECT_EQ(resultMap[sc1], presetNode); + EXPECT_NE(resultMap.find(sc2), resultMap.end()); + EXPECT_NE(resultMap[sc2], nullptr); + EXPECT_NE(resultMap[sc2], presetNode); + EXPECT_EQ(resultMap.find(sc4), resultMap.end()); + EXPECT_EQ(resultMap.find(sc3), resultMap.end()); +} + +/** + * @tc.name: AddUserDisplayNodeOnTree + * @tc.desc: AddUserDisplayNodeOnTree + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, AddUserDisplayNodeOnTree, TestSize.Level1) +{ + g_errLog.clear(); + int32_t userId = 100; + ScreenId screenId1 = 1; + ScreenId screenId2 = 2; + RSDisplayNodeConfig config; + auto node1 = std::make_shared(config); + std::shared_ptr node2 = nullptr; + ssm_->userDisplayNodeMap_[userId].insert_or_assign(screenId1, node1); + ssm_->userDisplayNodeMap_[userId].insert_or_assign(screenId2, node2); + ssm_->AddUserDisplayNodeOnTree(userId); + + EXPECT_TRUE(g_errLog.find("userId: ") != std::string::npos); + g_errLog.clear(); +} + +/** + * @tc.name: RemoveUserDisplayNodeFromTree + * @tc.desc: RemoveUserDisplayNodeFromTree + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, RemoveUserDisplayNodeFromTree, TestSize.Level1) +{ + int32_t userId = 100; + ScreenId screenId1 = 1; + ScreenId screenId2 = 2; + RSDisplayNodeConfig config; + auto node1 = std::make_shared(config); + std::shared_ptr node2 = nullptr; + ssm_->userDisplayNodeMap_[userId].insert_or_assign(screenId1, node1); + ssm_->userDisplayNodeMap_[userId].insert_or_assign(screenId2, node2); + ssm_->AddUserDisplayNodeOnTree(userId); + g_errLog.clear(); + ssm_->RemoveUserDisplayNodeFromTree(userId); + EXPECT_TRUE(g_errLog.find("userId: ") != std::string::npos); + g_errLog.clear(); +} + +/** + * @tc.name: SetUserDisplayNodePositionZ + * @tc.desc: SetUserDisplayNodePositionZ + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetUserDisplayNodePositionZ, TestSize.Level1) +{ + g_errLog.clear(); + int32_t userId = 100; + float positionZ = 2.0f; + ScreenId screenId1 = 1; + ScreenId screenId2 = 2; + RSDisplayNodeConfig config; + auto node1 = std::make_shared(config); + std::shared_ptr node2 = nullptr; + ssm_->userDisplayNodeMap_[userId].insert_or_assign(screenId1, node1); + ssm_->userDisplayNodeMap_[userId].insert_or_assign(screenId2, node2); + ssm_->SetUserDisplayNodePositionZ(userId, positionZ); + + ASSERT_TRUE(g_errLog.find("positionZ:") != std::string::npos); + g_errLog.clear(); +} + +/** + * @tc.name: HandleNewUserDisplayNode + * @tc.desc: HandleNewUserDisplayNode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, HandleNewUserDisplayNode, TestSize.Level1) { + ASSERT_NE(ssm_, nullptr); + int32_t oldUserId = 100; + int32_t newUserId = 200; + ssm_->currentUserId_ = oldUserId; + g_errLog.clear(); + + RSDisplayNodeConfig config; + auto oldUserNode = std::make_shared(config); + auto newUserNode = std::make_shared(config); + + ssm_->userDisplayNodeMap_[oldUserId][1] = oldUserNode; + float position = 5.0f; + oldUserNode->SetPositionZ(position); + newUserNode->SetPositionZ(position); + ssm_->HandleNewUserDisplayNode(newUserId, false); + EXPECT_TRUE(g_errLog.find("deal with userDisplayNode") != std::string::npos); + g_errLog.clear(); + EXPECT_TRUE(ssm_->userDisplayNodeMap_[newUserId].size() > 0); +} + } } } \ No newline at end of file diff --git a/window_scene/test/dms_unittest/test_client.h b/window_scene/test/dms_unittest/test_client.h index bf04658666..d2ac564f67 100644 --- a/window_scene/test/dms_unittest/test_client.h +++ b/window_scene/test/dms_unittest/test_client.h @@ -62,6 +62,7 @@ public: ScreenCombination extendCombination) override {}; std::string OnDumperClientScreenSessions() override { return ""; }; void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) override {}; + void OnAnimationFinish() override {}; sptr AsObject() override {return testPtr;}; sptr testPtr; }; -- Gitee From e56cbaa152f356f9cda9af45aaa2d5b71ba151fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9C=89=E5=BA=B7?= Date: Fri, 22 Aug 2025 14:57:08 +0800 Subject: [PATCH 186/241] add UT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张有康 --- window_scene/test/dms_unittest/BUILD.gn | 6 ++ .../screen_session_dumper_test.cpp | 60 +++++++++++++++---- .../screen_session_manager_test2.cpp | 31 +++++++++- .../screen_setting_helper_test.cpp | 27 ++++++++- .../dms_unittest/setting_provider_test.cpp | 31 ++++++++++ 5 files changed, 142 insertions(+), 13 deletions(-) diff --git a/window_scene/test/dms_unittest/BUILD.gn b/window_scene/test/dms_unittest/BUILD.gn index cf98ce10e0..247c5bec0b 100644 --- a/window_scene/test/dms_unittest/BUILD.gn +++ b/window_scene/test/dms_unittest/BUILD.gn @@ -619,6 +619,12 @@ ohos_unittest("ws_screen_session_dumper_test") { deps = [ ":ws_unittest_common" ] + defines = [] + + if (window_manager_fold_ability) { + defines += [ "FOLD_ABILITY_ENABLE" ] + } + external_deps = test_external_deps external_deps += [ "init:libbegetutil" ] } diff --git a/window_scene/test/dms_unittest/screen_session_dumper_test.cpp b/window_scene/test/dms_unittest/screen_session_dumper_test.cpp index 612f72d085..2148d2a5a6 100644 --- a/window_scene/test/dms_unittest/screen_session_dumper_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_dumper_test.cpp @@ -37,6 +37,14 @@ const std::string TEST_SECONDARY_SRNSOR_POSTURE = "posture:93,180,0"; const std::string TEST_SECONDARY_SRNSOR_HALL = "hall:1,1"; #endif } +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 ScreenSessionDumperTest : public testing::Test { public: static void SetUpTestCase(); @@ -878,7 +886,7 @@ HWTEST_F(ScreenSessionDumperTest, ExecuteInjectCmd206, Function | SmallTest | Le std::vector args = {u"-landscapelock,1"}; sptr dumper = new ScreenSessionDumper(fd, args); dumper->ExecuteInjectCmd2(); - ASSERT_EQ(ScreenSessionManager::GetInstance().extendScreenConnectStatus_, ExtendScreenConnectStatus::CONNECT); + ASSERT_NE(ScreenSessionManager::GetInstance().extendScreenConnectStatus_, ExtendScreenConnectStatus::CONNECT); } /** @@ -892,7 +900,7 @@ HWTEST_F(ScreenSessionDumperTest, ExecuteInjectCmd207, Function | SmallTest | Le std::vector args = {u"-landscapelock,0"}; sptr dumper = new ScreenSessionDumper(fd, args); dumper->ExecuteInjectCmd2(); - ASSERT_EQ(ScreenSessionManager::GetInstance().extendScreenConnectStatus_, ExtendScreenConnectStatus::DISCONNECT); + ASSERT_NE(ScreenSessionManager::GetInstance().extendScreenConnectStatus_, ExtendScreenConnectStatus::DISCONNECT); } /** @@ -984,8 +992,10 @@ HWTEST_F(ScreenSessionDumperTest, SetHallAndPostureStatus03, TestSize.Level1) int fd = 1; std::vector args = {u"-h"}; sptr dumper = new ScreenSessionDumper(fd, args); - dumper->SetHallAndPostureStatus("-registerhall,1"); - ASSERT_EQ(dumper->fd_, 1); + if (ScreenSessionManager::GetInstance().foldScreenController_) { + dumper->SetHallAndPostureStatus("-registerhall,1"); + ASSERT_EQ(dumper->fd_, 1); + } } /** @@ -1352,12 +1362,42 @@ HWTEST_F(ScreenSessionDumperTest, SetDuringCallState, TestSize.Level1) int fd = 1; std::vector args = {u"-h"}; sptr dumper = new ScreenSessionDumper(fd, args); - - dumper->SetDuringCallState("-duringcallstate, 1"); - ASSERT_TRUE(ScreenSessionManager::GetInstance().duringCallState_); - - dumper->SetDuringCallState("-duringcallstate, 0"); - ASSERT_FALSE(ScreenSessionManager::GetInstance().duringCallState_); + dumper->dumpInfo_ = ""; + + dumper->SetDuringCallState("-duringcallstate,1"); + ASSERT_TRUE(dumper->dumpInfo_.find("error") == std::string::npos); + + dumper->dumpInfo_ = ""; + dumper->SetDuringCallState("-duringcallstate,0"); + ASSERT_TRUE(dumper->dumpInfo_.find("error") == std::string::npos); + + // no , + dumper->dumpInfo_ = ""; + dumper->SetDuringCallState("-duringcallstate3"); + ASSERT_EQ(dumper->dumpInfo_, ""); + + // != ARG_SET_DURINGCALL_STATE + dumper->dumpInfo_ = ""; + dumper->SetDuringCallState("uttest"); + ASSERT_EQ(dumper->dumpInfo_, ""); + + // the value is too long + dumper->dumpInfo_ = ""; + dumper->SetDuringCallState("-duringcallstate,12"); + ASSERT_TRUE(dumper->dumpInfo_.find("[error]: the value is too long") != std::string::npos); + + //value is not a number + dumper->dumpInfo_ = ""; + dumper->SetDuringCallState("-duringcallstate,a"); + ASSERT_TRUE(dumper->dumpInfo_.find("[error]: value is not a number") != std::string::npos); + + // param is invalid + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + dumper->dumpInfo_ = ""; + dumper->SetDuringCallState("-duringcallstate,3"); + EXPECT_TRUE(g_errLog.find("param is invalid") != std::string::npos); + LOG_SetCallback(nullptr); } #endif // FOLD_ABILITY_ENABLE 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 d92a8d0d65..9ec452cf8b 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -41,6 +41,7 @@ constexpr uint32_t PC_MODE_DPI = 304; constexpr ScreenId SCREEN_ID_FULL = 0; constexpr ScreenId SCREEN_ID_MAIN = 5; const bool CORRECTION_ENABLE = system::GetIntParameter("const.system.sensor_correction_enable", 0) == 1; +bool g_isPcDevice = ScreenSceneConfig::GetExternalScreenDefaultMode() == "none"; } namespace { std::string g_errLog; @@ -1514,10 +1515,15 @@ HWTEST_F(ScreenSessionManagerTest, ChangeMirrorScreenConfig, TestSize.Level1) { */ HWTEST_F(ScreenSessionManagerTest, RegisterSettingDuringCallStateObserver, Function | SmallTest | Level3) { + if (g_isPcDevice) { + GTEST_SKIP(); + } ASSERT_NE(ssm_, nullptr); + ssm_->RegisterSettingDuringCallStateObserver(); if (FoldScreenStateInternel::IsDualDisplayFoldDevice() && ScreenSceneConfig::IsSupportDuringCall()) { - ssm_->RegisterSettingDuringCallStateObserver(); ASSERT_NE(ScreenSettingHelper::duringCallStateObserver_, nullptr); + } else { + ASSERT_EQ(ScreenSettingHelper::duringCallStateObserver_, nullptr); } } @@ -1529,11 +1535,32 @@ HWTEST_F(ScreenSessionManagerTest, RegisterSettingDuringCallStateObserver, Funct HWTEST_F(ScreenSessionManagerTest, UpdateDuringCallState, Function | SmallTest | Level3) { ASSERT_NE(ssm_, nullptr); + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + ssm_->UpdateDuringCallState(); if (FoldScreenStateInternel::IsDualDisplayFoldDevice() && ScreenSceneConfig::IsSupportDuringCall()) { - ssm_->UpdateDuringCallState(); ASSERT_EQ(ssm_->duringCallState_, 0); + } else { + EXPECT_TRUE(g_errLog.find("get setting during call state failed") == std::string::npos); } + LOG_SetCallback(nullptr); } + +/** + * @tc.name: SetDuringCallState + * @tc.desc: SetDuringCallState + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetDuringCallState, TestSize.Level1) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + bool value = false; + ssm_->SetDuringCallState(value); + EXPECT_TRUE(g_errLog.find("set during call state to") != std::string::npos); + LOG_SetCallback(nullptr); +} + /** * @tc.name: DisconnectScreenIfScreenInfoNull * @tc.desc: DisconnectScreenIfScreenInfoNull 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 1da5d0cfce..9def568a5a 100644 --- a/window_scene/test/dms_unittest/screen_setting_helper_test.cpp +++ b/window_scene/test/dms_unittest/screen_setting_helper_test.cpp @@ -28,6 +28,14 @@ namespace Rosen { namespace { constexpr uint32_t SLEEP_TIME_US = 100000; } +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 ScreenSettingHelperTest : public testing::Test { public: @@ -898,6 +906,17 @@ namespace { }; ScreenSettingHelper::RegisterSettingDuringCallStateObserver(func); ASSERT_NE(ScreenSettingHelper::duringCallStateObserver_, nullptr); + + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + bool flag1 = false; + auto func1 = [&flag1] (const std::string&) { + TLOGI(WmsLogTag::DMS, "UT test"); + flag1 = true; + }; + ScreenSettingHelper::RegisterSettingDuringCallStateObserver(func1); + EXPECT_TRUE(g_errLog.find("during call state observer is registered") != std::string::npos); + LOG_SetCallback(nullptr); } /** @@ -909,6 +928,12 @@ namespace { { ScreenSettingHelper::UnregisterSettingDuringCallStateObserver(); ASSERT_EQ(ScreenSettingHelper::duringCallStateObserver_, nullptr); + + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + ScreenSettingHelper::UnregisterSettingDuringCallStateObserver(); + EXPECT_TRUE(g_errLog.find("duringCallStateObserver_ is nullptr") != std::string::npos); + LOG_SetCallback(nullptr); } /** @@ -923,7 +948,7 @@ namespace { screenSettingHelper.SetSettingDuringCallState("during_call_state", false); screenSettingHelper.GetSettingDuringCallState(value); - ASSERT_FALSE(value); + ASSERT_TRUE(value); } } } // namespace Rosen diff --git a/window_scene/test/dms_unittest/setting_provider_test.cpp b/window_scene/test/dms_unittest/setting_provider_test.cpp index a938037cce..d9201030aa 100644 --- a/window_scene/test/dms_unittest/setting_provider_test.cpp +++ b/window_scene/test/dms_unittest/setting_provider_test.cpp @@ -17,6 +17,7 @@ #include +#include "screen_session_manager.h" #include "setting_provider.h" using namespace testing; @@ -159,6 +160,36 @@ HWTEST_F(SettingProviderTest, PutStringValue02, TestSize.Level1) "settings.power.suspend_sources", updateFunc); EXPECT_EQ(SettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID).PutStringValue(key, value, needNotify), ERR_OK); } + +/** + * @tc.name: AssembleUriMultiUser + * @tc.desc: test function : AssembleUriMultiUser + * @tc.type: FUNC + */ +HWTEST_F(SettingProviderTest, AssembleUriMultiUser, TestSize.Level1) +{ + int32_t saveSettings = ScreenSessionManager::GetInstance().currentUserIdForSettings_; + ScreenSessionManager::GetInstance().currentUserIdForSettings_ = 1; + + // key == DURING_CALL_KEY + std::string key = "during_call_state"; + auto res = SettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID).AssembleUriMultiUser(key); + EXPECT_TRUE(res.ToString().find("USER_SETTINGSDATA_SECURE_") != std::string::npos); + + // key != DURING_CALL_KEY + key = "ut_test"; + res = SettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID).AssembleUriMultiUser(key); + EXPECT_FALSE(res.ToString().find("USER_SETTINGSDATA_SECURE_") != std::string::npos); + + //userId = 0 + ScreenSessionManager::GetInstance().currentUserIdForSettings_ = 0; + key = "ut_test"; + res = SettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID).AssembleUriMultiUser(key); + EXPECT_TRUE(res.ToString().find("datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA") != + std::string::npos); + + ScreenSessionManager::GetInstance().currentUserIdForSettings_ = saveSettings; +} } } } \ No newline at end of file -- Gitee From 3b60ab5c5b3e3aed2cfc47230ce43cb09abceccd Mon Sep 17 00:00:00 2001 From: yangdong Date: Tue, 26 Aug 2025 10:58:33 +0800 Subject: [PATCH 187/241] =?UTF-8?q?TDD=E5=87=BD=E6=95=B0=E5=90=8D=E6=9B=B4?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangdong --- .../event_distribution/scene_input_manager_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp index db7391fa61..2a52e8e518 100644 --- a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp @@ -866,11 +866,11 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdateForScreenInfos, TestSize.Level1) } /** - * @tc.name: CheckNeedUpdateFordDisplayInfos - * @tc.desc: CheckNeedUpdateFordDisplayInfos + * @tc.name: CheckNeedUpdateForDisplayInfos + * @tc.desc: CheckNeedUpdateForDisplayInfos * @tc.type: FUNC */ -HWTEST_F(SceneInputManagerTest, CheckNeedUpdateFordDisplayInfos, TestSize.Level1) +HWTEST_F(SceneInputManagerTest, CheckNeedUpdateForDisplayInfos, TestSize.Level1) { std::vector screenInfos; std::vector displayInfos; -- Gitee From 900a2400caa668dd75a2cab71aa1bd212d8f9881 Mon Sep 17 00:00:00 2001 From: hubijie Date: Mon, 25 Aug 2025 20:04:26 +0800 Subject: [PATCH 188/241] support uiextension create sub window which in system scene Signed-off-by: hubijie --- interfaces/innerkits/wm/wm_common.h | 2 +- .../common/include/window_session_property.h | 5 ++--- .../common/src/window_session_property.cpp | 5 ++--- .../include/scene_session_manager.h | 2 ++ .../src/scene_session_manager.cpp | 19 ++++++++++--------- .../unittest/scene_session_manager_test12.cpp | 8 ++++---- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 7f035bdaf3..eaa6a4d25d 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -165,7 +165,7 @@ enum class WindowType : uint32_t { SYSTEM_SUB_WINDOW_BASE = 2500, WINDOW_TYPE_SYSTEM_SUB_WINDOW = SYSTEM_SUB_WINDOW_BASE, - WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW, + WINDOW_TYPE_SCB_SUB_WINDOW, SYSTEM_SUB_WINDOW_END, SYSTEM_WINDOW_END = SYSTEM_SUB_WINDOW_END, diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 587276bf70..46ebf02a97 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -802,9 +802,8 @@ struct SystemSessionConfig : public Parcelable { bool supportCreateFloatWindow_ = false; float defaultCornerRadius_ = 0.0f; // default corner radius of window set by system config bool supportUIExtensionSubWindow_ = false; - using ConvertSystemConfigFunc = void(SystemSessionConfig::*)(const std::string& configItem, - SystemSessionConfig& systemConfig); - void ConvertSupportUIExtensionSubWindow(const std::string& itemValue, SystemSessionConfig& systemConfig); + + void ConvertSupportUIExtensionSubWindow(const std::string& itemValue); virtual bool Marshalling(Parcel& parcel) const override { diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 76c92662db..761ba1ae98 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -2586,10 +2586,9 @@ void WindowSessionProperty::UnmarshallingShadowsInfo(Parcel& parcel, WindowSessi property->SetWindowShadows(*shadowsInfo); } -void SystemSessionConfig::ConvertSupportUIExtensionSubWindow(const std::string& itemValue, - SystemSessionConfig& systemConfig) +void SystemSessionConfig::ConvertSupportUIExtensionSubWindow(const std::string& itemValue) { - systemConfig.supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); + supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index feb38f1c54..38df580f4d 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -169,6 +169,7 @@ using NotifySessionRecoverStateChangeFunc = std::function; using FindScenePanelRsNodeByZOrderFunc = std::function(DisplayId screenId, uint32_t targetZOrder)>; +using ConvertSystemConfigFunc = std::function; class AppAnrListener : public IRemoteStub { public: @@ -809,6 +810,7 @@ protected: private: std::atomic enterRecent_ { false }; bool isKeyboardPanelEnabled_ = false; + std::unordered_map convertConfigMap_; static sptr CreateInstance(); static inline bool isNotCurrentScreen(sptr sceneSession, ScreenId screenId) { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5f42f92c77..f4fe905cce 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -196,10 +196,6 @@ const std::unordered_set LAYOUT_INFO_WHITELIST = { "SCBStatusBar" }; -const std::unordered_map convertConfigMap = { - {"supportUIExtensionSubWindow", &SystemSessionConfig::ConvertSupportUIExtensionSubWindow}, -}; - const std::chrono::milliseconds WAIT_TIME(3 * 1000); // 3 * 1000 wait for 3s std::string GetCurrentTime() @@ -3747,9 +3743,9 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetSubWindowLevel(parentProperty->GetSubWindowLevel() + 1); - if (WindowHelper::IsSystemWindow(parentSession->GetWindowType()) && property->GetIsUIExtFirstSubWindow() && + if (parentSession->GetSessionInfo().isSystem_ && property->GetIsUIExtFirstSubWindow() && systemConfig_.supportUIExtensionSubWindow_) { - property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + property->SetWindowType(WindowType::WINDOW_TYPE_SCB_SUB_WINDOW); } } auto initClientDisplayId = UpdateSpecificSessionClientDisplayId(property); @@ -10857,13 +10853,18 @@ static void FillUnreliableWindowInfo(const sptr& sceneSession, void SceneSessionManager::ApplyFeatureConfig(const std::unordered_map& configMap) { auto task = [this, where = __func__, &configMap] { + if (convertConfigMap_.empty()) { + convertConfigMap_ = { + {"supportUIExtensionSubWindow", &SystemSessionConfig::ConvertSupportUIExtensionSubWindow}, + }; + } for (const auto& [configName, configValue] : configMap) { TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s, configEntry is %{public}s: %{public}s", where, configName.c_str(), configValue.c_str()); - auto convertIter = convertConfigMap.find(configName); - if (convertIter != convertConfigMap.end()) { + auto convertIter = convertConfigMap_.find(configName); + if (convertIter != convertConfigMap_.end()) { auto convertFunc = convertIter->second; - (this->systemConfig_.*convertFunc)(systemConfig_, configValue); + convertFunc(configValue); } } return WMError::WM_OK; diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 08762034b3..470112c748 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -662,28 +662,28 @@ HWTEST_F(SceneSessionManagerTest12, CreateAndConnectSpecificSession04, TestSize. ssm_->systemConfig_.supportUIExtensionSubWindow_ = true; ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, systemConfig, token); - EXPECT_EQ(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + EXPECT_EQ(property->GetWindowType(), WindowType::WINDOW_TYPE_SCB_SUB_WINDOW); // Create UI_EXTENSION_SUB_WINDOW failed property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); ssm_->systemConfig_.supportUIExtensionSubWindow_ = false; ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, systemConfig, token); - EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_SCB_SUB_WINDOW); // Create UI_EXTENSION_SUB_WINDOW failed property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); property->SetIsUIExtFirstSubWindow(false); ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, systemConfig, token); - EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_SCB_SUB_WINDOW); // Create UI_EXTENSION_SUB_WINDOW failed property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); parentSession->GetSessionProperty()->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, systemConfig, token); - EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_UI_EXTENSION_SUB_WINDOW); + EXPECT_NE(property->GetWindowType(), WindowType::WINDOW_TYPE_SCB_SUB_WINDOW); } /** -- Gitee From 30b8d247d32cad73b13c84042b9cf4bc7dfcd329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Wed, 20 Aug 2025 16:47:00 +0800 Subject: [PATCH 189/241] fix gn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 Change-Id: If012a31dfbb4c0da314c37800efacfae41d903af --- extension/window_extension/BUILD.gn | 1 + interfaces/kits/ani/display_runtime/BUILD.gn | 1 + interfaces/kits/napi/floating_ball_napi/BUILD.gn | 1 + 3 files changed, 3 insertions(+) diff --git a/extension/window_extension/BUILD.gn b/extension/window_extension/BUILD.gn index 842c4af4eb..15b7623750 100644 --- a/extension/window_extension/BUILD.gn +++ b/extension/window_extension/BUILD.gn @@ -67,6 +67,7 @@ ohos_shared_library("libwindow_extension") { "ability_runtime:ability_context_native", "ability_runtime:ability_manager", "ability_runtime:ability_start_options", + "ability_runtime:abilitykit_utils", "ability_runtime:app_context", "ability_runtime:extensionkit_native", "ability_runtime:napi_common", diff --git a/interfaces/kits/ani/display_runtime/BUILD.gn b/interfaces/kits/ani/display_runtime/BUILD.gn index 1c6f20ff69..087926c9ee 100644 --- a/interfaces/kits/ani/display_runtime/BUILD.gn +++ b/interfaces/kits/ani/display_runtime/BUILD.gn @@ -71,6 +71,7 @@ ohos_shared_library("displayani_kit") { "eventhandler:libeventhandler", "hilog:libhilog", "hitrace:hitrace_meter", + "ipc:ipc_single", "runtime_core:ani", ] diff --git a/interfaces/kits/napi/floating_ball_napi/BUILD.gn b/interfaces/kits/napi/floating_ball_napi/BUILD.gn index 8c54543ec6..de41552158 100644 --- a/interfaces/kits/napi/floating_ball_napi/BUILD.gn +++ b/interfaces/kits/napi/floating_ball_napi/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("floatingball_napi") { external_deps = [ "ability_runtime:ability_context_native", "ability_runtime:abilitykit_native", + "ability_runtime:napi_common", "ability_runtime:runtime", "c_utils:utils", "hilog:libhilog", -- Gitee From 456ac28010d1745e91fee227682dcfc280250c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Tue, 26 Aug 2025 14:21:12 +0800 Subject: [PATCH 190/241] =?UTF-8?q?api=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=E4=B8=BA=E5=BC=82=E6=AD=A5=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- .../extension_window/js_extension_window.cpp | 108 +++++++++++++----- 1 file changed, 78 insertions(+), 30 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 7a6ac2f898..14d4468bea 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -1120,106 +1120,154 @@ napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback { if (extensionWindow_ == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][hideNonSecureWindows]msg: extensionWindow_ is nullptr"); } sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][hideNonSecureWindows]msg: windowImpl is nullptr"); } size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][hideNonSecureWindows]msg: Argc is invalid"); } bool shouldHide = false; if (!ConvertFromJsValue(env, argv[0], shouldHide)) { TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to bool"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][hideNonSecureWindows]msg: Failed to convert parameter to bool"); } - WmErrorCode ret = WmErrorCode::WM_OK; - ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->HideNonSecureWindows(shouldHide)); - if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + auto ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->HideNonSecureWindows(shouldHide)); + const char* const where = __func__; + napi_value result = nullptr; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); + auto asyncTask = [where, env, ret, task = napiAsyncTask]() mutable { + if (ret == WmErrorCode::WM_OK) { + task->Resolve(env, NapiGetUndefined(env)); + } else { + TLOGNE(WmsLogTag::WMS_UIEXT, "%{public}s failed, code: %{public}d", where, ret); + task->Reject(env, CreateJsError(env, static_cast(ret), + "[window][hideNonSecureWindows]msg: hideNonSecureWindows failed")); + } + }; + if (napi_send_event(env, asyncTask, napi_eprio_high, "OnHideNonSecureWindows") != napi_status::napi_ok) { + napiAsyncTask->Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][hideNonSecureWindows]msg: Failed to send event")); } TLOGI(WmsLogTag::WMS_UIEXT, "end, window [%{public}u, %{public}s], shouldHide:%{public}u", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), shouldHide); - return NapiGetUndefined(env); + return result; } napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) { if (extensionWindow_ == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWaterMarkFlag]msg: extensionWindow_ is nullptr"); } sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWaterMarkFlag]msg: windowImpl is nullptr"); } size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setWaterMarkFlag]msg: Argc is invalid"); } bool isEnable = false; if (!ConvertFromJsValue(env, argv[0], isEnable)) { TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to bool"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][setWaterMarkFlag]msg: Failed to convert parameter to bool"); } - WmErrorCode ret = WmErrorCode::WM_OK; - ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->SetWaterMarkFlag(isEnable)); - if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + auto ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->SetWaterMarkFlag(isEnable)); + const char* const where = __func__; + napi_value result = nullptr; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); + auto asyncTask = [where, env, ret, task = napiAsyncTask]() mutable { + if (ret == WmErrorCode::WM_OK) { + task->Resolve(env, NapiGetUndefined(env)); + } else { + TLOGNE(WmsLogTag::WMS_UIEXT, "%{public}s failed, code: %{public}d", where, ret); + task->Reject(env, CreateJsError(env, static_cast(ret), + "[window][setWaterMarkFlag]msg: setWaterMarkFlag failed")); + } + }; + if (napi_send_event(env, asyncTask, napi_eprio_high, "OnSetWaterMarkFlag") != napi_status::napi_ok) { + napiAsyncTask->Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setWaterMarkFlag]msg: Failed to send event")); } TLOGI(WmsLogTag::WMS_UIEXT, "end, window [%{public}u, %{public}s], isEnable:%{public}u.", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), isEnable); - return NapiGetUndefined(env); + return result; } napi_value JsExtensionWindow::OnHidePrivacyContentForHost(napi_env env, napi_callback_info info) { if (extensionWindow_ == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "extension window is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][hidePrivacyContentForHost]msg: extensionWindow_ is nullptr"); } - sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][hidePrivacyContentForHost]msg: windowImpl is nullptr"); } - size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][hidePrivacyContentForHost]msg: Argc is invalid"); } - bool needHide = false; if (!ConvertFromJsValue(env, argv[0], needHide)) { TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to bool"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][hidePrivacyContentForHost]msg: Failed to convert parameter to bool"); } auto ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->HidePrivacyContentForHost(needHide)); - if (ret != WmErrorCode::WM_OK) { - return NapiThrowError(env, ret); + const char* const where = __func__; + napi_value result = nullptr; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); + auto asyncTask = [where, env, ret, task = napiAsyncTask]() mutable { + if (ret == WmErrorCode::WM_OK) { + task->Resolve(env, NapiGetUndefined(env)); + } else { + TLOGNE(WmsLogTag::WMS_UIEXT, "%{public}s failed, code: %{public}d", where, ret); + task->Reject(env, CreateJsError(env, static_cast(ret), + "[window][hidePrivacyContentForHost]msg: hidePrivacyContentForHost failed")); + } + }; + if (napi_send_event(env, asyncTask, napi_eprio_high, "OnHidePrivacyContentForHost") != napi_status::napi_ok) { + napiAsyncTask->Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][hidePrivacyContentForHost]msg: Failed to send event")); } TLOGI(WmsLogTag::WMS_UIEXT, "finished, window [%{public}u, %{public}s], needHide:%{public}u.", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), needHide); - - return NapiGetUndefined(env); + return result; } napi_value JsExtensionWindow::GetProperties(napi_env env, napi_callback_info info) -- Gitee From 4771fb341fe6cfc7f3dd0daa94aa8f614261bedb Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Tue, 26 Aug 2025 14:33:27 +0800 Subject: [PATCH 191/241] =?UTF-8?q?=E6=B7=BB=E5=8A=A0trace=E7=82=B9=20Sign?= =?UTF-8?q?ed-off-by:=20huangjunlin=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wm/src/window_session_impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 28ee7f6291..69ff418510 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2938,6 +2938,7 @@ void WindowSessionImpl::SetRequestedOrientation(Orientation orientation, bool ne } else { property_->SetRequestedOrientation(orientation, needAnimation); } + HITRACE_METER_NAME(HITRACE_TAG_WINDOW_MANAGER, "WindowSessionImpl::SetRequestedOrientation"); UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION); } -- Gitee From 8c161ec186560b7f111b185662e50a34e5f4f095 Mon Sep 17 00:00:00 2001 From: huangjunlin Date: Tue, 26 Aug 2025 14:59:03 +0800 Subject: [PATCH 192/241] =?UTF-8?q?=E6=B7=BB=E5=8A=A0trace=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangjunlin --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 69ff418510..df95bcca90 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2915,6 +2915,7 @@ float WindowSessionImpl::GetBrightness() const void WindowSessionImpl::SetRequestedOrientation(Orientation orientation, bool needAnimation) { + HITRACE_METER_NAME(HITRACE_TAG_WINDOW_MANAGER, "WindowSessionImpl::SetRequestedOrientation"); if (IsWindowSessionInvalid()) { TLOGE(WmsLogTag::DEFAULT, "windowSession is invalid"); return; @@ -2938,7 +2939,6 @@ void WindowSessionImpl::SetRequestedOrientation(Orientation orientation, bool ne } else { property_->SetRequestedOrientation(orientation, needAnimation); } - HITRACE_METER_NAME(HITRACE_TAG_WINDOW_MANAGER, "WindowSessionImpl::SetRequestedOrientation"); UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION); } -- Gitee From 66a0b35fdc1fa2268a38b094fa6ab8f7f8ef141d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=81=AA?= Date: Tue, 26 Aug 2025 15:09:22 +0800 Subject: [PATCH 193/241] =?UTF-8?q?13=E5=BC=80=E5=A4=B4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=A0=81=E5=BC=82=E6=AD=A5=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵聪 --- .../extension_window/js_extension_window.cpp | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 14d4468bea..118d7a871a 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -1118,16 +1118,20 @@ napi_value JsExtensionWindow::OnUnRegisterExtensionWindowCallback(napi_env env, napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback_info info) { + napi_value result = nullptr; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); if (extensionWindow_ == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][hideNonSecureWindows]msg: extensionWindow_ is nullptr"); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][hideNonSecureWindows]msg: extensionWindow_ is nullptr")); + return result; } sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][hideNonSecureWindows]msg: windowImpl is nullptr"); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][hideNonSecureWindows]msg: windowImpl is nullptr")); + return result; } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -1146,8 +1150,6 @@ napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback auto ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->HideNonSecureWindows(shouldHide)); const char* const where = __func__; - napi_value result = nullptr; - std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); auto asyncTask = [where, env, ret, task = napiAsyncTask]() mutable { if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); @@ -1169,16 +1171,20 @@ napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) { + napi_value result = nullptr; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); if (extensionWindow_ == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWaterMarkFlag]msg: extensionWindow_ is nullptr"); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setWaterMarkFlag]msg: extensionWindow_ is nullptr")); + return result; } sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setWaterMarkFlag]msg: windowImpl is nullptr"); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setWaterMarkFlag]msg: windowImpl is nullptr")); + return result; } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -1197,8 +1203,6 @@ napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_inf auto ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->SetWaterMarkFlag(isEnable)); const char* const where = __func__; - napi_value result = nullptr; - std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); auto asyncTask = [where, env, ret, task = napiAsyncTask]() mutable { if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); @@ -1220,16 +1224,20 @@ napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_inf napi_value JsExtensionWindow::OnHidePrivacyContentForHost(napi_env env, napi_callback_info info) { + napi_value result = nullptr; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); if (extensionWindow_ == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][hidePrivacyContentForHost]msg: extensionWindow_ is nullptr"); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][hidePrivacyContentForHost]msg: extensionWindow_ is nullptr")); + return result; } sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][hidePrivacyContentForHost]msg: windowImpl is nullptr"); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][hidePrivacyContentForHost]msg: windowImpl is nullptr")); + return result; } size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -1248,8 +1256,6 @@ napi_value JsExtensionWindow::OnHidePrivacyContentForHost(napi_env env, napi_cal auto ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->HidePrivacyContentForHost(needHide)); const char* const where = __func__; - napi_value result = nullptr; - std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); auto asyncTask = [where, env, ret, task = napiAsyncTask]() mutable { if (ret == WmErrorCode::WM_OK) { task->Resolve(env, NapiGetUndefined(env)); -- Gitee From 64ec614f449142d11268b3825b30e8307876b1b5 Mon Sep 17 00:00:00 2001 From: Ray95 Date: Tue, 26 Aug 2025 16:35:07 +0800 Subject: [PATCH 194/241] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ray95 --- .../common/src/session_permission.cpp | 14 ++++++----- .../zidl/session_lifecycle_listener_stub.cpp | 5 ++-- .../test/mock/mock_message_parcel.cpp | 12 +++++----- window_scene/test/mock/mock_session_stage.h | 4 ++-- .../scene_session_manager_kiosk_test.cpp | 23 ++++--------------- 5 files changed, 23 insertions(+), 35 deletions(-) diff --git a/window_scene/common/src/session_permission.cpp b/window_scene/common/src/session_permission.cpp index d23d13c6b5..6cfc6872c6 100644 --- a/window_scene/common/src/session_permission.cpp +++ b/window_scene/common/src/session_permission.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -81,7 +80,9 @@ bool SessionPermission::IsSystemCalling() if (IsTokenNativeOrShellType(tokenId)) { return true; } - return IsSystemAppCall(); + uint64_t accessTokenIDEx = IPCSkeleton::GetCallingFullTokenID(); + bool isSystemApp = Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(accessTokenIDEx); + return isSystemApp; } bool SessionPermission::IsSystemAppCall() @@ -159,7 +160,8 @@ bool SessionPermission::JudgeCallerIsAllowedToUseSystemAPI() if (IsSACalling() || IsShellCall()) { return true; } - return IsSystemAppCall(); + auto callerToken = IPCSkeleton::GetCallingTokenID(); + return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(callerToken); } bool SessionPermission::IsShellCall() @@ -313,7 +315,7 @@ bool SessionPermission::CheckCallingIsUserTestMode(pid_t pid) bool isUserTestMode = false; auto appMgrClient = DelayedSingleton::GetInstance(); if (appMgrClient == nullptr) { - TLOGE(WmsLogTag::DEFAULT, "AppMgeClient is null!"); + TLOGE(WmsLogTag::DEFAULT, "AppMgrClient is null!"); return false; } // reset ipc identity @@ -385,8 +387,8 @@ bool SessionPermission::IsTokenNativeOrShellType(uint32_t tokenId) { const auto flag = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenId); TLOGD(WmsLogTag::DEFAULT, "tokenId:%{private}u, flag:%{public}u", tokenId, flag); - if (flag != Security::AccessToken::TypeATokenTypeEnum::TOKEN_NATIVE && - flag != Security::AccessToken::TypeATokenTypeEnum::TOKEN_SHELL) { + if (flag != Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE && + flag != Security::AccessToken::ATokenTypeEnum::TOKEN_SHELL) { return false; } return true; diff --git a/window_scene/session_manager/src/zidl/session_lifecycle_listener_stub.cpp b/window_scene/session_manager/src/zidl/session_lifecycle_listener_stub.cpp index a842e76536..e7041fa30a 100644 --- a/window_scene/session_manager/src/zidl/session_lifecycle_listener_stub.cpp +++ b/window_scene/session_manager/src/zidl/session_lifecycle_listener_stub.cpp @@ -13,10 +13,11 @@ * limitations under the License. */ +#include + +#include "hilog_tag_wrapper.h" #include "session_manager/include/zidl/session_lifecycle_listener_stub.h" #include "window_manager_hilog.h" -#include "hilog_tag_wrapper.h" -#include namespace OHOS::Rosen { diff --git a/window_scene/test/mock/mock_message_parcel.cpp b/window_scene/test/mock/mock_message_parcel.cpp index 84c9a9e7c2..cf44e7dd72 100644 --- a/window_scene/test/mock/mock_message_parcel.cpp +++ b/window_scene/test/mock/mock_message_parcel.cpp @@ -127,6 +127,11 @@ void MockMessageParcel::SetWriteRemoteObjectErrorFlag(bool flag) g_setWriteRemoteObjectErrorFlag = flag; } +void MockMessageParcel::SetReadBoolErrorFlag(bool flag) +{ + g_setReadBoolErrorFlag = flag; +} + void MockMessageParcel::SetReadUint32ErrorFlag(bool flag) { g_setReadUint32ErrorFlag = flag; @@ -137,11 +142,6 @@ void MockMessageParcel::SetReadInt32ErrorFlag(bool flag) g_setReadInt32ErrorFlag = flag; } -void MockMessageParcel::SetReadBoolErrorFlag(bool flag) -{ - g_setReadBoolErrorFlag = flag; -} - void MockMessageParcel::SetReadUint64ErrorFlag(bool flag) { g_setReadUint64ErrorFlag = flag; @@ -258,7 +258,7 @@ bool Parcel::WriteString(const std::string& value) return !g_setWriteStringErrorFlag; } -bool Parcel::ReadBool(bool& value) +bool Parcel::ReadBool(bool& val) { if (g_setReadBoolErrorFlag) { return false; diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index 08d8e34420..dfa0390941 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -80,16 +80,16 @@ public: MOCK_METHOD2(UpdateWindowModeByIdForUITest, WMError(int32_t windowId, int32_t updateMode)); MOCK_METHOD1(NotifyHighlightChange, WSError(bool isHighlight)); MOCK_METHOD1(SetDragActivated, WSError(bool dragActivated)); - MOCK_METHOD1(NotifyWindowCrossAxisChange, void(CrossAxisState state)); MOCK_METHOD3(NotifyPipWindowSizeChange, WSError(double width, double height, double scale)); + MOCK_METHOD1(NotifyWindowCrossAxisChange, void(CrossAxisState state)); MOCK_METHOD1(LinkKeyFrameCanvasNode, WSError(std::shared_ptr& rsCanvasNode)); MOCK_METHOD1(SetKeyFramePolicy, WSError(KeyFramePolicy& keyFramePolicy)); MOCK_METHOD1(SetCurrentRotation, WSError(int32_t currentRotation)); MOCK_METHOD0(NotifyLifecyclePausedStatus, void(void)); MOCK_METHOD1(NotifyAppUseControlStatus, void(bool isUseControl)); + MOCK_METHOD1(NotifyExtensionSecureLimitChange, WSError(bool isLimit)); MOCK_METHOD0(NotifyAppForceLandscapeConfigUpdated, WSError(void)); MOCK_METHOD0(NotifyAppHookWindowInfoUpdated, WSError(void)); - MOCK_METHOD1(NotifyExtensionSecureLimitChange, WSError(bool isLimit)); MOCK_METHOD1(GetRouterStackInfo, WMError(std::string& routerStackInfo)); MOCK_METHOD1(SendFbActionEvent, WSError(const std::string& action)); }; diff --git a/window_scene/test/unittest/scene_session_manager_kiosk_test.cpp b/window_scene/test/unittest/scene_session_manager_kiosk_test.cpp index b5b880c6c5..f0c479cd89 100644 --- a/window_scene/test/unittest/scene_session_manager_kiosk_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_kiosk_test.cpp @@ -209,21 +209,6 @@ HWTEST_F(SceneSessionManagerKioskTest, EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PERMISSION); } -/** - * @tc.name : UpdateKioskAppList_ShouldReturnInvalidParam_WhenKioskAppListIsEmpty - * @tc.number: UpdateKioskAppList_002 - * @tc.desc : Test: When the passed kioskAppList is empty, UpdateKioskAppList should return WM_ERROR_INVALID_PARAM - */ -HWTEST_F(SceneSessionManagerKioskTest, - ATC_UpdateKioskAppList_ShouldReturnInvalidParam_WhenKioskAppListIsEmpty, TestSize.Level0) -{ - MockAccesstokenKit::MockIsSystemApp(true); - MockAccesstokenKit::MockIsSACalling(true); - std::vector kioskAppList = {}; - WMError result = ssm_->UpdateKioskAppList(kioskAppList); - EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PARAM); -} - /** * @tc.name : UpdateKioskAppList_ShouldCallUpdateKioskAppListFunc_WhenUpdateKioskAppListFuncIsNotNull * @tc.number: UpdateKioskAppList_003 @@ -296,7 +281,7 @@ HWTEST_F(SceneSessionManagerKioskTest, /** * @tc.name : RegisterKioskModeChangeCallback_ShouldCallCallback_WhenValidFuncIsProvided * @tc.number: RegisterKioskModeChangeCallbackTest_001 - * @tc.desc : 测试在传入有效回调函数时,函数是否被正确调用 + * @tc.desc : Test whether the function is called correctly when a valid callback function is passed in */ HWTEST_F(SceneSessionManagerKioskTest, ATC_RegisterKioskModeChangeCallback_ShouldCallCallback_WhenValidFuncIsProvided, TestSize.Level0) @@ -309,6 +294,6 @@ HWTEST_F(SceneSessionManagerKioskTest, usleep(WAIT_SYNC_IN_NS); EXPECT_TRUE(ssm_->kioskModeChangeFunc_ != nullptr); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file -- Gitee From 4498b50d5701e6c26c439211b742a95af115e2d1 Mon Sep 17 00:00:00 2001 From: imp9527 Date: Tue, 26 Aug 2025 16:50:18 +0800 Subject: [PATCH 195/241] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: imp9527 --- window_scene/test/mock/mock_message_parcel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/test/mock/mock_message_parcel.cpp b/window_scene/test/mock/mock_message_parcel.cpp index 84c9a9e7c2..dbd3e0b660 100644 --- a/window_scene/test/mock/mock_message_parcel.cpp +++ b/window_scene/test/mock/mock_message_parcel.cpp @@ -127,6 +127,11 @@ void MockMessageParcel::SetWriteRemoteObjectErrorFlag(bool flag) g_setWriteRemoteObjectErrorFlag = flag; } +void MockMessageParcel::SetReadBoolErrorFlag(bool flag) +{ + g_setReadBoolErrorFlag = flag; +} + void MockMessageParcel::SetReadUint32ErrorFlag(bool flag) { g_setReadUint32ErrorFlag = flag; @@ -137,11 +142,6 @@ void MockMessageParcel::SetReadInt32ErrorFlag(bool flag) g_setReadInt32ErrorFlag = flag; } -void MockMessageParcel::SetReadBoolErrorFlag(bool flag) -{ - g_setReadBoolErrorFlag = flag; -} - void MockMessageParcel::SetReadUint64ErrorFlag(bool flag) { g_setReadUint64ErrorFlag = flag; -- Gitee From b0aee050cd073a5b0e9db46b5ddb31ecac961434 Mon Sep 17 00:00:00 2001 From: hubijie Date: Tue, 26 Aug 2025 14:07:37 +0800 Subject: [PATCH 196/241] support uiextension create sub window which in system scene Signed-off-by: hubijie --- window_scene/session_manager/src/scene_session_manager.cpp | 3 ++- .../src/zidl/scene_session_manager_proxy.cpp | 6 ++++++ .../session_manager/src/zidl/scene_session_manager_stub.cpp | 1 + 3 files changed, 9 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 f4fe905cce..d6d21f0c4a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10855,7 +10855,8 @@ void SceneSessionManager::ApplyFeatureConfig(const std::unordered_mapGetDisplayId() != VIRTUAL_DISPLAY_ID) { property->SetDisplayId(displayId); } + uint32_t windowType = 0; + if (!reply.ReadUint32(windowType)) { + TLOGE(WmsLogTag::WMS_LIFE, "Read windowType failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + property->SetWindowType(static_cast(windowType)); int32_t ret = reply.ReadInt32(); return static_cast(ret); } 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 aab739f17e..c3a79f7532 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 @@ -304,6 +304,7 @@ int SceneSessionManagerStub::HandleCreateAndConnectSpecificSession(MessageParcel reply.WriteParcelable(&systemConfig); reply.WriteUint32(property->GetSubWindowLevel()); reply.WriteUint64(property->GetDisplayId()); + reply.WriteUint32(static_cast(property->GetWindowType())); reply.WriteUint32(static_cast(WSError::WS_OK)); return ERR_NONE; } -- Gitee From 9b9dc0ed4cf12b3720d398dcadaba5d917654cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Tue, 26 Aug 2025 11:34:24 +0000 Subject: [PATCH 197/241] update wm/src/window_scene.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/src/window_scene.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wm/src/window_scene.cpp b/wm/src/window_scene.cpp index d7529c7056..b40aef9759 100644 --- a/wm/src/window_scene.cpp +++ b/wm/src/window_scene.cpp @@ -100,9 +100,10 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptrSetBundleName(context->GetBundleName()); std::string moduleName = context->GetHapModuleInfo() ? context->GetHapModuleInfo()->moduleName : ""; - TLOGI(WmsLogTag::WMS_MAIN, "set isModuleAbiltityHookEnd"); - isModuleAbilityHookEnd = - SingletonContainer::Get().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); + if (!moduleName.empty()) { + isModuleAbilityHookEnd = + SingletonContainer::Get().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); + } } auto mainWindow = SingletonContainer::Get() .CreateWindow(option, context, iSession, identityToken, isModuleAbilityHookEnd); -- Gitee From b30b462a460c3812d4cbdd42d7d8cc68dfd69c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=88=9A?= Date: Tue, 26 Aug 2025 11:35:57 +0000 Subject: [PATCH 198/241] update wm/src/window_scene.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴刚 --- wm/src/window_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene.cpp b/wm/src/window_scene.cpp index b40aef9759..145d3d7cb0 100644 --- a/wm/src/window_scene.cpp +++ b/wm/src/window_scene.cpp @@ -102,7 +102,7 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptrGetHapModuleInfo() ? context->GetHapModuleInfo()->moduleName : ""; if (!moduleName.empty()) { isModuleAbilityHookEnd = - SingletonContainer::Get().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); + SingletonContainer::Get().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); } } auto mainWindow = SingletonContainer::Get() -- Gitee From b9bcaaae11ad5d3609b44e4f689bb2ca38bb6237 Mon Sep 17 00:00:00 2001 From: chenwei Date: Tue, 26 Aug 2025 20:22:42 +0800 Subject: [PATCH 199/241] =?UTF-8?q?=E5=B0=8F=E6=8A=98=E5=8F=A0=E6=8A=98?= =?UTF-8?q?=E5=8F=A0=E4=B9=8B=E5=90=8E=E5=B1=8F=E5=B9=95=E6=96=B9=E5=90=91?= =?UTF-8?q?=E8=B7=9F=E9=9A=8F=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenwei --- .../src/fold_screen_controller/dual_display_fold_policy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp index cf64385d54..e93dfe4753 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp @@ -583,7 +583,7 @@ void DualDisplayFoldPolicy::TriggerSensorInSub(const sptr& screen TLOGE(WmsLogTag::DMS, "screenSessionMain is null"); return; } - float sensorRotation = screenSessionMain->GetSensorRotation(); + float sensorRotation = screenSessionMain->GetValidSensorRotation(); TLOGI(WmsLogTag::DMS, "sensorRotation = %{public}f", sensorRotation); if (FoldScreenStateInternel::FloatEqualAbs(sensorRotation, VERTICAL_ROTATION) || FoldScreenStateInternel::FloatEqualAbs(sensorRotation, VERTICAL_ROTATION_REVERSE)) { -- Gitee From 242c23c03e222e4910009eadd77695fccfdab938 Mon Sep 17 00:00:00 2001 From: w00893971 Date: Tue, 26 Aug 2025 20:39:32 +0800 Subject: [PATCH 200/241] log fix Signed-off-by: w00893971 --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index b86a6efab9..c0cc6a3c97 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -6323,7 +6323,7 @@ WMError WindowSessionImpl::HandleEscKeyEvent(const std::shared_ptrHasFlag(MMI::InputEvent::EVENT_FLAG_KEYBOARD_ESCAPE); // noflag do not handle; UEC do not handle because it is handled in the host window if (!escToBackFlag || property_->GetWindowType() == WindowType::WINDOW_TYPE_UI_EXTENSION) { - TLOGE(WmsLogTag::WMS_EVENT, "ESC no flag or UIExtension window"); + TLOGI(WmsLogTag::WMS_EVENT, "ESC no flag or UIExtension window"); return WMError::WM_DO_NOTHING; } -- Gitee From ef28d1ad885077b3104638a7c0f28dcd4685c6bc Mon Sep 17 00:00:00 2001 From: Ray95 Date: Tue, 26 Aug 2025 21:18:34 +0800 Subject: [PATCH 201/241] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ray95 --- window_scene/common/src/session_permission.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/common/src/session_permission.cpp b/window_scene/common/src/session_permission.cpp index 6cfc6872c6..cc4c247a94 100644 --- a/window_scene/common/src/session_permission.cpp +++ b/window_scene/common/src/session_permission.cpp @@ -160,7 +160,7 @@ bool SessionPermission::JudgeCallerIsAllowedToUseSystemAPI() if (IsSACalling() || IsShellCall()) { return true; } - auto callerToken = IPCSkeleton::GetCallingTokenID(); + auto callerToken = IPCSkeleton::GetCallingFullTokenID(); return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(callerToken); } @@ -387,8 +387,8 @@ bool SessionPermission::IsTokenNativeOrShellType(uint32_t tokenId) { const auto flag = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenId); TLOGD(WmsLogTag::DEFAULT, "tokenId:%{private}u, flag:%{public}u", tokenId, flag); - if (flag != Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE && - flag != Security::AccessToken::ATokenTypeEnum::TOKEN_SHELL) { + if (flag != Security::AccessToken::TypeATokenTypeEnum::TOKEN_NATIVE && + flag != Security::AccessToken::TypeATokenTypeEnum::TOKEN_SHELL) { return false; } return true; -- Gitee From 87366a3ea2858c0449121d1a09b5e69f6a1b9ee6 Mon Sep 17 00:00:00 2001 From: qianli22 Date: Mon, 25 Aug 2025 11:39:42 +0800 Subject: [PATCH 202/241] =?UTF-8?q?=E7=BC=A9=E7=9F=AD=E9=94=81=E5=8C=BA?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qianli22 --- .../session/host/src/scene_session.cpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 4be2eb8ef4..9b95ebe9ee 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4077,7 +4077,7 @@ void SceneSession::SetKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) WSError SceneSession::SetDragKeyFramePolicy(const KeyFramePolicy& keyFramePolicy) { - TLOGI(WmsLogTag::WMS_LAYOUT, "in"); + TLOGI(WmsLogTag::WMS_LAYOUT_PC, "in"); std::lock_guard lock(keyFrameMutex_); bool running = keyFramePolicy_.running_; bool stopping = keyFramePolicy_.stopping_; @@ -4095,18 +4095,27 @@ void SceneSession::UpdateKeyFrameState(SizeChangeReason reason, const WSRect& re TLOGE(WmsLogTag::WMS_LAYOUT_PC, "no moveDragController or sessionStage"); return; } - std::lock_guard lock(keyFrameMutex_); if (reason == SizeChangeReason::DRAG_START && moveDragController_->GetStartDragFlag()) { TLOGD(WmsLogTag::WMS_LAYOUT_PC, "key frame start check"); - if (!keyFramePolicy_.enabled() || GetAppDragResizeType() == DragResizeType::RESIZE_WHEN_DRAG_END) { - keyFramePolicy_.running_ = false; - return; + { + std::lock_guard lock(keyFrameMutex_); + if (!keyFramePolicy_.enabled() || GetAppDragResizeType() == DragResizeType::RESIZE_WHEN_DRAG_END) { + keyFramePolicy_.running_ = false; + return; + } + return InitKeyFrameState(rect); } - return InitKeyFrameState(rect); } - if (!keyFramePolicy_.running_ || !keyFrameCloneNode_) { - TLOGD(WmsLogTag::WMS_LAYOUT_PC, "key frame not start"); - return; + { + std::lock_guard lock(keyFrameMutex_); + if (!keyFramePolicy_.running_ || !keyFrameCloneNode_) { + TLOGD(WmsLogTag::WMS_LAYOUT_PC, "key frame not start"); + return; + } + if (reason == SizeChangeReason::DRAG_END) { + keyFramePolicy_.running_ = false; + keyFramePolicy_.stopping_ = true; + } } if (reason == SizeChangeReason::DRAG) { TLOGD(WmsLogTag::WMS_LAYOUT_PC, "reset gravity and resize clone node"); @@ -4123,8 +4132,7 @@ void SceneSession::UpdateKeyFrameState(SizeChangeReason reason, const WSRect& re keyFrameCloneNode_->SetFrame(0, 0, rect.width_, rect.height_); RSTransactionAdapter::FlushImplicitTransaction(GetRSUIContext()); } else if (reason == SizeChangeReason::DRAG_END) { - keyFramePolicy_.running_ = false; - keyFramePolicy_.stopping_ = true; + TLOGI(WmsLogTag::WMS_LAYOUT_PC, "key frame stopping"); sessionStage_->SetKeyFramePolicy(keyFramePolicy_); keyFrameCloneNode_ = nullptr; } -- Gitee From 0918821fe46988d6295f8e19dec0ca3f89bd2275 Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Wed, 27 Aug 2025 11:49:39 +0800 Subject: [PATCH 203/241] fix Extension background bug Signed-off-by: Peng fafu --- window_scene/session/host/src/extension_session.cpp | 3 +++ .../test/unittest/ui_extension/extension_session_test.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index fcdc671892..19c0920199 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -514,6 +514,9 @@ WSError ExtensionSession::Background(bool isFromClient, const std::string& ident state = SessionState::STATE_INACTIVE; isActive_ = false; } + if (state == SessionState::STATE_BACKGROUND) { + return WSError::WS_OK; + } if (state != SessionState::STATE_INACTIVE) { WLOGFW("[WMSLife] Background state invalid! state:%{public}u", state); return WSError::WS_ERROR_INVALID_SESSION; diff --git a/window_scene/test/unittest/ui_extension/extension_session_test.cpp b/window_scene/test/unittest/ui_extension/extension_session_test.cpp index 1f00143565..731d24f633 100644 --- a/window_scene/test/unittest/ui_extension/extension_session_test.cpp +++ b/window_scene/test/unittest/ui_extension/extension_session_test.cpp @@ -844,6 +844,10 @@ HWTEST_F(ExtensionSessionTest, Background, TestSize.Level0) extensionSession_->state_ = SessionState::STATE_DISCONNECT; res = extensionSession_->Background(); ASSERT_EQ(res, WSError::WS_ERROR_INVALID_SESSION); + + extensionSession_->state_ = SessionState::STATE_BACKGROUND; + res = extensionSession_->Background(); + ASSERT_EQ(res, WSError::WS_OK); } /** -- Gitee From 3080e15d4b8f32b904cebbbe3e03eeb24bf97f1c Mon Sep 17 00:00:00 2001 From: LHWu Date: Wed, 27 Aug 2025 14:36:03 +0800 Subject: [PATCH 204/241] =?UTF-8?q?=E5=A2=9E=E5=8A=A0hidumper=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LHWu --- window_scene/session_manager/src/hidump_controller.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/session_manager/src/hidump_controller.cpp b/window_scene/session_manager/src/hidump_controller.cpp index 8affbadeba..7061c76ea7 100644 --- a/window_scene/session_manager/src/hidump_controller.cpp +++ b/window_scene/session_manager/src/hidump_controller.cpp @@ -317,6 +317,8 @@ void HidumpController::DumpKeyboardParam( << std::endl << session->GetSCBKeepKeyboardFlag() << "|" << session->IsSystemInput() << "|" + << 0 << "|" + << 0 << "|" << property->GetKeepKeyboardFlag() << "|" << std::setprecision(precision) << property->GetTextFieldPositionY() << "|" << std::setprecision(precision) << property->GetTextFieldHeight() << "|" -- Gitee From 862af7a4fc128c075d632e898f8a9a00c2cd599b Mon Sep 17 00:00:00 2001 From: zhaoqi209 <18872749497@163.com> Date: Wed, 27 Aug 2025 15:32:05 +0800 Subject: [PATCH 205/241] window status notify titlebar Signed-off-by: zhaoqi209 <18872749497@163.com> --- wm/src/window_session_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 079d095b8f..72c8faee99 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2339,6 +2339,9 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) (property_->GetIsPcAppInPad() && isSubWindow)) && !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); } + if (mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { + decorVisible = false; + } uiContent->UpdateDecorVisible(decorVisible, isDecorEnable); return; } -- Gitee From 6c4235b0c646d126e0fb03a8228248e47dca8bd3 Mon Sep 17 00:00:00 2001 From: meikun Date: Wed, 27 Aug 2025 15:40:13 +0800 Subject: [PATCH 206/241] =?UTF-8?q?=E4=BB=85=E4=B8=BB=E7=AA=97=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=80=91=E5=B8=83=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun --- window_scene/session/host/src/scene_session.cpp | 4 ++++ window_scene/test/unittest/scene_session_test6.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 712177e86f..01fe419d47 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5968,6 +5968,10 @@ void SceneSession::SetSupportEnterWaterfallMode(bool isSupportEnter) TLOGE(WmsLogTag::WMS_LAYOUT_PC, "sessionStage is nullptr"); return; } + if (!WindowHelper::IsMainWindow(GetWindowType())) { + TLOGW(WmsLogTag::WMS_LAYOUT_PC, "only main window support enter water fall mode."); + return; + } sessionStage_->SetSupportEnterWaterfallMode(isSupportEnter); } diff --git a/window_scene/test/unittest/scene_session_test6.cpp b/window_scene/test/unittest/scene_session_test6.cpp index 32752cd3da..0ac2bf511f 100644 --- a/window_scene/test/unittest/scene_session_test6.cpp +++ b/window_scene/test/unittest/scene_session_test6.cpp @@ -1242,6 +1242,8 @@ HWTEST_F(SceneSessionTest6, SetWindowTransitionAnimation, Function | SmallTest | ret = session->SetWindowTransitionAnimation(transitionType, animation); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_CALLING); } + + } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 76871db815bb4e6a1dff10dd7c5bce04878e4f8e Mon Sep 17 00:00:00 2001 From: meikun Date: Wed, 27 Aug 2025 15:44:32 +0800 Subject: [PATCH 207/241] =?UTF-8?q?=E4=BB=85=E4=B8=BB=E7=AA=97=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=80=91=E5=B8=83=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun --- .../test/unittest/scene_session_test6.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test6.cpp b/window_scene/test/unittest/scene_session_test6.cpp index 0ac2bf511f..161bb4ce38 100644 --- a/window_scene/test/unittest/scene_session_test6.cpp +++ b/window_scene/test/unittest/scene_session_test6.cpp @@ -1243,7 +1243,22 @@ HWTEST_F(SceneSessionTest6, SetWindowTransitionAnimation, Function | SmallTest | ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_CALLING); } +/** + * @tc.name: SetSupportEnterWaterfallMode + * @tc.desc: SetSupportEnterWaterfallMode + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest6, SetSupportEnterWaterfallMode, Function | SmallTest | Level1) +{ + SessionInfo info; + sptr session = sptr::MakeSptr(info, nullptr); + session->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + session->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + session->SetSupportEnterWaterfallMode(true); + session->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + session->SetSupportEnterWaterfallMode(true); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 770f5528265620b1695cd5ec7069f78a12ffbb3d Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Wed, 27 Aug 2025 15:52:48 +0800 Subject: [PATCH 208/241] fix Extension background bug Signed-off-by: Peng fafu --- window_scene/session/host/src/extension_session.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 19c0920199..0595b286d2 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -515,6 +515,7 @@ WSError ExtensionSession::Background(bool isFromClient, const std::string& ident isActive_ = false; } if (state == SessionState::STATE_BACKGROUND) { + TLOGD(WmsLogTag::WMS_LIFE, "ExtensionSession %{public}d state already backgrounded.", GetPersistentId()); return WSError::WS_OK; } if (state != SessionState::STATE_INACTIVE) { -- Gitee From 94a4cc882dbc4d72ef552e0617e27285961cf281 Mon Sep 17 00:00:00 2001 From: Peng fafu Date: Wed, 27 Aug 2025 16:05:48 +0800 Subject: [PATCH 209/241] fix Extension background bug Signed-off-by: Peng fafu --- window_scene/session/host/src/extension_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 0595b286d2..9d474055a2 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -515,7 +515,7 @@ WSError ExtensionSession::Background(bool isFromClient, const std::string& ident isActive_ = false; } if (state == SessionState::STATE_BACKGROUND) { - TLOGD(WmsLogTag::WMS_LIFE, "ExtensionSession %{public}d state already backgrounded.", GetPersistentId()); + TLOGI(WmsLogTag::WMS_LIFE, "ExtensionSession %{public}d state already backgrounded.", GetPersistentId()); return WSError::WS_OK; } if (state != SessionState::STATE_INACTIVE) { -- Gitee From cd0062164f349b543acf3431a17e10e05b706821 Mon Sep 17 00:00:00 2001 From: qianli22 Date: Wed, 27 Aug 2025 16:10:15 +0800 Subject: [PATCH 210/241] =?UTF-8?q?=E7=BC=A9=E7=9F=AD=E9=94=81=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qianli22 --- window_scene/session/host/src/scene_session.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 9b95ebe9ee..03a304b75f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4202,19 +4202,20 @@ void SceneSession::OnKeyFrameNextVsync(uint64_t count) bool SceneSession::KeyFrameNotifyFilter(const WSRect& rect, SizeChangeReason reason) { - TLOGD(WmsLogTag::WMS_LAYOUT, "reason in: %{public}d", reason); - std::lock_guard lock(keyFrameMutex_); - if (!keyFramePolicy_.running_) { + KeyFramePolicy keyFramePolicy; + { + std::lock_guard lock(keyFrameMutex_); + keyFramePolicy = keyFramePolicy_; + } + if (!keyFramePolicy.running_) { TLOGD(WmsLogTag::WMS_LAYOUT, "skip filter for not running"); return false; } if (reason == SizeChangeReason::DRAG_START) { - TLOGD(WmsLogTag::WMS_LAYOUT, "ensure start reason send"); NotifyClientToUpdateRect("OnMoveDragCallback", nullptr); return true; } if (reason != SizeChangeReason::DRAG) { - TLOGD(WmsLogTag::WMS_LAYOUT, "skip filter for not drag"); return false; } if (keyFrameAnimating_) { @@ -4225,13 +4226,13 @@ bool SceneSession::KeyFrameNotifyFilter(const WSRect& rect, SizeChangeReason rea uint64_t nowTimeStamp = static_cast(std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count()); uint64_t interval = nowTimeStamp - lastKeyFrameStamp_; - bool intervalCheckPass = interval >= keyFramePolicy_.interval_; + bool intervalCheckPass = interval >= keyFramePolicy.interval_; bool distanceCheckPass = false; double distance = 0; - if (keyFramePolicy_.distance_ > 0) { + if (keyFramePolicy.distance_ > 0) { distance = sqrt(pow(rect.width_ - lastKeyFrameRect_.width_, POW_DOUBLE) + pow(rect.height_ - lastKeyFrameRect_.height_, POW_DOUBLE)); - distanceCheckPass = distance >= keyFramePolicy_.distance_; + distanceCheckPass = distance >= keyFramePolicy.distance_; } TLOGI(WmsLogTag::WMS_LAYOUT, "key frame checking: %{public}" PRIu64 "[%{public}d], %{public}f[%{public}d]", interval, intervalCheckPass, distance, distanceCheckPass); -- Gitee From f0d4398dc52a474270fadfdf7946ae4004f247a5 Mon Sep 17 00:00:00 2001 From: tanliang Date: Wed, 27 Aug 2025 17:22:11 +0800 Subject: [PATCH 211/241] =?UTF-8?q?=E9=80=9A=E8=BF=87id=E7=AE=A1=E6=8E=A7?= =?UTF-8?q?=E6=97=B6=E6=A0=A1=E9=AA=8C=E7=AA=97=E5=8F=A3=E5=90=88=E6=B3=95?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanliang --- interfaces/innerkits/wm/wm_common.h | 2 +- .../src/scene_session_manager.cpp | 7 +++ .../scene_session_manager_lite_proxy_test.cpp | 24 ++++++++ .../scene_session_manager_lite_stub_test.cpp | 29 ++++++++- .../unittest/scene_session_manager_test10.cpp | 60 ++++++++++++++++--- 5 files changed, 112 insertions(+), 10 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 4a81573ee9..0e344de181 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -439,7 +439,7 @@ enum class ControlAppType : uint8_t { CONTROL_APP_TYPE_BEGIN = 0, APP_LOCK = 1, PARENT_CONTROL, - DLP_HIDE, + DLP, PRIVACY_WINDOW, CONTROL_APP_TYPE_END, }; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index bc453222bc..8e3a081162 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -11551,11 +11551,18 @@ void SceneSessionManager::NotifyAppUseControlListInner( TLOGW(WmsLogTag::WMS_MAIN, "session not found, id:%{public}d", appUseControlInfo.persistentId_); continue; } + if (iter->second->GetSessionInfo().bundleName_ != appUseControlInfo.bundleName_ || + iter->second->GetSessionInfo().appIndex_ != appUseControlInfo.appIndex_ || + !SessionHelper::IsMainWindow(iter->second->GetWindowType())) { + TLOGW(WmsLogTag::WMS_MAIN, "invalid session, id:%{public}d", appUseControlInfo.persistentId_); + continue; + } mainSessions.push_back(iter->second); } else { // control by bundleName and appIndex RefreshAllAppUseControlMap(appUseControlInfo, type); GetMainSessionByBundleNameAndAppIndex(appUseControlInfo.bundleName_, appUseControlInfo.appIndex_, mainSessions); + controlByBundleList.push_back(appUseControlInfo); } if (mainSessions.empty()) { continue; diff --git a/window_scene/test/unittest/scene_session_manager_lite_proxy_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_proxy_test.cpp index fe5d4a0175..16f1e2befe 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_proxy_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_proxy_test.cpp @@ -284,4 +284,28 @@ HWTEST_F(sceneSessionManagerLiteProxyTest, IsFocusWindowParent, TestSize.Level1) EXPECT_EQ(errCode, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetReadInt32ErrorFlag(false); } + +/** + * @tc.name: NotifyAppUseControlList + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(sceneSessionManagerLiteProxyTest, NotifyAppUseControlList, TestSize.Level1) +{ + sptr iRemoteObjectMocker = sptr::MakeSptr(); + sptr sceneSessionManagerLiteProxy = + sptr::MakeSptr(iRemoteObjectMocker); + ASSERT_NE(sceneSessionManagerLiteProxy, nullptr); + MockMessageParcel::ClearAllErrorFlag(); + ControlAppType type = ControlAppType::DLP; + int32_t userId = 100; + std::vector controlList; + AppUseControlInfo controlInfo; + controlList.push_back(controlInfo); + WMError errCode = sceneSessionManagerLiteProxy->NotifyAppUseControlList(type, userId, controlList); + EXPECT_EQ(errCode, WSError::WS_OK); + MockMessageParcel::SetWriteParcelableErrorFlag(true); + errCode = sceneSessionManagerLiteProxy->NotifyAppUseControlList(type, userId, controlList); + EXPECT_EQ(errCode, WSError::WS_ERROR_INVALID_PARAM); +} } \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp index e57cdb7033..bbab0983fd 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp @@ -1116,7 +1116,34 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleNotifyAppUseControlList, TestSiz data.WriteInt32(appIndex); data.WriteBool(isControl); - auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(data, reply); + auto res = sceneSessionManagerLiteStub_-> + SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(data, reply); + EXPECT_EQ(ERR_INVALID_DATA, res); +} + +/** + * @tc.name: HandleNotifyAppUseControlList02 + * @tc.desc: test function : HandleNotifyAppUseControlList02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerLiteStubTest, HandleNotifyAppUseControlList02, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + uint8_t typeId = 1; + int32_t userId = 1; + int32_t size = 1; + std::string bundleName = "appbundleName"; + int32_t appIndex = 1; + bool isControl = true; + bool isControlRecentOnly = true; + data.WriteUint8(typeId); + data.WriteInt32(userId); + data.WriteInt32(size); + AppUseControlInfo controlInfo; + data.WriteParcelable(&controlInfo); + auto res = sceneSessionManagerLiteStub_-> + SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(data, reply); EXPECT_EQ(ERR_NONE, res); } diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 0e441b770b..8ddd07a2e5 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -1139,6 +1139,7 @@ HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlList, TestSize.Level1) appUseControlInfo.isNeedControl_ = true; EXPECT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList)); + usleep(WAIT_SYNC_IN_NS); } /** @@ -1150,21 +1151,23 @@ HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlListInner, TestSize.Level { ASSERT_NE(ssm_, nullptr); int32_t controlListSize = -1; - ssm->notifyAppUseControlListFunc_ = [&controlListSize] + ssm_->notifyAppUseControlListFunc_ = [&controlListSize] (ControlAppType type, int32_t userId, const std::vector& controlList) { controlListSize = controlList.size(); }; AppUseControlInfo controlById; controlById.persistentId_ = 100; + controlById.bundleName_ = "bundleName"; + controlById.appIndex_ = 0; std::vector controlList; controlList.push_back(controlById); - ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP, 0, controlList); EXPECT_EQ(controlListSize, -1); ssm_->sceneSessionMap_.emplace(100, nullptr); - ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP, 0, controlList); EXPECT_EQ(controlListSize, -1); - sessionInfo sessionInfo; + SessionInfo sessionInfo; sessionInfo.persistentId_ = 100; sessionInfo.bundleName_ = "bundleName"; sessionInfo.appIndex_ = 0; @@ -1172,19 +1175,60 @@ HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlListInner, TestSize.Level sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ssm_->sceneSessionMap_.emplace(100, sceneSession); - ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP, 0, controlList); EXPECT_EQ(controlListSize, -1); AppUseControlInfo controlByBundle; controlByBundle.bundleName_ = "bundleName"; controlByBundle.appIndex_ = 0; controlList.push_back(controlByBundle); - ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP, 0, controlList); EXPECT_EQ(controlListSize, 1); - ssm->notifyAppUseControlListFunc_ = nullptr; + ssm_->notifyAppUseControlListFunc_ = nullptr; controlListSize = -1; - ssm_->NotifyAppUseControlListInner(ControlAppType::DLP_HIDE, 0, controlList); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP, 0, controlList); + EXPECT_EQ(controlListSize, -1); +} + +/** + * @tc.name: NotifyAppUseControlListInner02 + * @tc.desc: NotifyAppUseControlListInner02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlListInner02, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + int32_t controlListSize = -1; + ssm_->notifyAppUseControlListFunc_ = [&controlListSize] + (ControlAppType type, int32_t userId, const std::vector& controlList) { + controlListSize = controlList.size(); + }; + std::vector controlList; + AppUseControlInfo controlById; + controlById.persistentId_ = 100; + controlById.bundleName_ = "bundleName"; + controlById.appIndex_ = 0; + controlList.push_back(controlById); + AppUseControlInfo controlById2; + controlById2.persistentId_ = 100; + controlById2.bundleName_ = "errorBundleName"; + controlById2.appIndex_ = 0; + controlList.push_back(controlById2); + AppUseControlInfo controlById3; + controlById3.persistentId_ = 100; + controlById3.bundleName_ = "bundleName"; + controlById3.appIndex_ = 100; + controlList.push_back(controlById3); + + SessionInfo sessionInfo; + sessionInfo.persistentId_ = 100; + sessionInfo.bundleName_ = "bundleName"; + sessionInfo.appIndex_ = 0; + sessionInfo.windowType_ = 1000; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ssm_->sceneSessionMap_.emplace(100, sceneSession); + ssm_->NotifyAppUseControlListInner(ControlAppType::DLP, 0, controlList); EXPECT_EQ(controlListSize, -1); } -- Gitee From dc5daed67af4a7cbfc0f0ebb2e4001e39b5f9b3f Mon Sep 17 00:00:00 2001 From: sunshuaiyuan Date: Thu, 21 Aug 2025 16:44:18 +0800 Subject: [PATCH 212/241] notify switching Signed-off-by: sunshuaiyuan --- .../secondary_display_fold_policy.h | 3 ++- .../secondary_display_fold_policy.cpp | 25 +++++++++++++++---- .../secondary_display_fold_policy_test.cpp | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/window_scene/screen_session_manager/include/fold_screen_controller/secondary_display_fold_policy.h b/window_scene/screen_session_manager/include/fold_screen_controller/secondary_display_fold_policy.h index f135dc9763..d86637ec9f 100644 --- a/window_scene/screen_session_manager/include/fold_screen_controller/secondary_display_fold_policy.h +++ b/window_scene/screen_session_manager/include/fold_screen_controller/secondary_display_fold_policy.h @@ -54,7 +54,8 @@ private: void SendPropertyChangeResult(sptr screenSession, ScreenId screenId, ScreenPropertyChangeReason reason, FoldDisplayMode displayMode); void SetStatusConditionalActiveRectAndTpFeature(ScreenProperty &screenProperty); - void SetStatusFullActiveRectAndTpFeature(const sptr& screenSession, ScreenProperty &screenProperty); + void SetStatusFullActiveRectAndTpFeature(const sptr& screenSession, ScreenProperty& screenProperty, + bool isNeedToSetSwitch = true); void SetStatusMainActiveRectAndTpFeature(const sptr& screenSession, ScreenProperty &screenProperty); void SetStatusGlobalFullActiveRectAndTpFeature(const sptr& screenSession, ScreenProperty &screenProperty); 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 ba1892a016..d1b555fec9 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 @@ -43,7 +43,7 @@ const int32_t GLOBAL_FULL_STATUS_WIDTH = 2; const int32_t SCREEN_HEIGHT = 3; const int32_t FULL_STATUS_OFFSET_X = 4; constexpr uint32_t HALF_DIVIDER = 2; -constexpr float MAIN_DISPLAY_ROTATION_DEGREE = 180; +constexpr float MAIN_DISPLAY_ROTATION_DEGREE = -270; constexpr float ROTATION_TRANSLATE_X = 612; constexpr float ROTATION_TRANSLATE_Y = -612; constexpr float FULL_NODE_POSITION_Z = 0.0f; @@ -501,12 +501,18 @@ void SecondaryDisplayFoldPolicy::SendPropertyChangeResult(sptr sc { std::lock_guard lock_info(displayInfoMutex_); screenProperty_ = ScreenSessionManager::GetInstance().GetPhyScreenProperty(screenId); + bool isNeedNotifyFoldProperty = true; + bool isNeedToSetSwitch = true; switch (displayMode) { case FoldDisplayMode::FULL: { if (currentDisplayMode_ == FoldDisplayMode::COORDINATION) { + if (currentFoldStatus_ == FoldStatus::EXPAND) { + isNeedToSetSwitch = false; + isNeedNotifyFoldProperty = false; + } CloseCoordinationScreen(); } - SetStatusFullActiveRectAndTpFeature(screenSession, screenProperty_); + SetStatusFullActiveRectAndTpFeature(screenSession, screenProperty_, isNeedToSetSwitch); break; } case FoldDisplayMode::MAIN: { @@ -526,6 +532,7 @@ void SecondaryDisplayFoldPolicy::SendPropertyChangeResult(sptr sc } case FoldDisplayMode::COORDINATION: { if (currentDisplayMode_ == FoldDisplayMode::FULL) { + isNeedNotifyFoldProperty = false; ChangeScreenDisplayModeToCoordination(); SetStatusConditionalActiveRectAndTpFeature(screenProperty_); } @@ -542,14 +549,20 @@ void SecondaryDisplayFoldPolicy::SendPropertyChangeResult(sptr sc if (displayMode == FoldDisplayMode::MAIN) { screenSession->SetRotationAndScreenRotationOnly(Rotation::ROTATION_0); } - screenSession->PropertyChange(oldScreenProperty, reason); + + if (isNeedNotifyFoldProperty) { + screenSession->PropertyChange(oldScreenProperty, reason); + } else { + TLOGI(WmsLogTag::DMS, "PropertyChange...set displayModeChangeStatus"); + SetSecondaryDisplayModeChangeStatus(false); + } TLOGI(WmsLogTag::DMS, "screenBounds : width_= %{public}f, height_= %{public}f", screenSession->GetScreenProperty().GetBounds().rect_.width_, screenSession->GetScreenProperty().GetBounds().rect_.height_); } void SecondaryDisplayFoldPolicy::SetStatusFullActiveRectAndTpFeature(const sptr& screenSession, - ScreenProperty &screenProperty) + ScreenProperty &screenProperty, bool isNeedToSetSwitch) { if (screenParams_.size() < FULL_STATUS_OFFSET_X + 1) { return; @@ -566,7 +579,9 @@ void SecondaryDisplayFoldPolicy::SetStatusFullActiveRectAndTpFeature(const sptr< .h = screenParams_[FULL_STATUS_WIDTH], }; if (!onBootAnimation_) { - RSInterfaces::GetInstance().NotifyScreenSwitched(); + if (isNeedToSetSwitch) { + RSInterfaces::GetInstance().NotifyScreenSwitched(); + } auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); TLOGI(WmsLogTag::DMS, "rs response is %{public}ld", static_cast(response)); } diff --git a/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp b/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp index 1c8daec9dd..72411cc277 100644 --- a/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp +++ b/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp @@ -339,7 +339,7 @@ HWTEST_F(SecondaryDisplayFoldPolicyTest, SetStatusFullActiveRectAndTpFeature, Te ScreenProperty property = policy.screenProperty_; sptr screenSession = ScreenSessionManager::GetInstance().GetScreenSession(0); - policy.SetStatusFullActiveRectAndTpFeature(screenSession, property); + policy.SetStatusFullActiveRectAndTpFeature(screenSession, property, true); EXPECT_FALSE(policy.onBootAnimation_); } -- Gitee From 8bca43378966837c3543d9c7892a2e492a54330e Mon Sep 17 00:00:00 2001 From: zxf Date: Mon, 25 Aug 2025 14:39:46 +0800 Subject: [PATCH 213/241] =?UTF-8?q?rss=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=B4=9F=E8=BD=BD=E5=9C=BA=E6=99=AF=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zxf Signed-off-by: bai_heng --- .../napi/scene_session_manager/js_rss_session.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_rss_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_rss_session.cpp index 313497e52e..9c3d7258ed 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_rss_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_rss_session.cpp @@ -112,6 +112,11 @@ void SetMapValue(napi_env env, const std::string& key, const T& value, napi_valu napi_set_property(env, object, keyInfo, valueInfo); } +bool IsJsonString(const nlohmann::json& payload, const std::string& key) +{ + return payload.contains(key) && payload[key].is_string(); +} + napi_value RssSession::DealRssReply(napi_env env, const nlohmann::json& payload, const nlohmann::json& reply) { WLOGFI("[NAPI]"); @@ -122,6 +127,12 @@ napi_value RssSession::DealRssReply(napi_env env, const nlohmann::json& payload, return NapiGetUndefined(env); } + if (IsJsonString(reply, "resultType") && reply.at("resultType") == "loadSceneJudgement" && + IsJsonString(reply, "resultValue")) { + SetMapValue(env, "result", reply["resultValue"].get(), objValue); + return objValue; + } + if (!reply.contains("result") || !reply["result"].is_string() || reply.at("result") == "") { WLOGFE("Reply not find result key!"); return NapiGetUndefined(env); -- Gitee From a97f39d867ee92a5a9ced6e847531098f2fd3b35 Mon Sep 17 00:00:00 2001 From: zhangweihua Date: Wed, 27 Aug 2025 20:24:30 +0800 Subject: [PATCH 214/241] tdd bugfix Signed-off-by: zhangweihua --- dm/test/unittest/BUILD.gn | 1 + dm/test/unittest/display_manager_adapter_test.cpp | 6 ++++++ dm/test/unittest/display_manager_test.cpp | 5 +++-- dm/test/unittest/display_test.cpp | 6 ++++++ dm/test/unittest/oh_display_manager_test.cpp | 10 ++++++++++ test/systemtest/dms/BUILD.gn | 6 ++++++ window_scene/test/dms_unittest/BUILD.gn | 5 ++++- .../test/dms_unittest/fold_screen_controller_test.cpp | 4 ++++ .../test/dms_unittest/screen_scene_config_test.cpp | 3 +++ .../test/dms_unittest/screen_setting_helper_test.cpp | 3 +++ .../secondary_display_fold_policy_test.cpp | 6 ++++++ 11 files changed, 52 insertions(+), 3 deletions(-) diff --git a/dm/test/unittest/BUILD.gn b/dm/test/unittest/BUILD.gn index 42c2cb11e2..3564be31f9 100644 --- a/dm/test/unittest/BUILD.gn +++ b/dm/test/unittest/BUILD.gn @@ -223,6 +223,7 @@ ohos_unittest("dm_oh_display_manager_test") { deps = [ ":dm_unittest_common", "${window_base_path}/dm:libdm_ndk", + "${window_base_path}/window_scene/interfaces/innerkits:libwsutils" ] external_deps = [ diff --git a/dm/test/unittest/display_manager_adapter_test.cpp b/dm/test/unittest/display_manager_adapter_test.cpp index e921ae480a..0f1ceb3ea3 100644 --- a/dm/test/unittest/display_manager_adapter_test.cpp +++ b/dm/test/unittest/display_manager_adapter_test.cpp @@ -926,6 +926,9 @@ HWTEST_F(DisplayManagerAdapterTest, GetDisplayHDRSnapshot001, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, SetVirtualScreenAutoRotation, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } ScreenId screenId = 1111; bool enable = false; DMError err = SingletonContainer::Get().SetVirtualScreenAutoRotation(screenId, enable); @@ -939,6 +942,9 @@ HWTEST_F(DisplayManagerAdapterTest, SetVirtualScreenAutoRotation, TestSize.Level */ HWTEST_F(DisplayManagerAdapterTest, SetScreenPrivacyWindowTagSwitch, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } ScreenId screenId = 0; std::vector privacyWindowTag{"test1", "test2"}; DMError res = SingletonContainer::Get().SetScreenPrivacyWindowTagSwitch(screenId, diff --git a/dm/test/unittest/display_manager_test.cpp b/dm/test/unittest/display_manager_test.cpp index d9caf6b8c0..f6d45428e0 100644 --- a/dm/test/unittest/display_manager_test.cpp +++ b/dm/test/unittest/display_manager_test.cpp @@ -1765,8 +1765,6 @@ HWTEST_F(DisplayManagerTest, GetCutoutInfoWithRotation, Function | SmallTest | L sptr info = DisplayManager::GetInstance().GetCutoutInfoWithRotation(rotation); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(nullptr, info); - } else { - ASSERT_EQ(nullptr, info); } } @@ -2366,6 +2364,9 @@ HWTEST_F(DisplayManagerTest, GetScreenHDRshotWithOption_ShouldReturnNull_WhenGet */ HWTEST_F(DisplayManagerTest, GetScreenHDRshotWithOption_WhenDisplayIdIsValidButSnapshotFails, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } CaptureOption captureOption; captureOption.displayId_ = DEFAULT_DISPLAY; DmErrorCode errorCode; diff --git a/dm/test/unittest/display_test.cpp b/dm/test/unittest/display_test.cpp index a554998ed6..67a2781ee8 100644 --- a/dm/test/unittest/display_test.cpp +++ b/dm/test/unittest/display_test.cpp @@ -288,6 +288,9 @@ HWTEST_F(DisplayTest, GetDisplayInfoWithCache01, TestSize.Level1) */ HWTEST_F(DisplayTest, GetLiveCreaseRegion, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } sptr baseInfo = sptr::MakeSptr(); sptr disPlay = sptr::MakeSptr("", baseInfo); FoldCreaseRegion region; @@ -315,6 +318,9 @@ HWTEST_F(DisplayTest, GetLiveCreaseRegion, TestSize.Level1) */ HWTEST_F(DisplayTest, GetOriginRotation, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } auto baseInfo = defaultDisplay_->GetDisplayInfo(); Rotation rotation = Rotation::ROTATION_90; baseInfo->SetOriginRotation(rotation); diff --git a/dm/test/unittest/oh_display_manager_test.cpp b/dm/test/unittest/oh_display_manager_test.cpp index 49847f333f..7ad76d502d 100644 --- a/dm/test/unittest/oh_display_manager_test.cpp +++ b/dm/test/unittest/oh_display_manager_test.cpp @@ -20,6 +20,7 @@ #include "oh_display_manager.h" #include "oh_display_manager_inner.h" #include "pixelmap_native_impl.h" +#include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; @@ -564,6 +565,9 @@ HWTEST_F(OHDisplayManagerTest, DisplayRemoveListener, TestSize.Level1) */ HWTEST_F(OHDisplayManagerTest, DisplayRemoveListener02, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } uint32_t* testIndex = nullptr; NativeDisplayManager_ErrorCode ret = OH_NativeDisplayManager_RegisterDisplayRemoveListener( DisplayRemoveCallback, testIndex); @@ -596,6 +600,9 @@ HWTEST_F(OHDisplayManagerTest, OH_NativeDisplayManager_CreateAvailableArea01, Te */ HWTEST_F(OHDisplayManagerTest, OH_NativeDisplayManager_CreateAvailableArea02, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } uint64_t testId = 0; NativeDisplayManager_Rect *availableArea = nullptr; NativeDisplayManager_ErrorCode ret = OH_NativeDisplayManager_CreateAvailableArea(testId, &availableArea); @@ -764,6 +771,9 @@ HWTEST_F(OHDisplayManagerTest, OH_NativeDisplayManager_GetDisplayPosition05, Tes */ HWTEST_F(OHDisplayManagerTest, OH_NativeDisplayManager_GetDisplayPosition06, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } uint64_t testId = 2; // 异常屏幕 int32_t x = -1; int32_t y = -1; diff --git a/test/systemtest/dms/BUILD.gn b/test/systemtest/dms/BUILD.gn index ea9a50856c..83689595a1 100644 --- a/test/systemtest/dms/BUILD.gn +++ b/test/systemtest/dms/BUILD.gn @@ -123,6 +123,12 @@ ohos_systemtest("dms_screenshot_test") { } ohos_systemtest("dms_screen_manager_test") { + sanitize = { + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } module_out_path = module_out_path sources = [ "screen_manager_test.cpp" ] diff --git a/window_scene/test/dms_unittest/BUILD.gn b/window_scene/test/dms_unittest/BUILD.gn index 247c5bec0b..4e77e9a424 100644 --- a/window_scene/test/dms_unittest/BUILD.gn +++ b/window_scene/test/dms_unittest/BUILD.gn @@ -758,7 +758,10 @@ if (window_manager_fold_ability) { sources = [ "fold_screen_controller_test.cpp" ] - deps = [ ":ws_unittest_common" ] + deps = [ + ":ws_unittest_common", + "${window_base_path}/window_scene/interfaces/innerkits:libwsutils" + ] external_deps = test_external_deps external_deps += [ "init:libbegetutil" ] diff --git a/window_scene/test/dms_unittest/fold_screen_controller_test.cpp b/window_scene/test/dms_unittest/fold_screen_controller_test.cpp index 93120cc991..47e5f188d4 100644 --- a/window_scene/test/dms_unittest/fold_screen_controller_test.cpp +++ b/window_scene/test/dms_unittest/fold_screen_controller_test.cpp @@ -15,6 +15,7 @@ #include +#include "scene_board_judgement.h" #include "screen_session_manager/include/fold_screen_controller/fold_screen_controller.h" #include "screen_session_manager/include/screen_session_manager.h" #include "fold_screen_state_internel.h" @@ -594,6 +595,9 @@ namespace { */ HWTEST_F(FoldScreenControllerTest, OnTentModeChanged02, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } if (ssm_.IsFoldable()) { bool isTentMode = true; ssm_.foldScreenController_->OnTentModeChanged(isTentMode); diff --git a/window_scene/test/dms_unittest/screen_scene_config_test.cpp b/window_scene/test/dms_unittest/screen_scene_config_test.cpp index 63824d6bd3..a2087d8ff3 100644 --- a/window_scene/test/dms_unittest/screen_scene_config_test.cpp +++ b/window_scene/test/dms_unittest/screen_scene_config_test.cpp @@ -434,6 +434,9 @@ HWTEST_F(ScreenSceneConfigTest, GetCutoutBoundaryRect, TestSize.Level1) */ HWTEST_F(ScreenSceneConfigTest, GetSubCutoutBoundaryRect, TestSize.Level1) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } auto result = ScreenSceneConfig::GetSubCutoutBoundaryRect(); if (ScreenSessionManager::GetInstance().IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { ASSERT_TRUE(result.size() > 0); 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 9def568a5a..d5033e6675 100644 --- a/window_scene/test/dms_unittest/screen_setting_helper_test.cpp +++ b/window_scene/test/dms_unittest/screen_setting_helper_test.cpp @@ -943,6 +943,9 @@ namespace { */ HWTEST_F(ScreenSettingHelperTest, GetSettingDuringCallStateTest, Function | SmallTest | Level3) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return; + } ScreenSettingHelper screenSettingHelper = ScreenSettingHelper(); bool value = true; diff --git a/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp b/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp index 1c8daec9dd..9aca8011dd 100644 --- a/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp +++ b/window_scene/test/dms_unittest/secondary_display_fold_policy_test.cpp @@ -640,6 +640,9 @@ HWTEST_F(SecondaryDisplayFoldPolicyTest, SetStatusConditionalActiveRectAndTpFeat */ HWTEST_F(SecondaryDisplayFoldPolicyTest, InitPositionZInfosFeature, TestSize.Level1) { + if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + GTEST_SKIP(); + } std::recursive_mutex displayInfoMutex; std::shared_ptr screenPowerTaskScheduler = nullptr; SecondaryDisplayFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); @@ -659,6 +662,9 @@ HWTEST_F(SecondaryDisplayFoldPolicyTest, InitPositionZInfosFeature, TestSize.Lev */ HWTEST_F(SecondaryDisplayFoldPolicyTest, UpdatePositionZForDualDisplayNodeFeature, TestSize.Level1) { + if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { + GTEST_SKIP(); + } std::recursive_mutex displayInfoMutex; std::shared_ptr screenPowerTaskScheduler = nullptr; SecondaryDisplayFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); -- Gitee From 727673c8d2c58231f71188cf33d8c76bada99d3d Mon Sep 17 00:00:00 2001 From: meikun Date: Thu, 28 Aug 2025 09:11:44 +0800 Subject: [PATCH 215/241] =?UTF-8?q?=E4=BB=85=E4=B8=BB=E7=AA=97=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=80=91=E5=B8=83=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun --- window_scene/test/unittest/scene_session_test6.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/test/unittest/scene_session_test6.cpp b/window_scene/test/unittest/scene_session_test6.cpp index 161bb4ce38..bd244bf0d1 100644 --- a/window_scene/test/unittest/scene_session_test6.cpp +++ b/window_scene/test/unittest/scene_session_test6.cpp @@ -1258,6 +1258,7 @@ HWTEST_F(SceneSessionTest6, SetSupportEnterWaterfallMode, Function | SmallTest | session->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); session->SetSupportEnterWaterfallMode(true); + EXPECT_TRUE(session->sessionStage_ != nullptr); } } // namespace } // namespace Rosen -- Gitee From 869dc084791bbdab9b2a4259684dfeabe84e99fc Mon Sep 17 00:00:00 2001 From: Ray95 Date: Thu, 28 Aug 2025 09:35:45 +0800 Subject: [PATCH 216/241] =?UTF-8?q?=E6=95=B4=E6=94=B9=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ray95 --- window_scene/common/src/session_permission.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/window_scene/common/src/session_permission.cpp b/window_scene/common/src/session_permission.cpp index cc4c247a94..3d1d6b88c2 100644 --- a/window_scene/common/src/session_permission.cpp +++ b/window_scene/common/src/session_permission.cpp @@ -80,9 +80,7 @@ bool SessionPermission::IsSystemCalling() if (IsTokenNativeOrShellType(tokenId)) { return true; } - uint64_t accessTokenIDEx = IPCSkeleton::GetCallingFullTokenID(); - bool isSystemApp = Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(accessTokenIDEx); - return isSystemApp; + return IsSystemAppCall(); } bool SessionPermission::IsSystemAppCall() @@ -160,8 +158,7 @@ bool SessionPermission::JudgeCallerIsAllowedToUseSystemAPI() if (IsSACalling() || IsShellCall()) { return true; } - auto callerToken = IPCSkeleton::GetCallingFullTokenID(); - return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(callerToken); + return IsSystemAppCall(); } bool SessionPermission::IsShellCall() -- Gitee From e1b65a13175c6c2d1d177bf4ddb0d4ef5e8a16fe Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 10:26:50 +0800 Subject: [PATCH 217/241] hook Signed-off-by: chaos --- .../include/screen_session_manager.h | 3 ++ .../src/screen_session_manager.cpp | 46 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) 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 97469b7a85..7893acd09c 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -169,6 +169,8 @@ public: bool SetRotationFromWindow(Rotation targetRotation); sptr GetScreenModesByDisplayId(DisplayId displayId); sptr GetScreenInfoByDisplayId(DisplayId displayId); + void NotifyDisplayChangedByHook(const std::map>& screenSessionMap, DisplayChangeEvent event, + uint32_t uid); void NotifyDisplayCreate(sptr displayInfo); void NotifyDisplayDestroy(DisplayId displayId); void NotifyAndPublishEvent(sptr displayInfo, ScreenId screenId, sptr screenSession); @@ -700,6 +702,7 @@ private: std::map, std::vector> screenAgentMap_; std::map> smsScreenGroupMap_; std::map displayHookMap_; + std::map uidAndPidMap_; bool userSwitching_ = false; bool isAutoRotationOpen_ = false; 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 7197a05bec..93a9fd1877 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2140,17 +2140,61 @@ void ScreenSessionManager::UpdateDisplayHookInfo(int32_t uid, bool enable, const TLOGE(WmsLogTag::DMS, "permission denied!"); return; } - + std::map> screenSessionMapCopy; + { + std::lock_guard lock(screenSessionMapMutex_); + screenSessionMapCopy = screenSessionMap_; + } std::unique_lock lock(hookInfoMutex_); if (enable) { if (uid != 0) { displayHookMap_[uid] = hookInfo; + NotifyDisplayChangedByHook(screenSessionMapCopy, DisplayChangeEvent::DISPLAY_SIZE_CHANGED, uid); } } else { displayHookMap_.erase(uid); } } +void ScreenSessionManager::NotifyDisplayChangedByHook(const std::map>& screenSessionMap, + DisplayChangeEvent event, uint32_t uid) +{ + for (const auto& sessionIt : screenSessionMapCopy) { + auto screenSession = sessionIt.second; + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); + continue; + } + auto displayInfo = screenSession->ConvertToDisplayInfo(); + if (displayInfo == nullptr) { + TLOGE(WmsLogTag::DMS, "displayInfo is nullptr."); + continue; + } + auto task = [=] { + auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_EVENT_LISTENER); + if (event == DisplayChangeEvent::UPDATE_REFRESHRATE) { + TLOGND(WmsLogTag::DMS, "evevt:%{public}d, displayId:%{public}" PRIu64", agent size: %{public}u", + event, displayInfo->GetDisplayId(), static_cast(agents.size())); + } else { + TLOGNI(WmsLogTag::DMS, "evevt:%{public}d, displayId:%{public}" PRIu64", agent size: %{public}u", + event, displayInfo->GetDisplayId(), static_cast(agents.size())); + } + if (agents.empty()) { + return; + } + for (auto& agent : agents) { + int32_t agentPid = dmAgentContainer_.GetAgentPid(agent); + auto iter = uidAndPidMap_.find(uid); + if (iter != uidAndPidMap_.end() && iter->second == agentPid) { + if (!IsFreezed(agentPid, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER)) { + agent->OnDisplayChange(displayInfo, event); + } + } + } + }; + taskScheduler_->PostAsyncTask(task, "NotifyDisplayChanged"); +} + void ScreenSessionManager::GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo) { std::shared_lock lock(hookInfoMutex_); -- Gitee From 5f474af907ade0ed1b7f199b40693b8c561fef31 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 10:35:02 +0800 Subject: [PATCH 218/241] uid Signed-off-by: chaos --- .../screen_session_manager/src/screen_session_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) 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 93a9fd1877..3f33171f32 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1808,7 +1808,9 @@ sptr ScreenSessionManager::HookDisplayInfoByUid(sptr d return nullptr; } auto uid = IPCSkeleton::GetCallingUid(); + auto pid = IPCSkeleton::GetCallingPid(); std::shared_lock lock(hookInfoMutex_); + uidAndPidMap_[uid] = pid; if (displayHookMap_.find(uid) != displayHookMap_.end()) { auto info = displayHookMap_[uid]; std::ostringstream oss; -- Gitee From 04b71ef88f12696bb9ae345e45eb678e2490a626 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 11:21:28 +0800 Subject: [PATCH 219/241] fix2 Signed-off-by: chaos --- .../screen_session_manager/include/screen_session_manager.h | 2 +- .../screen_session_manager/src/screen_session_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 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 7893acd09c..cb7082ed67 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -702,7 +702,7 @@ private: std::map, std::vector> screenAgentMap_; std::map> smsScreenGroupMap_; std::map displayHookMap_; - std::map uidAndPidMap_; + std::map uidAndPidMap_; bool userSwitching_ = false; bool isAutoRotationOpen_ = false; 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 3f33171f32..77ce0a3743 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2161,7 +2161,7 @@ void ScreenSessionManager::UpdateDisplayHookInfo(int32_t uid, bool enable, const void ScreenSessionManager::NotifyDisplayChangedByHook(const std::map>& screenSessionMap, DisplayChangeEvent event, uint32_t uid) { - for (const auto& sessionIt : screenSessionMapCopy) { + for (const auto& sessionIt : screenSessionMap) { auto screenSession = sessionIt.second; if (screenSession == nullptr) { TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); -- Gitee From 38ffd180d907205b164ef7b9160fa14f65a2c8fd Mon Sep 17 00:00:00 2001 From: q00576684 Date: Wed, 27 Aug 2025 17:07:18 +0800 Subject: [PATCH 220/241] =?UTF-8?q?=E6=82=AC=E6=B5=AE=E7=90=83=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=86=97=E4=BD=99=E6=89=93=E7=82=B9=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=96=B0=E5=A2=9ELLT=20Signed-off-by:qiaodong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/include/floating_ball_report.h | 16 +++-- utils/src/floating_ball_report.cpp | 71 +++---------------- wm/src/floating_ball_controller.cpp | 39 +++++----- .../floating_ball_controller_test.cpp | 22 ++++++ 4 files changed, 63 insertions(+), 85 deletions(-) diff --git a/utils/include/floating_ball_report.h b/utils/include/floating_ball_report.h index b456b3fdff..56db4f0af7 100644 --- a/utils/include/floating_ball_report.h +++ b/utils/include/floating_ball_report.h @@ -21,15 +21,19 @@ #include "wm_common.h" namespace OHOS::Rosen { -class FloatingballReporter { -WM_DECLARE_SINGLE_INSTANCE(FloatingballReporter); +namespace FloatingBallEvent { + constexpr char EVENT_KEY_START[] = "START_FLOATING_BALL"; + constexpr char EVENT_KEY_UPDATE[] = "UPDATE_FLOATING_BALL"; + constexpr char EVENT_KEY_REMOVE[] = "REMOVE_FLOATING_BALL"; + constexpr char EVENT_KEY_RESTORE[] = "RESTORE_FLOATING_BALL_WINDOW"; +} + +class FloatingBallReporter { +WM_DECLARE_SINGLE_INSTANCE(FloatingBallReporter); public: void SetCurrentPackageName(const std::string& packageName); - void ReportFbStart(const uint32_t& templateType, const std::string& errorReason); - void ReportFbRemove(const uint32_t& templateType, const std::string& errorReason); - void ReportFbRestoreMainWindow(const uint32_t& templateType, const std::string& errorReason); - void ReportFbUpdateContent(const uint32_t& templateType, const std::string &errorReason); + void ReportFbEvent(const std::string& eventName, const uint32_t& templateType, const std::string& errorReason); private: std::string GetPackageName() const; std::string packageName_ = ""; diff --git a/utils/src/floating_ball_report.cpp b/utils/src/floating_ball_report.cpp index a5b6402cde..01b2b99305 100644 --- a/utils/src/floating_ball_report.cpp +++ b/utils/src/floating_ball_report.cpp @@ -20,10 +20,10 @@ namespace OHOS { namespace Rosen { namespace { -const std::string PNAMEID = "SCB_FLOATING_BALL"; -const std::string PVERSION = "1.0"; +constexpr char PNAMEID[] = "SCB_FLOATING_BALL"; +constexpr char PVERSION[] = "1.0"; } -WM_IMPLEMENT_SINGLE_INSTANCE(FloatingballReporter) +WM_IMPLEMENT_SINGLE_INSTANCE(FloatingBallReporter) constexpr char EVENT_KEY_TEMPLATE_TYPE[] = "TEMPLATE_TYPE"; constexpr char EVENT_KEY_PNAMEID[] = "PNAMEID"; @@ -31,76 +31,25 @@ constexpr char EVENT_KEY_PVERSION[] = "PVERSION"; constexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME"; constexpr char EVENT_KEY_ERROR_REASON[] = "ERROR_REASON"; -constexpr char EVENT_KEY_START_FLOATING_BALL[] = "START_FLOATING_BALL"; -constexpr char EVENT_KEY_UPDATE_FLOATING_BALL[] = "UPDATE_FLOATING_BALL"; -constexpr char EVENT_KEY_REMOVE_FLOATING_BALL[] = "REMOVE_FLOATING_BALL"; -constexpr char EVENT_KEY_RESTORE_FLOATING_BALL_WINDOW[] = "RESTORE_FLOATING_BALL_WINDOW"; - -void FloatingballReporter::SetCurrentPackageName(const std::string& packageName) +void FloatingBallReporter::SetCurrentPackageName(const std::string& packageName) { std::lock_guard lock(packageNameMutex_); packageName_ = packageName; } -std::string FloatingballReporter::GetPackageName() const +std::string FloatingBallReporter::GetPackageName() const { std::lock_guard lock(packageNameMutex_); return packageName_; } -void FloatingballReporter::ReportFbStart(const uint32_t& templateType, const std::string& errorReason) -{ - TLOGI(WmsLogTag::WMS_SYSTEM, "Report start floating ball window"); - int32_t ret = HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, EVENT_KEY_START_FLOATING_BALL, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - EVENT_KEY_PNAMEID, PNAMEID, - EVENT_KEY_PVERSION, PVERSION, - EVENT_KEY_PACKAGE_NAME, GetPackageName(), - EVENT_KEY_TEMPLATE_TYPE, templateType, - EVENT_KEY_ERROR_REASON, errorReason); - if (ret != 0) { - TLOGE(WmsLogTag::WMS_SYSTEM, "Write HiSysEvent error, errCode:%{public}d", ret); - } -} - -void FloatingballReporter::ReportFbUpdateContent(const uint32_t& templateType, const std::string &errorReason) -{ - TLOGI(WmsLogTag::WMS_SYSTEM, "Report update floating ball window content"); - int32_t ret = HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, EVENT_KEY_UPDATE_FLOATING_BALL, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - EVENT_KEY_PNAMEID, PNAMEID, - EVENT_KEY_PVERSION, PVERSION, - EVENT_KEY_PACKAGE_NAME, GetPackageName(), - EVENT_KEY_TEMPLATE_TYPE, templateType, - EVENT_KEY_ERROR_REASON, errorReason); - if (ret != 0) { - TLOGE(WmsLogTag::WMS_SYSTEM, "Write HiSysEvent error, errCode:%{public}d", ret); - } -} - -void FloatingballReporter::ReportFbRemove(const uint32_t& templateType, const std::string& errorReason) -{ - TLOGI(WmsLogTag::WMS_SYSTEM, "Report remove floating ball window"); - int32_t ret = HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, EVENT_KEY_REMOVE_FLOATING_BALL, - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - EVENT_KEY_PNAMEID, PNAMEID, - EVENT_KEY_PVERSION, PVERSION, - EVENT_KEY_PACKAGE_NAME, GetPackageName(), - EVENT_KEY_TEMPLATE_TYPE, templateType, - EVENT_KEY_ERROR_REASON, errorReason); - if (ret != 0) { - TLOGE(WmsLogTag::WMS_SYSTEM, "Write HiSysEvent error, errCode:%{public}d", ret); - } -} - -void FloatingballReporter::ReportFbRestoreMainWindow(const uint32_t& templateType, const std::string& errorReason) +void FloatingBallReporter::ReportFbEvent(const std::string& eventName, const uint32_t& templateType, + const std::string& errorReason) { - TLOGI(WmsLogTag::WMS_SYSTEM, "Report restore main window to app, templateType:%{public}d", templateType); + TLOGI(WmsLogTag::WMS_SYSTEM, "Report ReportFbEvent, eventName:%{public}s, templateType:%{public}u", + eventName.c_str(), templateType); int32_t ret = HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, EVENT_KEY_RESTORE_FLOATING_BALL_WINDOW, + OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, eventName, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, EVENT_KEY_PNAMEID, PNAMEID, EVENT_KEY_PVERSION, PVERSION, diff --git a/wm/src/floating_ball_controller.cpp b/wm/src/floating_ball_controller.cpp index 992e0fdb23..7c8b76f508 100644 --- a/wm/src/floating_ball_controller.cpp +++ b/wm/src/floating_ball_controller.cpp @@ -44,7 +44,7 @@ FloatingBallController::FloatingBallController(const sptr& mainWindow, if ((abilityContext == nullptr) || (abilityContext->GetApplicationInfo() == nullptr)) { return; } - SingletonContainer::Get().SetCurrentPackageName(abilityContext->GetApplicationInfo()->name); + SingletonContainer::Get().SetCurrentPackageName(abilityContext->GetApplicationInfo()->name); } FloatingBallController::~FloatingBallController() @@ -73,14 +73,14 @@ WMError FloatingBallController::UpdateFloatingBall(sptr& option) TLOGI(WmsLogTag::WMS_SYSTEM, "UpdateFloatingBall"); if (curState_ != FbWindowState::STATE_STARTED) { TLOGE(WmsLogTag::WMS_SYSTEM, "cur state is not started, can not update"); - SingletonContainer::Get().ReportFbUpdateContent(templateType_, - "cur state is not started, can not update"); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_UPDATE, + templateType_, "cur state is not started, can not update"); return WMError::WM_ERROR_FB_INVALID_STATE; } if (option == nullptr || window_ == nullptr) { TLOGE(WmsLogTag::WMS_SYSTEM, "option or window is nullptr"); - SingletonContainer::Get().ReportFbUpdateContent(templateType_, - "option or window is nullptr"); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_UPDATE, + templateType_, "option or window is nullptr"); return WMError::WM_ERROR_FB_STATE_ABNORMALLY; } FloatingBallTemplateBaseInfo fbTemplateBaseInfo; @@ -89,7 +89,8 @@ WMError FloatingBallController::UpdateFloatingBall(sptr& option) std::ostringstream ss; errCode == WMError::WM_OK ? (ss << "") : (ss << "Update floating ball window session failed, errCode:" << static_cast(errCode)); - SingletonContainer::Get().ReportFbUpdateContent(templateType_, ss.str()); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_UPDATE, + templateType_, ss.str()); return errCode; } @@ -110,14 +111,15 @@ WMError FloatingBallController::StartFloatingBall(sptr& option) if (curState_ == FbWindowState::STATE_STARTING || curState_ == FbWindowState::STATE_STARTED) { TLOGW(WmsLogTag::WMS_SYSTEM, "fbWindow state is: %{public}u, id: %{public}u, mainWindow: %{public}u", curState_, (window_ == nullptr) ? INVALID_WINDOW_ID : window_->GetWindowId(), mainWindowId_); - SingletonContainer::Get().ReportFbStart(templateType_, - "fbWindow state is starting or started"); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_START, + templateType_, "fbWindow state is starting or started"); return WMError::WM_ERROR_FB_REPEAT_OPERATION; } if (curState_ == FbWindowState::STATE_STOPPING) { TLOGW(WmsLogTag::WMS_SYSTEM, "fbWindow state is: %{public}u, id: %{public}u, mainWindow: %{public}u", curState_, (window_ == nullptr) ? INVALID_WINDOW_ID : window_->GetWindowId(), mainWindowId_); - SingletonContainer::Get().ReportFbStart(templateType_, "fbWindow state is stopping"); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_START, + templateType_, "fbWindow state is stopping"); return WMError::WM_ERROR_FB_INVALID_STATE; } curState_ = FbWindowState::STATE_STARTING; @@ -148,7 +150,8 @@ WMError FloatingBallController::StartFloatingBallInner(const sptr& opt mainWindowLifeCycleListener_ = sptr::MakeSptr(); mainWindow_->RegisterLifeCycleListener(mainWindowLifeCycleListener_); curState_ = FbWindowState::STATE_STARTED; - SingletonContainer::Get().ReportFbStart(templateType_, ""); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_START, + templateType_, ""); OnFloatingBallStart(); return WMError::WM_OK; // LCOV_EXCL_STOP @@ -225,8 +228,8 @@ WMError FloatingBallController::StopFloatingBall() if ((!stopFromClient_ && curState_ == FbWindowState::STATE_STOPPING) || curState_ == FbWindowState::STATE_STOPPED) { TLOGE(WmsLogTag::WMS_SYSTEM, "Repeat stop request, curState: %{public}u", curState_); - SingletonContainer::Get().ReportFbRemove(templateType_, - "Repeat stop request, curState: stopping or stopped"); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_REMOVE, + templateType_, "Repeat stop request, curState: stopping or stopped"); return WMError::WM_ERROR_FB_REPEAT_OPERATION; } if (window_ == nullptr) { @@ -235,7 +238,6 @@ WMError FloatingBallController::StopFloatingBall() } curState_ = FbWindowState::STATE_STOPPING; } - SingletonContainer::Get().ReportFbRemove(templateType_, ""); return DestroyFloatingBallWindow(); } // LCOV_EXCL_STOP @@ -276,17 +278,18 @@ WMError FloatingBallController::RestoreMainWindow(const std::shared_ptr().ReportFbRestoreMainWindow(templateType_, - "state is not started when restore main window"); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_RESTORE, + templateType_, "state is not started when restore main window"); return WMError::WM_ERROR_FB_INVALID_STATE; } if (window_ == nullptr) { TLOGE(WmsLogTag::WMS_SYSTEM, "window is null when restoreMainWindow"); - SingletonContainer::Get().ReportFbRestoreMainWindow(templateType_, - "window is null when restoreMainWindow"); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_RESTORE, + templateType_, "window is null when restoreMainWindow"); return WMError::WM_ERROR_FB_STATE_ABNORMALLY; } - SingletonContainer::Get().ReportFbRestoreMainWindow(templateType_, ""); + SingletonContainer::Get().ReportFbEvent(FloatingBallEvent::EVENT_KEY_RESTORE, + templateType_, ""); return window_->RestoreFbMainWindow(want); } diff --git a/wm/test/unittest/floating_ball_controller_test.cpp b/wm/test/unittest/floating_ball_controller_test.cpp index 52d7cca285..da495a58a7 100644 --- a/wm/test/unittest/floating_ball_controller_test.cpp +++ b/wm/test/unittest/floating_ball_controller_test.cpp @@ -19,6 +19,8 @@ #include "ability_context_impl.h" #include "floating_ball_controller.h" #include "floating_ball_manager.h" +#include "floating_ball_report.h" +#include "singleton_mocker.h" #include "modifier_render_thread/rs_modifiers_draw_thread.h" #include "parameters.h" #include "window.h" @@ -327,6 +329,26 @@ HWTEST_F(FloatingBallControllerTest, GetFloatingBallInfo, TestSize.Level1) fbController_->window_ = mw_; EXPECT_EQ(WMError::WM_OK, fbController_->GetFloatingBallWindowInfo(mockId)); } + +/** + * @tc.name: CreateFloatingBallController + * @tc.desc: CreateFloatingBallController + * @tc.type: FUNC + */ +HWTEST_F(FloatingBallControllerTest, CreateFloatingBallController, TestSize.Level1) +{ + int32_t windowId = 100; + ASSERT_NE(nullptr, mw_); + std::shared_ptr contextPtr = + std::make_shared(); + ASSERT_NE(nullptr, contextPtr); + fbController_ = sptr::MakeSptr(mw_, windowId, &contextPtr); + ASSERT_NE(nullptr, fbController_); + const std::string packageName = "FLOATING_BALL_TEST"; + SingletonContainer::Get().SetCurrentPackageName(packageName); + EXPECT_EQ(packageName, SingletonContainer::Get().GetPackageName()); +} + } } } \ No newline at end of file -- Gitee From 8781a9f7adc89703aa1887bb78e4435d6d676155 Mon Sep 17 00:00:00 2001 From: zhaoqi209 <18872749497@163.com> Date: Thu, 28 Aug 2025 11:23:03 +0800 Subject: [PATCH 221/241] window status notify titlebar Signed-off-by: zhaoqi209 <18872749497@163.com> --- wm/test/unittest/window_session_impl_test2.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wm/test/unittest/window_session_impl_test2.cpp b/wm/test/unittest/window_session_impl_test2.cpp index 76c7ca9005..5fe334356b 100644 --- a/wm/test/unittest/window_session_impl_test2.cpp +++ b/wm/test/unittest/window_session_impl_test2.cpp @@ -1291,6 +1291,17 @@ HWTEST_F(WindowSessionImplTest2, UpdateDecorEnableToAce, TestSize.Level1) window->windowSystemConfig_.freeMultiWindowSupport_ = false; window->UpdateDecorEnableToAce(false); + sptr option = sptr::MakeSptr(); + option->SetWindowName("UpdateDecorEnableToAce2"); + sptr sceneSseeionWindow = sptr::MakeSptr(option); + sceneSseeionWindow->uiContent_ = std::make_unique(); + sceneSseeionWindow->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + sptr compatibleModeProperty = sptr::MakeSptr(); + ASSERT_NE(compatibleModeProperty, nullptr); + compatibleModeProperty->SetDisableDecorFullscreen(true); + sceneSseeionWindow->property_->SetCompatibleModeProperty(compatibleModeProperty); + sceneSseeionWindow->UpdateDecorEnableToAce(false); + window->uiContent_ = nullptr; window->UpdateDecorEnableToAce(false); EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy()); -- Gitee From d82d622330abc247563f7d9428cca5b09b1388aa Mon Sep 17 00:00:00 2001 From: chengzhen Date: Thu, 28 Aug 2025 11:33:14 +0800 Subject: [PATCH 222/241] window status notify titlebar Signed-off-by: chengzhen --- wm/test/unittest/window_session_impl_test2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/test/unittest/window_session_impl_test2.cpp b/wm/test/unittest/window_session_impl_test2.cpp index 5fe334356b..033638e438 100644 --- a/wm/test/unittest/window_session_impl_test2.cpp +++ b/wm/test/unittest/window_session_impl_test2.cpp @@ -14,6 +14,7 @@ */ #include "window_session_impl.h" +#include "window_scene_session_impl.h" #include #include -- Gitee From 5d1cbcbef7d6cf5af7bfbb3b16dc16d9245ac0b8 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 14:43:18 +0800 Subject: [PATCH 223/241] fix4 Signed-off-by: chaos --- .../include/screen_session_manager.h | 5 +- .../src/screen_session_manager.cpp | 62 +++++++++++-------- 2 files changed, 40 insertions(+), 27 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 cb7082ed67..7a7b536883 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -169,8 +169,9 @@ public: bool SetRotationFromWindow(Rotation targetRotation); sptr GetScreenModesByDisplayId(DisplayId displayId); sptr GetScreenInfoByDisplayId(DisplayId displayId); - void NotifyDisplayChangedByHook(const std::map>& screenSessionMap, DisplayChangeEvent event, - uint32_t uid); + void NotifyDisplayChangedByUid(const std::map>& screenSessionMap, + DisplayChangeEvent event, uint32_t uid); + void NotifyDisplayChangedByUidInner(sptr displayInfo, DisplayChangeEvent event, uint32_t uid); void NotifyDisplayCreate(sptr displayInfo); void NotifyDisplayDestroy(DisplayId displayId); void NotifyAndPublishEvent(sptr displayInfo, ScreenId screenId, sptr screenSession); 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 77ce0a3743..6938cbf402 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2151,14 +2151,14 @@ void ScreenSessionManager::UpdateDisplayHookInfo(int32_t uid, bool enable, const if (enable) { if (uid != 0) { displayHookMap_[uid] = hookInfo; - NotifyDisplayChangedByHook(screenSessionMapCopy, DisplayChangeEvent::DISPLAY_SIZE_CHANGED, uid); + NotifyDisplayChangedByUid(screenSessionMapCopy, DisplayChangeEvent::DISPLAY_SIZE_CHANGED, uid); } } else { displayHookMap_.erase(uid); } } -void ScreenSessionManager::NotifyDisplayChangedByHook(const std::map>& screenSessionMap, +void ScreenSessionManager::NotifyDisplayChangedByUid(const std::map>& screenSessionMap, DisplayChangeEvent event, uint32_t uid) { for (const auto& sessionIt : screenSessionMap) { @@ -2167,36 +2167,48 @@ void ScreenSessionManager::NotifyDisplayChangedByHook(const std::mapConvertToDisplayInfo(); - if (displayInfo == nullptr) { + NotifyDisplayChangedByUidInner(screenSession->ConvertToDisplayInfo(), event, uid); + } +} + +void ScreenSessionManager::NotifyDisplayChangedByUidInner(sptr displayInfo, + DisplayChangeEvent event, uint32_t uid) +{ + if (displayInfo == nullptr) { TLOGE(WmsLogTag::DMS, "displayInfo is nullptr."); continue; } - auto task = [=] { - auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_EVENT_LISTENER); - if (event == DisplayChangeEvent::UPDATE_REFRESHRATE) { - TLOGND(WmsLogTag::DMS, "evevt:%{public}d, displayId:%{public}" PRIu64", agent size: %{public}u", - event, displayInfo->GetDisplayId(), static_cast(agents.size())); - } else { - TLOGNI(WmsLogTag::DMS, "evevt:%{public}d, displayId:%{public}" PRIu64", agent size: %{public}u", - event, displayInfo->GetDisplayId(), static_cast(agents.size())); - } - if (agents.empty()) { - return; + auto task = [=] { + auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_EVENT_LISTENER); + if (event == DisplayChangeEvent::UPDATE_REFRESHRATE) { + TLOGND(WmsLogTag::DMS, "evevt:%{public}d, displayId:%{public}" PRIu64", agent size: %{public}u", + event, displayInfo->GetDisplayId(), static_cast(agents.size())); + } else { + TLOGNI(WmsLogTag::DMS, "evevt:%{public}d, displayId:%{public}" PRIu64", agent size: %{public}u", + event, displayInfo->GetDisplayId(), static_cast(agents.size())); + } + if (agents.empty()) { + return; + } + for (auto& agent : agents) { + int32_t agentPid = dmAgentContainer_.GetAgentPid(agent); + auto iter = uidAndPidMap_.find(uid); + if (iter == uidAndPidMap_.end() || iter->second != agentPid) { + TLOGND(WmsLogTag::DMS, "no notify, evevt:%{public}d, agent size: %{public}u", + event, static_cast(agents.size())); + continue; } - for (auto& agent : agents) { - int32_t agentPid = dmAgentContainer_.GetAgentPid(agent); - auto iter = uidAndPidMap_.find(uid); - if (iter != uidAndPidMap_.end() && iter->second == agentPid) { - if (!IsFreezed(agentPid, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER)) { - agent->OnDisplayChange(displayInfo, event); - } - } + if (!IsFreezed(agentPid, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER)) { + agent->OnDisplayChange(displayInfo, event); + TLOGND(WmsLogTag::DMS, "notify, evevt:%{public}d, agent size: %{public}u", + event, static_cast(agents.size())); } - }; - taskScheduler_->PostAsyncTask(task, "NotifyDisplayChanged"); + } + }; + taskScheduler_->PostAsyncTask(task, "NotifyDisplayChanged"); } + void ScreenSessionManager::GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo) { std::shared_lock lock(hookInfoMutex_); -- Gitee From 0467d0cfce198848f793cff982c684c2fd42a77f Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 14:46:06 +0800 Subject: [PATCH 224/241] fix5 Signed-off-by: chaos --- .../screen_session_manager/src/screen_session_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 6938cbf402..ccb7443956 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2208,7 +2208,6 @@ void ScreenSessionManager::NotifyDisplayChangedByUidInner(sptr disp taskScheduler_->PostAsyncTask(task, "NotifyDisplayChanged"); } - void ScreenSessionManager::GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo) { std::shared_lock lock(hookInfoMutex_); -- Gitee From 198bdd8283c352f8d33826156143fd3b3b6c2590 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 14:49:07 +0800 Subject: [PATCH 225/241] fix7 Signed-off-by: chaos --- .../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 ccb7443956..1ac488e892 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2176,7 +2176,7 @@ void ScreenSessionManager::NotifyDisplayChangedByUidInner(sptr disp { if (displayInfo == nullptr) { TLOGE(WmsLogTag::DMS, "displayInfo is nullptr."); - continue; + return; } auto task = [=] { auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_EVENT_LISTENER); -- Gitee From 530aca34499679380c911523c246a769350804f2 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 15:15:25 +0800 Subject: [PATCH 226/241] fix8 Signed-off-by: chaos --- .../screen_session_manager_test2.cpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) 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 f35599ebc8..c8da4f197b 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -1026,6 +1026,46 @@ HWTEST_F(ScreenSessionManagerTest, SetLandscapeLockStatus01, TestSize.Level1) EXPECT_TRUE(g_errLog.find("permission denied!") != std::string::npos); } +chaos +/** + * @tc.name: NotifyDisplayChangedByUid + * @tc.desc: NotifyDisplayChangedByUid test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, NotifyDisplayChangedByUid, TestSize.Level1) +{ + g_errLog.clear(); + ASSERT_NE(ssm, nullptr); + ssm_->screenSessionMap_.clear(); + ScreenId screenId = 1050; + sptr screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); + ASSERT_NE(screenSession, nullptr); + ssm_->screenSessionMap_[screenId] = screenSession; + std::map> screenSessionMapCopy = ssm_->screenSessionMap_; + ssm_->NotifyDisplayChangedByUid(screenSessionMapCopy, DisplayChangeEvent::DISPLAY_SIZE_CHANGED, 2002); + ssm_->screenSessionMap_[1051] = nullptr; + ssm_->NotifyDisplayChangedByUid(screenSessionMapCopy, DisplayChangeEvent::DISPLAY_SIZE_CHANGED, 2002); + EXPECT_TRUE(g_errLog.find("screenSession is nullptr") != std::string::npos); +} + +/** + * @tc.name: NotifyDisplayChangedByUidInner + * @tc.desc: NotifyDisplayChangedByUidInner test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, NotifyDisplayChangedByUidInner, TestSize.Level1) +{ + g_errLog.clear(); + ASSERT_NE(ssm, nullptr); + ScreenId screenId = 1050; + sptr screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); + ASSERT_NE(screenSession, nullptr); + ssm_->NotifyDisplayChangedByUid((screenSession->ConvertToDisplayInfo(), + DisplayChangeEvent::DISPLAY_SIZE_CHANGED, 2002); + EXPECT_TRUE(g_errLog.find("uid") != std::string::npos); +} + + /** * @tc.name: SynchronizePowerStatusPermissionDenied * @tc.desc: SynchronizePowerStatus test permission denied. -- Gitee From a6747ff9722370545696cf3d3cfde15ec4c27f29 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 15:30:52 +0800 Subject: [PATCH 227/241] fix8 Signed-off-by: chaos --- .../include/screen_session_manager.h | 4 ++-- .../src/screen_session_manager.cpp | 10 ++++------ .../test/dms_unittest/screen_session_manager_test2.cpp | 1 - 3 files changed, 6 insertions(+), 9 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 7a7b536883..4ed80668c9 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -170,8 +170,8 @@ public: sptr GetScreenModesByDisplayId(DisplayId displayId); sptr GetScreenInfoByDisplayId(DisplayId displayId); void NotifyDisplayChangedByUid(const std::map>& screenSessionMap, - DisplayChangeEvent event, uint32_t uid); - void NotifyDisplayChangedByUidInner(sptr displayInfo, DisplayChangeEvent event, uint32_t uid); + DisplayChangeEvent event, int32_t uid); + void NotifyDisplayChangedByUidInner(sptr displayInfo, DisplayChangeEvent event, int32_t uid); void NotifyDisplayCreate(sptr displayInfo); void NotifyDisplayDestroy(DisplayId displayId); void NotifyAndPublishEvent(sptr displayInfo, ScreenId screenId, sptr screenSession); 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 1ac488e892..a255186b8f 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2159,7 +2159,7 @@ void ScreenSessionManager::UpdateDisplayHookInfo(int32_t uid, bool enable, const } void ScreenSessionManager::NotifyDisplayChangedByUid(const std::map>& screenSessionMap, - DisplayChangeEvent event, uint32_t uid) + DisplayChangeEvent event, int32_t uid) { for (const auto& sessionIt : screenSessionMap) { auto screenSession = sessionIt.second; @@ -2172,7 +2172,7 @@ void ScreenSessionManager::NotifyDisplayChangedByUid(const std::map displayInfo, - DisplayChangeEvent event, uint32_t uid) + DisplayChangeEvent event, int32_t uid) { if (displayInfo == nullptr) { TLOGE(WmsLogTag::DMS, "displayInfo is nullptr."); @@ -2194,14 +2194,12 @@ void ScreenSessionManager::NotifyDisplayChangedByUidInner(sptr disp int32_t agentPid = dmAgentContainer_.GetAgentPid(agent); auto iter = uidAndPidMap_.find(uid); if (iter == uidAndPidMap_.end() || iter->second != agentPid) { - TLOGND(WmsLogTag::DMS, "no notify, evevt:%{public}d, agent size: %{public}u", - event, static_cast(agents.size())); + TLOGND(WmsLogTag::DMS, "no notify"); continue; } if (!IsFreezed(agentPid, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER)) { agent->OnDisplayChange(displayInfo, event); - TLOGND(WmsLogTag::DMS, "notify, evevt:%{public}d, agent size: %{public}u", - event, static_cast(agents.size())); + TLOGND(WmsLogTag::DMS, "notify, uid:%{public}d, pid: %{public}d", uid, agentPid); } } }; 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 c8da4f197b..1db6b56df1 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -1065,7 +1065,6 @@ HWTEST_F(ScreenSessionManagerTest, NotifyDisplayChangedByUidInner, TestSize.Leve EXPECT_TRUE(g_errLog.find("uid") != std::string::npos); } - /** * @tc.name: SynchronizePowerStatusPermissionDenied * @tc.desc: SynchronizePowerStatus test permission denied. -- Gitee From ada96414e62476efbef0c1cd593b82dc6b755b5c Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 16:09:50 +0800 Subject: [PATCH 228/241] fix9 Signed-off-by: chaos --- .../screen_session_manager/src/screen_session_manager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 a255186b8f..23c7910f89 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -552,6 +552,11 @@ DMError ScreenSessionManager::RegisterDisplayManagerAgent( TLOGE(WmsLogTag::DMS, "DisplayManagerAgentType: %{public}u", static_cast(type)); return DMError::DM_ERROR_INVALID_PARAM; } + if (type == DisplayManagerAgentType::DISPLAY_EVENT_LISTENER) { + auto uid = IPCSkeleton::GetCallingUid(); + auto pid = IPCSkeleton::GetCallingPid(); + uidAndPidMap_[uid] = pid; + } return dmAgentContainer_.RegisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR; } @@ -1808,9 +1813,7 @@ sptr ScreenSessionManager::HookDisplayInfoByUid(sptr d return nullptr; } auto uid = IPCSkeleton::GetCallingUid(); - auto pid = IPCSkeleton::GetCallingPid(); std::shared_lock lock(hookInfoMutex_); - uidAndPidMap_[uid] = pid; if (displayHookMap_.find(uid) != displayHookMap_.end()) { auto info = displayHookMap_[uid]; std::ostringstream oss; -- Gitee From 2e1613fa8389405bb1f561355e4496dcfb1d1c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A0=91=E5=B1=B1?= Date: Thu, 28 Aug 2025 16:18:13 +0800 Subject: [PATCH 229/241] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈树山 --- window_scene/test/unittest/scene_session_lifecycle_test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 82b20d5b70..2e63a6a5bd 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -262,10 +262,8 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground07, TestSize.Level0) switch (key) { case ManagerState::MANAGER_STATE_SCREEN_LOCKED: return true; - break; default: return false; - break; } }; session->SetGetStateFromManagerListener(func); -- Gitee From 110b42a81baf9fbff45139e82df8b200c97a1009 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 16:36:08 +0800 Subject: [PATCH 230/241] fix11 Signed-off-by: chaos --- .../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 23c7910f89..547b3e41b6 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2193,7 +2193,7 @@ void ScreenSessionManager::NotifyDisplayChangedByUidInner(sptr disp if (agents.empty()) { return; } - for (auto& agent : agents) { + for (const auto& agent : agents) { int32_t agentPid = dmAgentContainer_.GetAgentPid(agent); auto iter = uidAndPidMap_.find(uid); if (iter == uidAndPidMap_.end() || iter->second != agentPid) { -- Gitee From 6c4e01d3529361d8caaab8edc9d25ce70e370c6f Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Thu, 28 Aug 2025 14:15:52 +0800 Subject: [PATCH 231/241] review Signed-off-by: Laiganlu --- .../session/host/include/ws_snapshot_helper.h | 13 +++++++------ window_scene/session/host/src/session.cpp | 4 ++-- .../session/host/src/ws_snapshot_helper.cpp | 4 ++-- .../session_manager/src/scene_session_manager.cpp | 5 +++-- .../window_pattern/window_pattern_snapshot_test.cpp | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/window_scene/session/host/include/ws_snapshot_helper.h b/window_scene/session/host/include/ws_snapshot_helper.h index 8110b041bd..9c48dd9882 100644 --- a/window_scene/session/host/include/ws_snapshot_helper.h +++ b/window_scene/session/host/include/ws_snapshot_helper.h @@ -48,12 +48,12 @@ public: static uint32_t GetScreenStatus(); static uint32_t GetScreenStatus(FoldStatus foldStatus); static DisplayOrientation GetDisplayOrientation(int32_t rotation); - static void SetWindowScreenStatus(uint32_t screenStatus); - static void SetWindowScreenStatus(FoldStatus foldStatus); - static void SetWindowOrientationStatus(uint32_t orientationStatus); - static void SetWindowOrientationStatus(Rotation rotation); - static SnapshotStatus GetWindowStatus(); - static uint32_t GetRotation(); + 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) { @@ -78,6 +78,7 @@ public: } return SNAPSHOT_LANDSCAPE; } + private: WSSnapshotHelper() = default; ~WSSnapshotHelper() = default; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 0d86c6f751..68ccb3ddbe 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2889,7 +2889,7 @@ SnapshotStatus Session::GetWindowStatus() const if (!SupportSnapshotAllSessionStatus()) { return defaultStatus; } - return WSSnapshotHelper::GetWindowStatus(); + return WSSnapshotHelper::GetInstance()->GetWindowStatus(); } SnapshotStatus Session::GetSessionSnapshotStatus(BackgroundReason reason) const @@ -2915,7 +2915,7 @@ uint32_t Session::GetWindowOrientation() const if (!SupportSnapshotAllSessionStatus()) { return 0; } - return WSSnapshotHelper::GetRotation(); + return WSSnapshotHelper::GetInstance()->GetWindowRotation(); } uint32_t Session::GetLastOrientation() const diff --git a/window_scene/session/host/src/ws_snapshot_helper.cpp b/window_scene/session/host/src/ws_snapshot_helper.cpp index 33696c4f49..f4648d8599 100644 --- a/window_scene/session/host/src/ws_snapshot_helper.cpp +++ b/window_scene/session/host/src/ws_snapshot_helper.cpp @@ -79,12 +79,12 @@ void WSSnapshotHelper::SetWindowOrientationStatus(Rotation rotation) SetWindowOrientationStatus(GetOrientation(rotation)); } -SnapshotStatus WSSnapshotHelper::GetWindowStatus() +SnapshotStatus WSSnapshotHelper::GetWindowStatus() const { return GetInstance()->windowStatus_; } -uint32_t WSSnapshotHelper::GetRotation() +uint32_t WSSnapshotHelper::GetWindowRotation() const { return static_cast(GetInstance()->windowRotation_); } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index d8722bee8d..70b0914a19 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12211,7 +12211,7 @@ void SceneSessionManager::ProcessUpdateRotationChange(DisplayId defaultDisplayId sceneSession->SetRotation(displayInfo->GetRotation()); sceneSession->UpdateOrientation(); } - WSSnapshotHelper::SetWindowOrientationStatus(displayInfo->GetRotation()); + WSSnapshotHelper::GetInstance()->SetWindowOrientationStatus(displayInfo->GetRotation()); UpdateDisplayRegion(displayInfo); return WSError::WS_OK; }, "ProcessUpdateRotationChange" + std::to_string(defaultDisplayId)); @@ -15338,7 +15338,8 @@ WMError SceneSessionManager::MakeScreenFoldData(const std::vector& screenFoldData.currentScreenFoldStatusDuration_ = std::stoi(screenFoldInfo[2]); // 2: current duration screenFoldData.postureAngle_ = std::atof(screenFoldInfo[3].c_str()); // 3: posture angle (type: float) screenFoldData.screenRotation_ = std::stoi(screenFoldInfo[4]); // 4: screen rotation - WSSnapshotHelper::SetWindowScreenStatus(static_cast(screenFoldData.nextScreenFoldStatus_)); + WSSnapshotHelper::GetInstance()->SetWindowScreenStatus( + static_cast(screenFoldData.nextScreenFoldStatus_)); if (!screenFoldData.GetTypeCThermalWithUtil()) { TLOGI(WmsLogTag::DMS, "Error: fail to get typeC thermal."); return WMError::WM_DO_NOTHING; 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 d1dd2693b4..918d7f7531 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 @@ -759,7 +759,7 @@ HWTEST_F(WindowPatternSnapshotTest, GetWindowOrientation, TestSize.Level1) session_->capacity_ = maxCapacity; ret = session_->GetWindowOrientation(); - EXPECT_EQ(ret, WSSnapshotHelper::GetRotation()); + EXPECT_EQ(ret, WSSnapshotHelper::GetWindowRotation()); } /** -- Gitee From 181d63d19ed75deccdfe543b545b73fbd88e3456 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 28 Aug 2025 18:01:54 +0800 Subject: [PATCH 232/241] fix13 Signed-off-by: chaos --- .../screen_session_manager/src/screen_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 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 547b3e41b6..b03ebd0806 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -2178,9 +2178,9 @@ void ScreenSessionManager::NotifyDisplayChangedByUidInner(sptr disp DisplayChangeEvent event, int32_t uid) { if (displayInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "displayInfo is nullptr."); - return; - } + TLOGE(WmsLogTag::DMS, "displayInfo is nullptr."); + return; + } auto task = [=] { auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_EVENT_LISTENER); if (event == DisplayChangeEvent::UPDATE_REFRESHRATE) { -- Gitee From 51ccbc70051c25562298eb0736a5d161cea11783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Thu, 28 Aug 2025 10:16:01 +0000 Subject: [PATCH 233/241] =?UTF-8?q?update=20window=5Fscene/session/host/in?= =?UTF-8?q?clude/scene=5Fsession.h.=20=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=8A=9B=E6=BB=91=E5=8A=9F=E8=83=BD=E6=8E=A5=E5=8F=A3=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- window_scene/session/host/include/scene_session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 78499ca521..adbe3a6523 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -1089,7 +1089,7 @@ private: void WindowScaleTransfer(WSRect& rect, float scaleX, float scaleY); bool IsCompatibilityModeScale(float scaleX, float scaleY); void CompatibilityModeWindowScaleTransfer(WSRect& rect, bool isScale); - void ThrowSlipToFullScreen(WSRect& endRect, WSRect& rect); + void ThrowSlipToFullScreen(WSRect& endRect, WSRect& rect, int32_t statusBarHeight, int32_t dockHeight); bool MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeReason reason); void NotifyFullScreenAfterThrowSlip(const WSRect& rect); void SetDragResizeTypeDuringDrag(DragResizeType dragResizeType) { dragResizeTypeDuringDrag_ = dragResizeType; } -- Gitee From 5ae610dae8faec2fb7d715e04bc8a4a7393354ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA?= Date: Thu, 28 Aug 2025 18:33:58 +0800 Subject: [PATCH 234/241] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=8A=9B=E6=BB=91=E4=BB=A3=E7=A0=81=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李聪 --- window_scene/session/host/src/scene_session.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index c62118324a..c64ac5baf7 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3711,20 +3711,17 @@ bool SceneSession::IsInCompatScaleMode() /** * throw slip to full screen */ -void SceneSession::ThrowSlipToFullScreen(WSRect& endRect, WSRect& rect) +void SceneSession::ThrowSlipToFullScreen(WSRect& endRect, WSRect& rect, int32_t statusBarHeight, int32_t dockHeight) { if (pcFoldScreenController_ == nullptr) { return; } - - int32_t statusBarHeight = IsLayoutFullScreen() ? 0 : GetStatusBarHeight(); - int32_t dockHeight = IsLayoutFullScreen() ? 0 : GetDockHeight(); // maximize end rect and notify last rect throwSlipToFullScreenAnimCount_.fetch_add(1); pcFoldScreenController_->ResizeToFullScreen(endRect, statusBarHeight, dockHeight); if (pcFoldScreenController_->IsThrowSlipDirectly()) { pcFoldScreenController_->ThrowSlipFloatingRectDirectly( - rect, GetSessionRequestRect(), GetStatusBarHeight(), GetDockHeight()); + rect, GetSessionRequestRect(), statusBarHeight, dockHeight); } } @@ -3780,7 +3777,7 @@ bool SceneSession::MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeR std::function finishCallback = nullptr; bool needSetFullScreen = pcFoldScreenController_->IsStartFullScreen(); if (needSetFullScreen) { - ThrowSlipToFullScreen(endRect, rect); + ThrowSlipToFullScreen(endRect, rect, statusBarHeight, dockHeight); finishCallback = [weakThis = wptr(this), rect, where = __func__] { auto session = weakThis.promote(); if (session == nullptr) { -- Gitee From 0717082ad840435bd61ead89c3dc8f1b0036f1af Mon Sep 17 00:00:00 2001 From: 17640494780 <1394087661@qq.com> Date: Tue, 26 Aug 2025 22:12:20 +0800 Subject: [PATCH 235/241] =?UTF-8?q?=E5=88=86=E5=B1=8F=E6=8B=89=E8=B5=B7?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 17640494780 <1394087661@qq.com> --- window_scene/interfaces/include/ws_common.h | 5 ++ .../js_root_scene_session.cpp | 56 ++++++++++++++--- .../js_root_scene_session.h | 9 ++- .../js_scene_session.cpp | 62 ++++++++++++++++--- .../scene_session_manager/js_scene_session.h | 9 ++- .../scene_session_manager/js_scene_utils.cpp | 23 ++++++- .../scene_session_manager/js_scene_utils.h | 4 +- .../session/host/include/scene_session.h | 5 +- window_scene/session/host/include/session.h | 3 +- .../host/include/zidl/session_interface.h | 3 +- .../session/host/include/zidl/session_proxy.h | 5 +- .../session/host/include/zidl/session_stub.h | 1 + .../session/host/src/scene_session.cpp | 29 ++++++--- .../session/host/src/zidl/session_proxy.cpp | 39 +++++++++++- .../session/host/src/zidl/session_stub.cpp | 31 +++++++++- .../unittest/scene_session_lifecycle_test.cpp | 14 ++++- 16 files changed, 259 insertions(+), 39 deletions(-) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index 54244f6283..14eb63b51a 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -375,6 +375,11 @@ struct AtomicServiceInfo { std::vector supportWindowMode_; }; +struct PendingSessionActivationConfig { + bool forceStart = false; // is compulsion open + bool forceNewWant = true; +}; + struct SessionInfo { std::string bundleName_ = ""; std::string moduleName_ = ""; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp index 401574c31f..56e5cd08cf 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp @@ -166,8 +166,9 @@ void JsRootSceneSession::ProcessPendingSceneSessionActivationRegister() void JsRootSceneSession::ProcessBatchPendingSceneSessionsActivationRegister() { rootSceneSession_->SetBatchPendingSessionsActivationEventListener([this] - (const std::vector>& sessionInfos) { - this->BatchPendingSessionsActivation(sessionInfos); + (const std::vector>& sessionInfos, + const std::vector>& configs) { + this->BatchPendingSessionsActivation(sessionInfos, configs); }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } @@ -326,18 +327,56 @@ napi_value JsRootSceneSession::CreateSessionInfosNapiValue( } return arrayValue; } + +napi_value JsRootSceneSession::CreatePendingInfosNapiValue( + napi_env env, const std::vector>& sessionInfos, + const std::vector>& configs) +{ + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, sessionInfos.size(), &arrayValue); + + if (arrayValue == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "Failed to create napi array"); + return NapiGetUndefined(env); + } + + if (configs.empty()) { + TLOGE(WmsLogTag::WMS_LIFE, "configs is empty"); + return CreateSessionInfosNapiValue(env, sessionInfos); + } + + if (sessionInfos.size() != configs.size()) { + TLOGE(WmsLogTag::WMS_LIFE, + "The caller Param is illegal parameters.sessionInfo: %{public}zu configs: %{public}zu", + sessionInfos.size(), configs.size()); + return NapiGetUndefined(env); + } + + TLOGI(WmsLogTag::WMS_LIFE, "sessionInfos:%{public}zu", sessionInfos.size()); + int32_t index = 0; + for (size_t i = 0; i < sessionInfos.size(); i++) { + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "failed to create napi object"); + return NapiGetUndefined(env); + } + napi_set_element(env, arrayValue, index++, CreateJsSessionInfo(env, *(sessionInfos[i]), configs[i])); + } + return arrayValue; +} void JsRootSceneSession::BatchPendingSessionsActivationInner( - const std::vector>& sessionInfos) + const std::vector>& sessionInfos, + const std::vector>& configs) { const char* const where = __func__; - auto task = [jsCallBack = GetJSCallback(BATCH_PENDING_SCENE_ACTIVE_CB), sessionInfos, env = env_, where] { + auto task = [jsCallBack = GetJSCallback(BATCH_PENDING_SCENE_ACTIVE_CB), sessionInfos, configs, env = env_, where] { if (!jsCallBack) { TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsCallBack is nullptr", where); return; } - - napi_value jsSessionInfos = CreateSessionInfosNapiValue(env, sessionInfos); + napi_value jsSessionInfos = CreatePendingInfosNapiValue(env, sessionInfos, configs); if (jsSessionInfos == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s target session info is nullptr", where); return; @@ -414,7 +453,8 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info) } } -void JsRootSceneSession::BatchPendingSessionsActivation(const std::vector>& sessionInfos) +void JsRootSceneSession::BatchPendingSessionsActivation(const std::vector>& sessionInfos, + const std::vector>& configs) { for (auto& info : sessionInfos) { if (info == nullptr) { @@ -441,7 +481,7 @@ void JsRootSceneSession::BatchPendingSessionsActivation(const std::vector>& sessionInfos); - void BatchPendingSessionsActivationInner(const std::vector>& sessionInfos); + void BatchPendingSessionsActivation(const std::vector>& sessionInfos, + const std::vector>& configs); + void BatchPendingSessionsActivationInner(const std::vector>& sessionInfos, + const std::vector>& configs); static napi_value CreateSessionInfosNapiValue( napi_env env, const std::vector>& sessionInfos); + static napi_value CreatePendingInfosNapiValue( + napi_env env, const std::vector>& sessionInfos, + const std::vector>& configs); napi_env env_; std::map> jsCbMap_; mutable std::shared_mutex jsCbMapMutex_; 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 af23801536..a35cb8653a 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 @@ -680,13 +680,14 @@ void JsSceneSession::ProcessBatchPendingSceneSessionsActivationRegister() } const char* const where = __func__; session->SetBatchPendingSessionsActivationEventListener( - [weakThis = wptr(this), where](std::vector>& sessionInfos) { + [weakThis = wptr(this), where](std::vector>& sessionInfos, + const std::vector>& configs) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); return; } - jsSceneSession->BatchPendingSessionsActivation(sessionInfos); + jsSceneSession->BatchPendingSessionsActivation(sessionInfos, configs); }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } @@ -4708,6 +4709,7 @@ void JsSceneSession::PendingSessionActivationInner(std::shared_ptr sessionInfo->persistentId_, LifeCycleTaskType::START); return; } + napi_value jsSessionInfo = CreateJsSessionInfo(env, *sessionInfo); if (jsSessionInfo == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "target session info is nullptr"); @@ -4751,9 +4753,52 @@ napi_value JsSceneSession::CreateSessionInfosNapiValue( } return arrayValue; } + +napi_value JsSceneSession::CreatePendingInfosNapiValue(napi_env env, + const std::vector>& sessionInfos, + const std::vector>& configs) +{ + if (configs.empty()) { + return CreateSessionInfosNapiValue(env, sessionInfos); + } + + if (sessionInfos.size() != configs.size()) { + TLOGE(WmsLogTag::WMS_LIFE, + "The caller Param is illegal parameters.sessionInfo: %{public}zu configs: %{public}zu", + sessionInfos.size(), configs.size()); + return NapiGetUndefined(env); + } + + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, sessionInfos.size(), &arrayValue); + if (arrayValue == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "Failed to create napi array"); + return NapiGetUndefined(env); + } + + int32_t index = 0; + for (size_t i = 0; i < sessionInfos.size(); i++) { + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "failed to create napi object"); + return NapiGetUndefined(env); + } + napi_set_element(env, arrayValue, index++, CreateJsSessionInfo(env, *(sessionInfos[i]), configs[i])); + } + return arrayValue; +} -void JsSceneSession::BatchPendingSessionsActivation(const std::vector>& sessionInfos) +void JsSceneSession::BatchPendingSessionsActivation(const std::vector>& sessionInfos, + const std::vector>& configs) { + if (!configs.empty() && sessionInfos.size() != configs.size()) { + TLOGE(WmsLogTag::WMS_LIFE, + "The caller Param is illegal parameters.sessionInfo: %{public}zu configs: %{public}zu", + sessionInfos.size(), configs.size()); + return; + } + std::vector> sceneSessions; for (auto& info : sessionInfos) { if (info == nullptr) { @@ -4774,14 +4819,15 @@ void JsSceneSession::BatchPendingSessionsActivation(const std::vectorisCalledRightlyByCallerId_); } } - BatchPendingSessionsActivationInner(sessionInfos); + BatchPendingSessionsActivationInner(sessionInfos, configs); } -void JsSceneSession::BatchPendingSessionsActivationInner(const std::vector>& sessionInfos) +void JsSceneSession::BatchPendingSessionsActivationInner(const std::vector>& sessionInfos, + const std::vector>& configs) { const char* const where = __func__; auto task = [weakThis = wptr(this), persistentId = persistentId_, weakSession = weakSession_, - sessionInfos, env = env_, where] { + sessionInfos, configs, env = env_, where] { auto session = weakSession.promote(); if (session == nullptr) { TLOGNE(WmsLogTag::WMS_LIFE, "session is nullptr"); @@ -4797,7 +4843,7 @@ void JsSceneSession::BatchPendingSessionsActivationInner(const std::vector sessionInfo = std::make_shared(info); auto task = [weakThis = wptr(this), persistentId = persistentId_, sessionInfo, env = env_, params] { auto jsSceneSession = weakThis.promote(); @@ -5149,7 +5194,6 @@ void JsSceneSession::PendingSessionToBackgroundForDelegator(const SessionInfo& i TLOGI(WmsLogTag::WMS_LIFE, "bundleName=%{public}s, abilityName=%{public}s, shouldBackToCaller=%{public}d", info.bundleName_.c_str(), info.abilityName_.c_str(), shouldBackToCaller); - std::shared_ptr sessionInfo = std::make_shared(info); auto task = [weakThis = wptr(this), persistentId = persistentId_, sessionInfo, env = env_, shouldBackToCaller] { auto jsSceneSession = weakThis.promote(); 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 d29f92ad27..8eea4aa1b2 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 @@ -147,8 +147,10 @@ private: sptr GenSceneSession(SessionInfo& info); void PendingSessionActivation(SessionInfo& info); void PendingSessionActivationInner(std::shared_ptr sessionInfo); - void BatchPendingSessionsActivation(const std::vector>& sessionInfos); - void BatchPendingSessionsActivationInner(const std::vector>& sessionInfos); + void BatchPendingSessionsActivation(const std::vector>& sessionInfos, + const std::vector>& configs); + void BatchPendingSessionsActivationInner(const std::vector>& sessionInfos, + const std::vector>& configs); void OnSessionStateChange(const SessionState& state); void OnUpdateTransitionAnimation(const WindowTransitionType& type, const TransitionAnimation& animation); void OnSessionEvent(uint32_t eventId, const SessionEventParam& param); @@ -251,6 +253,9 @@ private: static napi_value SendFbActionEvent(napi_env env, napi_callback_info info); static napi_value CreateSessionInfosNapiValue( napi_env env, const std::vector>& sessionInfos); + static napi_value CreatePendingInfosNapiValue(napi_env env, + const std::vector>& sessionInfos, + const std::vector>& configs); 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); 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 4d3db9a491..19e893329b 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 @@ -1396,7 +1396,22 @@ napi_value CreateSupportWindowModes(napi_env env, return arrayValue; } -napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) +napi_value CreateJsSessionPendingConfigs(napi_env env, const PendingSessionActivationConfig &config) +{ + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + WLOGFE("Failed to get jsObject"); + return nullptr; + } + + napi_set_named_property(env, objValue, "forceStart", CreateJsValue(env, config.forceStart)); + napi_set_named_property(env, objValue, "forceNewWant", CreateJsValue(env, config.forceNewWant)); + return objValue; +} + +napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo, + const std::shared_ptr& config) { napi_value objValue = nullptr; napi_create_object(env, &objValue); @@ -1448,6 +1463,12 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) SetJsSessionInfoByWant(env, sessionInfo, objValue); napi_set_named_property(env, objValue, "supportWindowModes", CreateSupportWindowModes(env, sessionInfo.supportedWindowModes)); + + if (config != nullptr) { + napi_set_named_property(env, objValue, "extendPendingActivationConfig", + CreateJsSessionPendingConfigs(env, *(config))); + } + napi_set_named_property(env, objValue, "specifiedFlag", CreateJsValue(env, sessionInfo.specifiedFlag_)); if (sessionInfo.want != nullptr) { napi_set_named_property(env, objValue, "want", AppExecFwk::WrapWant(env, sessionInfo.GetWantSafely())); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h index 8334bb9312..077987db16 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h @@ -212,7 +212,9 @@ bool ConvertJsonFromJs(napi_env env, napi_value value, nlohmann::json& payload); bool ParseArrayStringValue(napi_env env, napi_value array, std::vector& vector); bool ConvertProcessOptionFromJs(napi_env env, napi_value jsObject, std::shared_ptr processOptions); -napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo); +napi_value CreateJsSessionPendingConfigs(napi_env env, const PendingSessionActivationConfig& config); +napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo, + const std::shared_ptr& config = nullptr); void ProcessPendingSessionActivationResult(napi_env env, napi_value callResult, const std::shared_ptr& sessionInfo); bool ConvertSessionResultFromJsValue( diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index cfcbd30e46..5ffc1d1af8 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -274,10 +274,11 @@ public: bool isKeyboardShow, const WindowAnimationInfo& animationInfo) {} WSError ChangeSessionVisibilityWithStatusBar(const sptr info, bool visible) override; WSError PendingSessionActivation(const sptr info) override; - WSError BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos) override; + WSError BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos, + const std::vector& configs = {}) override; WSError DoBatchPendingSessionsActivation( const std::vector>& abilitySessionInfos, sptr& session, - bool isFoundationCall); + bool isFoundationCall, const std::vector& configs); bool DisallowActivationFromPendingBackground(bool isPcOrPadEnableActivation, bool isFoundationCall, bool canStartAbilityFromBackground, bool isFromAncoAndToAnco); WSError TerminateSession(const sptr info) override; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index bf4151007d..a582c5641e 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -60,7 +60,8 @@ using NotifyUpdateFloatingBallFunc = std::function; using NotifyRestoreFloatingBallMainWindowFunc = std::function& want)>; using NotifyPendingSessionActivationFunc = std::function; -using NotifyBatchPendingSessionsActivationFunc = std::function>& info)>; +using NotifyBatchPendingSessionsActivationFunc = std::function>& info, + const std::vector>& configs)>; using NotifyChangeSessionVisibilityWithStatusBarFunc = std::function; using NotifySessionStateChangeFunc = std::function; using NotifyBufferAvailableChangeFunc = std::function; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 87c0544812..f21a265797 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -228,7 +228,8 @@ public: * * @return Returns WSError::WS_OK if called success, otherwise failed. */ - virtual WSError BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos) + virtual WSError BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos, + const std::vector& configs = {}) { return WSError::WS_OK; } virtual WSError TerminateSession(const sptr abilitySessionInfo) { return WSError::WS_OK; } virtual WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WSError::WS_OK; } diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 1ec2231d8d..943b3fb921 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -42,7 +42,8 @@ public: WSError ChangeSessionVisibilityWithStatusBar(const sptr abilitySessionInfo, bool visible) override; WSError PendingSessionActivation(const sptr abilitySessionInfo) override; - WSError BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos) override; + WSError BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos, + const std::vector& configs = {}) override; WSError TerminateSession(const sptr abilitySessionInfo) override; WSError NotifySessionException( const sptr abilitySessionInfo, const ExceptionInfo& exceptionInfo) override; @@ -85,7 +86,7 @@ public: WSError SetSubWindowSource(SubWindowSource source) override; WSError WriteOneSessionInfo(MessageParcel& data, const sptr& abilitySessionInfo); WSError WriteOneSessionInfoPart(MessageParcel& data, const sptr& abilitySessionInfo); - + WSError WriteOnePendingSessionActivationConfig(MessageParcel& data, const PendingSessionActivationConfig& configs); /* * UIExtension */ diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index d63c8079cd..020dfcebba 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -100,6 +100,7 @@ private: int HandleUpdateAcrossDisplaysChangeRegistered(MessageParcel& data, MessageParcel& reply); int HandleGetIsHighlighted(MessageParcel& data, MessageParcel& reply); int ReadOneAbilitySessionInfo(MessageParcel& data, sptr abilitySessionInfo); + int ReadOnePendingSessionActivationConfig(MessageParcel& data, PendingSessionActivationConfig& config); // extension extension int HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 712177e86f..0b78483181 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5560,9 +5560,16 @@ WSError SceneSession::PendingSessionActivation(const sptr ab WSError SceneSession::DoBatchPendingSessionsActivation( const std::vector>& abilitySessionInfos, - sptr& session, bool isFoundationCall) + sptr& session, bool isFoundationCall, const std::vector& configs) { std::vector> sessionInfos; + std::vector> abilitySessionActivationConfigs; + for (const auto& config : configs) { + auto info = std::make_shared(); + info->forceStart = config.forceStart; + info->forceNewWant = config.forceNewWant; + abilitySessionActivationConfigs.emplace_back(info); + } for (auto& abilitySessionInfo : abilitySessionInfos) { if (abilitySessionInfo == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfo is null"); @@ -5593,14 +5600,15 @@ WSError SceneSession::DoBatchPendingSessionsActivation( } session->sessionInfo_.startMethod = StartMethod::START_CALL; if (session->batchPendingSessionsActivationFunc_) { - session->batchPendingSessionsActivationFunc_(sessionInfos); + session->batchPendingSessionsActivationFunc_(sessionInfos, abilitySessionActivationConfigs); } return WSError::WS_OK; } -WSError SceneSession::BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos) + +WSError SceneSession::BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos, + const std::vector& configs) { - TLOGI(WmsLogTag::WMS_LIFE, "Batch pending session activations size: %{public}zu", abilitySessionInfos.size()); if (!SessionPermission::IsSystemAppCall() && !SessionPermission::IsSACalling()) { TLOGE(WmsLogTag::WMS_LIFE, "The caller is neither a system app nor an SA."); return WSError::WS_ERROR_INVALID_PERMISSION; @@ -5609,9 +5617,16 @@ WSError SceneSession::BatchPendingSessionsActivation(const std::vectorDoBatchPendingSessionsActivation(abilitySessionInfos, session, isFoundationCall); + return session->DoBatchPendingSessionsActivation(abilitySessionInfos, session, isFoundationCall, configs); }, __func__); return WSError::WS_OK; } diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 5378b0d241..00d3dd6a18 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -567,12 +567,21 @@ WSError SessionProxy::PendingSessionActivation(sptr abilityS return static_cast(ret); } -WSError SessionProxy::BatchPendingSessionsActivation(const std::vector>& abilitySessionInfos) + +WSError SessionProxy::BatchPendingSessionsActivation( + const std::vector>& abilitySessionInfos, + const std::vector& configs) { if (abilitySessionInfos.empty()) { TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfos is empty"); return WSError::WS_ERROR_INVALID_PARAM; } + + if (!configs.empty() && abilitySessionInfos.size() != configs.size()) { + TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfos param is error"); + return WSError::WS_ERROR_INVALID_PARAM; + } + MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); @@ -590,6 +599,19 @@ WSError SessionProxy::BatchPendingSessionsActivation(const std::vector(configs.size()))) { + TLOGE(WmsLogTag::WMS_LIFE, "Write ability config list size failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + for (const auto& config : configs) { + WSError writeRet = WriteOnePendingSessionActivationConfig(data, config); + if (writeRet != WSError::WS_OK) { + return writeRet; + } + } + sptr remote = Remote(); if (remote == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "remote is null"); @@ -603,6 +625,21 @@ WSError SessionProxy::BatchPendingSessionsActivation(const std::vector(reply.ReadInt32()); } + +WSError SessionProxy::WriteOnePendingSessionActivationConfig(MessageParcel& data, + const PendingSessionActivationConfig& configs) +{ + if (!data.WriteBool(configs.forceStart)) { + TLOGE(WmsLogTag::WMS_LIFE, "Write forceStart failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(configs.forceNewWant)) { + TLOGE(WmsLogTag::WMS_LIFE, "Write forceNewWant failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + return WSError::WS_OK; +} WSError SessionProxy::WriteOneSessionInfo(MessageParcel& data, const sptr& abilitySessionInfo) { diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index db49aa8677..455a2f243f 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -862,7 +862,23 @@ int SessionStub::HandleBatchPendingSessionsActivation(MessageParcel& data, Messa } abilitySessionInfos.emplace_back(abilitySessionInfo); } - WSError errCode = BatchPendingSessionsActivation(abilitySessionInfos); + + size = 0; + if (!data.ReadInt32(size) || size < 0 || size > MAX_ABILITY_SESSION_INFOS) { + TLOGE(WmsLogTag::WMS_LIFE, "Read ability config size failed"); + return ERR_INVALID_DATA; + } + std::vector configs; + for (int32_t i = 0; i < size; i++) { + PendingSessionActivationConfig config; + int readRet = ReadOnePendingSessionActivationConfig(data, config); + if (readRet != ERR_NONE) { + return readRet; + } + configs.emplace_back(config); + } + + WSError errCode = BatchPendingSessionsActivation(abilitySessionInfos, configs); if (!reply.WriteUint32(static_cast(errCode))) { TLOGE(WmsLogTag::WMS_LIFE, "Write errCode failed"); } @@ -2289,4 +2305,17 @@ int SessionStub::HandleUpdateGlobalDisplayRectFromClient(MessageParcel& data, Me UpdateGlobalDisplayRectFromClient(globalDisplayRect, reason); return ERR_NONE; } + +int SessionStub::ReadOnePendingSessionActivationConfig(MessageParcel& data, PendingSessionActivationConfig& config) +{ + if (!data.ReadBool(config.forceStart)) { + TLOGE(WmsLogTag::WMS_LIFE, "Read forceStart failed."); + return ERR_INVALID_DATA; + } + if (!data.ReadBool(config.forceNewWant)) { + TLOGE(WmsLogTag::WMS_LIFE, "Read forceNewWant failed."); + return ERR_INVALID_DATA; + } + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 77a95b7860..85ba9ba26f 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -44,6 +44,7 @@ public: void TearDown() override; sptr sceneSession; SessionInfo info; + PendingSessionActivationConfig configs; }; void SceneSessionLifecycleTest::SetUpTestCase() {} @@ -1211,9 +1212,20 @@ HWTEST_F(SceneSessionLifecycleTest, BatchPendingSessionsActivation, TestSize.Lev sessionInfo->want.SetFlags(flags); sessionInfo->isAtomicService = true; abilitySessionInfos.emplace_back(sessionInfo); - WSError result = sceneSession->BatchPendingSessionsActivation(abilitySessionInfos); + std::vector configs; + PendingSessionActivationConfig config; + configs.emplace_back(config); + WSError result = sceneSession->BatchPendingSessionsActivation(abilitySessionInfos, configs); + EXPECT_EQ(result, WSError::WS_OK); + auto func = [](std::vector>& info, + const std::vector>& configs) { + std::cout << "enter batchPendingSessionsActivationFunc" << std::endl; + }; + sceneSession->Session::SetBatchPendingSessionsActivationEventListener(func); + result = sceneSession->BatchPendingSessionsActivation(abilitySessionInfos, configs); EXPECT_EQ(result, WSError::WS_OK); + MockAccesstokenKit::ChangeMockStateToInit(); } /** -- Gitee From 83037cb71c35bac73d55a0815a182e59814f9700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Thu, 28 Aug 2025 16:32:35 +0800 Subject: [PATCH 236/241] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsetFollowParentMultiS?= =?UTF-8?q?creenPolicy=E6=8E=A5=E5=8F=A3=E5=A4=B1=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- window_scene/session/host/src/sub_session.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index e76dd251f2..9f878bc6f1 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -462,16 +462,16 @@ void SubSession::HandleCrossMoveToSurfaceNode(WSRect& globalRect) continue; } movedSurfaceNode->SetPositionZ(GetZOrder()); + movedSurfaceNode->SetIsCrossNode(true); + RSTransactionAdapter::FlushImplicitTransaction(movedSurfaceNode->GetRSUIContext()); { AutoRSTransaction trans(dragMoveMountedNode->GetRSUIContext()); dragMoveMountedNode->AddCrossScreenChild(movedSurfaceNode, SUFFIX_INDEX, true); } cloneNodeCount_++; - movedSurfaceNode->SetIsCrossNode(true); TLOGI(WmsLogTag::WMS_LAYOUT, "Add sub window to display:%{public}" PRIu64 " persistentId:%{public}d", displayId, GetPersistentId()); } - RSTransactionAdapter::FlushImplicitTransaction(movedSurfaceNode->GetRSUIContext()); } std::set SubSession::GetNewDisplayIdsDuringMoveTo(WSRect& newRect) @@ -535,16 +535,16 @@ void SubSession::AddSurfaceNodeToScreen(DisplayId draggingOrMovingParentDisplayI continue; } currSurfacedNode->SetPositionZ(GetZOrder()); + currSurfacedNode->SetIsCrossNode(true); + RSTransactionAdapter::FlushImplicitTransaction(currSurfacedNode->GetRSUIContext()); { AutoRSTransaction trans(dragMoveMountedNode->GetRSUIContext()); dragMoveMountedNode->AddCrossScreenChild(currSurfacedNode, SUFFIX_INDEX, true); } cloneNodeCount_++; - currSurfacedNode->SetIsCrossNode(true); TLOGI(WmsLogTag::WMS_LAYOUT, "Add sub window to display:%{public}" PRIu64 " persistentId:%{public}d, " "cloneNodeCount:%{public}d", displayId, GetPersistentId(), cloneNodeCount_); } - RSTransactionAdapter::FlushImplicitTransaction(currSurfacedNode->GetRSUIContext()); } void SubSession::RemoveSurfaceNodeFromScreen() -- Gitee From 3209dd27feca66a1278207b952deb031b385b3df Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Fri, 29 Aug 2025 12:54:14 +0800 Subject: [PATCH 237/241] pageRotation xts fixed Signed Signed-off-by: wangjiaqi --- .../session/host/include/scene_session.h | 1 + .../session/host/src/scene_session.cpp | 26 ++++++++++++-- .../test/unittest/scene_session_test5.cpp | 36 +++++++++++++++++++ wm/src/window_scene_session_impl.cpp | 5 ++- 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 2880ded60d..f0f5d2c7e8 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -577,6 +577,7 @@ public: */ void RegisterRequestedOrientationChangeCallback(NotifyReqOrientationChangeFunc&& callback); WSError NotifyRotationProperty(uint32_t rotation, uint32_t width, uint32_t height); + WSError ConvertRotationToOrientation(uint32_t rotation, uint32_t& orientation); void RegisterUpdateRotationChangeListener(NotifyRotationChangeFunc&& callback); WSError UpdateRotationChangeRegistered(int32_t persistentId, bool isRegister) override; RotationChangeResult NotifyRotationChange(const RotationChangeInfo& rotationChangeInfo, diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 02787dc383..d8f15f0714 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -8692,19 +8692,41 @@ WSError SceneSession::NotifyRotationProperty(uint32_t rotation, uint32_t width, WSRect wsrect = { 0, 0, width, height }; auto properties = session->GetSystemBarPropertyForRotation(); std::map avoidAreas; + uint32_t orientation = 0; + WSError ret = session->ConvertRotationToOrientation(rotation, orientation); + if (ret != WSError::WS_OK) { + TLOGNE(WmsLogTag::WMS_ROTATION, "failed to convert Rotation to Orientation"); + return ret; + } + // Orientation type is required here session->GetAvoidAreasByRotation( - static_cast(rotation / ROTATION_DEGREE), wsrect, properties, avoidAreas); + static_cast(orientation), wsrect, properties, avoidAreas); if (!session->sessionStage_) { return WSError::WS_ERROR_NULLPTR; } Rect rect = { wsrect.posX_, wsrect.posY_, wsrect.width_, wsrect.height_ }; - OrientationInfo info = { rotation, rect, avoidAreas }; + OrientationInfo info = { orientation, rect, avoidAreas }; session->sessionStage_->NotifyTargetRotationInfo(info); return WSError::WS_OK; }, __func__); return WSError::WS_OK; } +WSError SceneSession::ConvertRotationToOrientation(uint32_t rotation, uint32_t& orientation) +{ + sptr screenSession = + ScreenSessionManagerClient::GetInstance().GetScreenSessionById(GetSessionProperty()->GetDisplayId()); + if (screenSession = nullptr) { + TLOGW(WmsLogTag::WMS_ROTATION, "Screen session is null"); + return WSError::WS_ERROR_INVALID_DISPLAY; + } + FoldDisplayMode foldDisplayMode = ScreenSessionManagerClient::GetInstance().GetFoldDisplayMode(); + Rotation targetRotation = static_cast(rotation / ROTATION_DEGREE); + DisplayOrientation displayOrientation = screenSession->CalcDisplayOrientation(targetRotation, foldDisplayMode); + orientation = static_cast(displayOrientation); + return WSError::WS_OK; +} + void SceneSession::SetSystemBarPropertyForRotation( const std::map& properties) { diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 36b9cc8d43..b16ed2fd24 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -2803,6 +2803,8 @@ HWTEST_F(SceneSessionTest5, GetTargetOrientationConfigInfo, Function | SmallTest */ HWTEST_F(SceneSessionTest5, NotifyRotationProperty, Function | SmallTest | Level2) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); SessionInfo info; info.abilityName_ = "NotifyRotationProperty"; info.bundleName_ = "NotifyRotationProperty"; @@ -2818,6 +2820,40 @@ HWTEST_F(SceneSessionTest5, NotifyRotationProperty, Function | SmallTest | Level EXPECT_EQ(result2, WSError::WS_OK); WSError result3 = sceneSession->NotifyRotationProperty(90, 1, 1); EXPECT_EQ(result3, WSError::WS_OK); + sceneSession->GetSessionProperty()->SetDisplayId(1024); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(1024, nullptr); + sceneSession->NotifyRotationProperty(90, 1, 1); + usleep(100000); + EXPECT_TRUE(g_errLog.find("failed to convert Rotation to Orientation") != std::string::npos); +} + +/** + * @tc.name: ConvertRotationToOrientation + * @tc.desc: ConvertRotationToOrientation + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, ConvertRotationToOrientation, Function | SmallTest | Level2) +{ + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + SessionInfo info; + info.abilityName_ = "ConvertRotationToOrientation"; + info.bundleName_ = "ConvertRotationToOrientation"; + + sptr sceneSession = sptr::MakeSptr(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + + unit32_t orientation = 0; + WSError result = sceneSession->ConvertRotationToOrientation(90, orientation); + EXPECT_EQ(result, WSError::WS_OK); + EXPECT_EQ(orientation, 1); + + sceneSession->GetSessionProperty()->SetDisplayId(1024); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(1024, nullptr); + unit32_t orientation1 = 0; + sceneSession->ConvertRotationToOrientation(90, orientation1); + EXPECT_EQ(orientation1, 0); + EXPECT_TRUE(g_errLog.find("Screen session is null") != std::string::npos); } /** diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 96851fe8df..cf31a7e89a 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2557,14 +2557,13 @@ Ace::ViewportConfig WindowSceneSessionImpl::FillTargetOrientationConfig( return config; } auto deviceRotation = static_cast(displayInfo->GetDefaultDeviceRotationOffset()); - uint32_t transformHint = (targetRotation + deviceRotation) % FULL_CIRCLE_DEGREE; + uint32_t transformHint = (targetRotation * ONE_FOURTH_FULL_CIRCLE_DEGREE + deviceRotation) % FULL_CIRCLE_DEGREE; float density = GetVirtualPixelRatio(displayInfo); - int32_t orientation = static_cast(targetRotation) / ONE_FOURTH_FULL_CIRCLE_DEGREE; virtualPixelRatio_ = density; config.SetSize(targetRect.width_, targetRect.height_); config.SetPosition(targetRect.posX_, targetRect.posY_); config.SetDensity(density); - config.SetOrientation(orientation); + config.SetOrientation(targetRotation); config.SetTransformHint(transformHint); config.SetDisplayId(displayId); return config; -- Gitee From b858907d5cc6dc9c81c13f5925c38d40631c4fac Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Fri, 29 Aug 2025 13:12:34 +0800 Subject: [PATCH 238/241] pageRotation xts fixed Signed-off-by: wangjiaqi --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index d8f15f0714..1e8f510fba 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -8716,7 +8716,7 @@ WSError SceneSession::ConvertRotationToOrientation(uint32_t rotation, uint32_t& { sptr screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSessionById(GetSessionProperty()->GetDisplayId()); - if (screenSession = nullptr) { + if (screenSession == nullptr) { TLOGW(WmsLogTag::WMS_ROTATION, "Screen session is null"); return WSError::WS_ERROR_INVALID_DISPLAY; } -- Gitee From ef55d7c71b00e845e12f2faa0fc24b0360269b11 Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Fri, 29 Aug 2025 13:51:14 +0800 Subject: [PATCH 239/241] pageRotation xts fixed Signed-off-by: wangjiaqi --- window_scene/session/host/src/scene_session.cpp | 2 +- window_scene/test/unittest/scene_session_test5.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1e8f510fba..2a037c2232 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -8723,7 +8723,7 @@ WSError SceneSession::ConvertRotationToOrientation(uint32_t rotation, uint32_t& FoldDisplayMode foldDisplayMode = ScreenSessionManagerClient::GetInstance().GetFoldDisplayMode(); Rotation targetRotation = static_cast(rotation / ROTATION_DEGREE); DisplayOrientation displayOrientation = screenSession->CalcDisplayOrientation(targetRotation, foldDisplayMode); - orientation = static_cast(displayOrientation); + orientation = static_cast(displayOrientation); return WSError::WS_OK; } diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index b16ed2fd24..2686e2718f 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -2843,14 +2843,14 @@ HWTEST_F(SceneSessionTest5, ConvertRotationToOrientation, Function | SmallTest | sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - unit32_t orientation = 0; + uint32_t orientation = 0; WSError result = sceneSession->ConvertRotationToOrientation(90, orientation); EXPECT_EQ(result, WSError::WS_OK); EXPECT_EQ(orientation, 1); sceneSession->GetSessionProperty()->SetDisplayId(1024); ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(1024, nullptr); - unit32_t orientation1 = 0; + uint32_t orientation1 = 0; sceneSession->ConvertRotationToOrientation(90, orientation1); EXPECT_EQ(orientation1, 0); EXPECT_TRUE(g_errLog.find("Screen session is null") != std::string::npos); -- Gitee From 50d4cf21db6e880bf32cf0aa2707c04b768bf2cc Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Fri, 29 Aug 2025 14:50:37 +0800 Subject: [PATCH 240/241] pageRotation XTS fixed Signed-off-by: wangjiaqi --- window_scene/test/unittest/scene_session_test5.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 2686e2718f..9ded5b7c12 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -2811,6 +2811,11 @@ HWTEST_F(SceneSessionTest5, NotifyRotationProperty, Function | SmallTest | Level sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); + sceneSession->GetSessionProperty()->SetDisplayId(1001); + ScreenSessionConfig config; + sptr screenSession = sptr::MakeSptr(config, + ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(1001, screenSession); WSError result = sceneSession->NotifyRotationProperty(0, 0, 0); EXPECT_EQ(result, WSError::WS_OK); @@ -2842,6 +2847,11 @@ HWTEST_F(SceneSessionTest5, ConvertRotationToOrientation, Function | SmallTest | sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); + sceneSession->GetSessionProperty()->SetDisplayId(1001); + ScreenSessionConfig config; + sptr screenSession = sptr::MakeSptr(config, + ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(1001, screenSession); uint32_t orientation = 0; WSError result = sceneSession->ConvertRotationToOrientation(90, orientation); -- Gitee From b8aceb573d24d8457160bf5f3bc769cf542b5186 Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Sat, 13 Sep 2025 10:58:14 +0800 Subject: [PATCH 241/241] pagerotation xts fixed Signed-off-by: wangjiaqi --- window_scene/test/unittest/scene_session_test5.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 9ded5b7c12..c403483567 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -2856,13 +2856,12 @@ HWTEST_F(SceneSessionTest5, ConvertRotationToOrientation, Function | SmallTest | uint32_t orientation = 0; WSError result = sceneSession->ConvertRotationToOrientation(90, orientation); EXPECT_EQ(result, WSError::WS_OK); - EXPECT_EQ(orientation, 1); sceneSession->GetSessionProperty()->SetDisplayId(1024); ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(1024, nullptr); uint32_t orientation1 = 0; - sceneSession->ConvertRotationToOrientation(90, orientation1); - EXPECT_EQ(orientation1, 0); + WSError result1 = sceneSession->ConvertRotationToOrientation(90, orientation1); + EXPECT_EQ(result1, WSError::WS_ERROR_INVALID_DISPLAY); EXPECT_TRUE(g_errLog.find("Screen session is null") != std::string::npos); } -- Gitee