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,bool isUseDma)58 std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetDisplaySnapshot(DisplayId displayId,
59 DmErrorCode* errorCode, bool isUseDma)
60 {
61 INIT_PROXY_CHECK_RETURN(nullptr);
62
63 return displayManagerServiceProxy_->GetDisplaySnapshot(displayId, errorCode, isUseDma);
64 }
65
GetSnapshotByPicker(Media::Rect & rect,DmErrorCode * errorCode)66 std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode)
67 {
68 INIT_PROXY_CHECK_RETURN(nullptr);
69
70 return displayManagerServiceProxy_->GetSnapshotByPicker(rect, errorCode);
71 }
72
GetScreenSupportedColorGamuts(ScreenId screenId,std::vector<ScreenColorGamut> & colorGamuts)73 DMError ScreenManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId,
74 std::vector<ScreenColorGamut>& colorGamuts)
75 {
76 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
77
78 return displayManagerServiceProxy_->GetScreenSupportedColorGamuts(screenId, colorGamuts);
79 }
80
GetScreenColorGamut(ScreenId screenId,ScreenColorGamut & colorGamut)81 DMError ScreenManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut)
82 {
83 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
84
85 return displayManagerServiceProxy_->GetScreenColorGamut(screenId, colorGamut);
86 }
87
SetScreenColorGamut(ScreenId screenId,int32_t colorGamutIdx)88 DMError ScreenManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx)
89 {
90 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
91
92 return displayManagerServiceProxy_->SetScreenColorGamut(screenId, colorGamutIdx);
93 }
94
GetScreenGamutMap(ScreenId screenId,ScreenGamutMap & gamutMap)95 DMError ScreenManagerAdapter::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap)
96 {
97 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
98
99 return displayManagerServiceProxy_->GetScreenGamutMap(screenId, gamutMap);
100 }
101
SetScreenGamutMap(ScreenId screenId,ScreenGamutMap gamutMap)102 DMError ScreenManagerAdapter::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap)
103 {
104 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
105
106 return displayManagerServiceProxy_->SetScreenGamutMap(screenId, gamutMap);
107 }
108
SetScreenColorTransform(ScreenId screenId)109 DMError ScreenManagerAdapter::SetScreenColorTransform(ScreenId screenId)
110 {
111 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
112
113 return displayManagerServiceProxy_->SetScreenColorTransform(screenId);
114 }
115
GetPixelFormat(ScreenId screenId,GraphicPixelFormat & pixelFormat)116 DMError ScreenManagerAdapter::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat)
117 {
118 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
119
120 WLOGFI("ScreenManagerAdapter::GetPixelFormat");
121 return displayManagerServiceProxy_->GetPixelFormat(screenId, pixelFormat);
122 }
123
SetPixelFormat(ScreenId screenId,GraphicPixelFormat pixelFormat)124 DMError ScreenManagerAdapter::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat)
125 {
126 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
127
128 WLOGFI("ScreenManagerAdapter::SetPixelFormat");
129 return displayManagerServiceProxy_->SetPixelFormat(screenId, pixelFormat);
130 }
131
GetSupportedHDRFormats(ScreenId screenId,std::vector<ScreenHDRFormat> & hdrFormats)132 DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId,
133 std::vector<ScreenHDRFormat>& hdrFormats)
134 {
135 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
136
137 WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats");
138 return displayManagerServiceProxy_->GetSupportedHDRFormats(screenId, hdrFormats);
139 }
140
GetScreenHDRFormat(ScreenId screenId,ScreenHDRFormat & hdrFormat)141 DMError ScreenManagerAdapter::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat)
142 {
143 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
144
145 WLOGFI("ScreenManagerAdapter::GetScreenHDRFormat");
146 return displayManagerServiceProxy_->GetScreenHDRFormat(screenId, hdrFormat);
147 }
148
SetScreenHDRFormat(ScreenId screenId,int32_t modeIdx)149 DMError ScreenManagerAdapter::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx)
150 {
151 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
152
153 WLOGFI("ScreenManagerAdapter::SetScreenHDRFormat");
154 return displayManagerServiceProxy_->SetScreenHDRFormat(screenId, modeIdx);
155 }
156
GetSupportedColorSpaces(ScreenId screenId,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)157 DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId,
158 std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
159 {
160 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
161
162 WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces");
163 return displayManagerServiceProxy_->GetSupportedColorSpaces(screenId, colorSpaces);
164 }
165
GetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType & colorSpace)166 DMError ScreenManagerAdapter::GetScreenColorSpace(ScreenId screenId,
167 GraphicCM_ColorSpaceType& colorSpace)
168 {
169 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
170
171 WLOGFI("ScreenManagerAdapter::GetScreenColorSpace");
172 return displayManagerServiceProxy_->GetScreenColorSpace(screenId, colorSpace);
173 }
174
SetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType colorSpace)175 DMError ScreenManagerAdapter::SetScreenColorSpace(ScreenId screenId,
176 GraphicCM_ColorSpaceType colorSpace)
177 {
178 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
179
180 WLOGFI("ScreenManagerAdapter::SetScreenColorSpace");
181 return displayManagerServiceProxy_->SetScreenColorSpace(screenId, colorSpace);
182 }
183
GetSupportedHDRFormats(ScreenId screenId,std::vector<uint32_t> & hdrFormats)184 DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vector<uint32_t>& hdrFormats)
185 {
186 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
187
188 std::vector<ScreenHDRFormat> hdrFormatsVec;
189 DMError ret = GetSupportedHDRFormats(screenId, hdrFormatsVec);
190 for (auto value : hdrFormatsVec) {
191 hdrFormats.push_back(static_cast<uint32_t>(value));
192 }
193 WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats ret %{public}d", static_cast<int32_t>(ret));
194 return ret;
195 }
196
GetSupportedColorSpaces(ScreenId screenId,std::vector<uint32_t> & colorSpaces)197 DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, std::vector<uint32_t>& colorSpaces)
198 {
199 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
200
201 std::vector<GraphicCM_ColorSpaceType> colorSpacesVec;
202 DMError ret = GetSupportedColorSpaces(screenId, colorSpacesVec);
203 for (auto value : colorSpacesVec) {
204 colorSpaces.push_back(static_cast<uint32_t>(value));
205 }
206 WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces ret %{public}d", static_cast<int32_t>(ret));
207 return ret;
208 }
209
CreateVirtualScreen(VirtualScreenOption option,const sptr<IDisplayManagerAgent> & displayManagerAgent)210 ScreenId ScreenManagerAdapter::CreateVirtualScreen(VirtualScreenOption option,
211 const sptr<IDisplayManagerAgent>& displayManagerAgent)
212 {
213 INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID);
214
215 WLOGFI("DisplayManagerAdapter::CreateVirtualScreen");
216 return displayManagerServiceProxy_->CreateVirtualScreen(option, displayManagerAgent->AsObject());
217 }
218
DestroyVirtualScreen(ScreenId screenId)219 DMError ScreenManagerAdapter::DestroyVirtualScreen(ScreenId screenId)
220 {
221 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
222
223 WLOGFI("DisplayManagerAdapter::DestroyVirtualScreen");
224 return displayManagerServiceProxy_->DestroyVirtualScreen(screenId);
225 }
226
SetVirtualScreenSurface(ScreenId screenId,sptr<Surface> surface)227 DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
228 {
229 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
230
231 if (surface == nullptr) {
232 WLOGFE("Surface is nullptr");
233 return DMError::DM_ERROR_NULLPTR;
234 }
235 WLOGFI("DisplayManagerAdapter::SetVirtualScreenSurface");
236 return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface->GetProducer());
237 }
238
AddVirtualScreenBlockList(const std::vector<int32_t> & persistentIds)239 DMError ScreenManagerAdapter::AddVirtualScreenBlockList(const std::vector<int32_t>& persistentIds)
240 {
241 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
242 return displayManagerServiceProxy_->AddVirtualScreenBlockList(persistentIds);
243 }
244
RemoveVirtualScreenBlockList(const std::vector<int32_t> & persistentIds)245 DMError ScreenManagerAdapter::RemoveVirtualScreenBlockList(const std::vector<int32_t>& persistentIds)
246 {
247 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
248 return displayManagerServiceProxy_->RemoveVirtualScreenBlockList(persistentIds);
249 }
250
SetScreenPrivacyMaskImage(ScreenId screenId,const std::shared_ptr<Media::PixelMap> & privacyMaskImg)251 DMError ScreenManagerAdapter::SetScreenPrivacyMaskImage(ScreenId screenId,
252 const std::shared_ptr<Media::PixelMap>& privacyMaskImg)
253 {
254 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
255 WLOGFI("DisplayManagerAdapter::SetScreenPrivacyMaskImage");
256 return displayManagerServiceProxy_->SetScreenPrivacyMaskImage(screenId, privacyMaskImg);
257 }
258
SetVirtualMirrorScreenCanvasRotation(ScreenId screenId,bool canvasRotation)259 DMError ScreenManagerAdapter::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation)
260 {
261 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
262 WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenCanvasRotation");
263 return displayManagerServiceProxy_->SetVirtualMirrorScreenCanvasRotation(screenId, canvasRotation);
264 }
265
SetVirtualMirrorScreenScaleMode(ScreenId screenId,ScreenScaleMode scaleMode)266 DMError ScreenManagerAdapter::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
267 {
268 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
269 WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenScaleMode");
270 return displayManagerServiceProxy_->SetVirtualMirrorScreenScaleMode(screenId, scaleMode);
271 }
272
SetScreenRotationLocked(bool isLocked)273 DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked)
274 {
275 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
276 WLOGFI("DisplayManagerAdapter::SetScreenRotationLocked");
277 return displayManagerServiceProxy_->SetScreenRotationLocked(isLocked);
278 }
279
SetScreenRotationLockedFromJs(bool isLocked)280 DMError ScreenManagerAdapter::SetScreenRotationLockedFromJs(bool isLocked)
281 {
282 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
283 WLOGFI("DisplayManagerAdapter::SetScreenRotationLockedFromJs");
284 return displayManagerServiceProxy_->SetScreenRotationLockedFromJs(isLocked);
285 }
286
IsScreenRotationLocked(bool & isLocked)287 DMError ScreenManagerAdapter::IsScreenRotationLocked(bool& isLocked)
288 {
289 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
290 WLOGFI("DisplayManagerAdapter::IsScreenRotationLocked");
291 return displayManagerServiceProxy_->IsScreenRotationLocked(isLocked);
292 }
293
SetSpecifiedScreenPower(ScreenId screenId,ScreenPowerState state,PowerStateChangeReason reason)294 bool ScreenManagerAdapter::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
295 {
296 INIT_PROXY_CHECK_RETURN(false);
297 return displayManagerServiceProxy_->SetSpecifiedScreenPower(screenId, state, reason);
298 }
299
SetScreenPowerForAll(ScreenPowerState state,PowerStateChangeReason reason)300 bool ScreenManagerAdapter::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
301 {
302 INIT_PROXY_CHECK_RETURN(false);
303 return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason);
304 }
305
GetScreenPower(ScreenId dmsScreenId)306 ScreenPowerState ScreenManagerAdapter::GetScreenPower(ScreenId dmsScreenId)
307 {
308 INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE);
309 return displayManagerServiceProxy_->GetScreenPower(dmsScreenId);
310 }
311
GetScreenPower()312 ScreenPowerState ScreenManagerAdapter::GetScreenPower()
313 {
314 INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE);
315 return displayManagerServiceProxy_->GetScreenPower();
316 }
317
SetOrientation(ScreenId screenId,Orientation orientation)318 DMError ScreenManagerAdapter::SetOrientation(ScreenId screenId, Orientation orientation)
319 {
320 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
321
322 return displayManagerServiceProxy_->SetOrientation(screenId, orientation);
323 }
324
RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)325 DMError BaseAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
326 DisplayManagerAgentType type)
327 {
328 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
329
330 return displayManagerServiceProxy_->RegisterDisplayManagerAgent(displayManagerAgent, type);
331 }
332
UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)333 DMError BaseAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
334 DisplayManagerAgentType type)
335 {
336 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
337
338 return displayManagerServiceProxy_->UnregisterDisplayManagerAgent(displayManagerAgent, type);
339 }
340
WakeUpBegin(PowerStateChangeReason reason)341 bool DisplayManagerAdapter::WakeUpBegin(PowerStateChangeReason reason)
342 {
343 INIT_PROXY_CHECK_RETURN(false);
344
345 return displayManagerServiceProxy_->WakeUpBegin(reason);
346 }
347
WakeUpEnd()348 bool DisplayManagerAdapter::WakeUpEnd()
349 {
350 INIT_PROXY_CHECK_RETURN(false);
351
352 return displayManagerServiceProxy_->WakeUpEnd();
353 }
354
SuspendBegin(PowerStateChangeReason reason)355 bool DisplayManagerAdapter::SuspendBegin(PowerStateChangeReason reason)
356 {
357 INIT_PROXY_CHECK_RETURN(false);
358
359 return displayManagerServiceProxy_->SuspendBegin(reason);
360 }
361
SuspendEnd()362 bool DisplayManagerAdapter::SuspendEnd()
363 {
364 INIT_PROXY_CHECK_RETURN(false);
365
366 return displayManagerServiceProxy_->SuspendEnd();
367 }
368
GetInternalScreenId()369 ScreenId DisplayManagerAdapter::GetInternalScreenId()
370 {
371 INIT_PROXY_CHECK_RETURN(false);
372
373 return displayManagerServiceProxy_->GetInternalScreenId();
374 }
375
SetScreenPowerById(ScreenId screenId,ScreenPowerState state,PowerStateChangeReason reason)376 bool DisplayManagerAdapter::SetScreenPowerById(ScreenId screenId, ScreenPowerState state,
377 PowerStateChangeReason reason)
378 {
379 INIT_PROXY_CHECK_RETURN(false);
380
381 return displayManagerServiceProxy_->SetScreenPowerById(screenId, state, reason);
382 }
383
SetDisplayState(DisplayState state)384 bool DisplayManagerAdapter::SetDisplayState(DisplayState state)
385 {
386 INIT_PROXY_CHECK_RETURN(false);
387
388 return displayManagerServiceProxy_->SetDisplayState(state);
389 }
390
GetDisplayState(DisplayId displayId)391 DisplayState DisplayManagerAdapter::GetDisplayState(DisplayId displayId)
392 {
393 INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN);
394
395 return displayManagerServiceProxy_->GetDisplayState(displayId);
396 }
397
TryToCancelScreenOff()398 bool DisplayManagerAdapter::TryToCancelScreenOff()
399 {
400 INIT_PROXY_CHECK_RETURN(false);
401
402 return displayManagerServiceProxy_->TryToCancelScreenOff();
403 }
404
NotifyDisplayEvent(DisplayEvent event)405 void DisplayManagerAdapter::NotifyDisplayEvent(DisplayEvent event)
406 {
407 INIT_PROXY_CHECK_RETURN();
408
409 displayManagerServiceProxy_->NotifyDisplayEvent(event);
410 }
411
SetFreeze(std::vector<DisplayId> displayIds,bool isFreeze)412 bool DisplayManagerAdapter::SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze)
413 {
414 INIT_PROXY_CHECK_RETURN(false);
415
416 return displayManagerServiceProxy_->SetFreeze(displayIds, isFreeze);
417 }
418
InitDMSProxy()419 bool BaseAdapter::InitDMSProxy()
420 {
421 std::lock_guard<std::recursive_mutex> lock(mutex_);
422 if (!isProxyValid_) {
423 sptr<ISystemAbilityManager> systemAbilityManager =
424 SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
425 if (!systemAbilityManager) {
426 WLOGFE("Failed to get system ability mgr.");
427 return false;
428 }
429
430 sptr<IRemoteObject> remoteObject
431 = systemAbilityManager->GetSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID);
432 if (!remoteObject) {
433 WLOGFE("Failed to get display manager service.");
434 return false;
435 }
436
437 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
438 displayManagerServiceProxy_ = iface_cast<IScreenSessionManager>(remoteObject);
439 } else {
440 displayManagerServiceProxy_ = iface_cast<IDisplayManager>(remoteObject);
441 }
442 if ((!displayManagerServiceProxy_) || (!displayManagerServiceProxy_->AsObject())) {
443 WLOGFW("Failed to get system display manager services");
444 return false;
445 }
446
447 dmsDeath_ = new(std::nothrow) DMSDeathRecipient(*this);
448 if (dmsDeath_ == nullptr) {
449 WLOGFE("Failed to create death Recipient ptr DMSDeathRecipient");
450 return false;
451 }
452 if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(dmsDeath_)) {
453 WLOGFE("Failed to add death recipient");
454 return false;
455 }
456 isProxyValid_ = true;
457 }
458 return true;
459 }
460
DMSDeathRecipient(BaseAdapter & adapter)461 DMSDeathRecipient::DMSDeathRecipient(BaseAdapter& adapter) : adapter_(adapter)
462 {
463 }
464
OnRemoteDied(const wptr<IRemoteObject> & wptrDeath)465 void DMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
466 {
467 if (wptrDeath == nullptr) {
468 WLOGFE("wptrDeath is null");
469 return;
470 }
471
472 sptr<IRemoteObject> object = wptrDeath.promote();
473 if (!object) {
474 WLOGFE("object is null");
475 return;
476 }
477 WLOGFI("dms OnRemoteDied");
478 adapter_.Clear();
479 if (SingletonContainer::IsDestroyed()) {
480 WLOGFE("SingletonContainer is destroyed");
481 return;
482 }
483 SingletonContainer::Get<DisplayManager>().OnRemoteDied();
484 SingletonContainer::Get<ScreenManager>().OnRemoteDied();
485 return;
486 }
487
488
~BaseAdapter()489 BaseAdapter::~BaseAdapter()
490 {
491 WLOGFI("destory!");
492 std::lock_guard<std::recursive_mutex> lock(mutex_);
493 Clear();
494 displayManagerServiceProxy_ = nullptr;
495 }
496
Clear()497 void BaseAdapter::Clear()
498 {
499 WLOGFD("Clear!");
500 std::lock_guard<std::recursive_mutex> lock(mutex_);
501 if ((displayManagerServiceProxy_ != nullptr) && (displayManagerServiceProxy_->AsObject() != nullptr)) {
502 displayManagerServiceProxy_->AsObject()->RemoveDeathRecipient(dmsDeath_);
503 }
504 isProxyValid_ = false;
505 }
506
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenId,ScreenId & screenGroupId)507 DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
508 ScreenId& screenGroupId)
509 {
510 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
511
512 return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, screenGroupId);
513 }
514
MakeMirrorForRecord(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenId,ScreenId & screenGroupId)515 DMError ScreenManagerAdapter::MakeMirrorForRecord(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
516 ScreenId& screenGroupId)
517 {
518 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
519
520 return displayManagerServiceProxy_->MakeMirrorForRecord(mainScreenId, mirrorScreenId, screenGroupId);
521 }
522
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenId,DMRect mainScreenRegion,ScreenId & screenGroupId)523 DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
524 DMRect mainScreenRegion, ScreenId& screenGroupId)
525 {
526 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
527
528 return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, mainScreenRegion, screenGroupId);
529 }
530
SetMultiScreenMode(ScreenId mainScreenId,ScreenId secondaryScreenId,MultiScreenMode screenMode)531 DMError ScreenManagerAdapter::SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId,
532 MultiScreenMode screenMode)
533 {
534 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
535
536 return displayManagerServiceProxy_->SetMultiScreenMode(mainScreenId, secondaryScreenId, screenMode);
537 }
538
SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions,MultiScreenPositionOptions secondScreenOption)539 DMError ScreenManagerAdapter::SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions,
540 MultiScreenPositionOptions secondScreenOption)
541 {
542 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
543
544 return displayManagerServiceProxy_->SetMultiScreenRelativePosition(mainScreenOptions, secondScreenOption);
545 }
546
StopMirror(const std::vector<ScreenId> & mirrorScreenIds)547 DMError ScreenManagerAdapter::StopMirror(const std::vector<ScreenId>& mirrorScreenIds)
548 {
549 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
550
551 return displayManagerServiceProxy_->StopMirror(mirrorScreenIds);
552 }
553
DisableMirror(bool disableOrNot)554 DMError ScreenManagerAdapter::DisableMirror(bool disableOrNot)
555 {
556 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
557
558 return displayManagerServiceProxy_->DisableMirror(disableOrNot);
559 }
560
GetScreenInfo(ScreenId screenId)561 sptr<ScreenInfo> ScreenManagerAdapter::GetScreenInfo(ScreenId screenId)
562 {
563 if (screenId == SCREEN_ID_INVALID) {
564 WLOGFE("screen id is invalid");
565 return nullptr;
566 }
567 INIT_PROXY_CHECK_RETURN(nullptr);
568
569 sptr<ScreenInfo> screenInfo = displayManagerServiceProxy_->GetScreenInfoById(screenId);
570 return screenInfo;
571 }
572
GetAllDisplayIds()573 std::vector<DisplayId> DisplayManagerAdapter::GetAllDisplayIds()
574 {
575 WLOGFD("DisplayManagerAdapter::GetAllDisplayIds enter");
576 INIT_PROXY_CHECK_RETURN(std::vector<DisplayId>());
577
578 return displayManagerServiceProxy_->GetAllDisplayIds();
579 }
580
HasPrivateWindow(DisplayId displayId,bool & hasPrivateWindow)581 DMError DisplayManagerAdapter::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow)
582 {
583 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
584
585 return displayManagerServiceProxy_->HasPrivateWindow(displayId, hasPrivateWindow);
586 }
587
ConvertScreenIdToRsScreenId(ScreenId screenId,ScreenId & rsScreenId)588 bool DisplayManagerAdapter::ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId)
589 {
590 INIT_PROXY_CHECK_RETURN(false);
591
592 return displayManagerServiceProxy_->ConvertScreenIdToRsScreenId(screenId, rsScreenId);
593 }
594
HasImmersiveWindow(ScreenId screenId,bool & immersive)595 DMError DisplayManagerAdapter::HasImmersiveWindow(ScreenId screenId, bool& immersive)
596 {
597 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
598
599 return displayManagerServiceProxy_->HasImmersiveWindow(screenId, immersive);
600 }
601
GetDisplayInfo(DisplayId displayId)602 sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId)
603 {
604 WLOGFD("DisplayManagerAdapter::GetDisplayInfo enter, displayId: %{public}" PRIu64" ", displayId);
605 if (displayId == DISPLAY_ID_INVALID) {
606 WLOGFE("screen id is invalid");
607 return nullptr;
608 }
609 INIT_PROXY_CHECK_RETURN(nullptr);
610
611 return displayManagerServiceProxy_->GetDisplayInfoById(displayId);
612 }
613
GetVisibleAreaDisplayInfoById(DisplayId displayId)614 sptr<DisplayInfo> DisplayManagerAdapter::GetVisibleAreaDisplayInfoById(DisplayId displayId)
615 {
616 WLOGFD("enter, displayId: %{public}" PRIu64" ", displayId);
617 if (displayId == DISPLAY_ID_INVALID) {
618 WLOGFE("display id is invalid");
619 return nullptr;
620 }
621 INIT_PROXY_CHECK_RETURN(nullptr);
622
623 return displayManagerServiceProxy_->GetVisibleAreaDisplayInfoById(displayId);
624 }
625
GetCutoutInfo(DisplayId displayId)626 sptr<CutoutInfo> DisplayManagerAdapter::GetCutoutInfo(DisplayId displayId)
627 {
628 WLOGFD("DisplayManagerAdapter::GetCutoutInfo");
629 if (displayId == DISPLAY_ID_INVALID) {
630 WLOGFE("screen id is invalid");
631 return nullptr;
632 }
633 INIT_PROXY_CHECK_RETURN(nullptr);
634 return displayManagerServiceProxy_->GetCutoutInfo(displayId);
635 }
636
AddSurfaceNodeToDisplay(DisplayId displayId,std::shared_ptr<class RSSurfaceNode> & surfaceNode)637 DMError DisplayManagerAdapter::AddSurfaceNodeToDisplay(DisplayId displayId,
638 std::shared_ptr<class RSSurfaceNode>& surfaceNode)
639 {
640 if (displayId == DISPLAY_ID_INVALID) {
641 WLOGFE("screen id is invalid");
642 return DMError::DM_ERROR_INVALID_PARAM;
643 }
644 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
645 return displayManagerServiceProxy_->AddSurfaceNodeToDisplay(displayId, surfaceNode);
646 }
647
RemoveSurfaceNodeFromDisplay(DisplayId displayId,std::shared_ptr<class RSSurfaceNode> & surfaceNode)648 DMError DisplayManagerAdapter::RemoveSurfaceNodeFromDisplay(DisplayId displayId,
649 std::shared_ptr<class RSSurfaceNode>& surfaceNode)
650 {
651 if (displayId == DISPLAY_ID_INVALID) {
652 WLOGFE("screen id is invalid");
653 return DMError::DM_ERROR_INVALID_PARAM;
654 }
655 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
656 return displayManagerServiceProxy_->RemoveSurfaceNodeFromDisplay(displayId, surfaceNode);
657 }
658
IsFoldable()659 bool DisplayManagerAdapter::IsFoldable()
660 {
661 INIT_PROXY_CHECK_RETURN(false);
662
663 return displayManagerServiceProxy_->IsFoldable();
664 }
665
IsCaptured()666 bool DisplayManagerAdapter::IsCaptured()
667 {
668 INIT_PROXY_CHECK_RETURN(false);
669
670 return displayManagerServiceProxy_->IsCaptured();
671 }
672
GetFoldStatus()673 FoldStatus DisplayManagerAdapter::GetFoldStatus()
674 {
675 INIT_PROXY_CHECK_RETURN(FoldStatus::UNKNOWN);
676
677 return displayManagerServiceProxy_->GetFoldStatus();
678 }
679
GetFoldDisplayMode()680 FoldDisplayMode DisplayManagerAdapter::GetFoldDisplayMode()
681 {
682 INIT_PROXY_CHECK_RETURN(FoldDisplayMode::UNKNOWN);
683
684 return displayManagerServiceProxy_->GetFoldDisplayMode();
685 }
686
SetFoldDisplayMode(const FoldDisplayMode mode)687 void DisplayManagerAdapter::SetFoldDisplayMode(const FoldDisplayMode mode)
688 {
689 INIT_PROXY_CHECK_RETURN();
690
691 return displayManagerServiceProxy_->SetFoldDisplayMode(mode);
692 }
693
SetFoldDisplayModeFromJs(const FoldDisplayMode mode,std::string reason)694 DMError DisplayManagerAdapter::SetFoldDisplayModeFromJs(const FoldDisplayMode mode, std::string reason)
695 {
696 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
697
698 return displayManagerServiceProxy_->SetFoldDisplayModeFromJs(mode, reason);
699 }
700
SetDisplayScale(ScreenId screenId,float scaleX,float scaleY,float pivotX,float pivotY)701 void DisplayManagerAdapter::SetDisplayScale(ScreenId screenId,
702 float scaleX, float scaleY, float pivotX, float pivotY)
703 {
704 INIT_PROXY_CHECK_RETURN();
705
706 return displayManagerServiceProxy_->SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY);
707 }
708
SetFoldStatusLocked(bool locked)709 void DisplayManagerAdapter::SetFoldStatusLocked(bool locked)
710 {
711 INIT_PROXY_CHECK_RETURN();
712
713 return displayManagerServiceProxy_->SetFoldStatusLocked(locked);
714 }
715
SetFoldStatusLockedFromJs(bool locked)716 DMError DisplayManagerAdapter::SetFoldStatusLockedFromJs(bool locked)
717 {
718 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
719
720 return displayManagerServiceProxy_->SetFoldStatusLockedFromJs(locked);
721 }
722
GetCurrentFoldCreaseRegion()723 sptr<FoldCreaseRegion> DisplayManagerAdapter::GetCurrentFoldCreaseRegion()
724 {
725 INIT_PROXY_CHECK_RETURN(nullptr);
726
727 return displayManagerServiceProxy_->GetCurrentFoldCreaseRegion();
728 }
729
GetScreenGroupInfoById(ScreenId screenId)730 sptr<ScreenGroupInfo> ScreenManagerAdapter::GetScreenGroupInfoById(ScreenId screenId)
731 {
732 if (screenId == SCREEN_ID_INVALID) {
733 WLOGFE("screenGroup id is invalid");
734 return nullptr;
735 }
736 INIT_PROXY_CHECK_RETURN(nullptr);
737
738 return displayManagerServiceProxy_->GetScreenGroupInfoById(screenId);
739 }
740
GetAllScreenInfos(std::vector<sptr<ScreenInfo>> & screenInfos)741 DMError ScreenManagerAdapter::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
742 {
743 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
744
745 return displayManagerServiceProxy_->GetAllScreenInfos(screenInfos);
746 }
747
MakeExpand(std::vector<ScreenId> screenId,std::vector<Point> startPoint,ScreenId & screenGroupId)748 DMError ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
749 ScreenId& screenGroupId)
750 {
751 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
752
753 return displayManagerServiceProxy_->MakeExpand(screenId, startPoint, screenGroupId);
754 }
755
StopExpand(const std::vector<ScreenId> & expandScreenIds)756 DMError ScreenManagerAdapter::StopExpand(const std::vector<ScreenId>& expandScreenIds)
757 {
758 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
759
760 return displayManagerServiceProxy_->StopExpand(expandScreenIds);
761 }
762
763
RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)764 void ScreenManagerAdapter::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
765 {
766 INIT_PROXY_CHECK_RETURN();
767
768 displayManagerServiceProxy_->RemoveVirtualScreenFromGroup(screens);
769 }
770
SetScreenActiveMode(ScreenId screenId,uint32_t modeId)771 DMError ScreenManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
772 {
773 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
774
775 return displayManagerServiceProxy_->SetScreenActiveMode(screenId, modeId);
776 }
777
SetVirtualPixelRatio(ScreenId screenId,float virtualPixelRatio)778 DMError ScreenManagerAdapter::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
779 {
780 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
781
782 return displayManagerServiceProxy_->SetVirtualPixelRatio(screenId, virtualPixelRatio);
783 }
784
SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)785 DMError ScreenManagerAdapter::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
786 {
787 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
788
789 return displayManagerServiceProxy_->SetVirtualPixelRatioSystem(screenId, virtualPixelRatio);
790 }
791
SetDefaultDensityDpi(ScreenId screenId,float virtualPixelRatio)792 DMError ScreenManagerAdapter::SetDefaultDensityDpi(ScreenId screenId, float virtualPixelRatio)
793 {
794 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
795
796 return displayManagerServiceProxy_->SetDefaultDensityDpi(screenId, virtualPixelRatio);
797 }
798
SetResolution(ScreenId screenId,uint32_t width,uint32_t height,float virtualPixelRatio)799 DMError ScreenManagerAdapter::SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio)
800 {
801 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
802
803 return displayManagerServiceProxy_->SetResolution(screenId, width, height, virtualPixelRatio);
804 }
805
GetDensityInCurResolution(ScreenId screenId,float & virtualPixelRatio)806 DMError ScreenManagerAdapter::GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio)
807 {
808 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
809
810 return displayManagerServiceProxy_->GetDensityInCurResolution(screenId, virtualPixelRatio);
811 }
812
ResizeVirtualScreen(ScreenId screenId,uint32_t width,uint32_t height)813 DMError ScreenManagerAdapter::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)
814 {
815 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
816
817 return displayManagerServiceProxy_->ResizeVirtualScreen(screenId, width, height);
818 }
819
MakeUniqueScreen(const std::vector<ScreenId> & screenIds,std::vector<DisplayId> & displayIds)820 DMError ScreenManagerAdapter::MakeUniqueScreen(const std::vector<ScreenId>& screenIds,
821 std::vector<DisplayId>& displayIds)
822 {
823 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
824
825 return displayManagerServiceProxy_->MakeUniqueScreen(screenIds, displayIds);
826 }
827
GetAvailableArea(DisplayId displayId,DMRect & area)828 DMError DisplayManagerAdapter::GetAvailableArea(DisplayId displayId, DMRect& area)
829 {
830 if (displayId == DISPLAY_ID_INVALID) {
831 WLOGFE("displayId id is invalid");
832 return DMError::DM_ERROR_INVALID_PARAM;
833 }
834 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
835
836 return displayManagerServiceProxy_->GetAvailableArea(displayId, area);
837 }
838
GetExpandAvailableArea(DisplayId displayId,DMRect & area)839 DMError DisplayManagerAdapter::GetExpandAvailableArea(DisplayId displayId, DMRect& area)
840 {
841 if (displayId == DISPLAY_ID_INVALID) {
842 WLOGFE("displayId id is invalid");
843 return DMError::DM_ERROR_INVALID_PARAM;
844 }
845 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
846
847 return displayManagerServiceProxy_->GetExpandAvailableArea(displayId, area);
848 }
849
GetVirtualScreenFlag(ScreenId screenId)850 VirtualScreenFlag ScreenManagerAdapter::GetVirtualScreenFlag(ScreenId screenId)
851 {
852 INIT_PROXY_CHECK_RETURN(VirtualScreenFlag::DEFAULT);
853 if (screenId == SCREEN_ID_INVALID) {
854 WLOGFE("screenId id is invalid");
855 return VirtualScreenFlag::DEFAULT;
856 }
857
858 return displayManagerServiceProxy_->GetVirtualScreenFlag(screenId);
859 }
860
SetVirtualScreenFlag(ScreenId screenId,VirtualScreenFlag screenFlag)861 DMError ScreenManagerAdapter::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
862 {
863 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
864 if (screenId == SCREEN_ID_INVALID) {
865 WLOGFE("displayId id is invalid");
866 return DMError::DM_ERROR_INVALID_PARAM;
867 }
868 if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) {
869 return DMError::DM_ERROR_INVALID_PARAM;
870 }
871 return displayManagerServiceProxy_->SetVirtualScreenFlag(screenId, screenFlag);
872 }
873
SetVirtualScreenRefreshRate(ScreenId screenId,uint32_t refreshInterval)874 DMError ScreenManagerAdapter::SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
875 {
876 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
877
878 return displayManagerServiceProxy_->SetVirtualScreenRefreshRate(screenId, refreshInterval);
879 }
880
SetVirtualScreenBlackList(ScreenId screenId,std::vector<uint64_t> & windowIdList,std::vector<uint64_t> surfaceIdList)881 void DisplayManagerAdapter::SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList,
882 std::vector<uint64_t> surfaceIdList)
883 {
884 INIT_PROXY_CHECK_RETURN();
885 displayManagerServiceProxy_->SetVirtualScreenBlackList(screenId, windowIdList, surfaceIdList);
886 }
887
SetVirtualDisplayMuteFlag(ScreenId screenId,bool muteFlag)888 void DisplayManagerAdapter::SetVirtualDisplayMuteFlag(ScreenId screenId, bool muteFlag)
889 {
890 INIT_PROXY_CHECK_RETURN();
891 displayManagerServiceProxy_->SetVirtualDisplayMuteFlag(screenId, muteFlag);
892 }
893
DisablePowerOffRenderControl(ScreenId screenId)894 void DisplayManagerAdapter::DisablePowerOffRenderControl(ScreenId screenId)
895 {
896 INIT_PROXY_CHECK_RETURN();
897 displayManagerServiceProxy_->DisablePowerOffRenderControl(screenId);
898 }
899
ProxyForFreeze(const std::set<int32_t> & pidList,bool isProxy)900 DMError DisplayManagerAdapter::ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy)
901 {
902 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
903 return displayManagerServiceProxy_->ProxyForFreeze(pidList, isProxy);
904 }
905
ResetAllFreezeStatus()906 DMError DisplayManagerAdapter::ResetAllFreezeStatus()
907 {
908 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
909 return displayManagerServiceProxy_->ResetAllFreezeStatus();
910 }
911
GetAllDisplayPhysicalResolution()912 std::vector<DisplayPhysicalResolution> DisplayManagerAdapter::GetAllDisplayPhysicalResolution()
913 {
914 INIT_PROXY_CHECK_RETURN(std::vector<DisplayPhysicalResolution>{});
915 return displayManagerServiceProxy_->GetAllDisplayPhysicalResolution();
916 }
917
GetDisplayCapability(std::string & capabilitInfo)918 DMError DisplayManagerAdapter::GetDisplayCapability(std::string& capabilitInfo)
919 {
920 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
921 return displayManagerServiceProxy_->GetDisplayCapability(capabilitInfo);
922 }
923
SetVirtualScreenSecurityExemption(ScreenId screenId,uint32_t pid,std::vector<uint64_t> & windowIdList)924 DMError DisplayManagerAdapter::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
925 std::vector<uint64_t>& windowIdList)
926 {
927 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
928 return displayManagerServiceProxy_->SetVirtualScreenSecurityExemption(screenId, pid, windowIdList);
929 }
930
SetVirtualScreenStatus(ScreenId screenId,VirtualScreenStatus screenStatus)931 bool ScreenManagerAdapter::SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus)
932 {
933 INIT_PROXY_CHECK_RETURN(false);
934 return displayManagerServiceProxy_->SetVirtualScreenStatus(screenId, screenStatus);
935 }
936
SetVirtualScreenMaxRefreshRate(ScreenId id,uint32_t refreshRate,uint32_t & actualRefreshRate)937 DMError ScreenManagerAdapter::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
938 uint32_t& actualRefreshRate)
939 {
940 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
941 return displayManagerServiceProxy_->SetVirtualScreenMaxRefreshRate(id, refreshRate, actualRefreshRate);
942 }
943
GetScreenCapture(const CaptureOption & captureOption,DmErrorCode * errorCode)944 std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetScreenCapture(const CaptureOption& captureOption,
945 DmErrorCode* errorCode)
946 {
947 INIT_PROXY_CHECK_RETURN(nullptr);
948 return displayManagerServiceProxy_->GetScreenCapture(captureOption, errorCode);
949 }
950
GetPrimaryDisplayInfo()951 sptr<DisplayInfo> DisplayManagerAdapter::GetPrimaryDisplayInfo()
952 {
953 INIT_PROXY_CHECK_RETURN(nullptr);
954 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
955 return displayManagerServiceProxy_->GetPrimaryDisplayInfo();
956 } else {
957 return displayManagerServiceProxy_->GetDefaultDisplayInfo();
958 }
959 }
960
GetDisplaySnapshotWithOption(const CaptureOption & captureOption,DmErrorCode * errorCode)961 std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetDisplaySnapshotWithOption(const CaptureOption& captureOption,
962 DmErrorCode* errorCode)
963 {
964 INIT_PROXY_CHECK_RETURN(nullptr);
965 return displayManagerServiceProxy_->GetDisplaySnapshotWithOption(captureOption, errorCode);
966 }
967
SetScreenSkipProtectedWindow(const std::vector<ScreenId> & screenIds,bool isEnable)968 DMError ScreenManagerAdapter::SetScreenSkipProtectedWindow(const std::vector<ScreenId>& screenIds, bool isEnable)
969 {
970 INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
971 return displayManagerServiceProxy_->SetScreenSkipProtectedWindow(screenIds, isEnable);
972 }
973 } // namespace OHOS::Rosen
974