fix MakeExpand creating redundant display error

Signed-off-by: Klaus_q <wangqi175@huawei.com>
Change-Id: Ia3c1c4a11794ad35ab3bbd56de48333bacaab2a1
This commit is contained in:
Klaus_q
2022-03-14 21:30:35 +08:00
parent 5559b4f029
commit 4258db1261
3 changed files with 8 additions and 21 deletions
@@ -45,7 +45,6 @@ public:
sptr<AbstractDisplay> GetAbstractDisplay(DisplayId displayId) const;
sptr<AbstractDisplay> GetAbstractDisplayByScreen(ScreenId screenId) const;
std::vector<DisplayId> GetAllDisplayIds() const;
void AddDisplayForExpandScreen(sptr<AbstractScreen> absScreen);
void SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze);
private:
+8 -16
View File
@@ -390,6 +390,14 @@ void AbstractDisplayController::AddScreenToMirrorLocked(sptr<AbstractScreen> abs
void AbstractDisplayController::AddScreenToExpandLocked(sptr<AbstractScreen> absScreen)
{
for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) {
sptr<AbstractDisplay> abstractDisplay = iter->second;
if (abstractDisplay->GetAbstractScreenId() == absScreen->dmsId_) {
WLOGE("error, screenId: %{public}" PRIu64" already has corresponding display",
absScreen->dmsId_);
return;
}
}
WLOGI("bind display to expand. screen:%{public}" PRIu64"", absScreen->dmsId_);
sptr<SupportedScreenModes> info;
if (absScreen->type_ == ScreenType::VIRTUAL) {
@@ -417,22 +425,6 @@ void AbstractDisplayController::AddScreenToExpandLocked(sptr<AbstractScreen> abs
DisplayManagerAgentController::GetInstance().OnDisplayCreate(display->ConvertToDisplayInfo());
}
void AbstractDisplayController::AddDisplayForExpandScreen(sptr<AbstractScreen> absScreen)
{
for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) {
sptr<AbstractDisplay> abstractDisplay = iter->second;
if (abstractDisplay->GetAbstractScreenId() == absScreen->dmsId_) {
WLOGE("error, screenId: %{public}" PRIu64" already has corresponding display",
absScreen->dmsId_);
return;
}
}
WLOGI("screenId: %{public}" PRIu64" has no corresponding display, create new display.",
absScreen->dmsId_);
AddScreenToExpandLocked(absScreen);
}
void AbstractDisplayController::SetFreeze(std::vector<DisplayId> displayIds, bool toFreeze)
{
WM_SCOPED_TRACE("dms:SetAllFreeze");
-4
View File
@@ -481,10 +481,6 @@ ScreenId DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds
if (iter != allExpandScreenIds.end()) {
allExpandScreenIds.erase(iter);
}
for (ScreenId expandScreenId : allExpandScreenIds) {
auto expandScreen = abstractScreenController_->GetAbstractScreen(expandScreenId);
abstractDisplayController_->AddDisplayForExpandScreen(expandScreen);
}
SetShotScreen(defaultScreenId, shotScreenIds);
WM_SCOPED_TRACE("dms:MakeExpand");
if (!allExpandScreenIds.empty() && !abstractScreenController_->MakeExpand(allExpandScreenIds, startPoints)) {