1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "display_manager_adapter.h" 17 18#include <iremote_broker.h> 19#include <iservice_registry.h> 20#include <system_ability_definition.h> 21 22#include "display_manager.h" 23#include "dm_common.h" 24#include "scene_board_judgement.h" 25#include "screen_manager.h" 26#include "window_manager_hilog.h" 27#include "zidl/screen_session_manager_interface.h" 28 29namespace OHOS::Rosen { 30namespace { 31constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerAdapter"}; 32} 33WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAdapter) 34WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerAdapter) 35 36#define INIT_PROXY_CHECK_RETURN(ret) \ 37 do { \ 38 if (!InitDMSProxy()) { \ 39 WLOGFE("InitDMSProxy failed!"); \ 40 return ret; \ 41 } \ 42 } while (false) 43 44sptr<DisplayInfo> DisplayManagerAdapter::GetDefaultDisplayInfo() 45{ 46 INIT_PROXY_CHECK_RETURN(nullptr); 47 48 return displayManagerServiceProxy_->GetDefaultDisplayInfo(); 49} 50 51sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfoByScreenId(ScreenId screenId) 52{ 53 INIT_PROXY_CHECK_RETURN(nullptr); 54 55 return displayManagerServiceProxy_->GetDisplayInfoByScreen(screenId); 56} 57 58std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetDisplaySnapshot(DisplayId displayId, DmErrorCode* errorCode) 59{ 60 INIT_PROXY_CHECK_RETURN(nullptr); 61 62 return displayManagerServiceProxy_->GetDisplaySnapshot(displayId, errorCode); 63} 64 65std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode) 66{ 67 INIT_PROXY_CHECK_RETURN(nullptr); 68 69 return displayManagerServiceProxy_->GetSnapshotByPicker(rect, errorCode); 70} 71 72DMError ScreenManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId, 73 std::vector<ScreenColorGamut>& colorGamuts) 74{ 75 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 76 77 return displayManagerServiceProxy_->GetScreenSupportedColorGamuts(screenId, colorGamuts); 78} 79 80DMError ScreenManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) 81{ 82 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 83 84 return displayManagerServiceProxy_->GetScreenColorGamut(screenId, colorGamut); 85} 86 87DMError ScreenManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) 88{ 89 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 90 91 return displayManagerServiceProxy_->SetScreenColorGamut(screenId, colorGamutIdx); 92} 93 94DMError ScreenManagerAdapter::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) 95{ 96 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 97 98 return displayManagerServiceProxy_->GetScreenGamutMap(screenId, gamutMap); 99} 100 101DMError ScreenManagerAdapter::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) 102{ 103 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 104 105 return displayManagerServiceProxy_->SetScreenGamutMap(screenId, gamutMap); 106} 107 108DMError ScreenManagerAdapter::SetScreenColorTransform(ScreenId screenId) 109{ 110 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 111 112 return displayManagerServiceProxy_->SetScreenColorTransform(screenId); 113} 114 115DMError ScreenManagerAdapter::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) 116{ 117 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 118 119 WLOGFI("ScreenManagerAdapter::GetPixelFormat"); 120 return displayManagerServiceProxy_->GetPixelFormat(screenId, pixelFormat); 121} 122 123DMError ScreenManagerAdapter::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) 124{ 125 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 126 127 WLOGFI("ScreenManagerAdapter::SetPixelFormat"); 128 return displayManagerServiceProxy_->SetPixelFormat(screenId, pixelFormat); 129} 130 131DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, 132 std::vector<ScreenHDRFormat>& hdrFormats) 133{ 134 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 135 136 WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats"); 137 return displayManagerServiceProxy_->GetSupportedHDRFormats(screenId, hdrFormats); 138} 139 140DMError ScreenManagerAdapter::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) 141{ 142 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 143 144 WLOGFI("ScreenManagerAdapter::GetScreenHDRFormat"); 145 return displayManagerServiceProxy_->GetScreenHDRFormat(screenId, hdrFormat); 146} 147 148DMError ScreenManagerAdapter::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) 149{ 150 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 151 152 WLOGFI("ScreenManagerAdapter::SetScreenHDRFormat"); 153 return displayManagerServiceProxy_->SetScreenHDRFormat(screenId, modeIdx); 154} 155 156DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, 157 std::vector<GraphicCM_ColorSpaceType>& colorSpaces) 158{ 159 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 160 161 WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces"); 162 return displayManagerServiceProxy_->GetSupportedColorSpaces(screenId, colorSpaces); 163} 164 165DMError ScreenManagerAdapter::GetScreenColorSpace(ScreenId screenId, 166 GraphicCM_ColorSpaceType& colorSpace) 167{ 168 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 169 170 WLOGFI("ScreenManagerAdapter::GetScreenColorSpace"); 171 return displayManagerServiceProxy_->GetScreenColorSpace(screenId, colorSpace); 172} 173 174DMError ScreenManagerAdapter::SetScreenColorSpace(ScreenId screenId, 175 GraphicCM_ColorSpaceType colorSpace) 176{ 177 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 178 179 WLOGFI("ScreenManagerAdapter::SetScreenColorSpace"); 180 return displayManagerServiceProxy_->SetScreenColorSpace(screenId, colorSpace); 181} 182 183DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vector<uint32_t>& hdrFormats) 184{ 185 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 186 187 std::vector<ScreenHDRFormat> hdrFormatsVec; 188 DMError ret = GetSupportedHDRFormats(screenId, hdrFormatsVec); 189 for (auto value : hdrFormatsVec) { 190 hdrFormats.push_back(static_cast<uint32_t>(value)); 191 } 192 WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats ret %{public}d", static_cast<int32_t>(ret)); 193 return ret; 194} 195 196DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, std::vector<uint32_t>& colorSpaces) 197{ 198 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 199 200 std::vector<GraphicCM_ColorSpaceType> colorSpacesVec; 201 DMError ret = GetSupportedColorSpaces(screenId, colorSpacesVec); 202 for (auto value : colorSpacesVec) { 203 colorSpaces.push_back(static_cast<uint32_t>(value)); 204 } 205 WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces ret %{public}d", static_cast<int32_t>(ret)); 206 return ret; 207} 208 209ScreenId ScreenManagerAdapter::CreateVirtualScreen(VirtualScreenOption option, 210 const sptr<IDisplayManagerAgent>& displayManagerAgent) 211{ 212 INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID); 213 214 WLOGFI("DisplayManagerAdapter::CreateVirtualScreen"); 215 return displayManagerServiceProxy_->CreateVirtualScreen(option, displayManagerAgent->AsObject()); 216} 217 218DMError ScreenManagerAdapter::DestroyVirtualScreen(ScreenId screenId) 219{ 220 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 221 222 WLOGFI("DisplayManagerAdapter::DestroyVirtualScreen"); 223 return displayManagerServiceProxy_->DestroyVirtualScreen(screenId); 224} 225 226DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) 227{ 228 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 229 230 if (surface == nullptr) { 231 WLOGFE("Surface is nullptr"); 232 return DMError::DM_ERROR_NULLPTR; 233 } 234 WLOGFI("DisplayManagerAdapter::SetVirtualScreenSurface"); 235 return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface->GetProducer()); 236} 237 238DMError ScreenManagerAdapter::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation) 239{ 240 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 241 WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenCanvasRotation"); 242 return displayManagerServiceProxy_->SetVirtualMirrorScreenCanvasRotation(screenId, canvasRotation); 243} 244 245DMError ScreenManagerAdapter::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) 246{ 247 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 248 WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenScaleMode"); 249 return displayManagerServiceProxy_->SetVirtualMirrorScreenScaleMode(screenId, scaleMode); 250} 251 252DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked) 253{ 254 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 255 WLOGFI("DisplayManagerAdapter::SetScreenRotationLocked"); 256 return displayManagerServiceProxy_->SetScreenRotationLocked(isLocked); 257} 258 259DMError ScreenManagerAdapter::SetScreenRotationLockedFromJs(bool isLocked) 260{ 261 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 262 WLOGFI("DisplayManagerAdapter::SetScreenRotationLockedFromJs"); 263 return displayManagerServiceProxy_->SetScreenRotationLockedFromJs(isLocked); 264} 265 266DMError ScreenManagerAdapter::IsScreenRotationLocked(bool& isLocked) 267{ 268 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 269 WLOGFI("DisplayManagerAdapter::IsScreenRotationLocked"); 270 return displayManagerServiceProxy_->IsScreenRotationLocked(isLocked); 271} 272 273bool ScreenManagerAdapter::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) 274{ 275 INIT_PROXY_CHECK_RETURN(false); 276 return displayManagerServiceProxy_->SetSpecifiedScreenPower(screenId, state, reason); 277} 278 279bool ScreenManagerAdapter::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) 280{ 281 INIT_PROXY_CHECK_RETURN(false); 282 return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason); 283} 284 285ScreenPowerState ScreenManagerAdapter::GetScreenPower(ScreenId dmsScreenId) 286{ 287 INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE); 288 return displayManagerServiceProxy_->GetScreenPower(dmsScreenId); 289} 290 291DMError ScreenManagerAdapter::SetOrientation(ScreenId screenId, Orientation orientation) 292{ 293 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 294 295 return displayManagerServiceProxy_->SetOrientation(screenId, orientation); 296} 297 298DMError BaseAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent, 299 DisplayManagerAgentType type) 300{ 301 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 302 303 return displayManagerServiceProxy_->RegisterDisplayManagerAgent(displayManagerAgent, type); 304} 305 306DMError BaseAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent, 307 DisplayManagerAgentType type) 308{ 309 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 310 311 return displayManagerServiceProxy_->UnregisterDisplayManagerAgent(displayManagerAgent, type); 312} 313 314bool DisplayManagerAdapter::WakeUpBegin(PowerStateChangeReason reason) 315{ 316 INIT_PROXY_CHECK_RETURN(false); 317 318 return displayManagerServiceProxy_->WakeUpBegin(reason); 319} 320 321bool DisplayManagerAdapter::WakeUpEnd() 322{ 323 INIT_PROXY_CHECK_RETURN(false); 324 325 return displayManagerServiceProxy_->WakeUpEnd(); 326} 327 328bool DisplayManagerAdapter::SuspendBegin(PowerStateChangeReason reason) 329{ 330 INIT_PROXY_CHECK_RETURN(false); 331 332 return displayManagerServiceProxy_->SuspendBegin(reason); 333} 334 335bool DisplayManagerAdapter::SuspendEnd() 336{ 337 INIT_PROXY_CHECK_RETURN(false); 338 339 return displayManagerServiceProxy_->SuspendEnd(); 340} 341 342ScreenId DisplayManagerAdapter::GetInternalScreenId() 343{ 344 INIT_PROXY_CHECK_RETURN(false); 345 346 return displayManagerServiceProxy_->GetInternalScreenId(); 347} 348 349bool DisplayManagerAdapter::SetScreenPowerById(ScreenId screenId, ScreenPowerState state, 350 PowerStateChangeReason reason) 351{ 352 INIT_PROXY_CHECK_RETURN(false); 353 354 return displayManagerServiceProxy_->SetScreenPowerById(screenId, state, reason); 355} 356 357bool DisplayManagerAdapter::SetDisplayState(DisplayState state) 358{ 359 INIT_PROXY_CHECK_RETURN(false); 360 361 return displayManagerServiceProxy_->SetDisplayState(state); 362} 363 364DisplayState DisplayManagerAdapter::GetDisplayState(DisplayId displayId) 365{ 366 INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN); 367 368 return displayManagerServiceProxy_->GetDisplayState(displayId); 369} 370 371bool DisplayManagerAdapter::TryToCancelScreenOff() 372{ 373 INIT_PROXY_CHECK_RETURN(false); 374 375 return displayManagerServiceProxy_->TryToCancelScreenOff(); 376} 377 378void DisplayManagerAdapter::NotifyDisplayEvent(DisplayEvent event) 379{ 380 INIT_PROXY_CHECK_RETURN(); 381 382 displayManagerServiceProxy_->NotifyDisplayEvent(event); 383} 384 385bool DisplayManagerAdapter::SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) 386{ 387 INIT_PROXY_CHECK_RETURN(false); 388 389 return displayManagerServiceProxy_->SetFreeze(displayIds, isFreeze); 390} 391 392bool BaseAdapter::InitDMSProxy() 393{ 394 std::lock_guard<std::recursive_mutex> lock(mutex_); 395 if (!isProxyValid_) { 396 sptr<ISystemAbilityManager> systemAbilityManager = 397 SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); 398 if (!systemAbilityManager) { 399 WLOGFE("Failed to get system ability mgr."); 400 return false; 401 } 402 403 sptr<IRemoteObject> remoteObject 404 = systemAbilityManager->GetSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID); 405 if (!remoteObject) { 406 WLOGFE("Failed to get display manager service."); 407 return false; 408 } 409 410 if (SceneBoardJudgement::IsSceneBoardEnabled()) { 411 displayManagerServiceProxy_ = iface_cast<IScreenSessionManager>(remoteObject); 412 } else { 413 displayManagerServiceProxy_ = iface_cast<IDisplayManager>(remoteObject); 414 } 415 if ((!displayManagerServiceProxy_) || (!displayManagerServiceProxy_->AsObject())) { 416 WLOGFW("Failed to get system display manager services"); 417 return false; 418 } 419 420 dmsDeath_ = new(std::nothrow) DMSDeathRecipient(*this); 421 if (dmsDeath_ == nullptr) { 422 WLOGFE("Failed to create death Recipient ptr DMSDeathRecipient"); 423 return false; 424 } 425 if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(dmsDeath_)) { 426 WLOGFE("Failed to add death recipient"); 427 return false; 428 } 429 isProxyValid_ = true; 430 } 431 return true; 432} 433 434DMSDeathRecipient::DMSDeathRecipient(BaseAdapter& adapter) : adapter_(adapter) 435{ 436} 437 438void DMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath) 439{ 440 if (wptrDeath == nullptr) { 441 WLOGFE("wptrDeath is null"); 442 return; 443 } 444 445 sptr<IRemoteObject> object = wptrDeath.promote(); 446 if (!object) { 447 WLOGFE("object is null"); 448 return; 449 } 450 WLOGFI("dms OnRemoteDied"); 451 adapter_.Clear(); 452 SingletonContainer::Get<DisplayManager>().OnRemoteDied(); 453 SingletonContainer::Get<ScreenManager>().OnRemoteDied(); 454 return; 455} 456 457 458BaseAdapter::~BaseAdapter() 459{ 460 WLOGFI("BaseAdapter destory!"); 461 std::lock_guard<std::recursive_mutex> lock(mutex_); 462 Clear(); 463 displayManagerServiceProxy_ = nullptr; 464} 465 466void BaseAdapter::Clear() 467{ 468 WLOGFD("BaseAdapter Clear!"); 469 std::lock_guard<std::recursive_mutex> lock(mutex_); 470 if ((displayManagerServiceProxy_ != nullptr) && (displayManagerServiceProxy_->AsObject() != nullptr)) { 471 displayManagerServiceProxy_->AsObject()->RemoveDeathRecipient(dmsDeath_); 472 } 473 isProxyValid_ = false; 474} 475 476DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId, 477 ScreenId& screenGroupId) 478{ 479 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 480 481 return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, screenGroupId); 482} 483 484DMError ScreenManagerAdapter::SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, 485 MultiScreenMode screenMode) 486{ 487 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 488 489 return displayManagerServiceProxy_->SetMultiScreenMode(mainScreenId, secondaryScreenId, screenMode); 490} 491 492DMError ScreenManagerAdapter::SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, 493 MultiScreenPositionOptions secondScreenOption) 494{ 495 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 496 497 return displayManagerServiceProxy_->SetMultiScreenRelativePosition(mainScreenOptions, secondScreenOption); 498} 499 500DMError ScreenManagerAdapter::StopMirror(const std::vector<ScreenId>& mirrorScreenIds) 501{ 502 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 503 504 return displayManagerServiceProxy_->StopMirror(mirrorScreenIds); 505} 506 507DMError ScreenManagerAdapter::DisableMirror(bool disableOrNot) 508{ 509 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 510 511 return displayManagerServiceProxy_->DisableMirror(disableOrNot); 512} 513 514sptr<ScreenInfo> ScreenManagerAdapter::GetScreenInfo(ScreenId screenId) 515{ 516 if (screenId == SCREEN_ID_INVALID) { 517 WLOGFE("screen id is invalid"); 518 return nullptr; 519 } 520 INIT_PROXY_CHECK_RETURN(nullptr); 521 522 sptr<ScreenInfo> screenInfo = displayManagerServiceProxy_->GetScreenInfoById(screenId); 523 return screenInfo; 524} 525 526std::vector<DisplayId> DisplayManagerAdapter::GetAllDisplayIds() 527{ 528 WLOGFD("DisplayManagerAdapter::GetAllDisplayIds enter"); 529 INIT_PROXY_CHECK_RETURN(std::vector<DisplayId>()); 530 531 return displayManagerServiceProxy_->GetAllDisplayIds(); 532} 533 534DMError DisplayManagerAdapter::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) 535{ 536 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 537 538 return displayManagerServiceProxy_->HasPrivateWindow(displayId, hasPrivateWindow); 539} 540 541bool DisplayManagerAdapter::ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) 542{ 543 INIT_PROXY_CHECK_RETURN(false); 544 545 return displayManagerServiceProxy_->ConvertScreenIdToRsScreenId(screenId, rsScreenId); 546} 547 548DMError DisplayManagerAdapter::HasImmersiveWindow(ScreenId screenId, bool& immersive) 549{ 550 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 551 552 return displayManagerServiceProxy_->HasImmersiveWindow(screenId, immersive); 553} 554 555sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId) 556{ 557 WLOGFD("DisplayManagerAdapter::GetDisplayInfo enter, displayId: %{public}" PRIu64" ", displayId); 558 if (displayId == DISPLAY_ID_INVALID) { 559 WLOGFE("screen id is invalid"); 560 return nullptr; 561 } 562 INIT_PROXY_CHECK_RETURN(nullptr); 563 564 return displayManagerServiceProxy_->GetDisplayInfoById(displayId); 565} 566 567sptr<CutoutInfo> DisplayManagerAdapter::GetCutoutInfo(DisplayId displayId) 568{ 569 WLOGFD("DisplayManagerAdapter::GetCutoutInfo"); 570 if (displayId == DISPLAY_ID_INVALID) { 571 WLOGFE("screen id is invalid"); 572 return nullptr; 573 } 574 INIT_PROXY_CHECK_RETURN(nullptr); 575 return displayManagerServiceProxy_->GetCutoutInfo(displayId); 576} 577 578DMError DisplayManagerAdapter::AddSurfaceNodeToDisplay(DisplayId displayId, 579 std::shared_ptr<class RSSurfaceNode>& surfaceNode) 580{ 581 if (displayId == DISPLAY_ID_INVALID) { 582 WLOGFE("screen id is invalid"); 583 return DMError::DM_ERROR_INVALID_PARAM; 584 } 585 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 586 return displayManagerServiceProxy_->AddSurfaceNodeToDisplay(displayId, surfaceNode); 587} 588 589DMError DisplayManagerAdapter::RemoveSurfaceNodeFromDisplay(DisplayId displayId, 590 std::shared_ptr<class RSSurfaceNode>& surfaceNode) 591{ 592 if (displayId == DISPLAY_ID_INVALID) { 593 WLOGFE("screen id is invalid"); 594 return DMError::DM_ERROR_INVALID_PARAM; 595 } 596 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 597 return displayManagerServiceProxy_->RemoveSurfaceNodeFromDisplay(displayId, surfaceNode); 598} 599 600bool DisplayManagerAdapter::IsFoldable() 601{ 602 INIT_PROXY_CHECK_RETURN(false); 603 604 return displayManagerServiceProxy_->IsFoldable(); 605} 606 607bool DisplayManagerAdapter::IsCaptured() 608{ 609 INIT_PROXY_CHECK_RETURN(false); 610 611 return displayManagerServiceProxy_->IsCaptured(); 612} 613 614FoldStatus DisplayManagerAdapter::GetFoldStatus() 615{ 616 INIT_PROXY_CHECK_RETURN(FoldStatus::UNKNOWN); 617 618 return displayManagerServiceProxy_->GetFoldStatus(); 619} 620 621FoldDisplayMode DisplayManagerAdapter::GetFoldDisplayMode() 622{ 623 INIT_PROXY_CHECK_RETURN(FoldDisplayMode::UNKNOWN); 624 625 return displayManagerServiceProxy_->GetFoldDisplayMode(); 626} 627 628void DisplayManagerAdapter::SetFoldDisplayMode(const FoldDisplayMode mode) 629{ 630 INIT_PROXY_CHECK_RETURN(); 631 632 return displayManagerServiceProxy_->SetFoldDisplayMode(mode); 633} 634 635DMError DisplayManagerAdapter::SetFoldDisplayModeFromJs(const FoldDisplayMode mode) 636{ 637 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 638 639 return displayManagerServiceProxy_->SetFoldDisplayModeFromJs(mode); 640} 641 642void DisplayManagerAdapter::SetDisplayScale(ScreenId screenId, 643 float scaleX, float scaleY, float pivotX, float pivotY) 644{ 645 INIT_PROXY_CHECK_RETURN(); 646 647 return displayManagerServiceProxy_->SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY); 648} 649 650void DisplayManagerAdapter::SetFoldStatusLocked(bool locked) 651{ 652 INIT_PROXY_CHECK_RETURN(); 653 654 return displayManagerServiceProxy_->SetFoldStatusLocked(locked); 655} 656 657DMError DisplayManagerAdapter::SetFoldStatusLockedFromJs(bool locked) 658{ 659 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 660 661 return displayManagerServiceProxy_->SetFoldStatusLockedFromJs(locked); 662} 663 664sptr<FoldCreaseRegion> DisplayManagerAdapter::GetCurrentFoldCreaseRegion() 665{ 666 INIT_PROXY_CHECK_RETURN(nullptr); 667 668 return displayManagerServiceProxy_->GetCurrentFoldCreaseRegion(); 669} 670 671sptr<ScreenGroupInfo> ScreenManagerAdapter::GetScreenGroupInfoById(ScreenId screenId) 672{ 673 if (screenId == SCREEN_ID_INVALID) { 674 WLOGFE("screenGroup id is invalid"); 675 return nullptr; 676 } 677 INIT_PROXY_CHECK_RETURN(nullptr); 678 679 return displayManagerServiceProxy_->GetScreenGroupInfoById(screenId); 680} 681 682DMError ScreenManagerAdapter::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos) 683{ 684 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 685 686 return displayManagerServiceProxy_->GetAllScreenInfos(screenInfos); 687} 688 689DMError ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint, 690 ScreenId& screenGroupId) 691{ 692 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 693 694 return displayManagerServiceProxy_->MakeExpand(screenId, startPoint, screenGroupId); 695} 696 697DMError ScreenManagerAdapter::StopExpand(const std::vector<ScreenId>& expandScreenIds) 698{ 699 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 700 701 return displayManagerServiceProxy_->StopExpand(expandScreenIds); 702} 703 704 705void ScreenManagerAdapter::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) 706{ 707 INIT_PROXY_CHECK_RETURN(); 708 709 displayManagerServiceProxy_->RemoveVirtualScreenFromGroup(screens); 710} 711 712DMError ScreenManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId) 713{ 714 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 715 716 return displayManagerServiceProxy_->SetScreenActiveMode(screenId, modeId); 717} 718 719DMError ScreenManagerAdapter::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) 720{ 721 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 722 723 return displayManagerServiceProxy_->SetVirtualPixelRatio(screenId, virtualPixelRatio); 724} 725 726DMError ScreenManagerAdapter::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) 727{ 728 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 729 730 return displayManagerServiceProxy_->SetVirtualPixelRatioSystem(screenId, virtualPixelRatio); 731} 732 733DMError ScreenManagerAdapter::SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) 734{ 735 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 736 737 return displayManagerServiceProxy_->SetResolution(screenId, width, height, virtualPixelRatio); 738} 739 740DMError ScreenManagerAdapter::GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) 741{ 742 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 743 744 return displayManagerServiceProxy_->GetDensityInCurResolution(screenId, virtualPixelRatio); 745} 746 747DMError ScreenManagerAdapter::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) 748{ 749 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 750 751 return displayManagerServiceProxy_->ResizeVirtualScreen(screenId, width, height); 752} 753 754DMError ScreenManagerAdapter::MakeUniqueScreen(const std::vector<ScreenId>& screenIds) 755{ 756 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 757 758 return displayManagerServiceProxy_->MakeUniqueScreen(screenIds); 759} 760 761DMError DisplayManagerAdapter::GetAvailableArea(DisplayId displayId, DMRect& area) 762{ 763 if (displayId == DISPLAY_ID_INVALID) { 764 WLOGFE("displayId id is invalid"); 765 return DMError::DM_ERROR_INVALID_PARAM; 766 } 767 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 768 769 return displayManagerServiceProxy_->GetAvailableArea(displayId, area); 770} 771 772VirtualScreenFlag ScreenManagerAdapter::GetVirtualScreenFlag(ScreenId screenId) 773{ 774 INIT_PROXY_CHECK_RETURN(VirtualScreenFlag::DEFAULT); 775 if (screenId == SCREEN_ID_INVALID) { 776 WLOGFE("screenId id is invalid"); 777 return VirtualScreenFlag::DEFAULT; 778 } 779 780 return displayManagerServiceProxy_->GetVirtualScreenFlag(screenId); 781} 782 783DMError ScreenManagerAdapter::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) 784{ 785 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 786 if (screenId == SCREEN_ID_INVALID) { 787 WLOGFE("displayId id is invalid"); 788 return DMError::DM_ERROR_INVALID_PARAM; 789 } 790 if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { 791 return DMError::DM_ERROR_INVALID_PARAM; 792 } 793 return displayManagerServiceProxy_->SetVirtualScreenFlag(screenId, screenFlag); 794} 795 796DMError ScreenManagerAdapter::SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval) 797{ 798 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 799 800 return displayManagerServiceProxy_->SetVirtualScreenRefreshRate(screenId, refreshInterval); 801} 802 803void DisplayManagerAdapter::SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList) 804{ 805 INIT_PROXY_CHECK_RETURN(); 806 displayManagerServiceProxy_->SetVirtualScreenBlackList(screenId, windowIdList); 807} 808 809void DisplayManagerAdapter::DisablePowerOffRenderControl(ScreenId screenId) 810{ 811 INIT_PROXY_CHECK_RETURN(); 812 displayManagerServiceProxy_->DisablePowerOffRenderControl(screenId); 813} 814 815DMError DisplayManagerAdapter::ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy) 816{ 817 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 818 return displayManagerServiceProxy_->ProxyForFreeze(pidList, isProxy); 819} 820 821DMError DisplayManagerAdapter::ResetAllFreezeStatus() 822{ 823 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 824 return displayManagerServiceProxy_->ResetAllFreezeStatus(); 825} 826 827std::vector<DisplayPhysicalResolution> DisplayManagerAdapter::GetAllDisplayPhysicalResolution() 828{ 829 INIT_PROXY_CHECK_RETURN(std::vector<DisplayPhysicalResolution>{}); 830 return displayManagerServiceProxy_->GetAllDisplayPhysicalResolution(); 831} 832 833DMError DisplayManagerAdapter::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, 834 std::vector<uint64_t>& windowIdList) 835{ 836 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 837 return displayManagerServiceProxy_->SetVirtualScreenSecurityExemption(screenId, pid, windowIdList); 838} 839 840bool ScreenManagerAdapter::SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) 841{ 842 INIT_PROXY_CHECK_RETURN(false); 843 return displayManagerServiceProxy_->SetVirtualScreenStatus(screenId, screenStatus); 844} 845 846DMError ScreenManagerAdapter::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, 847 uint32_t& actualRefreshRate) 848{ 849 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); 850 return displayManagerServiceProxy_->SetVirtualScreenMaxRefreshRate(id, refreshRate, actualRefreshRate); 851} 852 853} // namespace OHOS::Rosen