1 /*
2 * Copyright (c) 2023 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 "zidl/screen_session_manager_proxy.h"
17 #include "marshalling_helper.h"
18
19 namespace OHOS::Rosen {
20 namespace {
21 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenSessionManagerProxy"};
22 }
23
GetDefaultDisplayInfo()24 sptr<DisplayInfo> OHOS::Rosen::ScreenSessionManagerProxy::GetDefaultDisplayInfo()
25 {
26 MessageParcel data;
27 MessageParcel reply;
28 MessageOption option;
29 if (!data.WriteInterfaceToken(GetDescriptor())) {
30 WLOGFE("WriteInterfaceToken failed");
31 return nullptr;
32 }
33 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO),
34 data, reply, option) != ERR_NONE) {
35 WLOGFE("SendRequest failed");
36 return nullptr;
37 }
38
39 sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
40 if (info == nullptr) {
41 WLOGFW("read display info failed, info is nullptr.");
42 }
43 return info;
44 }
45
SetScreenActiveMode(ScreenId screenId,uint32_t modeId)46 DMError ScreenSessionManagerProxy::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
47 {
48 MessageParcel data;
49 MessageParcel reply;
50 MessageOption option;
51 if (!data.WriteInterfaceToken(GetDescriptor())) {
52 WLOGFE("SetScreenActiveMode: WriteInterfaceToken failed");
53 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
54 }
55 if (!data.WriteUint64(screenId) || !data.WriteUint32(modeId)) {
56 WLOGFE("SetScreenActiveMode: write screenId/modeId failed");
57 return DMError::DM_ERROR_IPC_FAILED;
58 }
59 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE),
60 data, reply, option) != ERR_NONE) {
61 WLOGFE("SetScreenActiveMode: SendRequest failed");
62 return DMError::DM_ERROR_IPC_FAILED;
63 }
64 return static_cast<DMError>(reply.ReadInt32());
65 }
66
SetVirtualPixelRatio(ScreenId screenId,float virtualPixelRatio)67 DMError ScreenSessionManagerProxy::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
68 {
69 MessageParcel data;
70 MessageParcel reply;
71 MessageOption option;
72 if (!data.WriteInterfaceToken(GetDescriptor())) {
73 WLOGFE("WriteInterfaceToken failed");
74 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
75 }
76 if (!data.WriteUint64(screenId) || !data.WriteFloat(virtualPixelRatio)) {
77 WLOGFE("write screenId/modeId failed");
78 return DMError::DM_ERROR_IPC_FAILED;
79 }
80 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO),
81 data, reply, option) != ERR_NONE) {
82 WLOGFE("SendRequest failed");
83 return DMError::DM_ERROR_IPC_FAILED;
84 }
85 return static_cast<DMError>(reply.ReadInt32());
86 }
87
GetScreenColorGamut(ScreenId screenId,ScreenColorGamut & colorGamut)88 DMError ScreenSessionManagerProxy::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut)
89 {
90 sptr<IRemoteObject> remote = Remote();
91 if (remote == nullptr) {
92 WLOGFW("DisplayManagerProxy::GetScreenColorGamut: remote is nullptr");
93 return DMError::DM_ERROR_NULLPTR;
94 }
95
96 MessageParcel data;
97 MessageParcel reply;
98 MessageOption option;
99 if (!data.WriteInterfaceToken(GetDescriptor())) {
100 WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteInterfaceToken failed");
101 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
102 }
103 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
104 WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteUint64 uint64_t failed");
105 return DMError::DM_ERROR_IPC_FAILED;
106 }
107 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT),
108 data, reply, option) != ERR_NONE) {
109 WLOGFW("DisplayManagerProxy::GetScreenColorGamut: SendRequest failed");
110 return DMError::DM_ERROR_IPC_FAILED;
111 }
112 DMError ret = static_cast<DMError>(reply.ReadInt32());
113 if (ret != DMError::DM_OK) {
114 return ret;
115 }
116 colorGamut = static_cast<ScreenColorGamut>(reply.ReadUint32());
117 return ret;
118 }
119
SetScreenColorGamut(ScreenId screenId,int32_t colorGamutIdx)120 DMError ScreenSessionManagerProxy::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx)
121 {
122 sptr<IRemoteObject> remote = Remote();
123 if (remote == nullptr) {
124 WLOGFW("DisplayManagerProxy::SetScreenColorGamut: remote is nullptr");
125 return DMError::DM_ERROR_NULLPTR;
126 }
127
128 MessageParcel data;
129 MessageParcel reply;
130 MessageOption option;
131 if (!data.WriteInterfaceToken(GetDescriptor())) {
132 WLOGFW("DisplayManagerProxy::SetScreenColorGamut: WriteInterfaceToken failed");
133 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
134 }
135 if (!data.WriteUint64(static_cast<uint64_t>(screenId)) || !data.WriteInt32(colorGamutIdx)) {
136 WLOGFW("DisplayManagerProxy::SetScreenColorGamut: Write failed");
137 return DMError::DM_ERROR_IPC_FAILED;
138 }
139 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT),
140 data, reply, option) != ERR_NONE) {
141 WLOGFW("DisplayManagerProxy::SetScreenColorGamut: SendRequest failed");
142 return DMError::DM_ERROR_IPC_FAILED;
143 }
144 return static_cast<DMError>(reply.ReadInt32());
145 }
146
GetScreenGamutMap(ScreenId screenId,ScreenGamutMap & gamutMap)147 DMError ScreenSessionManagerProxy::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap)
148 {
149 sptr<IRemoteObject> remote = Remote();
150 if (remote == nullptr) {
151 WLOGFW("DisplayManagerProxy::GetScreenGamutMap: remote is nullptr");
152 return DMError::DM_ERROR_NULLPTR;
153 }
154
155 MessageParcel data;
156 MessageParcel reply;
157 MessageOption option;
158 if (!data.WriteInterfaceToken(GetDescriptor())) {
159 WLOGFW("DisplayManagerProxy::GetScreenGamutMap: WriteInterfaceToken failed");
160 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
161 }
162 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
163 WLOGFW("DisplayManagerProxy::GetScreenGamutMap: WriteUint64 screenId failed");
164 return DMError::DM_ERROR_IPC_FAILED;
165 }
166 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP),
167 data, reply, option) != ERR_NONE) {
168 WLOGFW("DisplayManagerProxy::GetScreenGamutMap: SendRequest failed");
169 return DMError::DM_ERROR_IPC_FAILED;
170 }
171 DMError ret = static_cast<DMError>(reply.ReadInt32());
172 if (ret != DMError::DM_OK) {
173 return ret;
174 }
175 gamutMap = static_cast<ScreenGamutMap>(reply.ReadUint32());
176 return ret;
177 }
178
SetScreenGamutMap(ScreenId screenId,ScreenGamutMap gamutMap)179 DMError ScreenSessionManagerProxy::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap)
180 {
181 sptr<IRemoteObject> remote = Remote();
182 if (remote == nullptr) {
183 WLOGFW("DisplayManagerProxy::SetScreenGamutMap: remote is nullptr");
184 return DMError::DM_ERROR_NULLPTR;
185 }
186
187 MessageParcel data;
188 MessageParcel reply;
189 MessageOption option;
190 if (!data.WriteInterfaceToken(GetDescriptor())) {
191 WLOGFW("DisplayManagerProxy::SetScreenGamutMap: WriteInterfaceToken failed");
192 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
193 }
194 if (!data.WriteUint64(static_cast<uint64_t>(screenId)) || !data.WriteUint32(static_cast<uint32_t>(gamutMap))) {
195 WLOGFW("DisplayManagerProxy::SetScreenGamutMap: Writ failed");
196 return DMError::DM_ERROR_IPC_FAILED;
197 }
198 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP),
199 data, reply, option) != ERR_NONE) {
200 WLOGFW("DisplayManagerProxy::SetScreenGamutMap: SendRequest failed");
201 return DMError::DM_ERROR_IPC_FAILED;
202 }
203 return static_cast<DMError>(reply.ReadInt32());
204 }
205
SetScreenColorTransform(ScreenId screenId)206 DMError ScreenSessionManagerProxy::SetScreenColorTransform(ScreenId screenId)
207 {
208 sptr<IRemoteObject> remote = Remote();
209 if (remote == nullptr) {
210 WLOGFW("DisplayManagerProxy::SetScreenColorTransform: remote is nullptr");
211 return DMError::DM_ERROR_NULLPTR;
212 }
213
214 MessageParcel data;
215 MessageParcel reply;
216 MessageOption option;
217 if (!data.WriteInterfaceToken(GetDescriptor())) {
218 WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteInterfaceToken failed");
219 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
220 }
221 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
222 WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteUint64 screenId failed");
223 return DMError::DM_ERROR_IPC_FAILED;
224 }
225 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM),
226 data, reply, option) != ERR_NONE) {
227 WLOGFW("DisplayManagerProxy::SetScreenColorTransform: SendRequest failed");
228 return DMError::DM_ERROR_IPC_FAILED;
229 }
230 return static_cast<DMError>(reply.ReadInt32());
231 }
232
RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)233 DMError ScreenSessionManagerProxy::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
234 DisplayManagerAgentType type)
235 {
236 MessageParcel data;
237 MessageParcel reply;
238 MessageOption option;
239 if (!data.WriteInterfaceToken(GetDescriptor())) {
240 WLOGFE("WriteInterfaceToken failed");
241 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
242 }
243
244 if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
245 WLOGFE("Write IDisplayManagerAgent failed");
246 return DMError::DM_ERROR_IPC_FAILED;
247 }
248
249 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
250 WLOGFE("Write DisplayManagerAgent type failed");
251 return DMError::DM_ERROR_IPC_FAILED;
252 }
253
254 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
255 data, reply, option) != ERR_NONE) {
256 WLOGFE("SendRequest failed");
257 return DMError::DM_ERROR_IPC_FAILED;
258 }
259 return static_cast<DMError>(reply.ReadInt32());
260 }
261
UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)262 DMError ScreenSessionManagerProxy::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
263 DisplayManagerAgentType type)
264 {
265 MessageParcel data;
266 MessageParcel reply;
267 MessageOption option;
268 if (!data.WriteInterfaceToken(GetDescriptor())) {
269 WLOGFE("WriteInterfaceToken failed");
270 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
271 }
272
273 if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
274 WLOGFE("Write IWindowManagerAgent failed");
275 return DMError::DM_ERROR_IPC_FAILED;
276 }
277
278 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
279 WLOGFE("Write DisplayManagerAgent type failed");
280 return DMError::DM_ERROR_IPC_FAILED;
281 }
282
283 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
284 data, reply, option) != ERR_NONE) {
285 WLOGFE("SendRequest failed");
286 return DMError::DM_ERROR_IPC_FAILED;
287 }
288 return static_cast<DMError>(reply.ReadInt32());
289 }
290
WakeUpBegin(PowerStateChangeReason reason)291 bool OHOS::Rosen::ScreenSessionManagerProxy::WakeUpBegin(PowerStateChangeReason reason)
292 {
293 sptr<IRemoteObject> remote = Remote();
294 if (remote == nullptr) {
295 WLOGFE("WakeUpBegin remote is nullptr");
296 return false;
297 }
298
299 MessageParcel data;
300 MessageParcel reply;
301 MessageOption option;
302
303 if (!data.WriteInterfaceToken(GetDescriptor())) {
304 WLOGFE("WakeUpBegin: WriteInterfaceToken failed");
305 return false;
306 }
307 if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
308 WLOGFE("WakeUpBegin: Write PowerStateChangeReason failed");
309 return false;
310 }
311 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
312 data, reply, option) != ERR_NONE) {
313 WLOGFW("WakeUpBegin: SendRequest failed");
314 return false;
315 }
316 return reply.ReadBool();
317 }
318
WakeUpEnd()319 bool OHOS::Rosen::ScreenSessionManagerProxy::WakeUpEnd()
320 {
321 sptr<IRemoteObject> remote = Remote();
322 if (remote == nullptr) {
323 WLOGFE("WakeUpEnd remote is nullptr");
324 return false;
325 }
326
327 MessageParcel data;
328 MessageParcel reply;
329 MessageOption option;
330
331 if (!data.WriteInterfaceToken(GetDescriptor())) {
332 WLOGFE("WakeUpEnd: WriteInterfaceToken failed");
333 return false;
334 }
335 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
336 data, reply, option) != ERR_NONE) {
337 WLOGFW("WakeUpEnd: SendRequest failed");
338 return false;
339 }
340 return reply.ReadBool();
341 }
342
SuspendBegin(PowerStateChangeReason reason)343 bool OHOS::Rosen::ScreenSessionManagerProxy::SuspendBegin(PowerStateChangeReason reason)
344 {
345 sptr<IRemoteObject> remote = Remote();
346 if (remote == nullptr) {
347 WLOGFE("SuspendBegin remote is nullptr");
348 return false;
349 }
350
351 MessageParcel data;
352 MessageParcel reply;
353 MessageOption option;
354
355 if (!data.WriteInterfaceToken(GetDescriptor())) {
356 WLOGFE("SuspendBegin: WriteInterfaceToken failed");
357 return false;
358 }
359 if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
360 WLOGFE("SuspendBegin: Write PowerStateChangeReason failed");
361 return false;
362 }
363 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN),
364 data, reply, option) != ERR_NONE) {
365 WLOGFW("SuspendBegin: SendRequest failed");
366 return false;
367 }
368 return reply.ReadBool();
369 }
370
SuspendEnd()371 bool OHOS::Rosen::ScreenSessionManagerProxy::SuspendEnd()
372 {
373 sptr<IRemoteObject> remote = Remote();
374 if (remote == nullptr) {
375 WLOGFE("SuspendEnd remote is nullptr");
376 return false;
377 }
378
379 MessageParcel data;
380 MessageParcel reply;
381 MessageOption option;
382
383 if (!data.WriteInterfaceToken(GetDescriptor())) {
384 WLOGFE("SuspendEnd: WriteInterfaceToken failed");
385 return false;
386 }
387 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_END),
388 data, reply, option) != ERR_NONE) {
389 WLOGFW("SuspendEnd: SendRequest failed");
390 return false;
391 }
392 return reply.ReadBool();
393 }
394
SetDisplayState(DisplayState state)395 bool OHOS::Rosen::ScreenSessionManagerProxy::SetDisplayState(DisplayState state)
396 {
397 sptr<IRemoteObject> remote = Remote();
398 if (remote == nullptr) {
399 WLOGFE("SetDisplayState remote is nullptr");
400 return false;
401 }
402
403 MessageParcel data;
404 MessageParcel reply;
405 MessageOption option;
406 if (!data.WriteInterfaceToken(GetDescriptor())) {
407 WLOGFE("WriteInterfaceToken failed");
408 return false;
409 }
410 if (!data.WriteUint32(static_cast<uint32_t>(state))) {
411 WLOGFE("Write DisplayState failed");
412 return false;
413 }
414 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
415 data, reply, option) != ERR_NONE) {
416 WLOGFW("SendRequest failed");
417 return false;
418 }
419 return reply.ReadBool();
420 }
421
SetScreenPowerForAll(ScreenPowerState state,PowerStateChangeReason reason)422 bool OHOS::Rosen::ScreenSessionManagerProxy::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
423 {
424 sptr<IRemoteObject> remote = Remote();
425 if (remote == nullptr) {
426 WLOGFE("SetScreenPowerForAll remote is nullptr");
427 return false;
428 }
429
430 MessageParcel data;
431 MessageParcel reply;
432 MessageOption option;
433 if (!data.WriteInterfaceToken(GetDescriptor())) {
434 WLOGFE("WriteInterfaceToken failed");
435 return false;
436 }
437 if (!data.WriteUint32(static_cast<uint32_t>(state))) {
438 WLOGFE("Write ScreenPowerState failed");
439 return false;
440 }
441 if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
442 WLOGFE("Write PowerStateChangeReason failed");
443 return false;
444 }
445 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL),
446 data, reply, option) != ERR_NONE) {
447 WLOGFW("SendRequest failed");
448 return false;
449 }
450 return reply.ReadBool();
451 }
452
GetDisplayState(DisplayId displayId)453 DisplayState OHOS::Rosen::ScreenSessionManagerProxy::GetDisplayState(DisplayId displayId)
454 {
455 sptr<IRemoteObject> remote = Remote();
456 if (remote == nullptr) {
457 WLOGFE("GetDisplayState remote is nullptr");
458 return DisplayState::UNKNOWN;
459 }
460
461 MessageParcel data;
462 MessageParcel reply;
463 MessageOption option;
464 if (!data.WriteInterfaceToken(GetDescriptor())) {
465 WLOGFE("WriteInterfaceToken failed");
466 return DisplayState::UNKNOWN;
467 }
468 if (!data.WriteUint64(displayId)) {
469 WLOGFE("Write displayId failed");
470 return DisplayState::UNKNOWN;
471 }
472 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE),
473 data, reply, option) != ERR_NONE) {
474 WLOGFW("SendRequest failed");
475 return DisplayState::UNKNOWN;
476 }
477 return static_cast<DisplayState>(reply.ReadUint32());
478 }
479
NotifyDisplayEvent(DisplayEvent event)480 void OHOS::Rosen::ScreenSessionManagerProxy::NotifyDisplayEvent(DisplayEvent event)
481 {
482 sptr<IRemoteObject> remote = Remote();
483 if (remote == nullptr) {
484 WLOGFE("NotifyDisplayEvent remote is nullptr");
485 return;
486 }
487
488 MessageParcel data;
489 MessageParcel reply;
490 MessageOption option;
491 if (!data.WriteInterfaceToken(GetDescriptor())) {
492 WLOGFE("WriteInterfaceToken failed");
493 return;
494 }
495 if (!data.WriteUint32(static_cast<uint32_t>(event))) {
496 WLOGFE("Write DisplayEvent failed");
497 return;
498 }
499 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
500 data, reply, option) != ERR_NONE) {
501 WLOGFW("SendRequest failed");
502 return;
503 }
504 }
505
GetScreenPower(ScreenId dmsScreenId)506 ScreenPowerState OHOS::Rosen::ScreenSessionManagerProxy::GetScreenPower(ScreenId dmsScreenId)
507 {
508 sptr<IRemoteObject> remote = Remote();
509 if (remote == nullptr) {
510 WLOGFE("GetScreenPower remote is nullptr");
511 return ScreenPowerState::INVALID_STATE;
512 }
513
514 MessageParcel data;
515 MessageParcel reply;
516 MessageOption option;
517 if (!data.WriteInterfaceToken(GetDescriptor())) {
518 WLOGFE("WriteInterfaceToken failed");
519 return ScreenPowerState::INVALID_STATE;
520 }
521 if (!data.WriteUint64(static_cast<uint64_t>(dmsScreenId))) {
522 WLOGFE("Write dmsScreenId failed");
523 return ScreenPowerState::INVALID_STATE;
524 }
525 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER),
526 data, reply, option) != ERR_NONE) {
527 WLOGFW("SendRequest failed");
528 return ScreenPowerState::INVALID_STATE;
529 }
530 return static_cast<ScreenPowerState>(reply.ReadUint32());
531 }
532
CreateVirtualScreen(VirtualScreenOption virtualOption,const sptr<IRemoteObject> & displayManagerAgent)533 ScreenId ScreenSessionManagerProxy::CreateVirtualScreen(VirtualScreenOption virtualOption,
534 const sptr<IRemoteObject>& displayManagerAgent)
535 {
536 WLOGFI("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: ENTER");
537 sptr<IRemoteObject> remote = Remote();
538 if (remote == nullptr) {
539 WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: remote is nullptr");
540 return SCREEN_ID_INVALID;
541 }
542
543 MessageParcel data;
544 MessageParcel reply;
545 MessageOption option;
546 if (!data.WriteInterfaceToken(GetDescriptor())) {
547 WLOGFE("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: WriteInterfaceToken failed");
548 return SCREEN_ID_INVALID;
549 }
550 bool res = data.WriteString(virtualOption.name_) && data.WriteUint32(virtualOption.width_) &&
551 data.WriteUint32(virtualOption.height_) && data.WriteFloat(virtualOption.density_) &&
552 data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_);
553 if (virtualOption.surface_ != nullptr && virtualOption.surface_->GetProducer() != nullptr) {
554 res = res &&
555 data.WriteBool(true) &&
556 data.WriteRemoteObject(virtualOption.surface_->GetProducer()->AsObject());
557 } else {
558 WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: surface is nullptr");
559 res = res && data.WriteBool(false);
560 }
561 if (displayManagerAgent != nullptr) {
562 res = res &&
563 data.WriteRemoteObject(displayManagerAgent);
564 }
565 if (!res) {
566 WLOGFE("SCB: ScreenSessionManagerProxy::Write data failed");
567 return SCREEN_ID_INVALID;
568 }
569 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN),
570 data, reply, option) != ERR_NONE) {
571 WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: SendRequest failed");
572 return SCREEN_ID_INVALID;
573 }
574
575 ScreenId screenId = static_cast<ScreenId>(reply.ReadUint64());
576 return screenId;
577 }
578
SetVirtualScreenSurface(ScreenId screenId,sptr<IBufferProducer> surface)579 DMError ScreenSessionManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface)
580 {
581 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: ENTER");
582 sptr<IRemoteObject> remote = Remote();
583 if (remote == nullptr) {
584 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: remote is nullptr");
585 return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
586 }
587
588 MessageParcel data;
589 MessageParcel reply;
590 MessageOption option;
591 if (!data.WriteInterfaceToken(GetDescriptor())) {
592 WLOGFE("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: WriteInterfaceToken failed");
593 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
594 }
595 bool res = data.WriteUint64(static_cast<uint64_t>(screenId));
596 if (surface != nullptr) {
597 res = res &&
598 data.WriteBool(true) &&
599 data.WriteRemoteObject(surface->AsObject());
600 } else {
601 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: surface is nullptr");
602 res = res && data.WriteBool(false);
603 }
604 if (!res) {
605 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: Write screenId/surface failed");
606 return DMError::DM_ERROR_IPC_FAILED;
607 }
608 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE),
609 data, reply, option) != ERR_NONE) {
610 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: SendRequest failed");
611 return DMError::DM_ERROR_IPC_FAILED;
612 }
613 return static_cast<DMError>(reply.ReadInt32());
614 }
615
DestroyVirtualScreen(ScreenId screenId)616 DMError ScreenSessionManagerProxy::DestroyVirtualScreen(ScreenId screenId)
617 {
618 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: ENTER");
619 sptr<IRemoteObject> remote = Remote();
620 if (remote == nullptr) {
621 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: remote is nullptr");
622 return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
623 }
624
625 MessageParcel data;
626 MessageParcel reply;
627 MessageOption option;
628 if (!data.WriteInterfaceToken(GetDescriptor())) {
629 WLOGFE("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: WriteInterfaceToken failed");
630 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
631 }
632 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
633 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: WriteUint64 screenId failed");
634 return DMError::DM_ERROR_IPC_FAILED;
635 }
636 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN),
637 data, reply, option) != ERR_NONE) {
638 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: SendRequest failed");
639 return DMError::DM_ERROR_IPC_FAILED;
640 }
641 return static_cast<DMError>(reply.ReadInt32());
642 }
643
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenIds,ScreenId & screenGroupId)644 DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId,
645 std::vector<ScreenId> mirrorScreenIds, ScreenId& screenGroupId)
646 {
647 WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: ENTER");
648 sptr<IRemoteObject> remote = Remote();
649 if (remote == nullptr) {
650 WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: remote is null");
651 return DMError::DM_ERROR_NULLPTR;
652 }
653
654 MessageParcel data;
655 MessageParcel reply;
656 MessageOption option;
657 if (!data.WriteInterfaceToken(GetDescriptor())) {
658 WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: WriteInterfaceToken failed");
659 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
660 }
661 bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
662 data.WriteUInt64Vector(mirrorScreenIds);
663 if (!res) {
664 WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: data write failed");
665 return DMError::DM_ERROR_IPC_FAILED;
666 }
667 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR),
668 data, reply, option) != ERR_NONE) {
669 WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: SendRequest failed");
670 return DMError::DM_ERROR_IPC_FAILED;
671 }
672 DMError ret = static_cast<DMError>(reply.ReadInt32());
673 screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
674 return ret;
675 }
676
GetScreenGroupInfoById(ScreenId screenId)677 sptr<ScreenGroupInfo> ScreenSessionManagerProxy::GetScreenGroupInfoById(ScreenId screenId)
678 {
679 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: ENTER!");
680 sptr<IRemoteObject> remote = Remote();
681 if (remote == nullptr) {
682 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: remote is nullptr");
683 return nullptr;
684 }
685
686 MessageParcel data;
687 MessageParcel reply;
688 MessageOption option;
689 if (!data.WriteInterfaceToken(GetDescriptor())) {
690 WLOGFE("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: WriteInterfaceToken failed");
691 return nullptr;
692 }
693 if (!data.WriteUint64(screenId)) {
694 WLOGFE("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: Write screenId failed");
695 return nullptr;
696 }
697 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID),
698 data, reply, option) != ERR_NONE) {
699 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: SendRequest failed");
700 return nullptr;
701 }
702
703 sptr<ScreenGroupInfo> info = reply.ReadStrongParcelable<ScreenGroupInfo>();
704 if (info == nullptr) {
705 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById SendRequest nullptr.");
706 return nullptr;
707 }
708 return info;
709 }
710
RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)711 void ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
712 {
713 WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: ENTER!");
714 sptr<IRemoteObject> remote = Remote();
715 if (remote == nullptr) {
716 WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup:remote is null");
717 return;
718 }
719
720 MessageParcel data;
721 MessageParcel reply;
722 MessageOption option(MessageOption::TF_ASYNC);
723 if (!data.WriteInterfaceToken(GetDescriptor())) {
724 WLOGFE("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: WriteInterfaceToken failed");
725 return;
726 }
727 bool res = data.WriteUInt64Vector(screens);
728 if (!res) {
729 WLOGFE("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: write screens failed.");
730 return;
731 }
732 if (remote->SendRequest(static_cast<uint32_t>(
733 DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP),
734 data, reply, option) != ERR_NONE) {
735 WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup:: SendRequest failed");
736 }
737 }
738
GetDisplaySnapshot(DisplayId displayId,DmErrorCode * errorCode)739 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetDisplaySnapshot(DisplayId displayId,
740 DmErrorCode* errorCode)
741 {
742 WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot enter");
743 sptr<IRemoteObject> remote = Remote();
744 if (remote == nullptr) {
745 WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: remote is nullptr");
746 return nullptr;
747 }
748
749 MessageParcel data;
750 MessageParcel reply;
751 MessageOption option;
752 if (!data.WriteInterfaceToken(GetDescriptor())) {
753 WLOGFE("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: WriteInterfaceToken failed");
754 return nullptr;
755 }
756
757 if (!data.WriteUint64(displayId)) {
758 WLOGFE("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: Write displayId failed");
759 return nullptr;
760 }
761
762 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT),
763 data, reply, option) != ERR_NONE) {
764 WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: SendRequest failed");
765 return nullptr;
766 }
767
768 std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
769 if (pixelMap == nullptr) {
770 WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: SendRequest nullptr.");
771 return nullptr;
772 }
773 return pixelMap;
774 }
775
GetDisplayInfoById(DisplayId displayId)776 sptr<DisplayInfo> ScreenSessionManagerProxy::GetDisplayInfoById(DisplayId displayId)
777 {
778 sptr<IRemoteObject> remote = Remote();
779 if (remote == nullptr) {
780 WLOGFW("GetDisplayInfoById: remote is nullptr");
781 return nullptr;
782 }
783
784 MessageParcel data;
785 MessageParcel reply;
786 MessageOption option;
787 if (!data.WriteInterfaceToken(GetDescriptor())) {
788 WLOGFE("GetDisplayInfoById: WriteInterfaceToken failed");
789 return nullptr;
790 }
791 if (!data.WriteUint64(displayId)) {
792 WLOGFW("GetDisplayInfoById: WriteUint64 displayId failed");
793 return nullptr;
794 }
795 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID),
796 data, reply, option) != ERR_NONE) {
797 WLOGFW("GetDisplayInfoById: SendRequest failed");
798 return nullptr;
799 }
800
801 sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
802 if (info == nullptr) {
803 WLOGFW("DisplayManagerProxy::GetDisplayInfoById SendRequest nullptr.");
804 return nullptr;
805 }
806 return info;
807 }
808
GetDisplayInfoByScreen(ScreenId screenId)809 sptr<DisplayInfo> ScreenSessionManagerProxy::GetDisplayInfoByScreen(ScreenId screenId)
810 {
811 sptr<IRemoteObject> remote = Remote();
812 if (remote == nullptr) {
813 WLOGFE("fail to get displayInfo by screenId: remote is null");
814 return nullptr;
815 }
816
817 MessageParcel data;
818 MessageParcel reply;
819 MessageOption option;
820 if (!data.WriteInterfaceToken(GetDescriptor())) {
821 WLOGFE("fail to get displayInfo by screenId: WriteInterfaceToken failed");
822 return nullptr;
823 }
824 if (!data.WriteUint64(screenId)) {
825 WLOGFW("fail to get displayInfo by screenId: WriteUint64 displayId failed");
826 return nullptr;
827 }
828 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN),
829 data, reply, option) != ERR_NONE) {
830 WLOGFW("fail to get displayInfo by screenId: SendRequest failed");
831 return nullptr;
832 }
833
834 sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
835 if (info == nullptr) {
836 WLOGFW("fail to get displayInfo by screenId: SendRequest null");
837 return nullptr;
838 }
839 return info;
840 }
841
GetAllDisplayIds()842 std::vector<DisplayId> ScreenSessionManagerProxy::GetAllDisplayIds()
843 {
844 std::vector<DisplayId> allDisplayIds;
845 MessageParcel data;
846 MessageParcel reply;
847 MessageOption option;
848 if (!data.WriteInterfaceToken(GetDescriptor())) {
849 WLOGFE("WriteInterfaceToken failed");
850 return allDisplayIds;
851 }
852 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
853 data, reply, option) != ERR_NONE) {
854 WLOGFW("SendRequest failed");
855 return allDisplayIds;
856 }
857 reply.ReadUInt64Vector(&allDisplayIds);
858 return allDisplayIds;
859 }
860
GetScreenInfoById(ScreenId screenId)861 sptr<ScreenInfo> ScreenSessionManagerProxy::GetScreenInfoById(ScreenId screenId)
862 {
863 sptr<IRemoteObject> remote = Remote();
864 if (remote == nullptr) {
865 WLOGFW("GetScreenInfoById: remote is nullptr");
866 return nullptr;
867 }
868
869 MessageParcel data;
870 MessageParcel reply;
871 MessageOption option;
872 if (!data.WriteInterfaceToken(GetDescriptor())) {
873 WLOGFE("GetScreenInfoById: WriteInterfaceToken failed");
874 return nullptr;
875 }
876 if (!data.WriteUint64(screenId)) {
877 WLOGFE("GetScreenInfoById: Write screenId failed");
878 return nullptr;
879 }
880 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID),
881 data, reply, option) != ERR_NONE) {
882 WLOGFW("GetScreenInfoById: SendRequest failed");
883 return nullptr;
884 }
885
886 sptr<ScreenInfo> info = reply.ReadStrongParcelable<ScreenInfo>();
887 if (info == nullptr) {
888 WLOGFW("GetScreenInfoById SendRequest nullptr.");
889 return nullptr;
890 }
891 for (auto& mode : info->GetModes()) {
892 WLOGFI("info modes is width: %{public}u, height: %{public}u, refreshRate: %{public}u",
893 mode->width_, mode->height_, mode->refreshRate_);
894 }
895 return info;
896 }
897
GetAllScreenInfos(std::vector<sptr<ScreenInfo>> & screenInfos)898 DMError ScreenSessionManagerProxy::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
899 {
900 sptr<IRemoteObject> remote = Remote();
901 if (remote == nullptr) {
902 WLOGFW("GetAllScreenInfos: remote is nullptr");
903 return DMError::DM_ERROR_NULLPTR;
904 }
905
906 MessageParcel data;
907 MessageParcel reply;
908 MessageOption option;
909 if (!data.WriteInterfaceToken(GetDescriptor())) {
910 WLOGFE("GetAllScreenInfos: WriteInterfaceToken failed");
911 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
912 }
913 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS),
914 data, reply, option) != ERR_NONE) {
915 WLOGFW("GetAllScreenInfos: SendRequest failed");
916 return DMError::DM_ERROR_IPC_FAILED;
917 }
918 DMError ret = static_cast<DMError>(reply.ReadInt32());
919 MarshallingHelper::UnmarshallingVectorParcelableObj<ScreenInfo>(reply, screenInfos);
920 return ret;
921 }
922
GetScreenSupportedColorGamuts(ScreenId screenId,std::vector<ScreenColorGamut> & colorGamuts)923 DMError ScreenSessionManagerProxy::GetScreenSupportedColorGamuts(ScreenId screenId,
924 std::vector<ScreenColorGamut>& colorGamuts)
925 {
926 sptr<IRemoteObject> remote = Remote();
927 if (remote == nullptr) {
928 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: remote is nullptr");
929 return DMError::DM_ERROR_NULLPTR;
930 }
931
932 MessageParcel data;
933 MessageParcel reply;
934 MessageOption option;
935 if (!data.WriteInterfaceToken(GetDescriptor())) {
936 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteInterfaceToken failed");
937 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
938 }
939 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
940 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteUint64 screenId failed");
941 return DMError::DM_ERROR_IPC_FAILED;
942 }
943 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS),
944 data, reply, option) != ERR_NONE) {
945 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: SendRequest failed");
946 return DMError::DM_ERROR_IPC_FAILED;
947 }
948 DMError ret = static_cast<DMError>(reply.ReadInt32());
949 if (ret != DMError::DM_OK) {
950 return ret;
951 }
952 MarshallingHelper::UnmarshallingVectorObj<ScreenColorGamut>(reply, colorGamuts,
953 [](Parcel& parcel, ScreenColorGamut& color) {
954 uint32_t value;
955 bool res = parcel.ReadUint32(value);
956 color = static_cast<ScreenColorGamut>(value);
957 return res;
958 }
959 );
960 return ret;
961 }
962
SetOrientation(ScreenId screenId,Orientation orientation)963 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetOrientation(ScreenId screenId, Orientation orientation)
964 {
965 sptr<IRemoteObject> remote = Remote();
966 if (remote == nullptr) {
967 WLOGFW("fail to set orientation: remote is null");
968 return DMError::DM_ERROR_NULLPTR;
969 }
970
971 MessageParcel data;
972 MessageParcel reply;
973 MessageOption option;
974 if (!data.WriteInterfaceToken(GetDescriptor())) {
975 WLOGFE("fail to set orientation: WriteInterfaceToken failed");
976 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
977 }
978 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
979 WLOGFW("fail to set orientation: Write screenId failed");
980 return DMError::DM_ERROR_IPC_FAILED;
981 }
982 if (!data.WriteUint32(static_cast<uint32_t>(orientation))) {
983 WLOGFW("fail to set orientation: Write orientation failed");
984 return DMError::DM_ERROR_IPC_FAILED;
985 }
986 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_ORIENTATION),
987 data, reply, option) != ERR_NONE) {
988 WLOGFW("fail to set orientation: SendRequest failed");
989 return DMError::DM_ERROR_IPC_FAILED;
990 }
991 return static_cast<DMError>(reply.ReadInt32());
992 }
993
SetScreenRotationLocked(bool isLocked)994 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetScreenRotationLocked(bool isLocked)
995 {
996 sptr<IRemoteObject> remote = Remote();
997 if (remote == nullptr) {
998 WLOGFW("remote is null");
999 return DMError::DM_ERROR_NULLPTR;
1000 }
1001
1002 MessageParcel data;
1003 MessageParcel reply;
1004 MessageOption option;
1005 if (!data.WriteInterfaceToken(GetDescriptor())) {
1006 WLOGFE("WriteInterfaceToken failed");
1007 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1008 }
1009 if (!data.WriteBool(isLocked)) {
1010 WLOGFE("write isLocked failed");
1011 return DMError::DM_ERROR_IPC_FAILED;
1012 }
1013 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED),
1014 data, reply, option) != ERR_NONE) {
1015 WLOGFE("SendRequest failed");
1016 return DMError::DM_ERROR_IPC_FAILED;
1017 }
1018 return static_cast<DMError>(reply.ReadInt32());
1019 }
1020
IsScreenRotationLocked(bool & isLocked)1021 DMError OHOS::Rosen::ScreenSessionManagerProxy::IsScreenRotationLocked(bool& isLocked)
1022 {
1023 sptr<IRemoteObject> remote = Remote();
1024 if (remote == nullptr) {
1025 WLOGFW("remote is nullptr");
1026 return DMError::DM_ERROR_NULLPTR;
1027 }
1028
1029 MessageParcel data;
1030 MessageParcel reply;
1031 MessageOption option;
1032 if (!data.WriteInterfaceToken(GetDescriptor())) {
1033 WLOGFE("WriteInterfaceToken failed");
1034 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1035 }
1036 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED),
1037 data, reply, option) != ERR_NONE) {
1038 WLOGFW("SendRequest failed");
1039 return DMError::DM_ERROR_IPC_FAILED;
1040 }
1041 DMError ret = static_cast<DMError>(reply.ReadInt32());
1042 isLocked = reply.ReadBool();
1043 return ret;
1044 }
1045
GetCutoutInfo(DisplayId displayId)1046 sptr<CutoutInfo> ScreenSessionManagerProxy::GetCutoutInfo(DisplayId displayId)
1047 {
1048 sptr<IRemoteObject> remote = Remote();
1049 if (remote == nullptr) {
1050 WLOGFW("get cutout info : remote is null");
1051 return nullptr;
1052 }
1053 MessageParcel data;
1054 MessageParcel reply;
1055 MessageOption option;
1056 if (!data.WriteInterfaceToken(GetDescriptor())) {
1057 WLOGFE("get cutout info : failed");
1058 return nullptr;
1059 }
1060 if (!data.WriteUint64(displayId)) {
1061 WLOGFE("get cutout info: write displayId failed");
1062 return nullptr;
1063 }
1064 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO),
1065 data, reply, option) != ERR_NONE) {
1066 WLOGFW("GetCutoutInfo: GetCutoutInfo failed");
1067 return nullptr;
1068 }
1069 sptr<CutoutInfo> info = reply.ReadParcelable<CutoutInfo>();
1070 return info;
1071 }
HasPrivateWindow(DisplayId displayId,bool & hasPrivateWindow)1072 DMError OHOS::Rosen::ScreenSessionManagerProxy::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow)
1073 {
1074 sptr<IRemoteObject> remote = Remote();
1075 if (remote == nullptr) {
1076 WLOGFW("remote is nullptr");
1077 return DMError::DM_ERROR_NULLPTR;
1078 }
1079
1080 MessageParcel data;
1081 MessageParcel reply;
1082 MessageOption option;
1083 if (!data.WriteInterfaceToken(GetDescriptor())) {
1084 WLOGFE("WriteInterfaceToken failed");
1085 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1086 }
1087
1088 if (!data.WriteUint64(displayId)) {
1089 return DMError::DM_ERROR_IPC_FAILED;
1090 }
1091
1092 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW),
1093 data, reply, option) != ERR_NONE) {
1094 WLOGFW("SendRequest failed");
1095 return DMError::DM_ERROR_IPC_FAILED;
1096 }
1097 DMError ret = static_cast<DMError>(reply.ReadInt32());
1098 hasPrivateWindow = reply.ReadBool();
1099 return ret;
1100 }
1101
DumpAllScreensInfo(std::string & dumpInfo)1102 void ScreenSessionManagerProxy::DumpAllScreensInfo(std::string& dumpInfo)
1103 {
1104 sptr<IRemoteObject> remote = Remote();
1105 if (remote == nullptr) {
1106 WLOGFW("remote is null");
1107 return;
1108 }
1109 MessageParcel data;
1110 MessageParcel reply;
1111 MessageOption option;
1112 if (!data.WriteInterfaceToken(GetDescriptor())) {
1113 WLOGFE("failed");
1114 return;
1115 }
1116 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN),
1117 data, reply, option) != ERR_NONE) {
1118 WLOGFW("failed");
1119 return;
1120 }
1121 dumpInfo = reply.ReadString();
1122 }
DumpSpecialScreenInfo(ScreenId id,std::string & dumpInfo)1123 void ScreenSessionManagerProxy::DumpSpecialScreenInfo(ScreenId id, std::string& dumpInfo)
1124 {
1125 sptr<IRemoteObject> remote = Remote();
1126 if (remote == nullptr) {
1127 WLOGFW("remote is null");
1128 return;
1129 }
1130 MessageParcel data;
1131 MessageParcel reply;
1132 MessageOption option;
1133 if (!data.WriteInterfaceToken(GetDescriptor())) {
1134 WLOGFE("failed");
1135 return;
1136 }
1137 if (!data.WriteUint64(id)) {
1138 WLOGFE("write ScreenId failed");
1139 return;
1140 }
1141 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_SPECIAL_SCREEN),
1142 data, reply, option) != ERR_NONE) {
1143 WLOGFW("failed");
1144 return;
1145 }
1146 dumpInfo = reply.ReadString();
1147 }
1148
1149 //Fold Screen
SetFoldDisplayMode(const FoldDisplayMode displayMode)1150 void ScreenSessionManagerProxy::SetFoldDisplayMode(const FoldDisplayMode displayMode)
1151 {
1152 sptr<IRemoteObject> remote = Remote();
1153 if (remote == nullptr) {
1154 WLOGFW("remote is null");
1155 return;
1156 }
1157 MessageParcel data;
1158 MessageParcel reply;
1159 MessageOption option;
1160 if (!data.WriteInterfaceToken(GetDescriptor())) {
1161 WLOGFE("WriteInterfaceToken Failed");
1162 return;
1163 }
1164 if (!data.WriteUint32(static_cast<uint32_t>(displayMode))) {
1165 WLOGFE("Write displayMode failed");
1166 return;
1167 }
1168 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE),
1169 data, reply, option) != ERR_NONE) {
1170 WLOGFE("Send TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE request failed");
1171 }
1172 }
1173
GetFoldDisplayMode()1174 FoldDisplayMode ScreenSessionManagerProxy::GetFoldDisplayMode()
1175 {
1176 sptr<IRemoteObject> remote = Remote();
1177 if (remote == nullptr) {
1178 WLOGFW("remote is null");
1179 return FoldDisplayMode::UNKNOWN;
1180 }
1181 MessageParcel data;
1182 MessageParcel reply;
1183 MessageOption option;
1184 if (!data.WriteInterfaceToken(GetDescriptor())) {
1185 WLOGFE("WriteInterfaceToken Failed");
1186 return FoldDisplayMode::UNKNOWN;
1187 }
1188 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE),
1189 data, reply, option) != ERR_NONE) {
1190 WLOGFE("Send TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE request failed");
1191 return FoldDisplayMode::UNKNOWN;
1192 }
1193 return static_cast<FoldDisplayMode>(reply.ReadUint32());
1194 }
1195
IsFoldable()1196 bool ScreenSessionManagerProxy::IsFoldable()
1197 {
1198 sptr<IRemoteObject> remote = Remote();
1199 if (remote == nullptr) {
1200 WLOGFW("remote is null");
1201 return false;
1202 }
1203
1204 MessageParcel data;
1205 MessageParcel reply;
1206 MessageOption option;
1207 if (!data.WriteInterfaceToken(GetDescriptor())) {
1208 WLOGFE("WriteInterfaceToken failed");
1209 return false;
1210 }
1211 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE),
1212 data, reply, option) != ERR_NONE) {
1213 WLOGFE("SendRequest failed");
1214 return false;
1215 }
1216 return reply.ReadBool();
1217 }
1218
GetFoldStatus()1219 FoldStatus ScreenSessionManagerProxy::GetFoldStatus()
1220 {
1221 sptr<IRemoteObject> remote = Remote();
1222 if (remote == nullptr) {
1223 WLOGFW("remote is null");
1224 return FoldStatus::UNKNOWN;
1225 }
1226
1227 MessageParcel data;
1228 MessageParcel reply;
1229 MessageOption option;
1230 if (!data.WriteInterfaceToken(GetDescriptor())) {
1231 WLOGFE("WriteInterfaceToken failed");
1232 return FoldStatus::UNKNOWN;
1233 }
1234 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS),
1235 data, reply, option) != ERR_NONE) {
1236 WLOGFE("SendRequest failed");
1237 return FoldStatus::UNKNOWN;
1238 }
1239 return static_cast<FoldStatus>(reply.ReadUint32());
1240 }
1241
GetCurrentFoldCreaseRegion()1242 sptr<FoldCreaseRegion> ScreenSessionManagerProxy::GetCurrentFoldCreaseRegion()
1243 {
1244 sptr<IRemoteObject> remote = Remote();
1245 if (remote == nullptr) {
1246 WLOGFW("remote is null");
1247 return nullptr;
1248 }
1249
1250 MessageParcel data;
1251 MessageParcel reply;
1252 MessageOption option;
1253 if (!data.WriteInterfaceToken(GetDescriptor())) {
1254 WLOGFE("WriteInterfaceToken failed");
1255 return nullptr;
1256 }
1257 if (remote->SendRequest(
1258 static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION),
1259 data, reply, option) != ERR_NONE) {
1260 WLOGFE("SendRequest failed");
1261 return nullptr;
1262 }
1263 return reply.ReadStrongParcelable<FoldCreaseRegion>();
1264 }
1265 } // namespace OHOS::Rosen
1266