已合并
fix screen power status issue #17704
fix screen power status issue #17704
已合并
wulong158创建于 1月23日
3 个文件变更+62-3
@@ -1121,6 +1121,11 @@ private:
1121 std::atomic<bool> curResolutionEffectEnable_ = false;1121 std::atomic<bool> curResolutionEffectEnable_ = false;
1122 DMError SyncScreenPropertyChangedToServer(ScreenId screenId, const ScreenProperty& screenProperty) override;1122 DMError SyncScreenPropertyChangedToServer(ScreenId screenId, const ScreenProperty& screenProperty) override;
1123 void SetOptionConfig(ScreenId screenId, VirtualScreenOption option);1123 void SetOptionConfig(ScreenId screenId, VirtualScreenOption option);
1124+ void DoSetScreenPowerStatus(ScreenId rsScreenId, ScreenPowerStatus status);
1125+ void ClearScreenPowerStatus(ScreenId rsScreenId);
1126+ 
1127+ std::map<ScreenId, ScreenPowerStatus> screenPowerStatusMap_;
1128+ std::mutex screenPowerStatusMapMutex_;
1124 std::function<void(sptr<ScreenSession>& screenSession,1129 std::function<void(sptr<ScreenSession>& screenSession,
1125 SuperFoldStatusChangeEvents changeEvent)> propertyChangedCallback_;1130 SuperFoldStatusChangeEvents changeEvent)> propertyChangedCallback_;
1126 std::mutex callbackMutex_;1131 std::mutex callbackMutex_;
@@ -1952,6 +1952,8 @@ void ScreenSessionManager::HandleMapWhenScreenDisconnect(ScreenId screenId)
1952 std::lock_guard<std::recursive_mutex> lock(physicalScreenSessionMapMutex_);1952 std::lock_guard<std::recursive_mutex> lock(physicalScreenSessionMapMutex_);
1953 physicalScreenSessionMap_.erase(screenId);1953 physicalScreenSessionMap_.erase(screenId);
1954 }1954 }
1955+ 
1956+ ClearScreenPowerStatus(screenId);
1955}1957}
1956 1958 
1957void ScreenSessionManager::HandlePCScreenDisconnect(sptr<ScreenSession>& screenSession)1959void ScreenSessionManager::HandlePCScreenDisconnect(sptr<ScreenSession>& screenSession)
@@ -13340,7 +13342,7 @@ bool ScreenSessionManager::SetRSScreenPowerStatusExt(ScreenId screenId, ScreenPo
13340 rsScreenId = screenId;13342 rsScreenId = screenId;
13341 }13343 }
13342 }13344 }
13343- rsInterface_.SetScreenPowerStatus(rsScreenId, status);13345+ DoSetScreenPowerStatus(rsScreenId, status);
13344 if (status == ScreenPowerStatus::POWER_STATUS_ON) {13346 if (status == ScreenPowerStatus::POWER_STATUS_ON) {
13345#ifdef POWERMGR_DISPLAY_MANAGER_ENABLE13347#ifdef POWERMGR_DISPLAY_MANAGER_ENABLE
13346 uint32_t ret = DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().NotifyBrightnessManagerScreenPowerStatus(13348 uint32_t ret = DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().NotifyBrightnessManagerScreenPowerStatus(
@@ -13367,8 +13369,8 @@ void ScreenSessionManager::CheckAnotherScreenStatus(ScreenId screenId, ScreenPow
13367 if (secondScreenStatus == PanelPowerStatus::PANEL_POWER_STATUS_ON) {13369 if (secondScreenStatus == PanelPowerStatus::PANEL_POWER_STATUS_ON) {
13368 TLOGNFI(WmsLogTag::DMS, "Another screen is on while set screen: %{public}" PRIu64 " on, do on and off",13370 TLOGNFI(WmsLogTag::DMS, "Another screen is on while set screen: %{public}" PRIu64 " on, do on and off",
13369 screenId);13371 screenId);
13370- rsInterface_.SetScreenPowerStatus(secondScreenId, ScreenPowerStatus::POWER_STATUS_ON);13372+ DoSetScreenPowerStatus(secondScreenId, ScreenPowerStatus::POWER_STATUS_ON);
13371- rsInterface_.SetScreenPowerStatus(secondScreenId, ScreenPowerStatus::POWER_STATUS_OFF);13373+ DoSetScreenPowerStatus(secondScreenId, ScreenPowerStatus::POWER_STATUS_OFF);
13372 } else {13374 } else {
13373 TLOGNFI(WmsLogTag::DMS, "Another screen status is not on while set screen: %{public}" PRIu64 " on,"13375 TLOGNFI(WmsLogTag::DMS, "Another screen status is not on while set screen: %{public}" PRIu64 " on,"
13374 " set screen power status directly", screenId);13376 " set screen power status directly", screenId);
@@ -14434,5 +14436,39 @@ std::shared_ptr<TaskScheduler> ScreenSessionManager::GetScreenPowerTaskScheduler
14434{14436{
14435 return screenPowerTaskScheduler_;14437 return screenPowerTaskScheduler_;
14436}14438}
14439+ 
14440+void ScreenSessionManager::DoSetScreenPowerStatus(ScreenId rsScreenId, ScreenPowerStatus status)
14441+{
14442+ bool setAdvancedOffFlag = false;
14443+ {
14444+ std::lock_guard<std::mutex> lock(screenPowerStatusMapMutex_);
14445+ auto it = screenPowerStatusMap_.find(rsScreenId);
14446+ if (it != screenPowerStatusMap_.end() && it->second == ScreenPowerStatus::POWER_STATUS_ON_ADVANCED &&
14447+ status == ScreenPowerStatus::POWER_STATUS_OFF) {
14448+ setAdvancedOffFlag = true;
14449+ }
14450+ }
14451+ 
14452+ // when the power status is ON_ADVANCED and need to be set to OFF,first set the status to OFF_ADVANCED.
14453+ if (setAdvancedOffFlag) {
14454+ TLOGNFW(WmsLogTag::DMS,
14455+ "set the power status to OFF_ADVANCED first, screenId: %{public}" PRIu64 ", status: %{public}d.", rsScreenId,
14456+ status);
14457+ rsInterface_.SetScreenPowerStatus(rsScreenId, ScreenPowerStatus::POWER_STATUS_OFF_ADVANCED);
14458+ return;
14459+ }
14460+ 
14461+ rsInterface_.SetScreenPowerStatus(rsScreenId, status);
14462+ {
14463+ std::lock_guard<std::mutex> lock(screenPowerStatusMapMutex_);
14464+ screenPowerStatusMap_[rsScreenId] = status;
14465+ }
14466+}
14467+ 
14468+void ScreenSessionManager::ClearScreenPowerStatus(ScreenId rsScreenId)
14469+{
14470+ std::lock_guard<std::mutex> lock(screenPowerStatusMapMutex_);
14471+ screenPowerStatusMap_.erase(rsScreenId);
14472+}
14437// LCOV_EXCL_STOP14473// LCOV_EXCL_STOP
14438} // namespace OHOS::Rosen14474} // namespace OHOS::Rosen
@@ -3593,6 +3593,24 @@ HWTEST_F(ScreenSessionManagerTest, IsOnboardDisplay_systemCall, Function | Small
3593 MockAccesstokenKit::MockIsSACalling(true);3593 MockAccesstokenKit::MockIsSACalling(true);
3594 MockAccesstokenKit::MockIsSystemApp(true);3594 MockAccesstokenKit::MockIsSystemApp(true);
3595}3595}
3596+ 
3597+/**
3598+@tc.name: DoSetScreenPowerStatusTest
3599+@tc.desc: when the power status is ON_ADVANCED and need to be set to OFF,first set the status to OFF_ADVANCED
3600+@tc.type: FUNC
3601+*/
3602+HWTEST_F(ScreenSessionManagerTest, DoSetScreenPowerStatusTest, TestSize.Level1)
3603+{
3604+ ASSERT_NE(ssm_, nullptr);
3605+ g_errLog.clear();
3606+ LOG_SetCallback(MyLogCallback);
3607+ ssm_->SetRSScreenPowerStatusExt(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_ON_ADVANCED,
3608+ ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY);
3609+ 
3610+ ssm_->SetRSScreenPowerStatusExt(SCREEN_ID_FULL, ScreenPowerStatus::POWER_STATUS_OFF,
3611+ ScreenPowerOnReason::SAME_DISPLAY_TO_SINGLE_DISPLAY);
3612+ EXPECT_TRUE(g_errLog.find("set the power status to OFF_ADVANCED first") != std::string::npos);
3613+}
3596}3614}
3597}3615}
3598}3616}