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