• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
29 namespace OHOS::Rosen {
30 namespace {
31     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerAdapter"};
32 }
33 WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAdapter)
WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerAdapter)34 WM_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 
44 sptr<DisplayInfo> DisplayManagerAdapter::GetDefaultDisplayInfo()
45 {
46     INIT_PROXY_CHECK_RETURN(nullptr);
47 
48     return displayManagerServiceProxy_->GetDefaultDisplayInfo();
49 }
50 
GetDisplayInfoByScreenId(ScreenId screenId)51 sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfoByScreenId(ScreenId screenId)
52 {
53     INIT_PROXY_CHECK_RETURN(nullptr);
54 
55     return  displayManagerServiceProxy_->GetDisplayInfoByScreen(screenId);
56 }
57 
GetDisplaySnapshot(DisplayId displayId,DmErrorCode * errorCode)58 std::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 
GetScreenSupportedColorGamuts(ScreenId screenId,std::vector<ScreenColorGamut> & colorGamuts)65 DMError ScreenManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId,
66     std::vector<ScreenColorGamut>& colorGamuts)
67 {
68     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
69 
70     return displayManagerServiceProxy_->GetScreenSupportedColorGamuts(screenId, colorGamuts);
71 }
72 
GetScreenColorGamut(ScreenId screenId,ScreenColorGamut & colorGamut)73 DMError ScreenManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut)
74 {
75     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
76 
77     return displayManagerServiceProxy_->GetScreenColorGamut(screenId, colorGamut);
78 }
79 
SetScreenColorGamut(ScreenId screenId,int32_t colorGamutIdx)80 DMError ScreenManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx)
81 {
82     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
83 
84     return displayManagerServiceProxy_->SetScreenColorGamut(screenId, colorGamutIdx);
85 }
86 
GetScreenGamutMap(ScreenId screenId,ScreenGamutMap & gamutMap)87 DMError ScreenManagerAdapter::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap)
88 {
89     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
90 
91     return displayManagerServiceProxy_->GetScreenGamutMap(screenId, gamutMap);
92 }
93 
SetScreenGamutMap(ScreenId screenId,ScreenGamutMap gamutMap)94 DMError ScreenManagerAdapter::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap)
95 {
96     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
97 
98     return displayManagerServiceProxy_->SetScreenGamutMap(screenId, gamutMap);
99 }
100 
SetScreenColorTransform(ScreenId screenId)101 DMError ScreenManagerAdapter::SetScreenColorTransform(ScreenId screenId)
102 {
103     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
104 
105     return displayManagerServiceProxy_->SetScreenColorTransform(screenId);
106 }
107 
GetPixelFormat(ScreenId screenId,GraphicPixelFormat & pixelFormat)108 DMError ScreenManagerAdapter::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat)
109 {
110     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
111     WLOGFI("ScreenManagerAdapter::GetPixelFormat");
112     return displayManagerServiceProxy_->GetPixelFormat(screenId, pixelFormat);
113 }
114 
SetPixelFormat(ScreenId screenId,GraphicPixelFormat pixelFormat)115 DMError ScreenManagerAdapter::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat)
116 {
117     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
118     WLOGFI("ScreenManagerAdapter::SetPixelFormat");
119     return displayManagerServiceProxy_->SetPixelFormat(screenId, pixelFormat);
120 }
121 
GetSupportedHDRFormats(ScreenId screenId,std::vector<ScreenHDRFormat> & hdrFormats)122 DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId,
123     std::vector<ScreenHDRFormat>& hdrFormats)
124 {
125     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
126     WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats");
127     return displayManagerServiceProxy_->GetSupportedHDRFormats(screenId, hdrFormats);
128 }
129 
GetScreenHDRFormat(ScreenId screenId,ScreenHDRFormat & hdrFormat)130 DMError ScreenManagerAdapter::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat)
131 {
132     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
133     WLOGFI("ScreenManagerAdapter::GetScreenHDRFormat");
134     return displayManagerServiceProxy_->GetScreenHDRFormat(screenId, hdrFormat);
135 }
136 
SetScreenHDRFormat(ScreenId screenId,int32_t modeIdx)137 DMError ScreenManagerAdapter::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx)
138 {
139     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
140     WLOGFI("ScreenManagerAdapter::SetScreenHDRFormat");
141     return displayManagerServiceProxy_->SetScreenHDRFormat(screenId, modeIdx);
142 }
143 
GetSupportedColorSpaces(ScreenId screenId,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)144 DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId,
145     std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
146 {
147     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
148     WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces");
149     return displayManagerServiceProxy_->GetSupportedColorSpaces(screenId, colorSpaces);
150 }
151 
GetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType & colorSpace)152 DMError ScreenManagerAdapter::GetScreenColorSpace(ScreenId screenId,
153     GraphicCM_ColorSpaceType& colorSpace)
154 {
155     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
156     WLOGFI("ScreenManagerAdapter::GetScreenColorSpace");
157     return displayManagerServiceProxy_->GetScreenColorSpace(screenId, colorSpace);
158 }
159 
SetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType colorSpace)160 DMError ScreenManagerAdapter::SetScreenColorSpace(ScreenId screenId,
161     GraphicCM_ColorSpaceType colorSpace)
162 {
163     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
164     WLOGFI("ScreenManagerAdapter::SetScreenColorSpace");
165     return displayManagerServiceProxy_->SetScreenColorSpace(screenId, colorSpace);
166 }
167 
GetSupportedHDRFormats(ScreenId screenId,std::vector<uint32_t> & hdrFormats)168 DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vector<uint32_t>& hdrFormats)
169 {
170     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
171     std::vector<ScreenHDRFormat> hdrFormatsVec;
172     DMError ret = GetSupportedHDRFormats(screenId, hdrFormatsVec);
173     for (auto value : hdrFormatsVec) {
174         hdrFormats.push_back(static_cast<uint32_t>(value));
175     }
176     WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats ret %{public}d", static_cast<int32_t>(ret));
177     return ret;
178 }
179 
GetSupportedColorSpaces(ScreenId screenId,std::vector<uint32_t> & colorSpaces)180 DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, std::vector<uint32_t>& colorSpaces)
181 {
182     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
183     std::vector<GraphicCM_ColorSpaceType> colorSpacesVec;
184     DMError ret = GetSupportedColorSpaces(screenId, colorSpacesVec);
185     for (auto value : colorSpacesVec) {
186         colorSpaces.push_back(static_cast<uint32_t>(value));
187     }
188     WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces ret %{public}d", static_cast<int32_t>(ret));
189     return ret;
190 }
191 
CreateVirtualScreen(VirtualScreenOption option,const sptr<IDisplayManagerAgent> & displayManagerAgent)192 ScreenId ScreenManagerAdapter::CreateVirtualScreen(VirtualScreenOption option,
193     const sptr<IDisplayManagerAgent>& displayManagerAgent)
194 {
195     INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID);
196 
197     WLOGFI("DisplayManagerAdapter::CreateVirtualScreen");
198     return displayManagerServiceProxy_->CreateVirtualScreen(option, displayManagerAgent->AsObject());
199 }
200 
DestroyVirtualScreen(ScreenId screenId)201 DMError ScreenManagerAdapter::DestroyVirtualScreen(ScreenId screenId)
202 {
203     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
204 
205     WLOGFI("DisplayManagerAdapter::DestroyVirtualScreen");
206     return displayManagerServiceProxy_->DestroyVirtualScreen(screenId);
207 }
208 
SetVirtualScreenSurface(ScreenId screenId,sptr<Surface> surface)209 DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
210 {
211     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
212 
213     if (surface == nullptr) {
214         WLOGFE("Surface is nullptr");
215         return DMError::DM_ERROR_NULLPTR;
216     }
217     WLOGFI("DisplayManagerAdapter::SetVirtualScreenSurface");
218     return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface->GetProducer());
219 }
220 
SetVirtualMirrorScreenCanvasRotation(ScreenId screenId,bool canvasRotation)221 DMError ScreenManagerAdapter::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation)
222 {
223     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
224     WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenCanvasRotation");
225     return displayManagerServiceProxy_->SetVirtualMirrorScreenCanvasRotation(screenId, canvasRotation);
226 }
227 
SetScreenRotationLocked(bool isLocked)228 DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked)
229 {
230     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
231     WLOGFI("DisplayManagerAdapter::SetScreenRotationLocked");
232     return displayManagerServiceProxy_->SetScreenRotationLocked(isLocked);
233 }
234 
IsScreenRotationLocked(bool & isLocked)235 DMError ScreenManagerAdapter::IsScreenRotationLocked(bool& isLocked)
236 {
237     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
238     WLOGFI("DisplayManagerAdapter::IsScreenRotationLocked");
239     return displayManagerServiceProxy_->IsScreenRotationLocked(isLocked);
240 }
241 
SetSpecifiedScreenPower(ScreenId screenId,ScreenPowerState state,PowerStateChangeReason reason)242 bool ScreenManagerAdapter::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
243 {
244     INIT_PROXY_CHECK_RETURN(false);
245     return displayManagerServiceProxy_->SetSpecifiedScreenPower(screenId, state, reason);
246 }
247 
SetScreenPowerForAll(ScreenPowerState state,PowerStateChangeReason reason)248 bool ScreenManagerAdapter::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
249 {
250     INIT_PROXY_CHECK_RETURN(false);
251     return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason);
252 }
253 
GetScreenPower(ScreenId dmsScreenId)254 ScreenPowerState ScreenManagerAdapter::GetScreenPower(ScreenId dmsScreenId)
255 {
256     INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE);
257     return displayManagerServiceProxy_->GetScreenPower(dmsScreenId);
258 }
259 
SetOrientation(ScreenId screenId,Orientation orientation)260 DMError ScreenManagerAdapter::SetOrientation(ScreenId screenId, Orientation orientation)
261 {
262     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
263 
264     return displayManagerServiceProxy_->SetOrientation(screenId, orientation);
265 }
266 
RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)267 DMError BaseAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
268     DisplayManagerAgentType type)
269 {
270     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
271 
272     return displayManagerServiceProxy_->RegisterDisplayManagerAgent(displayManagerAgent, type);
273 }
274 
UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)275 DMError BaseAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
276     DisplayManagerAgentType type)
277 {
278     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
279 
280     return displayManagerServiceProxy_->UnregisterDisplayManagerAgent(displayManagerAgent, type);
281 }
282 
WakeUpBegin(PowerStateChangeReason reason)283 bool DisplayManagerAdapter::WakeUpBegin(PowerStateChangeReason reason)
284 {
285     INIT_PROXY_CHECK_RETURN(false);
286 
287     return displayManagerServiceProxy_->WakeUpBegin(reason);
288 }
289 
WakeUpEnd()290 bool DisplayManagerAdapter::WakeUpEnd()
291 {
292     INIT_PROXY_CHECK_RETURN(false);
293 
294     return displayManagerServiceProxy_->WakeUpEnd();
295 }
296 
SuspendBegin(PowerStateChangeReason reason)297 bool DisplayManagerAdapter::SuspendBegin(PowerStateChangeReason reason)
298 {
299     INIT_PROXY_CHECK_RETURN(false);
300 
301     return displayManagerServiceProxy_->SuspendBegin(reason);
302 }
303 
SuspendEnd()304 bool DisplayManagerAdapter::SuspendEnd()
305 {
306     INIT_PROXY_CHECK_RETURN(false);
307 
308     return displayManagerServiceProxy_->SuspendEnd();
309 }
310 
SetDisplayState(DisplayState state)311 bool DisplayManagerAdapter::SetDisplayState(DisplayState state)
312 {
313     INIT_PROXY_CHECK_RETURN(false);
314 
315     return displayManagerServiceProxy_->SetDisplayState(state);
316 }
317 
GetDisplayState(DisplayId displayId)318 DisplayState DisplayManagerAdapter::GetDisplayState(DisplayId displayId)
319 {
320     INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN);
321 
322     return displayManagerServiceProxy_->GetDisplayState(displayId);
323 }
324 
NotifyDisplayEvent(DisplayEvent event)325 void DisplayManagerAdapter::NotifyDisplayEvent(DisplayEvent event)
326 {
327     INIT_PROXY_CHECK_RETURN();
328 
329     displayManagerServiceProxy_->NotifyDisplayEvent(event);
330 }
331 
SetFreeze(std::vector<DisplayId> displayIds,bool isFreeze)332 bool DisplayManagerAdapter::SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze)
333 {
334     INIT_PROXY_CHECK_RETURN(false);
335     return displayManagerServiceProxy_->SetFreeze(displayIds, isFreeze);
336 }
337 
InitDMSProxy()338 bool BaseAdapter::InitDMSProxy()
339 {
340     std::lock_guard<std::recursive_mutex> lock(mutex_);
341     if (!isProxyValid_) {
342         sptr<ISystemAbilityManager> systemAbilityManager =
343                 SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
344         if (!systemAbilityManager) {
345             WLOGFE("Failed to get system ability mgr.");
346             return false;
347         }
348 
349         sptr<IRemoteObject> remoteObject
350             = systemAbilityManager->GetSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID);
351         if (!remoteObject) {
352             WLOGFE("Failed to get display manager service.");
353             return false;
354         }
355 
356         if (SceneBoardJudgement::IsSceneBoardEnabled()) {
357             displayManagerServiceProxy_ = iface_cast<IScreenSessionManager>(remoteObject);
358         } else {
359             displayManagerServiceProxy_ = iface_cast<IDisplayManager>(remoteObject);
360         }
361         if ((!displayManagerServiceProxy_) || (!displayManagerServiceProxy_->AsObject())) {
362             WLOGFW("Failed to get system display manager services");
363             return false;
364         }
365 
366         dmsDeath_ = new(std::nothrow) DMSDeathRecipient(*this);
367         if (dmsDeath_ == nullptr) {
368             WLOGFE("Failed to create death Recipient ptr DMSDeathRecipient");
369             return false;
370         }
371         if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(dmsDeath_)) {
372             WLOGFE("Failed to add death recipient");
373             return false;
374         }
375         isProxyValid_ = true;
376     }
377     return true;
378 }
379 
DMSDeathRecipient(BaseAdapter & adapter)380 DMSDeathRecipient::DMSDeathRecipient(BaseAdapter& adapter) : adapter_(adapter)
381 {
382 }
383 
OnRemoteDied(const wptr<IRemoteObject> & wptrDeath)384 void DMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
385 {
386     if (wptrDeath == nullptr) {
387         WLOGFE("wptrDeath is null");
388         return;
389     }
390 
391     sptr<IRemoteObject> object = wptrDeath.promote();
392     if (!object) {
393         WLOGFE("object is null");
394         return;
395     }
396     WLOGFI("dms OnRemoteDied");
397     adapter_.Clear();
398     SingletonContainer::Get<DisplayManager>().OnRemoteDied();
399     SingletonContainer::Get<ScreenManager>().OnRemoteDied();
400     return;
401 }
402 
403 
~BaseAdapter()404 BaseAdapter::~BaseAdapter()
405 {
406     WLOGFI("BaseAdapter destory!");
407     std::lock_guard<std::recursive_mutex> lock(mutex_);
408     displayManagerServiceProxy_ = nullptr;
409 }
410 
Clear()411 void BaseAdapter::Clear()
412 {
413     WLOGFI("BaseAdapter Clear!");
414     std::lock_guard<std::recursive_mutex> lock(mutex_);
415     if ((displayManagerServiceProxy_ != nullptr) && (displayManagerServiceProxy_->AsObject() != nullptr)) {
416         displayManagerServiceProxy_->AsObject()->RemoveDeathRecipient(dmsDeath_);
417     }
418     isProxyValid_ = false;
419 }
420 
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenId,ScreenId & screenGroupId)421 DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
422                                          ScreenId& screenGroupId)
423 {
424     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
425 
426     return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
427 }
428 
StopMirror(const std::vector<ScreenId> & mirrorScreenIds)429 DMError ScreenManagerAdapter::StopMirror(const std::vector<ScreenId>& mirrorScreenIds)
430 {
431     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
432 
433     return displayManagerServiceProxy_->StopMirror(mirrorScreenIds);
434 }
435 
DisableMirror(bool disableOrNot)436 DMError ScreenManagerAdapter::DisableMirror(bool disableOrNot)
437 {
438     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
439 
440     return displayManagerServiceProxy_->DisableMirror(disableOrNot);
441 }
442 
GetScreenInfo(ScreenId screenId)443 sptr<ScreenInfo> ScreenManagerAdapter::GetScreenInfo(ScreenId screenId)
444 {
445     if (screenId == SCREEN_ID_INVALID) {
446         WLOGFE("screen id is invalid");
447         return nullptr;
448     }
449     INIT_PROXY_CHECK_RETURN(nullptr);
450 
451     sptr<ScreenInfo> screenInfo = displayManagerServiceProxy_->GetScreenInfoById(screenId);
452     return screenInfo;
453 }
454 
GetAllDisplayIds()455 std::vector<DisplayId> DisplayManagerAdapter::GetAllDisplayIds()
456 {
457     WLOGFI("DisplayManagerAdapter::GetAllDisplayIds enter");
458     INIT_PROXY_CHECK_RETURN(std::vector<DisplayId>());
459 
460     return displayManagerServiceProxy_->GetAllDisplayIds();
461 }
462 
HasPrivateWindow(DisplayId displayId,bool & hasPrivateWindow)463 DMError DisplayManagerAdapter::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow)
464 {
465     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
466 
467     return displayManagerServiceProxy_->HasPrivateWindow(displayId, hasPrivateWindow);
468 }
469 
ConvertScreenIdToRsScreenId(ScreenId screenId,ScreenId & rsScreenId)470 bool DisplayManagerAdapter::ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId)
471 {
472     INIT_PROXY_CHECK_RETURN(false);
473 
474     return displayManagerServiceProxy_->ConvertScreenIdToRsScreenId(screenId, rsScreenId);
475 }
476 
HasImmersiveWindow(bool & immersive)477 DMError DisplayManagerAdapter::HasImmersiveWindow(bool& immersive)
478 {
479     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
480 
481     return displayManagerServiceProxy_->HasImmersiveWindow(immersive);
482 }
483 
GetDisplayInfo(DisplayId displayId)484 sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId)
485 {
486     WLOGFD("DisplayManagerAdapter::GetDisplayInfo enter, displayId: %{public}" PRIu64" ", displayId);
487     if (displayId == DISPLAY_ID_INVALID) {
488         WLOGFW("screen id is invalid");
489         return nullptr;
490     }
491     INIT_PROXY_CHECK_RETURN(nullptr);
492 
493     return displayManagerServiceProxy_->GetDisplayInfoById(displayId);
494 }
495 
GetCutoutInfo(DisplayId displayId)496 sptr<CutoutInfo> DisplayManagerAdapter::GetCutoutInfo(DisplayId displayId)
497 {
498     WLOGFI("DisplayManagerAdapter::GetCutoutInfo");
499     if (displayId == DISPLAY_ID_INVALID) {
500         WLOGFE("screen id is invalid");
501         return nullptr;
502     }
503     INIT_PROXY_CHECK_RETURN(nullptr);
504     return displayManagerServiceProxy_->GetCutoutInfo(displayId);
505 }
506 
AddSurfaceNodeToDisplay(DisplayId displayId,std::shared_ptr<class RSSurfaceNode> & surfaceNode)507 DMError DisplayManagerAdapter::AddSurfaceNodeToDisplay(DisplayId displayId,
508     std::shared_ptr<class RSSurfaceNode>& surfaceNode)
509 {
510     if (displayId == DISPLAY_ID_INVALID) {
511         WLOGFE("screen id is invalid");
512         return DMError::DM_ERROR_INVALID_PARAM;
513     }
514     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
515     return displayManagerServiceProxy_->AddSurfaceNodeToDisplay(displayId, surfaceNode);
516 }
517 
RemoveSurfaceNodeFromDisplay(DisplayId displayId,std::shared_ptr<class RSSurfaceNode> & surfaceNode)518 DMError DisplayManagerAdapter::RemoveSurfaceNodeFromDisplay(DisplayId displayId,
519     std::shared_ptr<class RSSurfaceNode>& surfaceNode)
520 {
521     if (displayId == DISPLAY_ID_INVALID) {
522         WLOGFE("screen id is invalid");
523         return DMError::DM_ERROR_INVALID_PARAM;
524     }
525     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
526     return displayManagerServiceProxy_->RemoveSurfaceNodeFromDisplay(displayId, surfaceNode);
527 }
528 
IsFoldable()529 bool DisplayManagerAdapter::IsFoldable()
530 {
531     INIT_PROXY_CHECK_RETURN(false);
532 
533     return displayManagerServiceProxy_->IsFoldable();
534 }
535 
GetFoldStatus()536 FoldStatus DisplayManagerAdapter::GetFoldStatus()
537 {
538     INIT_PROXY_CHECK_RETURN(FoldStatus::UNKNOWN);
539 
540     return displayManagerServiceProxy_->GetFoldStatus();
541 }
542 
GetFoldDisplayMode()543 FoldDisplayMode DisplayManagerAdapter::GetFoldDisplayMode()
544 {
545     INIT_PROXY_CHECK_RETURN(FoldDisplayMode::UNKNOWN);
546 
547     return displayManagerServiceProxy_->GetFoldDisplayMode();
548 }
549 
SetFoldDisplayMode(const FoldDisplayMode mode)550 void DisplayManagerAdapter::SetFoldDisplayMode(const FoldDisplayMode mode)
551 {
552     INIT_PROXY_CHECK_RETURN();
553 
554     return displayManagerServiceProxy_->SetFoldDisplayMode(mode);
555 }
556 
SetFoldStatusLocked(bool locked)557 void DisplayManagerAdapter::SetFoldStatusLocked(bool locked)
558 {
559     INIT_PROXY_CHECK_RETURN();
560 
561     return displayManagerServiceProxy_->SetFoldStatusLocked(locked);
562 }
563 
GetCurrentFoldCreaseRegion()564 sptr<FoldCreaseRegion> DisplayManagerAdapter::GetCurrentFoldCreaseRegion()
565 {
566     INIT_PROXY_CHECK_RETURN(nullptr);
567 
568     return displayManagerServiceProxy_->GetCurrentFoldCreaseRegion();
569 }
570 
GetScreenGroupInfoById(ScreenId screenId)571 sptr<ScreenGroupInfo> ScreenManagerAdapter::GetScreenGroupInfoById(ScreenId screenId)
572 {
573     if (screenId == SCREEN_ID_INVALID) {
574         WLOGFE("screenGroup id is invalid");
575         return nullptr;
576     }
577     INIT_PROXY_CHECK_RETURN(nullptr);
578 
579     return displayManagerServiceProxy_->GetScreenGroupInfoById(screenId);
580 }
581 
GetAllScreenInfos(std::vector<sptr<ScreenInfo>> & screenInfos)582 DMError ScreenManagerAdapter::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
583 {
584     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
585 
586     return displayManagerServiceProxy_->GetAllScreenInfos(screenInfos);
587 }
588 
MakeExpand(std::vector<ScreenId> screenId,std::vector<Point> startPoint,ScreenId & screenGroupId)589 DMError ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
590                                          ScreenId& screenGroupId)
591 {
592     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
593 
594     return displayManagerServiceProxy_->MakeExpand(screenId, startPoint, screenGroupId);
595 }
596 
StopExpand(const std::vector<ScreenId> & expandScreenIds)597 DMError ScreenManagerAdapter::StopExpand(const std::vector<ScreenId>& expandScreenIds)
598 {
599     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
600 
601     return displayManagerServiceProxy_->StopExpand(expandScreenIds);
602 }
603 
604 
RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)605 void ScreenManagerAdapter::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
606 {
607     INIT_PROXY_CHECK_RETURN();
608 
609     displayManagerServiceProxy_->RemoveVirtualScreenFromGroup(screens);
610 }
611 
SetScreenActiveMode(ScreenId screenId,uint32_t modeId)612 DMError ScreenManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
613 {
614     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
615 
616     return displayManagerServiceProxy_->SetScreenActiveMode(screenId, modeId);
617 }
618 
SetVirtualPixelRatio(ScreenId screenId,float virtualPixelRatio)619 DMError ScreenManagerAdapter::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
620 {
621     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
622 
623     return displayManagerServiceProxy_->SetVirtualPixelRatio(screenId, virtualPixelRatio);
624 }
625 
SetResolution(ScreenId screenId,uint32_t width,uint32_t height,float virtualPixelRatio)626 DMError ScreenManagerAdapter::SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio)
627 {
628     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
629 
630     return displayManagerServiceProxy_->SetResolution(screenId, width, height, virtualPixelRatio);
631 }
632 
GetDensityInCurResolution(ScreenId screenId,float & virtualPixelRatio)633 DMError ScreenManagerAdapter::GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio)
634 {
635     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
636 
637     return displayManagerServiceProxy_->GetDensityInCurResolution(screenId, virtualPixelRatio);
638 }
639 
ResizeVirtualScreen(ScreenId screenId,uint32_t width,uint32_t height)640 DMError ScreenManagerAdapter::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)
641 {
642     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
643 
644     return displayManagerServiceProxy_->ResizeVirtualScreen(screenId, width, height);
645 }
646 
MakeUniqueScreen(const std::vector<ScreenId> & screenIds)647 DMError ScreenManagerAdapter::MakeUniqueScreen(const std::vector<ScreenId>& screenIds)
648 {
649     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
650 
651     return displayManagerServiceProxy_->MakeUniqueScreen(screenIds);
652 }
653 
GetAvailableArea(DisplayId displayId,DMRect & area)654 DMError DisplayManagerAdapter::GetAvailableArea(DisplayId displayId, DMRect& area)
655 {
656     if (displayId == DISPLAY_ID_INVALID) {
657         WLOGFE("displayId id is invalid");
658         return DMError::DM_ERROR_INVALID_PARAM;
659     }
660     INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
661 
662     return displayManagerServiceProxy_->GetAvailableArea(displayId, area);
663 }
664 } // namespace OHOS::Rosen