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 5ecf98da0e5f7f87c23d11b00912853663dbc74c..b31070e91ff446e1a7b276852e9a60042010c66a 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -480,7 +480,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 39b34b648a855a8b64fba8f2fb369649178562cc..cd840596a6e64f378df752b86d0cf23de937b507 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"); } @@ -11300,7 +11302,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()) { @@ -11312,9 +11315,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 2e7f3850b25c559e7e61140303df179e87bf01b5..73680274e98e566200399eeff19db366a52e9f23 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -6741,20 +6741,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 b7e28ddc1b3ddd21bc7672ee7d6910f56de26ee5..3b6947ba684c3d80b782279f081f593f1d7a842e 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test2.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test2.cpp @@ -160,6 +160,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: SetDisplayNodeSecurity * @tc.desc: SetDisplayNodeSecurity test