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