From 5b525cfcf3f4e2979227e3d343484a4e395f01c3 Mon Sep 17 00:00:00 2001 From: hubijie Date: Fri, 25 Jul 2025 15:00:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=92=8Cpad=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=85=A8=E5=B1=80=E5=88=9B=E5=BB=BA=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E6=9D=83=E9=99=90=20Signed-off-by:=20hubijie=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/scene_session_manager.cpp | 7 +++- .../unittest/scene_session_manager_test12.cpp | 38 +++++++++++++++++++ 2 files changed, 43 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 af7367b65e..fcd31dab97 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4108,13 +4108,16 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptrGetIsPcAppInPad(); + bool isPhoneOrPad = systemConfig_.IsPadWindow() || systemConfig_.IsPhoneWindow(); // WINDOW_TYPE_FLOAT could be created with the corresponding permission if (SessionPermission::VerifyCallingPermission("ohos.permission.SYSTEM_FLOAT_WINDOW") && (SessionPermission::IsSystemCalling() || SessionPermission::IsStartByHdcd() || - (systemConfig_.supportTypeFloatWindow_ && !isPadAndNotPcApp))) { + systemConfig_.supportTypeFloatWindow_)) { TLOGI(WmsLogTag::WMS_SYSTEM, "check float permission success."); return true; + } else if (SessionPermission::VerifyCallingPermission("ohos.permission.SYSTEM_FLOAT_WINDOW") && isPhoneOrPad) { + TLOGI(WmsLogTag::WMS_SYSTEM, "check float permission success. DeviceType is phone or pad."); + return true; } else { TLOGI(WmsLogTag::WMS_SYSTEM, "check float permission failed."); return false; diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 03191a834a..19f2006395 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -544,6 +544,44 @@ HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_014, TestSiz EXPECT_EQ(true, ssm_->CheckSystemWindowPermission(property)); } +/** + * @tc.name: TestCheckSystemWindowPermission_014 + * @tc.desc: Test CheckSystemWindowPermission with windowType FLOAT in phone + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_015, TestSize.Level1) +{ + sptr property = sptr::MakeSptr(); + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + + MockAccesstokenKit::MockIsSACalling(false); + WindowUIType oldType = ssm_->systemConfig_.windowUIType_; + ssm_->systemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; + MockAccesstokenKit::MockAccessTokenKitRet(0); + + EXPECT_EQ(true, ssm_->CheckSystemWindowPermission(property)); + ssm_->systemConfig_.windowUIType_ = oldType; +} + +/** + * @tc.name: TestCheckSystemWindowPermission_014 + * @tc.desc: Test CheckSystemWindowPermission with windowType FLOAT in pad + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_016, TestSize.Level1) +{ + sptr property = sptr::MakeSptr(); + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + + MockAccesstokenKit::MockIsSACalling(false); + WindowUIType oldType = ssm_->systemConfig_.windowUIType_; + ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + MockAccesstokenKit::MockAccessTokenKitRet(0); + + EXPECT_EQ(true, ssm_->CheckSystemWindowPermission(property)); + ssm_->systemConfig_.windowUIType_ = oldType; +} + /** * @tc.name: CreateAndConnectSpecificSession * @tc.desc: CreateAndConnectSpecificSession -- Gitee