From 8fd9197e9c179e638f3d82ee7b5b78439ea37f22 Mon Sep 17 00:00:00 2001 From: zhjs Date: Fri, 5 Sep 2025 15:41:51 +0800 Subject: [PATCH 1/2] !15669:dms Signed-off-by: zhjs Signed-off-by: zhongruqi --- .../include/screen_session_manager.h | 3 +- .../src/screen_session_manager.cpp | 16 +++-- .../screen_session_manager_test.cpp | 31 ++++++-- .../screen_session_manager_test2.cpp | 70 +++++++++++++++++++ 4 files changed, 108 insertions(+), 12 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 4b72ed6fa6..b2273277b6 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -477,7 +477,8 @@ public: void UpdateScreenIdManager(sptr& innerScreen, sptr& externalScreen); std::string DumperClientScreenSessions(); void SetMultiScreenModeChangeTracker(std::string changeProc); - void SetRSScreenPowerStatus(ScreenId screenId, ScreenPowerStatus status); + void SetRSScreenPowerStatus(ScreenId screenId, ScreenPowerStatus status, + ScreenPowerOnReason reason = ScreenPowerOnReason::DEAFULT_REASON); void NotifyScreenMaskAppear() override; bool IsSystemSleep(); void SwitchSubscriberInit(); 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 7ad286ec41..40b83b2b35 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -378,7 +378,8 @@ void ScreenSessionManager::FoldScreenPowerInit() #endif SetRSScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_OFF); foldScreenController_->AddOrRemoveDisplayNodeToTree(SCREEN_ID_MAIN, REMOVE_DISPLAY_MODE); - SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON); + SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON, + ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY); } else if (currentScreenId == SCREEN_ID_MAIN) { TLOGI(WmsLogTag::DMS, "ScreenSessionManager Fold Screen Power Main animation Init 3."); SetRSScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_OFF_FAKE); @@ -392,7 +393,8 @@ void ScreenSessionManager::FoldScreenPowerInit() #endif SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF); foldScreenController_->AddOrRemoveDisplayNodeToTree(SCREEN_ID_FULL, REMOVE_DISPLAY_MODE); - SetRSScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON); + SetRSScreenPowerStatus(SCREEN_ID_MAIN, ScreenPowerStatus::POWER_STATUS_ON, + ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY); } else { TLOGI(WmsLogTag::DMS, "ScreenSessionManager Fold Screen Power Init, invalid active screen id"); } @@ -11263,7 +11265,8 @@ void ScreenSessionManager::NotifyExtendScreenDestroyFinish() userSwitching_ = false; } -void ScreenSessionManager::SetRSScreenPowerStatus(ScreenId screenId, ScreenPowerStatus status) +void ScreenSessionManager::SetRSScreenPowerStatus(ScreenId screenId, ScreenPowerStatus status, + ScreenPowerOnReason reason) { ScreenId rsScreenId = screenId; if (IsConcurrentUser()) { @@ -11275,9 +11278,10 @@ void ScreenSessionManager::SetRSScreenPowerStatus(ScreenId screenId, ScreenPower if (status == ScreenPowerStatus::POWER_STATUS_ON) { #ifdef POWERMGR_DISPLAY_MANAGER_ENABLE uint32_t ret = DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().NotifyBrightnessManagerScreenPowerStatus( - static_cast(screenId), static_cast(status)); - TLOGI(WmsLogTag::DMS, "notify brightness, screenId:%{public}" PRIu64 ", status:%{public}u, ret = %{public}u", - screenId, static_cast(status), ret); + static_cast(screenId), static_cast(status), static_cast(reason)); + TLOGI(WmsLogTag::DMS, "notify brightness, screenId:%{public}" PRIu64 ", status:%{public}u, "\ + "reason=%{public}u,ret = %{public}u", + screenId, static_cast(status), static_cast(reason), ret); #endif } } 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 1f4299e0d6..193a2ae3cd 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -6710,20 +6710,41 @@ HWTEST_F(ScreenSessionManagerTest, ShouldHandleNonExistingGroupSmsId, TestSize.L } /** - * @tc.name: SetRSScreenPowerStatus - * @tc.desc: call RS power func, and notify brightness while screen on + * @tc.name: SetRSScreenPowerStatus01 + * @tc.desc: call RS power func, and notify brightness & reason while screen on * @tc.type: FUNC */ -HWTEST_F(ScreenSessionManagerTest, SetRSScreenPowerStatus, TestSize.Level1) +HWTEST_F(ScreenSessionManagerTest, SetRSScreenPowerStatus01, TestSize.Level1) { ScreenPowerState state; EXPECT_NE(ssm_, nullptr); - ssm_->SetRSScreenPowerStatus(0, ScreenPowerStatus::POWER_STATUS_ON); + ssm_->SetRSScreenPowerStatus(0, ScreenPowerStatus::POWER_STATUS_ON, ScreenPowerOnReason::DEAFULT_REASON); state = ssm_->GetScreenPower(0); EXPECT_EQ(state, ScreenPowerState::POWER_ON); - ssm_->SetRSScreenPowerStatus(0, ScreenPowerStatus::POWER_STATUS_OFF); + ssm_->SetRSScreenPowerStatus(0, ScreenPowerStatus::POWER_STATUS_OFF, ScreenPowerOnReason::DEAFULT_REASON); + state = ssm_->GetScreenPower(0); + EXPECT_EQ(state, ScreenPowerState::POWER_OFF); +} + +/** + * @tc.name: SetRSScreenPowerStatus02 + * @tc.desc: call RS power func, and notify brightness & reason while screen on + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetRSScreenPowerStatus02, TestSize.Level1) +{ + ScreenPowerState state; + EXPECT_NE(ssm_, nullptr); + + ssm_->SetRSScreenPowerStatus(0, ScreenPowerStatus::POWER_STATUS_ON, + ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY); + state = ssm_->GetScreenPower(0); + EXPECT_EQ(state, ScreenPowerState::POWER_ON); + + ssm_->SetRSScreenPowerStatus(0, ScreenPowerStatus::POWER_STATUS_OFF, + ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY); state = ssm_->GetScreenPower(0); EXPECT_EQ(state, ScreenPowerState::POWER_OFF); } 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 f88edbefb0..867413cc40 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -154,6 +154,76 @@ HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold03, TestSize.Level1) EXPECT_TRUE(g_errLog.find("set advancedOn powerStatus off") == std::string::npos); } +/** + * @tc.name: SetScreenPowerForFold04 + * @tc.desc: SetScreenPowerForFold test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold04, TestSize.Level1) +{ + if (!FoldScreenStateInternel::IsFoldScreenDevice()) { + GTEST_SKIP(); + } + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + sptr ssm = sptr::MakeSptr(); + ssm->SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON_ADVANCED, + ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY); + + 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: SetScreenPowerForFold05 + * @tc.desc: SetScreenPowerForFold test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold05, TestSize.Level1) +{ + if (!FoldScreenStateInternel::IsFoldScreenDevice()) { + GTEST_SKIP(); + } + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + sptr ssm = sptr::MakeSptr(); + ssm->SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON_ADVANCED, + ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY); + + 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: SetScreenPowerForFold06 + * @tc.desc: SetScreenPowerForFold test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold06, TestSize.Level1) +{ + if (!FoldScreenStateInternel::IsFoldScreenDevice()) { + GTEST_SKIP(); + } + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); + sptr ssm = sptr::MakeSptr(); + ssm->SetRSScreenPowerStatus(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON_ADVANCED, + ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY); + + 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 0b872b86482da5a13ee8262a98f47981121ccd33 Mon Sep 17 00:00:00 2001 From: zhongruqi Date: Mon, 15 Sep 2025 01:49:02 +0000 Subject: [PATCH 2/2] update window_scene/test/dms_unittest/screen_session_manager_test2.cpp. Signed-off-by: zhongruqi --- .../test/dms_unittest/screen_session_manager_test2.cpp | 3 +++ 1 file changed, 3 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 1eebac808c..3b6947ba68 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -228,6 +228,9 @@ HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForFold06, TestSize.Level1) 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: SetDisplayNodeSecurity * @tc.desc: SetDisplayNodeSecurity test * @tc.type: FUNC -- Gitee