From eb129556649320bdd6954f908075b9fb356a3218 Mon Sep 17 00:00:00 2001 From: youqijing Date: Fri, 18 Feb 2022 17:31:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3Expand=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8BDisplay=E5=B0=BA=E5=AF=B8=E5=8F=98=E5=8C=96=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=AD=BB=E9=94=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: youqijing Change-Id: Iae2ae474a0c4ddb6083f62be470f81663e5b951a --- .../include/abstract_display_controller.h | 4 +- dmserver/src/abstract_display_controller.cpp | 71 +++++++++++-------- dmserver/src/abstract_screen_controller.cpp | 4 +- 3 files changed, 47 insertions(+), 32 deletions(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index f57fb987..ed3119a8 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -51,8 +51,8 @@ private: void BindAloneScreenLocked(sptr absScreen); void AddScreenToMirrorLocked(sptr absScreen); void AddScreenToExpandLocked(sptr absScreen); - void ProcessNormalScreenDisconnected(sptr absScreen, sptr screenGroup); - void ProcessExpandScreenDisconnected(sptr absScreen, sptr screenGroup); + DisplayId ProcessNormalScreenDisconnected(sptr absScreen, sptr screenGroup); + DisplayId ProcessExpandScreenDisconnected(sptr absScreen, sptr screenGroup); bool UpdateDisplaySize(sptr absDisplay, sptr info); std::recursive_mutex& mutex_; diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index aa9899e8..9fa335c1 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -129,67 +129,82 @@ void AbstractDisplayController::OnAbstractScreenConnect(sptr abs void AbstractDisplayController::OnAbstractScreenDisconnect(sptr absScreen) { - WLOGI("disconnect screen. id:%{public}" PRIu64"", absScreen->dmsId_); if (absScreen == nullptr) { WLOGE("the information of the screen is wrong"); return; } - std::lock_guard lock(mutex_); - sptr screenGroup = absScreen->GetGroup(); - if (screenGroup == nullptr) { - WLOGE("the group information of the screen is wrong"); + WLOGI("disconnect screen. id:%{public}" PRIu64"", absScreen->dmsId_); + sptr screenGroup; + DisplayId absDisplayId = DISPLAY_ID_INVALD; + { + std::lock_guard lock(mutex_); + screenGroup = absScreen->GetGroup(); + if (screenGroup == nullptr) { + WLOGE("the group information of the screen is wrong"); + return; + } + if (screenGroup->combination_ == ScreenCombination::SCREEN_ALONE + || screenGroup->combination_ == ScreenCombination::SCREEN_MIRROR) { + absDisplayId = ProcessNormalScreenDisconnected(absScreen, screenGroup); + } else if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { + absDisplayId = ProcessExpandScreenDisconnected(absScreen, screenGroup); + } else { + WLOGE("support in future. combination:%{public}u", screenGroup->combination_); + } + } + if (absDisplayId == DISPLAY_ID_INVALD) { + WLOGE("the displayId of the disconnected expand screen was not found"); return; } if (screenGroup->combination_ == ScreenCombination::SCREEN_ALONE || screenGroup->combination_ == ScreenCombination::SCREEN_MIRROR) { - ProcessNormalScreenDisconnected(absScreen, screenGroup); + if (screenGroup->GetChildCount() == 0) { + abstractDisplayMap_.erase(absDisplayId); + DisplayManagerAgentController::GetInstance().OnDisplayDestroy(absDisplayId); + } } else if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { - ProcessExpandScreenDisconnected(absScreen, screenGroup); + DisplayManagerService::GetInstance().NotifyDisplayStateChange( + absDisplayId, DisplayStateChangeType::DESTROY); + DisplayManagerAgentController::GetInstance().OnDisplayDestroy(absDisplayId); + abstractDisplayMap_.erase(absDisplayId); } else { WLOGE("support in future. combination:%{public}u", screenGroup->combination_); } } -void AbstractDisplayController::ProcessNormalScreenDisconnected( +DisplayId AbstractDisplayController::ProcessNormalScreenDisconnected( sptr absScreen, sptr screenGroup) { WLOGI("normal screen disconnect"); ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId(); sptr defaultScreen = abstractScreenController_->GetAbstractScreen(defaultScreenId); for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) { + DisplayId displayId = iter->first; sptr abstractDisplay = iter->second; - if (abstractDisplay->GetAbstractScreenId() != absScreen->dmsId_) { - continue; - } - abstractDisplay->BindAbstractScreen(defaultScreen); - if (screenGroup->GetChildCount() == 0) { - abstractDisplayMap_.erase(iter); - DisplayManagerAgentController::GetInstance().OnDisplayDestroy(abstractDisplay->GetId()); + if (abstractDisplay->GetAbstractScreenId() == absScreen->dmsId_) { + WLOGI("normal screen disconnect, displayId: %{public}" PRIu64", screenId: %{public}" PRIu64"", + displayId, abstractDisplay->GetAbstractScreenId()); + abstractDisplay->BindAbstractScreen(defaultScreen); + return displayId; } } + return DISPLAY_ID_INVALD; } -void AbstractDisplayController::ProcessExpandScreenDisconnected( +DisplayId AbstractDisplayController::ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup) { WLOGI("expand screen disconnect"); - ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId(); - sptr defaultScreen = abstractScreenController_->GetAbstractScreen(defaultScreenId); for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) { DisplayId displayId = iter->first; sptr abstractDisplay = iter->second; - if (abstractDisplay->GetAbstractScreenId() != absScreen->dmsId_) { - continue; + if (abstractDisplay->GetAbstractScreenId() == absScreen->dmsId_) { + WLOGI("expand screen disconnect, displayId: %{public}" PRIu64", screenId: %{public}" PRIu64"", + displayId, abstractDisplay->GetAbstractScreenId()); + return displayId; } - WLOGI("notify wms and dm which expand screen disconnect, displayId: %{public}" PRIu64"" - ", screenId: %{public}" PRIu64"", displayId, abstractDisplay->GetAbstractScreenId()); - // Notify disconnect event to WMS - DisplayManagerService::GetInstance().NotifyDisplayStateChange(displayId, DisplayStateChangeType::DESTROY); - // Notify disconnect event to DisplayManager - DisplayManagerAgentController::GetInstance().OnDisplayDestroy(abstractDisplay->GetId()); - abstractDisplayMap_.erase(iter); - break; } + return DISPLAY_ID_INVALD; } void AbstractDisplayController::OnAbstractScreenChange(sptr absScreen, DisplayChangeEvent event) diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index 956fa434..ed327ffd 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -752,7 +752,7 @@ void AbstractScreenController::DumpScreenGroupInfo() const std::string screenType = "UNDEFINE"; NodeId nodeId = (screenGroup->rsDisplayNode_ == nullptr) ? 0 : screenGroup->rsDisplayNode_->GetId(); WLOGI("%{public}10s %{public}20" PRIu64" %{public}20" PRIu64" %{public}20" PRIu64" %{public}10s %{public}20" - PRIu64" %{public}10s %{public}20" PRIu64" ", isGroup.c_str(), screenGroup->dmsId_,screenGroup->rsId_, + PRIu64" %{public}10s %{public}20" PRIu64" ", isGroup.c_str(), screenGroup->dmsId_, screenGroup->rsId_, screenGroup->groupDmsId_, screenType.c_str(), nodeId, isMirrored.c_str(), screenGroup->rSDisplayNodeConfig_.mirrorNodeId); auto childrenScreen = screenGroup->GetChildren(); @@ -769,7 +769,7 @@ void AbstractScreenController::DumpScreenGroupInfo() const isMirrored = screen->rSDisplayNodeConfig_.isMirrored ? "true" : "false"; nodeId = (screen->rsDisplayNode_ == nullptr) ? 0 : screen->rsDisplayNode_->GetId(); WLOGI("%{public}10s %{public}20" PRIu64" %{public}20" PRIu64" %{public}20" PRIu64" %{public}10s %{public}20" - PRIu64" %{public}10s %{public}20" PRIu64" ", isGroup.c_str(), screen->dmsId_,screen->rsId_, + PRIu64" %{public}10s %{public}20" PRIu64" ", isGroup.c_str(), screen->dmsId_, screen->rsId_, screen->groupDmsId_, screenType.c_str(), nodeId, isMirrored.c_str(), screen->rSDisplayNodeConfig_.mirrorNodeId); }