• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 #include "marshalling_helper.h"
19 
20 namespace OHOS::Rosen {
21 namespace {
22 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenSessionManagerProxy" };
23 }
24 
GetDefaultDisplayInfo()25 sptr<DisplayInfo> OHOS::Rosen::ScreenSessionManagerProxy::GetDefaultDisplayInfo()
26 {
27     sptr<IRemoteObject> remote = Remote();
28     if (remote == nullptr) {
29         WLOGFW("GetDefaultDisplayInfo: remote is nullptr");
30         return nullptr;
31     }
32 
33     MessageParcel data;
34     MessageParcel reply;
35     MessageOption option;
36     if (!data.WriteInterfaceToken(GetDescriptor())) {
37         WLOGFE("WriteInterfaceToken failed");
38         return nullptr;
39     }
40     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO),
41         data, reply, option) != ERR_NONE) {
42         WLOGFE("SendRequest failed");
43         return nullptr;
44     }
45 
46     sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
47     if (info == nullptr) {
48         WLOGFW("read display info failed, info is nullptr.");
49     }
50     return info;
51 }
52 
SetScreenActiveMode(ScreenId screenId,uint32_t modeId)53 DMError ScreenSessionManagerProxy::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
54 {
55     sptr<IRemoteObject> remote = Remote();
56     if (remote == nullptr) {
57         WLOGFW("SetScreenActiveMode: remote is nullptr");
58         return DMError::DM_ERROR_IPC_FAILED;
59     }
60 
61     MessageParcel data;
62     MessageParcel reply;
63     MessageOption option;
64     if (!data.WriteInterfaceToken(GetDescriptor())) {
65         WLOGFE("SetScreenActiveMode: WriteInterfaceToken failed");
66         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
67     }
68     if (!data.WriteUint64(screenId) || !data.WriteUint32(modeId)) {
69         WLOGFE("SetScreenActiveMode: write screenId/modeId failed");
70         return DMError::DM_ERROR_IPC_FAILED;
71     }
72     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE),
73         data, reply, option) != ERR_NONE) {
74         WLOGFE("SetScreenActiveMode: SendRequest failed");
75         return DMError::DM_ERROR_IPC_FAILED;
76     }
77     return static_cast<DMError>(reply.ReadInt32());
78 }
79 
SetVirtualPixelRatio(ScreenId screenId,float virtualPixelRatio)80 DMError ScreenSessionManagerProxy::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio)
81 {
82     sptr<IRemoteObject> remote = Remote();
83     if (remote == nullptr) {
84         WLOGFW("SetVirtualPixelRatio: remote is nullptr");
85         return DMError::DM_ERROR_IPC_FAILED;
86     }
87 
88     MessageParcel data;
89     MessageParcel reply;
90     MessageOption option;
91     if (!data.WriteInterfaceToken(GetDescriptor())) {
92         WLOGFE("WriteInterfaceToken failed");
93         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
94     }
95     if (!data.WriteUint64(screenId) || !data.WriteFloat(virtualPixelRatio)) {
96         WLOGFE("write screenId/modeId failed");
97         return DMError::DM_ERROR_IPC_FAILED;
98     }
99     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO),
100         data, reply, option) != ERR_NONE) {
101         WLOGFE("SendRequest failed");
102         return DMError::DM_ERROR_IPC_FAILED;
103     }
104     return static_cast<DMError>(reply.ReadInt32());
105 }
106 
SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)107 DMError ScreenSessionManagerProxy::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
108 {
109     sptr<IRemoteObject> remote = Remote();
110     if (remote == nullptr) {
111         WLOGFW("SetVirtualPixelRatioSystem: remote is nullptr");
112         return DMError::DM_ERROR_IPC_FAILED;
113     }
114 
115     MessageParcel data;
116     MessageParcel reply;
117     MessageOption option;
118     if (!data.WriteInterfaceToken(GetDescriptor())) {
119         WLOGFE("WriteInterfaceToken failed");
120         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
121     }
122     if (!data.WriteUint64(screenId) || !data.WriteFloat(virtualPixelRatio)) {
123         WLOGFE("write screenId/modeId failed");
124         return DMError::DM_ERROR_IPC_FAILED;
125     }
126     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM),
127         data, reply, option) != ERR_NONE) {
128         WLOGFE("SendRequest failed");
129         return DMError::DM_ERROR_IPC_FAILED;
130     }
131     return static_cast<DMError>(reply.ReadInt32());
132 }
133 
SetDefaultDensityDpi(ScreenId screenId,float virtualPixelRatio)134 DMError ScreenSessionManagerProxy::SetDefaultDensityDpi(ScreenId screenId, float virtualPixelRatio)
135 {
136     sptr<IRemoteObject> remote = Remote();
137     if (remote == nullptr) {
138         WLOGFW("SetDefaultDensity: remote is nullptr");
139         return DMError::DM_ERROR_IPC_FAILED;
140     }
141 
142     MessageParcel data;
143     MessageParcel reply;
144     MessageOption option;
145     if (!data.WriteInterfaceToken(GetDescriptor())) {
146         WLOGFE("WriteInterfaceToken failed");
147         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
148     }
149     if (!data.WriteUint64(screenId) || !data.WriteFloat(virtualPixelRatio)) {
150         WLOGFE("write screenId/virtualPixelRatio failed");
151         return DMError::DM_ERROR_IPC_FAILED;
152     }
153     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_DEFAULT_DENSITY_DPI),
154         data, reply, option) != ERR_NONE) {
155         WLOGFE("SendRequest failed");
156         return DMError::DM_ERROR_IPC_FAILED;
157     }
158     return static_cast<DMError>(reply.ReadInt32());
159 }
160 
SetResolution(ScreenId screenId,uint32_t width,uint32_t height,float virtualPixelRatio)161 DMError ScreenSessionManagerProxy::SetResolution(ScreenId screenId, uint32_t width, uint32_t height,
162     float virtualPixelRatio)
163 {
164     sptr<IRemoteObject> remote = Remote();
165     if (remote == nullptr) {
166         WLOGFW("SetResolution: remote is nullptr");
167         return DMError::DM_ERROR_IPC_FAILED;
168     }
169 
170     MessageParcel data;
171     MessageParcel reply;
172     MessageOption option;
173     if (!data.WriteInterfaceToken(GetDescriptor())) {
174         WLOGFE("WriteInterfaceToken failed");
175         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
176     }
177     if (!data.WriteUint64(screenId) || !data.WriteUint32(width) ||
178         !data.WriteUint32(height) || !data.WriteFloat(virtualPixelRatio)) {
179         WLOGFE("write screenId/width/height/virtualPixelRatio failed");
180         return DMError::DM_ERROR_IPC_FAILED;
181     }
182     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_RESOLUTION),
183         data, reply, option) != ERR_NONE) {
184         WLOGFE("SendRequest failed");
185         return DMError::DM_ERROR_IPC_FAILED;
186     }
187     return static_cast<DMError>(reply.ReadInt32());
188 }
189 
GetDensityInCurResolution(ScreenId screenId,float & virtualPixelRatio)190 DMError ScreenSessionManagerProxy::GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio)
191 {
192     sptr<IRemoteObject> remote = Remote();
193     if (remote == nullptr) {
194         WLOGFW("GetDensityInCurResolution: remote is nullptr");
195         return DMError::DM_ERROR_IPC_FAILED;
196     }
197 
198     MessageParcel data;
199     MessageParcel reply;
200     MessageOption option;
201     if (!data.WriteInterfaceToken(GetDescriptor())) {
202         WLOGFE("WriteInterfaceToken failed");
203         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
204     }
205     if (!data.WriteUint64(screenId)) {
206         WLOGFE("write screenId failed");
207         return DMError::DM_ERROR_IPC_FAILED;
208     }
209     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION),
210         data, reply, option) != ERR_NONE) {
211         WLOGFE("SendRequest failed");
212         return DMError::DM_ERROR_IPC_FAILED;
213     }
214     virtualPixelRatio = reply.ReadFloat();
215     return static_cast<DMError>(reply.ReadInt32());
216 }
217 
GetScreenColorGamut(ScreenId screenId,ScreenColorGamut & colorGamut)218 DMError ScreenSessionManagerProxy::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut)
219 {
220     sptr<IRemoteObject> remote = Remote();
221     if (remote == nullptr) {
222         WLOGFW("DisplayManagerProxy::GetScreenColorGamut: remote is nullptr");
223         return DMError::DM_ERROR_NULLPTR;
224     }
225 
226     MessageParcel data;
227     MessageParcel reply;
228     MessageOption option;
229     if (!data.WriteInterfaceToken(GetDescriptor())) {
230         WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteInterfaceToken failed");
231         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
232     }
233     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
234         WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteUint64 uint64_t failed");
235         return DMError::DM_ERROR_IPC_FAILED;
236     }
237     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT),
238         data, reply, option) != ERR_NONE) {
239         WLOGFW("DisplayManagerProxy::GetScreenColorGamut: SendRequest failed");
240         return DMError::DM_ERROR_IPC_FAILED;
241     }
242     DMError ret = static_cast<DMError>(reply.ReadInt32());
243     if (ret != DMError::DM_OK) {
244         return ret;
245     }
246     colorGamut = static_cast<ScreenColorGamut>(reply.ReadUint32());
247     return ret;
248 }
249 
SetScreenColorGamut(ScreenId screenId,int32_t colorGamutIdx)250 DMError ScreenSessionManagerProxy::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx)
251 {
252     sptr<IRemoteObject> remote = Remote();
253     if (remote == nullptr) {
254         WLOGFW("DisplayManagerProxy::SetScreenColorGamut: remote is nullptr");
255         return DMError::DM_ERROR_NULLPTR;
256     }
257 
258     MessageParcel data;
259     MessageParcel reply;
260     MessageOption option;
261     if (!data.WriteInterfaceToken(GetDescriptor())) {
262         WLOGFW("DisplayManagerProxy::SetScreenColorGamut: WriteInterfaceToken failed");
263         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
264     }
265     if (!data.WriteUint64(static_cast<uint64_t>(screenId)) || !data.WriteInt32(colorGamutIdx)) {
266         WLOGFW("DisplayManagerProxy::SetScreenColorGamut: Write failed");
267         return DMError::DM_ERROR_IPC_FAILED;
268     }
269     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT),
270         data, reply, option) != ERR_NONE) {
271         WLOGFW("DisplayManagerProxy::SetScreenColorGamut: SendRequest failed");
272         return DMError::DM_ERROR_IPC_FAILED;
273     }
274     return static_cast<DMError>(reply.ReadInt32());
275 }
276 
GetScreenGamutMap(ScreenId screenId,ScreenGamutMap & gamutMap)277 DMError ScreenSessionManagerProxy::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap)
278 {
279     sptr<IRemoteObject> remote = Remote();
280     if (remote == nullptr) {
281         WLOGFW("DisplayManagerProxy::GetScreenGamutMap: remote is nullptr");
282         return DMError::DM_ERROR_NULLPTR;
283     }
284 
285     MessageParcel data;
286     MessageParcel reply;
287     MessageOption option;
288     if (!data.WriteInterfaceToken(GetDescriptor())) {
289         WLOGFW("DisplayManagerProxy::GetScreenGamutMap: WriteInterfaceToken failed");
290         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
291     }
292     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
293         WLOGFW("DisplayManagerProxy::GetScreenGamutMap: WriteUint64 screenId failed");
294         return DMError::DM_ERROR_IPC_FAILED;
295     }
296     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP),
297         data, reply, option) != ERR_NONE) {
298         WLOGFW("DisplayManagerProxy::GetScreenGamutMap: SendRequest failed");
299         return DMError::DM_ERROR_IPC_FAILED;
300     }
301     DMError ret = static_cast<DMError>(reply.ReadInt32());
302     if (ret != DMError::DM_OK) {
303         return ret;
304     }
305     gamutMap = static_cast<ScreenGamutMap>(reply.ReadUint32());
306     return ret;
307 }
308 
SetScreenGamutMap(ScreenId screenId,ScreenGamutMap gamutMap)309 DMError ScreenSessionManagerProxy::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap)
310 {
311     sptr<IRemoteObject> remote = Remote();
312     if (remote == nullptr) {
313         WLOGFW("DisplayManagerProxy::SetScreenGamutMap: remote is nullptr");
314         return DMError::DM_ERROR_NULLPTR;
315     }
316 
317     MessageParcel data;
318     MessageParcel reply;
319     MessageOption option;
320     if (!data.WriteInterfaceToken(GetDescriptor())) {
321         WLOGFW("DisplayManagerProxy::SetScreenGamutMap: WriteInterfaceToken failed");
322         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
323     }
324     if (!data.WriteUint64(static_cast<uint64_t>(screenId)) || !data.WriteUint32(static_cast<uint32_t>(gamutMap))) {
325         WLOGFW("DisplayManagerProxy::SetScreenGamutMap: Writ failed");
326         return DMError::DM_ERROR_IPC_FAILED;
327     }
328     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP),
329         data, reply, option) != ERR_NONE) {
330         WLOGFW("DisplayManagerProxy::SetScreenGamutMap: SendRequest failed");
331         return DMError::DM_ERROR_IPC_FAILED;
332     }
333     return static_cast<DMError>(reply.ReadInt32());
334 }
335 
SetScreenColorTransform(ScreenId screenId)336 DMError ScreenSessionManagerProxy::SetScreenColorTransform(ScreenId screenId)
337 {
338     sptr<IRemoteObject> remote = Remote();
339     if (remote == nullptr) {
340         WLOGFW("DisplayManagerProxy::SetScreenColorTransform: remote is nullptr");
341         return DMError::DM_ERROR_NULLPTR;
342     }
343 
344     MessageParcel data;
345     MessageParcel reply;
346     MessageOption option;
347     if (!data.WriteInterfaceToken(GetDescriptor())) {
348         WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteInterfaceToken failed");
349         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
350     }
351     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
352         WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteUint64 screenId failed");
353         return DMError::DM_ERROR_IPC_FAILED;
354     }
355     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM),
356         data, reply, option) != ERR_NONE) {
357         WLOGFW("DisplayManagerProxy::SetScreenColorTransform: SendRequest failed");
358         return DMError::DM_ERROR_IPC_FAILED;
359     }
360     return static_cast<DMError>(reply.ReadInt32());
361 }
362 
GetPixelFormat(ScreenId screenId,GraphicPixelFormat & pixelFormat)363 DMError ScreenSessionManagerProxy::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat)
364 {
365     sptr<IRemoteObject> remote = Remote();
366     if (remote == nullptr) {
367         WLOGFW("GetPixelFormat: remote is nullptr");
368         return DMError::DM_ERROR_NULLPTR;
369     }
370 
371     MessageParcel data;
372     MessageParcel reply;
373     MessageOption option;
374     if (!data.WriteInterfaceToken(GetDescriptor())) {
375         WLOGFW("GetPixelFormat: WriteInterfaceToken failed");
376         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
377     }
378     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
379         WLOGFW("GetPixelFormat: WriteUint64 uint64_t failed");
380         return DMError::DM_ERROR_IPC_FAILED;
381     }
382     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_PIXEL_FORMAT),
383         data, reply, option) != ERR_NONE) {
384         WLOGFW("GetPixelFormat: SendRequest failed");
385         return DMError::DM_ERROR_IPC_FAILED;
386     }
387     DMError ret = static_cast<DMError>(reply.ReadInt32());
388     if (ret != DMError::DM_OK) {
389         return ret;
390     }
391     pixelFormat = static_cast<GraphicPixelFormat>(reply.ReadUint32());
392     return ret;
393 }
394 
SetPixelFormat(ScreenId screenId,GraphicPixelFormat pixelFormat)395 DMError ScreenSessionManagerProxy::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat)
396 {
397     sptr<IRemoteObject> remote = Remote();
398     if (remote == nullptr) {
399         WLOGFW("SetPixelFormat: remote is nullptr");
400         return DMError::DM_ERROR_NULLPTR;
401     }
402 
403     MessageParcel data;
404     MessageParcel reply;
405     MessageOption option;
406     if (!data.WriteInterfaceToken(GetDescriptor())) {
407         WLOGFW("SetPixelFormat: WriteInterfaceToken failed");
408         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
409     }
410     if (!data.WriteUint64(static_cast<uint64_t>(screenId)) || !data.WriteInt32(pixelFormat)) {
411         WLOGFW("SetPixelFormat: WriteUint64 screenId failed");
412         return DMError::DM_ERROR_IPC_FAILED;
413     }
414     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_PIXEL_FORMAT),
415         data, reply, option) != ERR_NONE) {
416         WLOGFW("SetPixelFormat: SendRequest failed");
417         return DMError::DM_ERROR_IPC_FAILED;
418     }
419     return static_cast<DMError>(reply.ReadInt32());
420 }
421 
GetSupportedHDRFormats(ScreenId screenId,std::vector<ScreenHDRFormat> & hdrFormats)422 DMError ScreenSessionManagerProxy::GetSupportedHDRFormats(ScreenId screenId, std::vector<ScreenHDRFormat>& hdrFormats)
423 {
424     sptr<IRemoteObject> remote = Remote();
425     if (remote == nullptr) {
426         WLOGFW("GetSupportedHDRFormats: remote is nullptr");
427         return DMError::DM_ERROR_NULLPTR;
428     }
429 
430     MessageParcel data;
431     MessageParcel reply;
432     MessageOption option;
433     if (!data.WriteInterfaceToken(GetDescriptor())) {
434         WLOGFW("GetSupportedHDRFormats: WriteInterfaceToken failed");
435         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
436     }
437     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
438         WLOGFW("GetSupportedHDRFormats: WriteUint64 screenId failed");
439         return DMError::DM_ERROR_IPC_FAILED;
440     }
441     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT),
442         data, reply, option) != ERR_NONE) {
443         WLOGFW("GetSupportedHDRFormats: SendRequest failed");
444         return DMError::DM_ERROR_IPC_FAILED;
445     }
446     DMError ret = static_cast<DMError>(reply.ReadInt32());
447     if (ret != DMError::DM_OK) {
448         return ret;
449     }
450     MarshallingHelper::UnmarshallingVectorObj<ScreenHDRFormat>(reply, hdrFormats,
451         [](Parcel& parcel, ScreenHDRFormat& hdrFormat) {
452             uint32_t value;
453             bool res = parcel.ReadUint32(value);
454             hdrFormat = static_cast<ScreenHDRFormat>(value);
455             return res;
456         }
457     );
458     return ret;
459 }
460 
GetScreenHDRFormat(ScreenId screenId,ScreenHDRFormat & hdrFormat)461 DMError ScreenSessionManagerProxy::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat)
462 {
463     sptr<IRemoteObject> remote = Remote();
464     if (remote == nullptr) {
465         WLOGFW("GetScreenHDRFormat: remote is nullptr");
466         return DMError::DM_ERROR_NULLPTR;
467     }
468 
469     MessageParcel data;
470     MessageParcel reply;
471     MessageOption option;
472     if (!data.WriteInterfaceToken(GetDescriptor())) {
473         WLOGFW("GetScreenHDRFormat: WriteInterfaceToken failed");
474         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
475     }
476     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
477         WLOGFW("GetScreenHDRFormat: WriteUint64 uint64_t failed");
478         return DMError::DM_ERROR_IPC_FAILED;
479     }
480     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_HDR_FORMAT),
481         data, reply, option) != ERR_NONE) {
482         WLOGFW("GetScreenHDRFormat: SendRequest failed");
483         return DMError::DM_ERROR_IPC_FAILED;
484     }
485     DMError ret = static_cast<DMError>(reply.ReadInt32());
486     if (ret != DMError::DM_OK) {
487         return ret;
488     }
489     hdrFormat = static_cast<ScreenHDRFormat>(reply.ReadUint32());
490     return ret;
491 }
492 
SetScreenHDRFormat(ScreenId screenId,int32_t modeIdx)493 DMError ScreenSessionManagerProxy::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx)
494 {
495     sptr<IRemoteObject> remote = Remote();
496     if (remote == nullptr) {
497         WLOGFW("SetScreenHDRFormat: remote is nullptr");
498         return DMError::DM_ERROR_NULLPTR;
499     }
500 
501     MessageParcel data;
502     MessageParcel reply;
503     MessageOption option;
504     if (!data.WriteInterfaceToken(GetDescriptor())) {
505         WLOGFW("SetScreenHDRFormat: WriteInterfaceToken failed");
506         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
507     }
508     if (!data.WriteUint64(static_cast<uint64_t>(screenId)) || !data.WriteInt32(modeIdx)) {
509         WLOGFW("SetScreenHDRFormat: WriteUint64 screenId failed");
510         return DMError::DM_ERROR_IPC_FAILED;
511     }
512     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_HDR_FORMAT),
513         data, reply, option) != ERR_NONE) {
514         WLOGFW("SetScreenHDRFormat: SendRequest failed");
515         return DMError::DM_ERROR_IPC_FAILED;
516     }
517     return static_cast<DMError>(reply.ReadInt32());
518 }
519 
GetSupportedColorSpaces(ScreenId screenId,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)520 DMError ScreenSessionManagerProxy::GetSupportedColorSpaces(ScreenId screenId,
521     std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
522 {
523     sptr<IRemoteObject> remote = Remote();
524     if (remote == nullptr) {
525         WLOGFW("GetSupportedColorSpaces: remote is nullptr");
526         return DMError::DM_ERROR_NULLPTR;
527     }
528 
529     MessageParcel data;
530     MessageParcel reply;
531     MessageOption option;
532     if (!data.WriteInterfaceToken(GetDescriptor())) {
533         WLOGFW("GetSupportedColorSpaces: WriteInterfaceToken failed");
534         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
535     }
536     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
537         WLOGFW("GetSupportedColorSpaces: WriteUint64 screenId failed");
538         return DMError::DM_ERROR_IPC_FAILED;
539     }
540     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE),
541         data, reply, option) != ERR_NONE) {
542         WLOGFW("GetSupportedColorSpaces: SendRequest failed");
543         return DMError::DM_ERROR_IPC_FAILED;
544     }
545     DMError ret = static_cast<DMError>(reply.ReadInt32());
546     if (ret != DMError::DM_OK) {
547         return ret;
548     }
549     MarshallingHelper::UnmarshallingVectorObj<GraphicCM_ColorSpaceType>(reply, colorSpaces,
550         [](Parcel& parcel, GraphicCM_ColorSpaceType& color) {
551             uint32_t value;
552             bool res = parcel.ReadUint32(value);
553             color = static_cast<GraphicCM_ColorSpaceType>(value);
554             return res;
555         }
556     );
557     return ret;
558 }
559 
GetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType & colorSpace)560 DMError ScreenSessionManagerProxy::GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace)
561 {
562     sptr<IRemoteObject> remote = Remote();
563     if (remote == nullptr) {
564         WLOGFW("GetScreenColorSpace: remote is nullptr");
565         return DMError::DM_ERROR_NULLPTR;
566     }
567 
568     MessageParcel data;
569     MessageParcel reply;
570     MessageOption option;
571     if (!data.WriteInterfaceToken(GetDescriptor())) {
572         WLOGFW("GetScreenColorSpace: WriteInterfaceToken failed");
573         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
574     }
575     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
576         WLOGFW("GetScreenColorSpace: WriteUint64 screenId failed");
577         return DMError::DM_ERROR_IPC_FAILED;
578     }
579     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_SPACE),
580         data, reply, option) != ERR_NONE) {
581         WLOGFW("GetScreenColorSpace: SendRequest failed");
582         return DMError::DM_ERROR_IPC_FAILED;
583     }
584     DMError ret = static_cast<DMError>(reply.ReadInt32());
585     if (ret != DMError::DM_OK) {
586         return ret;
587     }
588     colorSpace = static_cast<GraphicCM_ColorSpaceType>(reply.ReadUint32());
589     return ret;
590 }
591 
SetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType colorSpace)592 DMError ScreenSessionManagerProxy::SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace)
593 {
594     sptr<IRemoteObject> remote = Remote();
595     if (remote == nullptr) {
596         WLOGFW("SetScreenColorSpace: remote is nullptr");
597         return DMError::DM_ERROR_NULLPTR;
598     }
599 
600     MessageParcel data;
601     MessageParcel reply;
602     MessageOption option;
603     if (!data.WriteInterfaceToken(GetDescriptor())) {
604         WLOGFW("SetScreenColorSpace: WriteInterfaceToken failed");
605         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
606     }
607     if (!data.WriteUint64(static_cast<uint64_t>(screenId)) || !data.WriteInt32(colorSpace)) {
608         WLOGFW("SetScreenColorSpace: Write failed");
609         return DMError::DM_ERROR_IPC_FAILED;
610     }
611     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_SPACE),
612         data, reply, option) != ERR_NONE) {
613         WLOGFW("SetScreenColorSpace: SendRequest failed");
614         return DMError::DM_ERROR_IPC_FAILED;
615     }
616     return static_cast<DMError>(reply.ReadInt32());
617 }
618 
RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)619 DMError ScreenSessionManagerProxy::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
620     DisplayManagerAgentType type)
621 {
622     sptr<IRemoteObject> remote = Remote();
623     if (remote == nullptr) {
624         WLOGFW("RegisterDisplayManagerAgent: remote is nullptr");
625         return DMError::DM_ERROR_IPC_FAILED;
626     }
627 
628     MessageParcel data;
629     MessageParcel reply;
630     MessageOption option;
631     if (!data.WriteInterfaceToken(GetDescriptor())) {
632         WLOGFE("WriteInterfaceToken failed");
633         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
634     }
635     if (displayManagerAgent == nullptr) {
636         WLOGFE("IDisplayManagerAgent is null");
637         return DMError::DM_ERROR_INVALID_PARAM;
638     }
639 
640     if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
641         WLOGFE("Write IDisplayManagerAgent failed");
642         return DMError::DM_ERROR_IPC_FAILED;
643     }
644 
645     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
646         WLOGFE("Write DisplayManagerAgent type failed");
647         return DMError::DM_ERROR_IPC_FAILED;
648     }
649 
650     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
651         data, reply, option) != ERR_NONE) {
652         WLOGFE("SendRequest failed");
653         return DMError::DM_ERROR_IPC_FAILED;
654     }
655     return static_cast<DMError>(reply.ReadInt32());
656 }
657 
UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent> & displayManagerAgent,DisplayManagerAgentType type)658 DMError ScreenSessionManagerProxy::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
659     DisplayManagerAgentType type)
660 {
661     sptr<IRemoteObject> remote = Remote();
662     if (remote == nullptr) {
663         WLOGFW("UnregisterDisplayManagerAgent: remote is nullptr");
664         return DMError::DM_ERROR_IPC_FAILED;
665     }
666 
667     MessageParcel data;
668     MessageParcel reply;
669     MessageOption option;
670     if (!data.WriteInterfaceToken(GetDescriptor())) {
671         WLOGFE("WriteInterfaceToken failed");
672         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
673     }
674 
675     if (displayManagerAgent == nullptr) {
676         WLOGFE("IDisplayManagerAgent is null");
677         return DMError::DM_ERROR_INVALID_PARAM;
678     }
679 
680     if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
681         WLOGFE("Write IWindowManagerAgent failed");
682         return DMError::DM_ERROR_IPC_FAILED;
683     }
684 
685     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
686         WLOGFE("Write DisplayManagerAgent type failed");
687         return DMError::DM_ERROR_IPC_FAILED;
688     }
689 
690     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT),
691         data, reply, option) != ERR_NONE) {
692         WLOGFE("SendRequest failed");
693         return DMError::DM_ERROR_IPC_FAILED;
694     }
695     return static_cast<DMError>(reply.ReadInt32());
696 }
697 
WakeUpBegin(PowerStateChangeReason reason)698 bool OHOS::Rosen::ScreenSessionManagerProxy::WakeUpBegin(PowerStateChangeReason reason)
699 {
700     sptr<IRemoteObject> remote = Remote();
701     if (remote == nullptr) {
702         WLOGFE("[UL_POWER]WakeUpBegin remote is nullptr");
703         return false;
704     }
705 
706     MessageParcel data;
707     MessageParcel reply;
708     MessageOption option;
709 
710     if (!data.WriteInterfaceToken(GetDescriptor())) {
711         WLOGFE("[UL_POWER]WakeUpBegin: WriteInterfaceToken failed");
712         return false;
713     }
714     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
715         WLOGFE("[UL_POWER]WakeUpBegin: Write PowerStateChangeReason failed");
716         return false;
717     }
718     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
719         data, reply, option) != ERR_NONE) {
720         WLOGFW("[UL_POWER]WakeUpBegin: SendRequest failed");
721         return false;
722     }
723     return reply.ReadBool();
724 }
725 
WakeUpEnd()726 bool OHOS::Rosen::ScreenSessionManagerProxy::WakeUpEnd()
727 {
728     sptr<IRemoteObject> remote = Remote();
729     if (remote == nullptr) {
730         WLOGFE("[UL_POWER]WakeUpEnd remote is nullptr");
731         return false;
732     }
733 
734     MessageParcel data;
735     MessageParcel reply;
736     MessageOption option;
737 
738     if (!data.WriteInterfaceToken(GetDescriptor())) {
739         WLOGFE("[UL_POWER]WakeUpEnd: WriteInterfaceToken failed");
740         return false;
741     }
742     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
743         data, reply, option) != ERR_NONE) {
744         WLOGFW("[UL_POWER]WakeUpEnd: SendRequest failed");
745         return false;
746     }
747     return reply.ReadBool();
748 }
749 
SuspendBegin(PowerStateChangeReason reason)750 bool OHOS::Rosen::ScreenSessionManagerProxy::SuspendBegin(PowerStateChangeReason reason)
751 {
752     sptr<IRemoteObject> remote = Remote();
753     if (remote == nullptr) {
754         WLOGFE("[UL_POWER]SuspendBegin remote is nullptr");
755         return false;
756     }
757 
758     MessageParcel data;
759     MessageParcel reply;
760     MessageOption option;
761 
762     if (!data.WriteInterfaceToken(GetDescriptor())) {
763         WLOGFE("[UL_POWER]SuspendBegin: WriteInterfaceToken failed");
764         return false;
765     }
766     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
767         WLOGFE("[UL_POWER]SuspendBegin: Write PowerStateChangeReason failed");
768         return false;
769     }
770     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN),
771         data, reply, option) != ERR_NONE) {
772         WLOGFW("[UL_POWER]SuspendBegin: SendRequest failed");
773         return false;
774     }
775     return reply.ReadBool();
776 }
777 
SuspendEnd()778 bool OHOS::Rosen::ScreenSessionManagerProxy::SuspendEnd()
779 {
780     sptr<IRemoteObject> remote = Remote();
781     if (remote == nullptr) {
782         WLOGFE("[UL_POWER]SuspendEnd remote is nullptr");
783         return false;
784     }
785 
786     MessageParcel data;
787     MessageParcel reply;
788     MessageOption option;
789 
790     if (!data.WriteInterfaceToken(GetDescriptor())) {
791         WLOGFE("[UL_POWER]SuspendEnd: WriteInterfaceToken failed");
792         return false;
793     }
794     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_END),
795         data, reply, option) != ERR_NONE) {
796         WLOGFW("[UL_POWER]SuspendEnd: SendRequest failed");
797         return false;
798     }
799     return reply.ReadBool();
800 }
801 
GetInternalScreenId()802 ScreenId OHOS::Rosen::ScreenSessionManagerProxy::GetInternalScreenId()
803 {
804     sptr<IRemoteObject> remote = Remote();
805     if (remote == nullptr) {
806         WLOGFE("[UL_POWER]GetInternalScreenId remote is nullptr");
807         return SCREEN_ID_INVALID;
808     }
809 
810     MessageParcel data;
811     MessageParcel reply;
812     MessageOption option(MessageOption::TF_SYNC);
813 
814     if (!data.WriteInterfaceToken(GetDescriptor())) {
815         WLOGFE("[UL_POWER]GetInternalScreenId: WriteInterfaceToken failed");
816         return SCREEN_ID_INVALID;
817     }
818     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_INTERNAL_SCREEN_ID),
819         data, reply, option) != ERR_NONE) {
820         WLOGFW("[UL_POWER]GetInternalScreenId: SendRequest failed");
821         return SCREEN_ID_INVALID;
822     }
823     return reply.ReadUint64();
824 }
825 
SetScreenPowerById(ScreenId screenId,ScreenPowerState state,PowerStateChangeReason reason)826 bool OHOS::Rosen::ScreenSessionManagerProxy::SetScreenPowerById(ScreenId screenId, ScreenPowerState state,
827     PowerStateChangeReason reason)
828 {
829     sptr<IRemoteObject> remote = Remote();
830     if (remote == nullptr) {
831         WLOGFE("[UL_POWER]SetScreenPowerById remote is nullptr");
832         return false;
833     }
834 
835     MessageParcel data;
836     MessageParcel reply;
837     MessageOption option(MessageOption::TF_SYNC);
838     if (!data.WriteInterfaceToken(GetDescriptor())) {
839         WLOGFE("[UL_POWER]WriteInterfaceToken failed");
840         return false;
841     }
842     if (!data.WriteUint64(screenId)) {
843         WLOGFE("[UL_POWER]Write ScreenId failed");
844         return false;
845     }
846     if (!data.WriteUint32(static_cast<uint32_t>(state))) {
847         WLOGFE("[UL_POWER]Write ScreenPowerState failed");
848         return false;
849     }
850     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
851         WLOGFE("[UL_POWER]Write PowerStateChangeReason failed");
852         return false;
853     }
854     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_BY_ID),
855         data, reply, option) != ERR_NONE) {
856         WLOGFW("[UL_POWER]SendRequest failed");
857         return false;
858     }
859     return reply.ReadBool();
860 }
861 
SetDisplayState(DisplayState state)862 bool OHOS::Rosen::ScreenSessionManagerProxy::SetDisplayState(DisplayState state)
863 {
864     sptr<IRemoteObject> remote = Remote();
865     if (remote == nullptr) {
866         WLOGFE("[UL_POWER]SetDisplayState remote is nullptr");
867         return false;
868     }
869 
870     MessageParcel data;
871     MessageParcel reply;
872     MessageOption option;
873     if (!data.WriteInterfaceToken(GetDescriptor())) {
874         WLOGFE("[UL_POWER]WriteInterfaceToken failed");
875         return false;
876     }
877     if (!data.WriteUint32(static_cast<uint32_t>(state))) {
878         WLOGFE("[UL_POWER]Write DisplayState failed");
879         return false;
880     }
881     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
882         data, reply, option) != ERR_NONE) {
883         WLOGFW("[UL_POWER]SendRequest failed");
884         return false;
885     }
886     return reply.ReadBool();
887 }
888 
SetSpecifiedScreenPower(ScreenId screenId,ScreenPowerState state,PowerStateChangeReason reason)889 bool OHOS::Rosen::ScreenSessionManagerProxy::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
890 {
891     sptr<IRemoteObject> remote = Remote();
892     if (remote == nullptr) {
893         WLOGFE("[UL_POWER]SetSpecifiedScreenPower remote is nullptr");
894         return false;
895     }
896 
897     MessageParcel data;
898     MessageParcel reply;
899     MessageOption option;
900     if (!data.WriteInterfaceToken(GetDescriptor())) {
901         WLOGFE("[UL_POWER]WriteInterfaceToken failed");
902         return false;
903     }
904     if (!data.WriteUint32(static_cast<uint32_t>(screenId))) {
905         WLOGFE("[UL_POWER]Write ScreenId failed");
906         return false;
907     }
908     if (!data.WriteUint32(static_cast<uint32_t>(state))) {
909         WLOGFE("[UL_POWER]Write ScreenPowerState failed");
910         return false;
911     }
912     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
913         WLOGFE("[UL_POWER]Write PowerStateChangeReason failed");
914         return false;
915     }
916     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER),
917         data, reply, option) != ERR_NONE) {
918         WLOGFW("[UL_POWER]SendRequest failed");
919         return false;
920     }
921     return reply.ReadBool();
922 }
923 
SetScreenPowerForAll(ScreenPowerState state,PowerStateChangeReason reason)924 bool OHOS::Rosen::ScreenSessionManagerProxy::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason)
925 {
926     sptr<IRemoteObject> remote = Remote();
927     if (remote == nullptr) {
928         WLOGFE("[UL_POWER]SetScreenPowerForAll remote is nullptr");
929         return false;
930     }
931 
932     MessageParcel data;
933     MessageParcel reply;
934     MessageOption option;
935     if (!data.WriteInterfaceToken(GetDescriptor())) {
936         WLOGFE("[UL_POWER]WriteInterfaceToken failed");
937         return false;
938     }
939     if (!data.WriteUint32(static_cast<uint32_t>(state))) {
940         WLOGFE("[UL_POWER]Write ScreenPowerState failed");
941         return false;
942     }
943     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
944         WLOGFE("[UL_POWER]Write PowerStateChangeReason failed");
945         return false;
946     }
947     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL),
948         data, reply, option) != ERR_NONE) {
949         WLOGFW("[UL_POWER]SendRequest failed");
950         return false;
951     }
952     return reply.ReadBool();
953 }
954 
GetDisplayState(DisplayId displayId)955 DisplayState OHOS::Rosen::ScreenSessionManagerProxy::GetDisplayState(DisplayId displayId)
956 {
957     sptr<IRemoteObject> remote = Remote();
958     if (remote == nullptr) {
959         WLOGFE("GetDisplayState remote is nullptr");
960         return DisplayState::UNKNOWN;
961     }
962 
963     MessageParcel data;
964     MessageParcel reply;
965     MessageOption option;
966     if (!data.WriteInterfaceToken(GetDescriptor())) {
967         WLOGFE("WriteInterfaceToken failed");
968         return DisplayState::UNKNOWN;
969     }
970     if (!data.WriteUint64(displayId)) {
971         WLOGFE("Write displayId failed");
972         return DisplayState::UNKNOWN;
973     }
974     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE),
975         data, reply, option) != ERR_NONE) {
976         WLOGFW("SendRequest failed");
977         return DisplayState::UNKNOWN;
978     }
979     return static_cast<DisplayState>(reply.ReadUint32());
980 }
981 
NotifyDisplayEvent(DisplayEvent event)982 void OHOS::Rosen::ScreenSessionManagerProxy::NotifyDisplayEvent(DisplayEvent event)
983 {
984     sptr<IRemoteObject> remote = Remote();
985     if (remote == nullptr) {
986         WLOGFE("[UL_POWER]NotifyDisplayEvent remote is nullptr");
987         return;
988     }
989 
990     MessageParcel data;
991     MessageParcel reply;
992     MessageOption option;
993     if (!data.WriteInterfaceToken(GetDescriptor())) {
994         WLOGFE("[UL_POWER]WriteInterfaceToken failed");
995         return;
996     }
997     if (!data.WriteUint32(static_cast<uint32_t>(event))) {
998         WLOGFE("[UL_POWER]Write DisplayEvent failed");
999         return;
1000     }
1001     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT),
1002         data, reply, option) != ERR_NONE) {
1003         WLOGFW("[UL_POWER]SendRequest failed");
1004         return;
1005     }
1006 }
1007 
GetScreenPower(ScreenId dmsScreenId)1008 ScreenPowerState OHOS::Rosen::ScreenSessionManagerProxy::GetScreenPower(ScreenId dmsScreenId)
1009 {
1010     sptr<IRemoteObject> remote = Remote();
1011     if (remote == nullptr) {
1012         WLOGFE("GetScreenPower remote is nullptr");
1013         return ScreenPowerState::INVALID_STATE;
1014     }
1015 
1016     MessageParcel data;
1017     MessageParcel reply;
1018     MessageOption option;
1019     if (!data.WriteInterfaceToken(GetDescriptor())) {
1020         WLOGFE("WriteInterfaceToken failed");
1021         return ScreenPowerState::INVALID_STATE;
1022     }
1023     if (!data.WriteUint64(static_cast<uint64_t>(dmsScreenId))) {
1024         WLOGFE("Write dmsScreenId failed");
1025         return ScreenPowerState::INVALID_STATE;
1026     }
1027     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER),
1028         data, reply, option) != ERR_NONE) {
1029         WLOGFW("SendRequest failed");
1030         return ScreenPowerState::INVALID_STATE;
1031     }
1032     return static_cast<ScreenPowerState>(reply.ReadUint32());
1033 }
1034 
GetScreenPower()1035 ScreenPowerState OHOS::Rosen::ScreenSessionManagerProxy::GetScreenPower()
1036 {
1037     sptr<IRemoteObject> remote = Remote();
1038     if (remote == nullptr) {
1039         WLOGFE("GetScreenPower remote is nullptr");
1040         return ScreenPowerState::INVALID_STATE;
1041     }
1042 
1043     MessageParcel data;
1044     MessageParcel reply;
1045     MessageOption option;
1046     if (!data.WriteInterfaceToken(GetDescriptor())) {
1047         WLOGFE("WriteInterfaceToken failed");
1048         return ScreenPowerState::INVALID_STATE;
1049     }
1050     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER_AUTO),
1051         data, reply, option) != ERR_NONE) {
1052         WLOGFW("SendRequest failed");
1053         return ScreenPowerState::INVALID_STATE;
1054     }
1055     return static_cast<ScreenPowerState>(reply.ReadUint32());
1056 }
1057 
TryToCancelScreenOff()1058 bool OHOS::Rosen::ScreenSessionManagerProxy::TryToCancelScreenOff()
1059 {
1060     sptr<IRemoteObject> remote = Remote();
1061     if (remote == nullptr) {
1062         WLOGFE("[UL_POWER]TryToCancelScreenOff remote is nullptr");
1063         return false;
1064     }
1065 
1066     MessageParcel data;
1067     MessageParcel reply;
1068     MessageOption option;
1069 
1070     if (!data.WriteInterfaceToken(GetDescriptor())) {
1071         WLOGFE("[UL_POWER]TryToCancelScreenOff: WriteInterfaceToken failed");
1072         return false;
1073     }
1074     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF),
1075         data, reply, option) != ERR_NONE) {
1076         WLOGFW("[UL_POWER]TryToCancelScreenOff: SendRequest failed");
1077         return false;
1078     }
1079     return reply.ReadBool();
1080 }
1081 
CreateVirtualScreen(VirtualScreenOption virtualOption,const sptr<IRemoteObject> & displayManagerAgent)1082 ScreenId ScreenSessionManagerProxy::CreateVirtualScreen(VirtualScreenOption virtualOption,
1083                                                         const sptr<IRemoteObject>& displayManagerAgent)
1084 {
1085     WLOGFI("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: ENTER");
1086     sptr<IRemoteObject> remote = Remote();
1087     if (remote == nullptr) {
1088         WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: remote is nullptr");
1089         return SCREEN_ID_INVALID;
1090     }
1091 
1092     MessageParcel data;
1093     MessageParcel reply;
1094     MessageOption option;
1095     if (!data.WriteInterfaceToken(GetDescriptor())) {
1096         WLOGFE("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: WriteInterfaceToken failed");
1097         return SCREEN_ID_INVALID;
1098     }
1099     bool res = data.WriteString(virtualOption.name_) && data.WriteUint32(virtualOption.width_) &&
1100         data.WriteUint32(virtualOption.height_) && data.WriteFloat(virtualOption.density_) &&
1101         data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_) &&
1102         data.WriteUInt64Vector(virtualOption.missionIds_) &&
1103         data.WriteUint32(static_cast<uint32_t>(virtualOption.virtualScreenType_));
1104     if (virtualOption.surface_ != nullptr && virtualOption.surface_->GetProducer() != nullptr) {
1105         res = res &&
1106             data.WriteBool(true) &&
1107             data.WriteRemoteObject(virtualOption.surface_->GetProducer()->AsObject());
1108     } else {
1109         WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: surface is nullptr");
1110         res = res && data.WriteBool(false);
1111     }
1112     if (displayManagerAgent != nullptr) {
1113         res = res &&
1114             data.WriteRemoteObject(displayManagerAgent);
1115     }
1116     if (!res) {
1117         WLOGFE("SCB: ScreenSessionManagerProxy::Write data failed");
1118         return SCREEN_ID_INVALID;
1119     }
1120     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN),
1121         data, reply, option) != ERR_NONE) {
1122         WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: SendRequest failed");
1123         return SCREEN_ID_INVALID;
1124     }
1125 
1126     ScreenId screenId = static_cast<ScreenId>(reply.ReadUint64());
1127     return screenId;
1128 }
1129 
SetVirtualScreenSurface(ScreenId screenId,sptr<IBufferProducer> surface)1130 DMError ScreenSessionManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface)
1131 {
1132     WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: ENTER");
1133     sptr<IRemoteObject> remote = Remote();
1134     if (remote == nullptr) {
1135         WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: remote is nullptr");
1136         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1137     }
1138 
1139     MessageParcel data;
1140     MessageParcel reply;
1141     MessageOption option;
1142     if (!data.WriteInterfaceToken(GetDescriptor())) {
1143         WLOGFE("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: WriteInterfaceToken failed");
1144         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1145     }
1146     bool res = data.WriteUint64(static_cast<uint64_t>(screenId));
1147     if (surface != nullptr) {
1148         res = res &&
1149             data.WriteBool(true) &&
1150             data.WriteRemoteObject(surface->AsObject());
1151     } else {
1152         WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: surface is nullptr");
1153         res = res && data.WriteBool(false);
1154     }
1155     if (!res) {
1156         WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: Write screenId/surface failed");
1157         return DMError::DM_ERROR_IPC_FAILED;
1158     }
1159     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE),
1160         data, reply, option) != ERR_NONE) {
1161         WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: SendRequest failed");
1162         return DMError::DM_ERROR_IPC_FAILED;
1163     }
1164     return static_cast<DMError>(reply.ReadInt32());
1165 }
1166 
AddVirtualScreenBlockList(const std::vector<int32_t> & persistentIds)1167 DMError ScreenSessionManagerProxy::AddVirtualScreenBlockList(const std::vector<int32_t>& persistentIds)
1168 {
1169     sptr<IRemoteObject> remote = Remote();
1170     if (remote == nullptr) {
1171         TLOGW(WmsLogTag::DMS, "remote is nullptr");
1172         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1173     }
1174 
1175     MessageParcel data;
1176     MessageParcel reply;
1177     MessageOption option;
1178     if (!data.WriteInterfaceToken(GetDescriptor())) {
1179         TLOGE(WmsLogTag::DMS, "write token failed");
1180         return DMError::DM_ERROR_IPC_FAILED;
1181     }
1182     if (!data.WriteUint64(persistentIds.size())) {
1183         TLOGE(WmsLogTag::DMS, "write size failed");
1184         return DMError::DM_ERROR_IPC_FAILED;
1185     }
1186     for (const auto persistentId : persistentIds) {
1187         if (!data.WriteInt32(persistentId)) {
1188             TLOGE(WmsLogTag::DMS, "write persistentId failed");
1189             return DMError::DM_ERROR_IPC_FAILED;
1190         }
1191     }
1192     if (remote->SendRequest(
1193         static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_ADD_VIRTUAL_SCREEN_BLOCK_LIST),
1194         data, reply, option) != ERR_NONE) {
1195         TLOGE(WmsLogTag::DMS, "SendRequest failed");
1196         return DMError::DM_ERROR_IPC_FAILED;
1197     }
1198     return static_cast<DMError>(reply.ReadInt32());
1199 }
1200 
RemoveVirtualScreenBlockList(const std::vector<int32_t> & persistentIds)1201 DMError ScreenSessionManagerProxy::RemoveVirtualScreenBlockList(const std::vector<int32_t>& persistentIds)
1202 {
1203     sptr<IRemoteObject> remote = Remote();
1204     if (remote == nullptr) {
1205         TLOGW(WmsLogTag::DMS, "remote is nullptr");
1206         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1207     }
1208 
1209     MessageParcel data;
1210     MessageParcel reply;
1211     MessageOption option;
1212     if (!data.WriteInterfaceToken(GetDescriptor())) {
1213         TLOGE(WmsLogTag::DMS, "write token failed");
1214         return DMError::DM_ERROR_IPC_FAILED;
1215     }
1216     if (!data.WriteUint64(persistentIds.size())) {
1217         TLOGE(WmsLogTag::DMS, "write size failed");
1218         return DMError::DM_ERROR_IPC_FAILED;
1219     }
1220     for (const auto persistentId : persistentIds) {
1221         if (!data.WriteInt32(persistentId)) {
1222             TLOGE(WmsLogTag::DMS, "write persistentId failed");
1223             return DMError::DM_ERROR_IPC_FAILED;
1224         }
1225     }
1226     if (remote->SendRequest(
1227         static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_BLOCK_LIST),
1228         data, reply, option) != ERR_NONE) {
1229         TLOGE(WmsLogTag::DMS, "SendRequest failed");
1230         return DMError::DM_ERROR_IPC_FAILED;
1231     }
1232     return static_cast<DMError>(reply.ReadInt32());
1233 }
1234 
SetScreenPrivacyMaskImage(ScreenId screenId,const std::shared_ptr<Media::PixelMap> & privacyMaskImg)1235 DMError ScreenSessionManagerProxy::SetScreenPrivacyMaskImage(ScreenId screenId,
1236     const std::shared_ptr<Media::PixelMap>& privacyMaskImg)
1237 {
1238     WLOGFW("SCB: ScreenSessionManagerProxy::SetScreenPrivacyMaskImage: ENTER");
1239     sptr<IRemoteObject> remote = Remote();
1240     if (remote == nullptr) {
1241         WLOGFW("SCB: ScreenSessionManagerProxy::SetScreenPrivacyMaskImage: remote is nullptr");
1242         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1243     }
1244 
1245     MessageParcel data;
1246     MessageParcel reply;
1247     MessageOption option;
1248     if (!data.WriteInterfaceToken(GetDescriptor())) {
1249         WLOGFE("SCB: ScreenSessionManagerProxy::SetScreenPrivacyMaskImage: WriteInterfaceToken failed");
1250         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1251     }
1252     if (privacyMaskImg != nullptr) {
1253         if (!data.WriteBool(true) || !data.WriteParcelable(privacyMaskImg.get())) {
1254             WLOGFW("SCB: ScreenSessionManagerProxy::SetScreenPrivacyMaskImage: Write privacyMaskImg failed");
1255             return DMError::DM_ERROR_IPC_FAILED;
1256         }
1257     } else {
1258         if (!data.WriteBool(false)) {
1259             WLOGFW("SCB: ScreenSessionManagerProxy::SetScreenPrivacyMaskImage: failed");
1260             return DMError::DM_ERROR_IPC_FAILED;
1261         }
1262     }
1263     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
1264         WLOGFW("SCB: ScreenSessionManagerProxy::SetScreenPrivacyMaskImage: Write screenId failed");
1265         return DMError::DM_ERROR_IPC_FAILED;
1266     }
1267 
1268     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_PRIVACY_MASKIMAGE),
1269         data, reply, option) != ERR_NONE) {
1270     WLOGFW("SCB: ScreenSessionManagerProxy::SetScreenPrivacyMaskImage: SendRequest failed");
1271     return DMError::DM_ERROR_IPC_FAILED;
1272     }
1273     return static_cast<DMError>(reply.ReadInt32());
1274 }
1275 
SetVirtualMirrorScreenCanvasRotation(ScreenId screenId,bool canvasRotation)1276 DMError ScreenSessionManagerProxy::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation)
1277 {
1278     WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualMirrorScreenCanvasRotation: ENTER");
1279     sptr<IRemoteObject> remote = Remote();
1280     if (remote == nullptr) {
1281         WLOGFW("SCB: SetVirtualMirrorScreenCanvasRotation: remote is nullptr");
1282         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1283     }
1284 
1285     MessageParcel data;
1286     MessageParcel reply;
1287     MessageOption option;
1288     if (!data.WriteInterfaceToken(GetDescriptor())) {
1289         WLOGFE("SCB: SetVirtualMirrorScreenCanvasRotation: WriteInterfaceToken failed");
1290         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1291     }
1292     bool res = data.WriteUint64(static_cast<uint64_t>(screenId)) && data.WriteBool(canvasRotation);
1293     if (!res) {
1294         WLOGFW("SCB:SetVirtualMirrorScreenCanvasRotation: Write screenId/bufferRotation failed");
1295         return DMError::DM_ERROR_IPC_FAILED;
1296     }
1297     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_CANVAS_ROTATION),
1298         data, reply, option) != ERR_NONE) {
1299         WLOGFW("SCB:SetVirtualMirrorScreenCanvasRotation: SendRequest failed");
1300         return DMError::DM_ERROR_IPC_FAILED;
1301     }
1302     return static_cast<DMError>(reply.ReadInt32());
1303 }
1304 
SetVirtualMirrorScreenScaleMode(ScreenId screenId,ScreenScaleMode scaleMode)1305 DMError ScreenSessionManagerProxy::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
1306 {
1307     sptr<IRemoteObject> remote = Remote();
1308     if (remote == nullptr) {
1309         WLOGFW("SetVirtualMirrorScreenScaleMode: remote is nullptr");
1310         return DMError::DM_ERROR_IPC_FAILED;
1311     }
1312 
1313     if (screenId == SCREEN_ID_INVALID) {
1314         return DMError::DM_ERROR_INVALID_PARAM;
1315     }
1316     MessageParcel data;
1317     MessageParcel reply;
1318     MessageOption option;
1319     if (!data.WriteInterfaceToken(GetDescriptor())) {
1320         WLOGFE("WriteInterfaceToken failed");
1321         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1322     }
1323     bool res = data.WriteUint64(static_cast<uint64_t>(screenId)) && data.WriteUint32(static_cast<uint32_t>(scaleMode));
1324     if (!res) {
1325         WLOGFE("Write screenId/scaleMode failed");
1326         return DMError::DM_ERROR_WRITE_DATA_FAILED;
1327     }
1328     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE),
1329         data, reply, option) != ERR_NONE) {
1330         WLOGFW("SendRequest failed");
1331         return DMError::DM_ERROR_IPC_FAILED;
1332     }
1333     return static_cast<DMError>(reply.ReadInt32());
1334 }
1335 
ResizeVirtualScreen(ScreenId screenId,uint32_t width,uint32_t height)1336 DMError ScreenSessionManagerProxy::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)
1337 {
1338     WLOGFI("ScreenSessionManagerProxy::ResizeVirtualScreen: ENTER");
1339     sptr<IRemoteObject> remote = Remote();
1340     if (remote == nullptr) {
1341         WLOGFW("ScreenSessionManagerProxy::ResizeVirtualScreen: remote is nullptr");
1342         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1343     }
1344 
1345     MessageParcel data;
1346     MessageParcel reply;
1347     MessageOption option;
1348 
1349     if (!data.WriteInterfaceToken(GetDescriptor())) {
1350         WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteInterfaceToken failed");
1351         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1352     }
1353     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
1354         WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteUnit64 screenId failed");
1355         return DMError::DM_ERROR_IPC_FAILED;
1356     }
1357     if (!data.WriteUint32(width)) {
1358         WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteUnit32 width failed");
1359         return DMError::DM_ERROR_IPC_FAILED;
1360     }
1361     if (!data.WriteUint32(height)) {
1362         WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteUnit32 height failed");
1363         return DMError::DM_ERROR_IPC_FAILED;
1364     }
1365     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_RESIZE_VIRTUAL_SCREEN),
1366         data, reply, option) != ERR_NONE) {
1367         WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen fail: SendRequest failed");
1368         return DMError::DM_ERROR_NULLPTR;
1369     }
1370     return static_cast<DMError>(reply.ReadInt32());
1371 }
1372 
DestroyVirtualScreen(ScreenId screenId)1373 DMError ScreenSessionManagerProxy::DestroyVirtualScreen(ScreenId screenId)
1374 {
1375     WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: ENTER");
1376     sptr<IRemoteObject> remote = Remote();
1377     if (remote == nullptr) {
1378         WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: remote is nullptr");
1379         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1380     }
1381 
1382     MessageParcel data;
1383     MessageParcel reply;
1384     MessageOption option;
1385     if (!data.WriteInterfaceToken(GetDescriptor())) {
1386         WLOGFE("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: WriteInterfaceToken failed");
1387         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1388     }
1389     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
1390         WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: WriteUint64 screenId failed");
1391         return DMError::DM_ERROR_IPC_FAILED;
1392     }
1393     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN),
1394         data, reply, option) != ERR_NONE) {
1395         WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: SendRequest failed");
1396         return DMError::DM_ERROR_IPC_FAILED;
1397     }
1398     return static_cast<DMError>(reply.ReadInt32());
1399 }
1400 
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenIds,ScreenId & screenGroupId)1401 DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId,
1402                                               std::vector<ScreenId> mirrorScreenIds, ScreenId& screenGroupId)
1403 {
1404     WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: ENTER");
1405     sptr<IRemoteObject> remote = Remote();
1406     if (remote == nullptr) {
1407         WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: remote is null");
1408         return DMError::DM_ERROR_NULLPTR;
1409     }
1410 
1411     MessageParcel data;
1412     MessageParcel reply;
1413     MessageOption option;
1414     if (!data.WriteInterfaceToken(GetDescriptor())) {
1415         WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: WriteInterfaceToken failed");
1416         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1417     }
1418     bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
1419         data.WriteUInt64Vector(mirrorScreenIds);
1420     if (!res) {
1421         WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: data write failed");
1422         return DMError::DM_ERROR_IPC_FAILED;
1423     }
1424     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR),
1425         data, reply, option) != ERR_NONE) {
1426         WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: SendRequest failed");
1427         return DMError::DM_ERROR_IPC_FAILED;
1428     }
1429     DMError ret = static_cast<DMError>(reply.ReadInt32());
1430     screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
1431     return ret;
1432 }
1433 
MakeMirrorForRecord(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenIds,ScreenId & screenGroupId)1434 DMError ScreenSessionManagerProxy::MakeMirrorForRecord(ScreenId mainScreenId,
1435     std::vector<ScreenId> mirrorScreenIds, ScreenId& screenGroupId)
1436 {
1437     WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: ENTER");
1438     sptr<IRemoteObject> remote = Remote();
1439     if (remote == nullptr) {
1440         WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: remote is null");
1441         return DMError::DM_ERROR_NULLPTR;
1442     }
1443 
1444     MessageParcel data;
1445     MessageParcel reply;
1446     MessageOption option;
1447     if (!data.WriteInterfaceToken(GetDescriptor())) {
1448         WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: WriteInterfaceToken failed");
1449         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1450     }
1451     bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
1452         data.WriteUInt64Vector(mirrorScreenIds);
1453     if (!res) {
1454         WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: data write failed");
1455         return DMError::DM_ERROR_IPC_FAILED;
1456     }
1457     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR_FOR_RECORD),
1458         data, reply, option) != ERR_NONE) {
1459         WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: SendRequest failed");
1460         return DMError::DM_ERROR_IPC_FAILED;
1461     }
1462     DMError ret = static_cast<DMError>(reply.ReadInt32());
1463     screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
1464     return ret;
1465 }
1466 
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenIds,DMRect mainScreenRegion,ScreenId & screenGroupId)1467 DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
1468                                               DMRect mainScreenRegion, ScreenId& screenGroupId)
1469 {
1470     WLOGFW("ScreenSessionManagerProxy::MakeMirror: ENTER");
1471     sptr<IRemoteObject> remote = Remote();
1472     if (remote == nullptr) {
1473         WLOGFW("ScreenSessionManagerProxy::MakeMirror: create mirror fail: remote is null");
1474         return DMError::DM_ERROR_NULLPTR;
1475     }
1476 
1477     MessageParcel data;
1478     MessageParcel reply;
1479     MessageOption option;
1480     if (!data.WriteInterfaceToken(GetDescriptor())) {
1481         WLOGFE("ScreenSessionManagerProxy::MakeMirror: create mirror fail: WriteInterfaceToken failed");
1482         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1483     }
1484     bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
1485         data.WriteUInt64Vector(mirrorScreenIds);
1486     if (!res) {
1487         WLOGFE("ScreenSessionManagerProxy::MakeMirror: create mirror fail: write screenId failed");
1488         return DMError::DM_ERROR_IPC_FAILED;
1489     }
1490     if (!data.WriteInt32(mainScreenRegion.posX_) || !data.WriteInt32(mainScreenRegion.posY_) ||
1491         !data.WriteUint32(mainScreenRegion.width_) || !data.WriteUint32(mainScreenRegion.height_)) {
1492         WLOGFE("ScreenSessionManagerProxy::MakeMirror: Write mainScreenRegion failed");
1493         return DMError::DM_ERROR_IPC_FAILED;
1494     }
1495     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR_WITH_REGION),
1496         data, reply, option) != ERR_NONE) {
1497         WLOGFW("ScreenSessionManagerProxy::MakeMirror: create mirror fail: SendRequest failed");
1498         return DMError::DM_ERROR_IPC_FAILED;
1499     }
1500     DMError ret = static_cast<DMError>(reply.ReadInt32());
1501     screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
1502     return ret;
1503 }
1504 
SetMultiScreenMode(ScreenId mainScreenId,ScreenId secondaryScreenId,MultiScreenMode screenMode)1505 DMError ScreenSessionManagerProxy::SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId,
1506     MultiScreenMode screenMode)
1507 {
1508     sptr<IRemoteObject> remote = Remote();
1509     if (remote == nullptr) {
1510         WLOGFW("remote is null");
1511         return DMError::DM_ERROR_NULLPTR;
1512     }
1513 
1514     MessageParcel data;
1515     MessageParcel reply;
1516     MessageOption option;
1517     if (!data.WriteInterfaceToken(GetDescriptor())) {
1518         WLOGFE("WriteInterfaceToken failed");
1519         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1520     }
1521     bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
1522         data.WriteUint64(static_cast<uint64_t>(secondaryScreenId)) &&
1523         data.WriteUint32(static_cast<uint32_t>(screenMode));
1524     if (!res) {
1525         WLOGFE("data write failed");
1526         return DMError::DM_ERROR_IPC_FAILED;
1527     }
1528     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_MULTI_SCREEN_MODE_SWITCH),
1529         data, reply, option) != ERR_NONE) {
1530         WLOGFW("SendRequest failed");
1531         return DMError::DM_ERROR_IPC_FAILED;
1532     }
1533     DMError ret = static_cast<DMError>(reply.ReadInt32());
1534     return ret;
1535 }
1536 
SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions,MultiScreenPositionOptions secondScreenOption)1537 DMError ScreenSessionManagerProxy::SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions,
1538     MultiScreenPositionOptions secondScreenOption)
1539 {
1540     sptr<IRemoteObject> remote = Remote();
1541     if (remote == nullptr) {
1542         WLOGFW("remote is null");
1543         return DMError::DM_ERROR_NULLPTR;
1544     }
1545 
1546     MessageParcel data;
1547     MessageParcel reply;
1548     MessageOption option;
1549     if (!data.WriteInterfaceToken(GetDescriptor())) {
1550         WLOGFE("WriteInterfaceToken failed");
1551         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1552     }
1553     bool res = data.WriteUint64(mainScreenOptions.screenId_) &&
1554         data.WriteUint32(mainScreenOptions.startX_) && data.WriteUint32(mainScreenOptions.startY_) &&
1555         data.WriteUint64(secondScreenOption.screenId_) &&
1556         data.WriteUint32(secondScreenOption.startX_) && data.WriteUint32(secondScreenOption.startY_);
1557     if (!res) {
1558         WLOGFE("data write failed");
1559         return DMError::DM_ERROR_IPC_FAILED;
1560     }
1561     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_MULTI_SCREEN_POSITION),
1562         data, reply, option) != ERR_NONE) {
1563         WLOGFW("SendRequest failed");
1564         return DMError::DM_ERROR_IPC_FAILED;
1565     }
1566     DMError ret = static_cast<DMError>(reply.ReadInt32());
1567     return ret;
1568 }
1569 
StopMirror(const std::vector<ScreenId> & mirrorScreenIds)1570 DMError ScreenSessionManagerProxy::StopMirror(const std::vector<ScreenId>& mirrorScreenIds)
1571 {
1572     sptr<IRemoteObject> remote = Remote();
1573     if (remote == nullptr) {
1574         WLOGFW("StopMirror fail: remote is null");
1575         return DMError::DM_ERROR_NULLPTR;
1576     }
1577 
1578     MessageParcel data;
1579     MessageParcel reply;
1580     MessageOption option;
1581     if (!data.WriteInterfaceToken(GetDescriptor())) {
1582         WLOGFE("StopMirror fail: WriteInterfaceToken failed");
1583         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1584     }
1585     bool res = data.WriteUInt64Vector(mirrorScreenIds);
1586     if (!res) {
1587         WLOGFE("StopMirror fail: data write failed");
1588         return DMError::DM_ERROR_IPC_FAILED;
1589     }
1590     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR),
1591         data, reply, option) != ERR_NONE) {
1592         WLOGFW("StopMirror fail: SendRequest failed");
1593         return DMError::DM_ERROR_IPC_FAILED;
1594     }
1595     return static_cast<DMError>(reply.ReadInt32());
1596 }
1597 
DisableMirror(bool disableOrNot)1598 DMError ScreenSessionManagerProxy::DisableMirror(bool disableOrNot)
1599 {
1600     WLOGFI("SCB: ScreenSessionManagerProxy::DisableMirror %{public}d", disableOrNot);
1601     sptr<IRemoteObject> remote = Remote();
1602     if (remote == nullptr) {
1603         WLOGFW("DisableMirror fail: remote is null");
1604         return DMError::DM_ERROR_NULLPTR;
1605     }
1606 
1607     MessageParcel data;
1608     MessageParcel reply;
1609     MessageOption option;
1610     if (!data.WriteInterfaceToken(GetDescriptor())) {
1611         WLOGFE("DisableMirror fail: WriteinterfaceToken failed");
1612         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1613     }
1614     if (!data.WriteBool(disableOrNot)) {
1615         WLOGFE("DisableMirror fail: data write failed");
1616         return DMError::DM_ERROR_IPC_FAILED;
1617     }
1618     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_DISABLE_MIRROR),
1619         data, reply, option) != ERR_NONE) {
1620         WLOGFW("DisableMirror fail: SendRequest failed");
1621         return DMError::DM_ERROR_IPC_FAILED;
1622     }
1623     return static_cast<DMError>(reply.ReadInt32());
1624 }
1625 
MakeExpand(std::vector<ScreenId> screenId,std::vector<Point> startPoint,ScreenId & screenGroupId)1626 DMError ScreenSessionManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
1627                                               ScreenId& screenGroupId)
1628 {
1629     WLOGFW("SCB: ScreenSessionManagerProxy::MakeExpand: ENTER");
1630     sptr<IRemoteObject> remote = Remote();
1631     if (remote == nullptr) {
1632         WLOGFW("SCB: ScreenSessionManagerProxy::MakeExpand: remote is null");
1633         return DMError::DM_ERROR_IPC_FAILED;
1634     }
1635 
1636     MessageParcel data;
1637     MessageParcel reply;
1638     MessageOption option;
1639     if (!data.WriteInterfaceToken(GetDescriptor())) {
1640         WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: WriteInterfaceToken failed");
1641         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1642     }
1643     if (!data.WriteUInt64Vector(screenId)) {
1644         WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: write screenId failed");
1645         return DMError::DM_ERROR_IPC_FAILED;
1646     }
1647     if (!MarshallingHelper::MarshallingVectorObj<Point>(data, startPoint, [](Parcel& parcel, const Point& point) {
1648             return parcel.WriteInt32(point.posX_) && parcel.WriteInt32(point.posY_);
1649         })) {
1650         WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: write startPoint failed");
1651         return DMError::DM_ERROR_IPC_FAILED;
1652     }
1653     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND),
1654         data, reply, option) != ERR_NONE) {
1655         WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: SendRequest failed");
1656         return DMError::DM_ERROR_IPC_FAILED;
1657     }
1658     DMError ret = static_cast<DMError>(reply.ReadInt32());
1659     screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
1660     return ret;
1661 }
1662 
StopExpand(const std::vector<ScreenId> & expandScreenIds)1663 DMError ScreenSessionManagerProxy::StopExpand(const std::vector<ScreenId>& expandScreenIds)
1664 {
1665     sptr<IRemoteObject> remote = Remote();
1666     if (remote == nullptr) {
1667         WLOGFW("StopExpand fail: remote is null");
1668         return DMError::DM_ERROR_NULLPTR;
1669     }
1670 
1671     MessageParcel data;
1672     MessageParcel reply;
1673     MessageOption option;
1674     if (!data.WriteInterfaceToken(GetDescriptor())) {
1675         WLOGFE("StopExpand fail: WriteInterfaceToken failed");
1676         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1677     }
1678     bool res = data.WriteUInt64Vector(expandScreenIds);
1679     if (!res) {
1680         WLOGFE("StopExpand fail: data write failed");
1681         return DMError::DM_ERROR_IPC_FAILED;
1682     }
1683     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND),
1684         data, reply, option) != ERR_NONE) {
1685         WLOGFW("StopExpand fail: SendRequest failed");
1686         return DMError::DM_ERROR_IPC_FAILED;
1687     }
1688     return static_cast<DMError>(reply.ReadInt32());
1689 }
1690 
GetScreenGroupInfoById(ScreenId screenId)1691 sptr<ScreenGroupInfo> ScreenSessionManagerProxy::GetScreenGroupInfoById(ScreenId screenId)
1692 {
1693     WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: ENTER!");
1694     sptr<IRemoteObject> remote = Remote();
1695     if (remote == nullptr) {
1696         WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: remote is nullptr");
1697         return nullptr;
1698     }
1699 
1700     MessageParcel data;
1701     MessageParcel reply;
1702     MessageOption option;
1703     if (!data.WriteInterfaceToken(GetDescriptor())) {
1704         WLOGFE("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: WriteInterfaceToken failed");
1705         return nullptr;
1706     }
1707     if (!data.WriteUint64(screenId)) {
1708         WLOGFE("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: Write screenId failed");
1709         return nullptr;
1710     }
1711     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID),
1712         data, reply, option) != ERR_NONE) {
1713         WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: SendRequest failed");
1714         return nullptr;
1715     }
1716 
1717     sptr<ScreenGroupInfo> info = reply.ReadStrongParcelable<ScreenGroupInfo>();
1718     if (info == nullptr) {
1719         WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById SendRequest nullptr.");
1720         return nullptr;
1721     }
1722     return info;
1723 }
1724 
RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)1725 void ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
1726 {
1727     WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: ENTER!");
1728     sptr<IRemoteObject> remote = Remote();
1729     if (remote == nullptr) {
1730         WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup:remote is null");
1731         return;
1732     }
1733 
1734     MessageParcel data;
1735     MessageParcel reply;
1736     MessageOption option(MessageOption::TF_ASYNC);
1737     if (!data.WriteInterfaceToken(GetDescriptor())) {
1738         WLOGFE("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: WriteInterfaceToken failed");
1739         return;
1740     }
1741     bool res = data.WriteUInt64Vector(screens);
1742     if (!res) {
1743         WLOGFE("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: write screens failed.");
1744         return;
1745     }
1746     if (remote->SendRequest(static_cast<uint32_t>(
1747         DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP),
1748         data, reply, option) != ERR_NONE) {
1749         WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup:: SendRequest failed");
1750     }
1751 }
1752 
GetDisplaySnapshot(DisplayId displayId,DmErrorCode * errorCode,bool isUseDma)1753 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetDisplaySnapshot(DisplayId displayId,
1754     DmErrorCode* errorCode, bool isUseDma)
1755 {
1756     WLOGFD("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot enter");
1757     sptr<IRemoteObject> remote = Remote();
1758     if (remote == nullptr) {
1759         WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: remote is nullptr");
1760         return nullptr;
1761     }
1762 
1763     MessageParcel data;
1764     MessageParcel reply;
1765     MessageOption option;
1766     if (!data.WriteInterfaceToken(GetDescriptor())) {
1767         WLOGFE("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: WriteInterfaceToken failed");
1768         return nullptr;
1769     }
1770 
1771     if (!data.WriteUint64(displayId)) {
1772         WLOGFE("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: Write displayId failed");
1773         return nullptr;
1774     }
1775 
1776     if (!data.WriteBool(isUseDma)) {
1777         WLOGFE("isUseDma fail: data write failed");
1778         return nullptr;
1779     }
1780 
1781     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT),
1782         data, reply, option) != ERR_NONE) {
1783         WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: SendRequest failed");
1784         return nullptr;
1785     }
1786 
1787     std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
1788     DmErrorCode replyErrorCode = static_cast<DmErrorCode>(reply.ReadInt32());
1789     if (errorCode) {
1790         *errorCode = replyErrorCode;
1791     }
1792     if (pixelMap == nullptr) {
1793         WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: SendRequest nullptr.");
1794         return nullptr;
1795     }
1796     return pixelMap;
1797 }
1798 
GetSnapshotByPicker(Media::Rect & rect,DmErrorCode * errorCode)1799 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetSnapshotByPicker(Media::Rect &rect,
1800     DmErrorCode* errorCode)
1801 {
1802     WLOGFD("enter");
1803     sptr<IRemoteObject> remote = Remote();
1804     *errorCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL;
1805     if (remote == nullptr) {
1806         WLOGFE("remote is nullptr");
1807         return nullptr;
1808     }
1809     MessageParcel data;
1810     MessageParcel reply;
1811     MessageOption option;
1812     if (!data.WriteInterfaceToken(GetDescriptor())) {
1813         WLOGFE("WriteInterfaceToken failed");
1814         return nullptr;
1815     }
1816     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SNAPSHOT_BY_PICKER),
1817         data, reply, option) != ERR_NONE) {
1818         WLOGFW("SendRequest failed");
1819         return nullptr;
1820     }
1821     std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>()); // need't to check nullptr
1822     *errorCode = static_cast<DmErrorCode>(reply.ReadInt32());
1823     rect.left = reply.ReadInt32();
1824     rect.top = reply.ReadInt32();
1825     rect.width = reply.ReadInt32();
1826     rect.height = reply.ReadInt32();
1827     return pixelMap;
1828 }
1829 
GetDisplayInfoById(DisplayId displayId)1830 sptr<DisplayInfo> ScreenSessionManagerProxy::GetDisplayInfoById(DisplayId displayId)
1831 {
1832     sptr<IRemoteObject> remote = Remote();
1833     if (remote == nullptr) {
1834         WLOGFW("GetDisplayInfoById: remote is nullptr");
1835         return nullptr;
1836     }
1837 
1838     MessageParcel data;
1839     MessageParcel reply;
1840     MessageOption option;
1841     if (!data.WriteInterfaceToken(GetDescriptor())) {
1842         WLOGFE("GetDisplayInfoById: WriteInterfaceToken failed");
1843         return nullptr;
1844     }
1845     if (!data.WriteUint64(displayId)) {
1846         WLOGFW("GetDisplayInfoById: WriteUint64 displayId failed");
1847         return nullptr;
1848     }
1849     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID),
1850         data, reply, option) != ERR_NONE) {
1851         WLOGFW("GetDisplayInfoById: SendRequest failed");
1852         return nullptr;
1853     }
1854 
1855     sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
1856     if (info == nullptr) {
1857         WLOGFW("DisplayManagerProxy::GetDisplayInfoById SendRequest nullptr.");
1858         return nullptr;
1859     }
1860     return info;
1861 }
1862 
GetVisibleAreaDisplayInfoById(DisplayId displayId)1863 sptr<DisplayInfo> ScreenSessionManagerProxy::GetVisibleAreaDisplayInfoById(DisplayId displayId)
1864 {
1865     sptr<IRemoteObject> remote = Remote();
1866     if (remote == nullptr) {
1867         WLOGFW("remote is nullptr");
1868         return nullptr;
1869     }
1870 
1871     MessageParcel data;
1872     MessageParcel reply;
1873     MessageOption option;
1874     if (!data.WriteInterfaceToken(GetDescriptor())) {
1875         WLOGFE("WriteInterfaceToken failed");
1876         return nullptr;
1877     }
1878     if (!data.WriteUint64(displayId)) {
1879         WLOGFW("WriteUint64 displayId failed");
1880         return nullptr;
1881     }
1882     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_VISIBLE_AREA_DISPLAY_INFO_BY_ID),
1883         data, reply, option) != ERR_NONE) {
1884         WLOGFW("SendRequest failed");
1885         return nullptr;
1886     }
1887 
1888     sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
1889     if (info == nullptr) {
1890         WLOGFW("SendRequest nullptr.");
1891         return nullptr;
1892     }
1893     return info;
1894 }
1895 
GetDisplayInfoByScreen(ScreenId screenId)1896 sptr<DisplayInfo> ScreenSessionManagerProxy::GetDisplayInfoByScreen(ScreenId screenId)
1897 {
1898     sptr<IRemoteObject> remote = Remote();
1899     if (remote == nullptr) {
1900         WLOGFE("fail to get displayInfo by screenId: remote is null");
1901         return nullptr;
1902     }
1903 
1904     MessageParcel data;
1905     MessageParcel reply;
1906     MessageOption option;
1907     if (!data.WriteInterfaceToken(GetDescriptor())) {
1908         WLOGFE("fail to get displayInfo by screenId: WriteInterfaceToken failed");
1909         return nullptr;
1910     }
1911     if (!data.WriteUint64(screenId)) {
1912         WLOGFW("fail to get displayInfo by screenId: WriteUint64 displayId failed");
1913         return nullptr;
1914     }
1915     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN),
1916         data, reply, option) != ERR_NONE) {
1917         WLOGFW("fail to get displayInfo by screenId: SendRequest failed");
1918         return nullptr;
1919     }
1920 
1921     sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
1922     if (info == nullptr) {
1923         WLOGFW("fail to get displayInfo by screenId: SendRequest null");
1924         return nullptr;
1925     }
1926     return info;
1927 }
1928 
GetAllDisplayIds()1929 std::vector<DisplayId> ScreenSessionManagerProxy::GetAllDisplayIds()
1930 {
1931     std::vector<DisplayId> allDisplayIds;
1932     sptr<IRemoteObject> remote = Remote();
1933     if (remote == nullptr) {
1934         WLOGFE("GetAllDisplayIds: remote is null");
1935         return allDisplayIds;
1936     }
1937 
1938     MessageParcel data;
1939     MessageParcel reply;
1940     MessageOption option;
1941     if (!data.WriteInterfaceToken(GetDescriptor())) {
1942         WLOGFE("WriteInterfaceToken failed");
1943         return allDisplayIds;
1944     }
1945     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
1946         data, reply, option) != ERR_NONE) {
1947         WLOGFW("SendRequest failed");
1948         return allDisplayIds;
1949     }
1950     reply.ReadUInt64Vector(&allDisplayIds);
1951     return allDisplayIds;
1952 }
1953 
GetScreenInfoById(ScreenId screenId)1954 sptr<ScreenInfo> ScreenSessionManagerProxy::GetScreenInfoById(ScreenId screenId)
1955 {
1956     sptr<IRemoteObject> remote = Remote();
1957     if (remote == nullptr) {
1958         WLOGFW("GetScreenInfoById: remote is nullptr");
1959         return nullptr;
1960     }
1961 
1962     MessageParcel data;
1963     MessageParcel reply;
1964     MessageOption option;
1965     if (!data.WriteInterfaceToken(GetDescriptor())) {
1966         WLOGFE("GetScreenInfoById: WriteInterfaceToken failed");
1967         return nullptr;
1968     }
1969     if (!data.WriteUint64(screenId)) {
1970         WLOGFE("GetScreenInfoById: Write screenId failed");
1971         return nullptr;
1972     }
1973     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID),
1974         data, reply, option) != ERR_NONE) {
1975         WLOGFW("GetScreenInfoById: SendRequest failed");
1976         return nullptr;
1977     }
1978 
1979     sptr<ScreenInfo> info = reply.ReadStrongParcelable<ScreenInfo>();
1980     if (info == nullptr) {
1981         WLOGFW("GetScreenInfoById SendRequest nullptr.");
1982         return nullptr;
1983     }
1984     for (auto& mode : info->GetModes()) {
1985         WLOGFD("info modes is id: %{public}u, width: %{public}u, height: %{public}u, refreshRate: %{public}u",
1986             mode->id_, mode->width_, mode->height_, mode->refreshRate_);
1987     }
1988     return info;
1989 }
1990 
GetAllScreenInfos(std::vector<sptr<ScreenInfo>> & screenInfos)1991 DMError ScreenSessionManagerProxy::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
1992 {
1993     sptr<IRemoteObject> remote = Remote();
1994     if (remote == nullptr) {
1995         WLOGFW("GetAllScreenInfos: remote is nullptr");
1996         return DMError::DM_ERROR_NULLPTR;
1997     }
1998 
1999     MessageParcel data;
2000     MessageParcel reply;
2001     MessageOption option;
2002     if (!data.WriteInterfaceToken(GetDescriptor())) {
2003         WLOGFE("GetAllScreenInfos: WriteInterfaceToken failed");
2004         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2005     }
2006     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS),
2007         data, reply, option) != ERR_NONE) {
2008         WLOGFW("GetAllScreenInfos: SendRequest failed");
2009         return DMError::DM_ERROR_IPC_FAILED;
2010     }
2011     DMError ret = static_cast<DMError>(reply.ReadInt32());
2012     MarshallingHelper::UnmarshallingVectorParcelableObj<ScreenInfo>(reply, screenInfos);
2013     return ret;
2014 }
2015 
GetScreenSupportedColorGamuts(ScreenId screenId,std::vector<ScreenColorGamut> & colorGamuts)2016 DMError ScreenSessionManagerProxy::GetScreenSupportedColorGamuts(ScreenId screenId,
2017     std::vector<ScreenColorGamut>& colorGamuts)
2018 {
2019     sptr<IRemoteObject> remote = Remote();
2020     if (remote == nullptr) {
2021         WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: remote is nullptr");
2022         return DMError::DM_ERROR_NULLPTR;
2023     }
2024 
2025     MessageParcel data;
2026     MessageParcel reply;
2027     MessageOption option;
2028     if (!data.WriteInterfaceToken(GetDescriptor())) {
2029         WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteInterfaceToken failed");
2030         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2031     }
2032     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
2033         WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteUint64 screenId failed");
2034         return DMError::DM_ERROR_IPC_FAILED;
2035     }
2036     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS),
2037         data, reply, option) != ERR_NONE) {
2038         WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: SendRequest failed");
2039         return DMError::DM_ERROR_IPC_FAILED;
2040     }
2041     DMError ret = static_cast<DMError>(reply.ReadInt32());
2042     if (ret != DMError::DM_OK) {
2043         return ret;
2044     }
2045     MarshallingHelper::UnmarshallingVectorObj<ScreenColorGamut>(reply, colorGamuts,
2046         [](Parcel& parcel, ScreenColorGamut& color) {
2047             uint32_t value;
2048             bool res = parcel.ReadUint32(value);
2049             color = static_cast<ScreenColorGamut>(value);
2050             return res;
2051         }
2052     );
2053     return ret;
2054 }
2055 
SetOrientation(ScreenId screenId,Orientation orientation)2056 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetOrientation(ScreenId screenId, Orientation orientation)
2057 {
2058     sptr<IRemoteObject> remote = Remote();
2059     if (remote == nullptr) {
2060         WLOGFW("fail to set orientation: remote is null");
2061         return DMError::DM_ERROR_NULLPTR;
2062     }
2063 
2064     MessageParcel data;
2065     MessageParcel reply;
2066     MessageOption option;
2067     if (!data.WriteInterfaceToken(GetDescriptor())) {
2068         WLOGFE("fail to set orientation: WriteInterfaceToken failed");
2069         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2070     }
2071     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
2072         WLOGFW("fail to set orientation: Write screenId failed");
2073         return DMError::DM_ERROR_IPC_FAILED;
2074     }
2075     if (!data.WriteUint32(static_cast<uint32_t>(orientation))) {
2076         WLOGFW("fail to set orientation: Write orientation failed");
2077         return DMError::DM_ERROR_IPC_FAILED;
2078     }
2079     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_ORIENTATION),
2080         data, reply, option) != ERR_NONE) {
2081         WLOGFW("fail to set orientation: SendRequest failed");
2082         return DMError::DM_ERROR_IPC_FAILED;
2083     }
2084     return static_cast<DMError>(reply.ReadInt32());
2085 }
2086 
SetScreenRotationLocked(bool isLocked)2087 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetScreenRotationLocked(bool isLocked)
2088 {
2089     sptr<IRemoteObject> remote = Remote();
2090     if (remote == nullptr) {
2091         WLOGFW("remote is null");
2092         return DMError::DM_ERROR_NULLPTR;
2093     }
2094 
2095     MessageParcel data;
2096     MessageParcel reply;
2097     MessageOption option;
2098     if (!data.WriteInterfaceToken(GetDescriptor())) {
2099         WLOGFE("WriteInterfaceToken failed");
2100         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2101     }
2102     if (!data.WriteBool(isLocked)) {
2103         WLOGFE("write isLocked failed");
2104         return DMError::DM_ERROR_IPC_FAILED;
2105     }
2106     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED),
2107         data, reply, option) != ERR_NONE) {
2108         WLOGFE("SendRequest failed");
2109         return DMError::DM_ERROR_IPC_FAILED;
2110     }
2111     return static_cast<DMError>(reply.ReadInt32());
2112 }
2113 
SetScreenRotationLockedFromJs(bool isLocked)2114 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetScreenRotationLockedFromJs(bool isLocked)
2115 {
2116     sptr<IRemoteObject> remote = Remote();
2117     if (remote == nullptr) {
2118         WLOGFW("remote is null");
2119         return DMError::DM_ERROR_NULLPTR;
2120     }
2121 
2122     MessageParcel data;
2123     MessageParcel reply;
2124     MessageOption option;
2125     if (!data.WriteInterfaceToken(GetDescriptor())) {
2126         WLOGFE("WriteInterfaceToken failed");
2127         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2128     }
2129     if (!data.WriteBool(isLocked)) {
2130         WLOGFE("write isLocked failed");
2131         return DMError::DM_ERROR_IPC_FAILED;
2132     }
2133     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS),
2134         data, reply, option) != ERR_NONE) {
2135         WLOGFE("SendRequest failed");
2136         return DMError::DM_ERROR_IPC_FAILED;
2137     }
2138     return static_cast<DMError>(reply.ReadInt32());
2139 }
2140 
IsScreenRotationLocked(bool & isLocked)2141 DMError OHOS::Rosen::ScreenSessionManagerProxy::IsScreenRotationLocked(bool& isLocked)
2142 {
2143     sptr<IRemoteObject> remote = Remote();
2144     if (remote == nullptr) {
2145         WLOGFW("remote is nullptr");
2146         return DMError::DM_ERROR_NULLPTR;
2147     }
2148 
2149     MessageParcel data;
2150     MessageParcel reply;
2151     MessageOption option;
2152     if (!data.WriteInterfaceToken(GetDescriptor())) {
2153         WLOGFE("WriteInterfaceToken failed");
2154         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2155     }
2156     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED),
2157         data, reply, option) != ERR_NONE) {
2158         WLOGFW("SendRequest failed");
2159         return DMError::DM_ERROR_IPC_FAILED;
2160     }
2161     DMError ret = static_cast<DMError>(reply.ReadInt32());
2162     isLocked = reply.ReadBool();
2163     return ret;
2164 }
2165 
GetCutoutInfo(DisplayId displayId)2166 sptr<CutoutInfo> ScreenSessionManagerProxy::GetCutoutInfo(DisplayId displayId)
2167 {
2168     sptr<IRemoteObject> remote = Remote();
2169     if (remote == nullptr) {
2170         WLOGFW("get cutout info : remote is null");
2171         return nullptr;
2172     }
2173     MessageParcel data;
2174     MessageParcel reply;
2175     MessageOption option;
2176     if (!data.WriteInterfaceToken(GetDescriptor())) {
2177         WLOGFE("get cutout info : failed");
2178         return nullptr;
2179     }
2180     if (!data.WriteUint64(displayId)) {
2181         WLOGFE("get cutout info: write displayId failed");
2182         return nullptr;
2183     }
2184     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO),
2185         data, reply, option) != ERR_NONE) {
2186         WLOGFW("GetCutoutInfo: GetCutoutInfo failed");
2187         return nullptr;
2188     }
2189     sptr<CutoutInfo> info = reply.ReadParcelable<CutoutInfo>();
2190     return info;
2191 }
2192 
HasImmersiveWindow(ScreenId screenId,bool & immersive)2193 DMError ScreenSessionManagerProxy::HasImmersiveWindow(ScreenId screenId, bool& immersive)
2194 {
2195     sptr<IRemoteObject> remote = Remote();
2196     if (remote == nullptr) {
2197         WLOGFW("remote is nullptr");
2198         return DMError::DM_ERROR_NULLPTR;
2199     }
2200 
2201     MessageParcel data;
2202     MessageParcel reply;
2203     MessageOption option;
2204     if (!data.WriteInterfaceToken(GetDescriptor())) {
2205         WLOGFE("WriteInterfaceToken failed");
2206         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2207     }
2208     if (!data.WriteUint64(screenId)) {
2209         return DMError::DM_ERROR_IPC_FAILED;
2210     }
2211 
2212     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_HAS_IMMERSIVE_WINDOW),
2213         data, reply, option) != ERR_NONE) {
2214         WLOGFW("SendRequest failed");
2215         return DMError::DM_ERROR_IPC_FAILED;
2216     }
2217     DMError ret = static_cast<DMError>(reply.ReadInt32());
2218     immersive = reply.ReadBool();
2219     return ret;
2220 }
2221 
ConvertScreenIdToRsScreenId(ScreenId screenId,ScreenId & rsScreenId)2222 bool OHOS::Rosen::ScreenSessionManagerProxy::ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId)
2223 {
2224     sptr<IRemoteObject> remote = Remote();
2225     if (remote == nullptr) {
2226         WLOGFW("remote is nullptr");
2227         return false;
2228     }
2229 
2230     MessageParcel data;
2231     MessageParcel reply;
2232     MessageOption option;
2233     if (!data.WriteInterfaceToken(GetDescriptor())) {
2234         WLOGFE("WriteInterfaceToken failed");
2235         return false;
2236     }
2237 
2238     if (!data.WriteUint64(screenId)) {
2239         return false;
2240     }
2241 
2242     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_CONVERT_SCREENID_TO_RSSCREENID),
2243         data, reply, option) != ERR_NONE) {
2244         WLOGFW("SendRequest failed");
2245         return false;
2246     }
2247     bool ret = reply.ReadBool();
2248     rsScreenId = static_cast<ScreenId>(reply.ReadUint64());
2249     return ret;
2250 }
2251 
HasPrivateWindow(DisplayId displayId,bool & hasPrivateWindow)2252 DMError OHOS::Rosen::ScreenSessionManagerProxy::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow)
2253 {
2254     sptr<IRemoteObject> remote = Remote();
2255     if (remote == nullptr) {
2256         WLOGFW("remote is nullptr");
2257         return DMError::DM_ERROR_NULLPTR;
2258     }
2259 
2260     MessageParcel data;
2261     MessageParcel reply;
2262     MessageOption option;
2263     if (!data.WriteInterfaceToken(GetDescriptor())) {
2264         WLOGFE("WriteInterfaceToken failed");
2265         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2266     }
2267 
2268     if (!data.WriteUint64(displayId)) {
2269         return DMError::DM_ERROR_IPC_FAILED;
2270     }
2271 
2272     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW),
2273         data, reply, option) != ERR_NONE) {
2274         WLOGFW("SendRequest failed");
2275         return DMError::DM_ERROR_IPC_FAILED;
2276     }
2277     DMError ret = static_cast<DMError>(reply.ReadInt32());
2278     hasPrivateWindow = reply.ReadBool();
2279     return ret;
2280 }
2281 
DumpAllScreensInfo(std::string & dumpInfo)2282 void ScreenSessionManagerProxy::DumpAllScreensInfo(std::string& dumpInfo)
2283 {
2284     sptr<IRemoteObject> remote = Remote();
2285     if (remote == nullptr) {
2286         WLOGFW("remote is null");
2287         return;
2288     }
2289     MessageParcel data;
2290     MessageParcel reply;
2291     MessageOption option;
2292     if (!data.WriteInterfaceToken(GetDescriptor())) {
2293         WLOGFE("failed");
2294         return;
2295     }
2296     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN),
2297         data, reply, option) != ERR_NONE) {
2298         WLOGFW("failed");
2299         return;
2300     }
2301     dumpInfo = reply.ReadString();
2302 }
2303 
DumpSpecialScreenInfo(ScreenId id,std::string & dumpInfo)2304 void ScreenSessionManagerProxy::DumpSpecialScreenInfo(ScreenId id, std::string& dumpInfo)
2305 {
2306     sptr<IRemoteObject> remote = Remote();
2307     if (remote == nullptr) {
2308         WLOGFW("remote is null");
2309         return;
2310     }
2311     MessageParcel data;
2312     MessageParcel reply;
2313     MessageOption option;
2314     if (!data.WriteInterfaceToken(GetDescriptor())) {
2315         WLOGFE("failed");
2316         return;
2317     }
2318     if (!data.WriteUint64(id)) {
2319         WLOGFE("write ScreenId failed");
2320         return;
2321     }
2322     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_SPECIAL_SCREEN),
2323         data, reply, option) != ERR_NONE) {
2324         WLOGFW("failed");
2325         return;
2326     }
2327     dumpInfo = reply.ReadString();
2328 }
2329 
2330 //Fold Screen
SetFoldDisplayMode(const FoldDisplayMode displayMode)2331 void ScreenSessionManagerProxy::SetFoldDisplayMode(const FoldDisplayMode displayMode)
2332 {
2333     sptr<IRemoteObject> remote = Remote();
2334     if (remote == nullptr) {
2335         WLOGFW("remote is null");
2336         return;
2337     }
2338     MessageParcel data;
2339     MessageParcel reply;
2340     MessageOption option;
2341     if (!data.WriteInterfaceToken(GetDescriptor())) {
2342         WLOGFE("WriteInterfaceToken Failed");
2343         return;
2344     }
2345     if (!data.WriteUint32(static_cast<uint32_t>(displayMode))) {
2346         WLOGFE("Write displayMode failed");
2347         return;
2348     }
2349     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE),
2350                             data, reply, option) != ERR_NONE) {
2351         WLOGFE("Send TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE request failed");
2352     }
2353 }
2354 
2355 //SetFoldDisplayModeFromJs add DMError to return DMErrorCode for js
SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode,std::string reason)2356 DMError ScreenSessionManagerProxy::SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode, std::string reason)
2357 {
2358     sptr<IRemoteObject> remote = Remote();
2359     if (remote == nullptr) {
2360         WLOGFW("remote is null");
2361         return DMError::DM_ERROR_NULLPTR;
2362     }
2363     MessageParcel data;
2364     MessageParcel reply;
2365     MessageOption option;
2366     if (!data.WriteInterfaceToken(GetDescriptor())) {
2367         WLOGFE("WriteInterfaceToken Failed");
2368         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2369     }
2370     if (!data.WriteUint32(static_cast<uint32_t>(displayMode))) {
2371         WLOGFE("Write displayMode failed");
2372         return DMError::DM_ERROR_IPC_FAILED;
2373     }
2374     if (!data.WriteString(reason)) {
2375         WLOGFE("Write reason failed");
2376         return DMError::DM_ERROR_IPC_FAILED;
2377     }
2378     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE_FROM_JS),
2379                             data, reply, option) != ERR_NONE) {
2380         WLOGFE("Send request failed");
2381         return DMError::DM_ERROR_IPC_FAILED;
2382     }
2383 
2384     DMError ret = static_cast<DMError>(reply.ReadInt32());
2385     return ret;
2386 }
2387 
SetDisplayScale(ScreenId screenId,float scaleX,float scaleY,float pivotX,float pivotY)2388 void ScreenSessionManagerProxy::SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX,
2389     float pivotY)
2390 {
2391     sptr<IRemoteObject> remote = Remote();
2392     if (remote == nullptr) {
2393         WLOGFW("remote is null");
2394         return;
2395     }
2396     MessageParcel data;
2397     MessageParcel reply;
2398     MessageOption option;
2399     if (!data.WriteInterfaceToken(GetDescriptor())) {
2400         WLOGFE("WriteInterfaceToken Failed");
2401         return;
2402     }
2403     if (!(data.WriteUint64(static_cast<uint64_t>(screenId)) && data.WriteFloat(scaleX) && data.WriteFloat(scaleY) &&
2404         data.WriteFloat(pivotX) && data.WriteFloat(pivotY))) {
2405         WLOGFE("Write screen scale info failed");
2406         return;
2407     }
2408     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE),
2409                             data, reply, option) != ERR_NONE) {
2410         WLOGFE("Send TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE request failed");
2411     }
2412 }
2413 
SetFoldStatusLocked(bool locked)2414 void ScreenSessionManagerProxy::SetFoldStatusLocked(bool locked)
2415 {
2416     sptr<IRemoteObject> remote = Remote();
2417     if (remote == nullptr) {
2418         WLOGFW("remote is null");
2419         return;
2420     }
2421     MessageParcel data;
2422     MessageParcel reply;
2423     MessageOption option;
2424     if (!data.WriteInterfaceToken(GetDescriptor())) {
2425         WLOGFE("WriteInterfaceToken Failed");
2426         return;
2427     }
2428     if (!data.WriteUint32(static_cast<uint32_t>(locked))) {
2429         WLOGFE("Write lock fold display status failed");
2430         return;
2431     }
2432     if (remote->SendRequest(static_cast<uint32_t>(
2433                             DisplayManagerMessage::TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS),
2434                             data, reply, option) != ERR_NONE) {
2435         WLOGFE("Send TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS request failed");
2436     }
2437 }
2438 
2439 // SetFoldStatusLockedFromJs add DMError to return DMErrorCode for js
SetFoldStatusLockedFromJs(bool locked)2440 DMError ScreenSessionManagerProxy::SetFoldStatusLockedFromJs(bool locked)
2441 {
2442     sptr<IRemoteObject> remote = Remote();
2443     if (remote == nullptr) {
2444         WLOGFW("remote is null");
2445         return DMError::DM_ERROR_NULLPTR;
2446     }
2447     MessageParcel data;
2448     MessageParcel reply;
2449     MessageOption option;
2450     if (!data.WriteInterfaceToken(GetDescriptor())) {
2451         WLOGFE("WriteInterfaceToken Failed");
2452         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2453     }
2454     if (!data.WriteUint32(static_cast<uint32_t>(locked))) {
2455         WLOGFE("Write lock fold display status failed");
2456         return DMError::DM_ERROR_IPC_FAILED;
2457     }
2458     if (remote->SendRequest(static_cast<uint32_t>(
2459                             DisplayManagerMessage::TRANS_ID_SET_LOCK_FOLD_DISPLAY_STATUS_FROM_JS),
2460                             data, reply, option) != ERR_NONE) {
2461         WLOGFE("Send request failed");
2462         return DMError::DM_ERROR_IPC_FAILED;
2463     }
2464 
2465     DMError ret = static_cast<DMError>(reply.ReadInt32());
2466     return ret;
2467 }
2468 
GetFoldDisplayMode()2469 FoldDisplayMode ScreenSessionManagerProxy::GetFoldDisplayMode()
2470 {
2471     sptr<IRemoteObject> remote = Remote();
2472     if (remote == nullptr) {
2473         WLOGFW("remote is null");
2474         return FoldDisplayMode::UNKNOWN;
2475     }
2476     MessageParcel data;
2477     MessageParcel reply;
2478     MessageOption option;
2479     if (!data.WriteInterfaceToken(GetDescriptor())) {
2480         WLOGFE("WriteInterfaceToken Failed");
2481         return FoldDisplayMode::UNKNOWN;
2482     }
2483     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE),
2484                             data, reply, option) != ERR_NONE) {
2485         WLOGFE("Send TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE request failed");
2486         return FoldDisplayMode::UNKNOWN;
2487     }
2488     return static_cast<FoldDisplayMode>(reply.ReadUint32());
2489 }
2490 
IsFoldable()2491 bool ScreenSessionManagerProxy::IsFoldable()
2492 {
2493     sptr<IRemoteObject> remote = Remote();
2494     if (remote == nullptr) {
2495         WLOGFW("remote is null");
2496         return false;
2497     }
2498 
2499     MessageParcel data;
2500     MessageParcel reply;
2501     MessageOption option;
2502     if (!data.WriteInterfaceToken(GetDescriptor())) {
2503         WLOGFE("WriteInterfaceToken failed");
2504         return false;
2505     }
2506     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE),
2507         data, reply, option) != ERR_NONE) {
2508         WLOGFE("SendRequest failed");
2509         return false;
2510     }
2511     return reply.ReadBool();
2512 }
2513 
IsCaptured()2514 bool ScreenSessionManagerProxy::IsCaptured()
2515 {
2516     sptr<IRemoteObject> remote = Remote();
2517     if (remote == nullptr) {
2518         WLOGFW("remote is null");
2519         return false;
2520     }
2521 
2522     MessageParcel data;
2523     MessageParcel reply;
2524     MessageOption option;
2525     if (!data.WriteInterfaceToken(GetDescriptor())) {
2526         WLOGFE("WriteInterfaceToken failed");
2527         return false;
2528     }
2529     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DEVICE_IS_CAPTURE),
2530         data, reply, option) != ERR_NONE) {
2531         WLOGFE("SendRequest failed");
2532         return false;
2533     }
2534     return reply.ReadBool();
2535 }
2536 
IsOrientationNeedChanged()2537 bool ScreenSessionManagerProxy::IsOrientationNeedChanged()
2538 {
2539     sptr<IRemoteObject> remote = Remote();
2540     if (remote == nullptr) {
2541         WLOGFW("remote is null");
2542         return false;
2543     }
2544 
2545     MessageParcel data;
2546     MessageParcel reply;
2547     MessageOption option;
2548     if (!data.WriteInterfaceToken(GetDescriptor())) {
2549         WLOGFE("WriteInterfaceToken failed");
2550         return false;
2551     }
2552     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_IS_ORIENTATION_NEED_CHANGE),
2553         data, reply, option) != ERR_NONE) {
2554         WLOGFE("SendRequest failed");
2555         return false;
2556     }
2557     return reply.ReadBool();
2558 }
2559 
GetFoldStatus()2560 FoldStatus ScreenSessionManagerProxy::GetFoldStatus()
2561 {
2562     sptr<IRemoteObject> remote = Remote();
2563     if (remote == nullptr) {
2564         WLOGFW("remote is null");
2565         return FoldStatus::UNKNOWN;
2566     }
2567 
2568     MessageParcel data;
2569     MessageParcel reply;
2570     MessageOption option;
2571     if (!data.WriteInterfaceToken(GetDescriptor())) {
2572         WLOGFE("WriteInterfaceToken failed");
2573         return FoldStatus::UNKNOWN;
2574     }
2575     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS),
2576         data, reply, option) != ERR_NONE) {
2577         WLOGFE("SendRequest failed");
2578         return FoldStatus::UNKNOWN;
2579     }
2580     return static_cast<FoldStatus>(reply.ReadUint32());
2581 }
2582 
GetSuperFoldStatus()2583 SuperFoldStatus ScreenSessionManagerProxy::GetSuperFoldStatus()
2584 {
2585     sptr<IRemoteObject> remote = Remote();
2586     if (remote == nullptr) {
2587         WLOGFW("remote is null");
2588         return SuperFoldStatus::UNKNOWN;
2589     }
2590 
2591     MessageParcel data;
2592     MessageParcel reply;
2593     MessageOption option;
2594     if (!data.WriteInterfaceToken(GetDescriptor())) {
2595         WLOGFE("WriteInterfaceToken failed");
2596         return SuperFoldStatus::UNKNOWN;
2597     }
2598     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_SUPER_FOLD_STATUS),
2599         data, reply, option) != ERR_NONE) {
2600         WLOGFE("SendRequest failed");
2601         return SuperFoldStatus::UNKNOWN;
2602     }
2603     return static_cast<SuperFoldStatus>(reply.ReadUint32());
2604 }
2605 
SetLandscapeLockStatus(bool isLocked)2606 void ScreenSessionManagerProxy::SetLandscapeLockStatus(bool isLocked)
2607 {
2608     sptr<IRemoteObject> remote = Remote();
2609     if (remote == nullptr) {
2610         WLOGFW("remote is null");
2611         return;
2612     }
2613 
2614     MessageParcel data;
2615     MessageParcel reply;
2616     MessageOption option;
2617     if (!data.WriteInterfaceToken(GetDescriptor())) {
2618         WLOGFE("WriteInterfaceToken failed");
2619         return;
2620     }
2621     if (!data.WriteBool(isLocked)) {
2622         WLOGFE("Write isLocked failed");
2623         return;
2624     }
2625     if (remote->SendRequest(
2626         static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_LANDSCAPE_LOCK_STATUS),
2627         data, reply, option) != ERR_NONE) {
2628         WLOGFE("SendRequest failed");
2629         return;
2630     }
2631 }
2632 
GetExtendScreenConnectStatus()2633 ExtendScreenConnectStatus ScreenSessionManagerProxy::GetExtendScreenConnectStatus()
2634 {
2635     sptr<IRemoteObject> remote = Remote();
2636     if (remote == nullptr) {
2637         WLOGFW("remote is null");
2638         return ExtendScreenConnectStatus::UNKNOWN;
2639     }
2640 
2641     MessageParcel data;
2642     MessageParcel reply;
2643     MessageOption option;
2644     if (!data.WriteInterfaceToken(GetDescriptor())) {
2645         WLOGFE("WriteInterfaceToken failed");
2646         return ExtendScreenConnectStatus::UNKNOWN;
2647     }
2648     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_EXTEND_SCREEN_CONNECT_STATUS),
2649         data, reply, option) != ERR_NONE) {
2650         WLOGFE("SendRequest failed");
2651         return ExtendScreenConnectStatus::UNKNOWN;
2652     }
2653     return static_cast<ExtendScreenConnectStatus>(reply.ReadUint32());
2654 }
2655 
GetCurrentFoldCreaseRegion()2656 sptr<FoldCreaseRegion> ScreenSessionManagerProxy::GetCurrentFoldCreaseRegion()
2657 {
2658     sptr<IRemoteObject> remote = Remote();
2659     if (remote == nullptr) {
2660         WLOGFW("remote is null");
2661         return nullptr;
2662     }
2663 
2664     MessageParcel data;
2665     MessageParcel reply;
2666     MessageOption option;
2667     if (!data.WriteInterfaceToken(GetDescriptor())) {
2668         WLOGFE("WriteInterfaceToken failed");
2669         return nullptr;
2670     }
2671     if (remote->SendRequest(
2672         static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION),
2673         data, reply, option) != ERR_NONE) {
2674         WLOGFE("SendRequest failed");
2675         return nullptr;
2676     }
2677     return reply.ReadStrongParcelable<FoldCreaseRegion>();
2678 }
2679 
MakeUniqueScreen(const std::vector<ScreenId> & screenIds,std::vector<DisplayId> & displayIds)2680 DMError ScreenSessionManagerProxy::MakeUniqueScreen(const std::vector<ScreenId>& screenIds,
2681     std::vector<DisplayId>& displayIds)
2682 {
2683     WLOGFI("ScreenSessionManagerProxy::MakeUniqueScreen");
2684     sptr<IRemoteObject> remote = Remote();
2685     if (remote == nullptr) {
2686         WLOGFW("make unique screen failed: remote is null");
2687         return DMError::DM_ERROR_NULLPTR;
2688     }
2689 
2690     MessageParcel data;
2691     MessageParcel reply;
2692     MessageOption option;
2693     if (!data.WriteInterfaceToken(GetDescriptor())) {
2694         WLOGFE("MakeUniqueScreen writeInterfaceToken failed");
2695         return DMError::DM_ERROR_NULLPTR;
2696     }
2697     if (!data.WriteUint32(screenIds.size())) {
2698         WLOGFE("MakeUniqueScreen write screenIds size failed");
2699         return DMError::DM_ERROR_INVALID_PARAM;
2700     }
2701     bool res = data.WriteUInt64Vector(screenIds);
2702     if (!res) {
2703         WLOGFE("MakeUniqueScreen fail: write screens failed");
2704         return DMError::DM_ERROR_NULLPTR;
2705     }
2706     if (remote->SendRequest(
2707         static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN),
2708         data, reply, option) != ERR_NONE) {
2709         WLOGFE("MakeUniqueScreen fail: SendRequest failed");
2710         return DMError::DM_ERROR_NULLPTR;
2711     }
2712     reply.ReadUInt64Vector(&displayIds);
2713     return static_cast<DMError>(reply.ReadInt32());
2714 }
2715 
SetClient(const sptr<IScreenSessionManagerClient> & client)2716 void ScreenSessionManagerProxy::SetClient(const sptr<IScreenSessionManagerClient>& client)
2717 {
2718     sptr<IRemoteObject> remote = Remote();
2719     if (remote == nullptr) {
2720         WLOGFE("SetClient: remote is null");
2721         return;
2722     }
2723 
2724     MessageParcel data;
2725     MessageParcel reply;
2726     MessageOption option(MessageOption::TF_SYNC);
2727     if (!data.WriteInterfaceToken(GetDescriptor())) {
2728         WLOGFE("WriteInterfaceToken failed");
2729         return;
2730     }
2731     if (!client || !data.WriteRemoteObject(client->AsObject())) {
2732         WLOGFE("WriteRemoteObject failed");
2733         return;
2734     }
2735     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_CLIENT),
2736         data, reply, option) != ERR_NONE) {
2737         WLOGFE("SendRequest failed");
2738         return;
2739     }
2740 }
2741 
SwitchUser()2742 void ScreenSessionManagerProxy::SwitchUser()
2743 {
2744     sptr<IRemoteObject> remote = Remote();
2745     if (remote == nullptr) {
2746         WLOGFE("SwitchUser: remote is null");
2747         return;
2748     }
2749 
2750     MessageParcel data;
2751     MessageParcel reply;
2752     MessageOption option(MessageOption::TF_SYNC);
2753     if (!data.WriteInterfaceToken(GetDescriptor())) {
2754         WLOGFE("WriteInterfaceToken failed");
2755         return;
2756     }
2757     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SWITCH_USER),
2758         data, reply, option) != ERR_NONE) {
2759         WLOGFE("SendRequest failed");
2760         return;
2761     }
2762 }
2763 
GetScreenProperty(ScreenId screenId)2764 ScreenProperty ScreenSessionManagerProxy::GetScreenProperty(ScreenId screenId)
2765 {
2766     sptr<IRemoteObject> remote = Remote();
2767     if (remote == nullptr) {
2768         WLOGFE("GetScreenProperty: remote is null");
2769         return {};
2770     }
2771 
2772     MessageParcel data;
2773     MessageParcel reply;
2774     MessageOption option(MessageOption::TF_SYNC);
2775     if (!data.WriteInterfaceToken(GetDescriptor())) {
2776         WLOGFE("WriteInterfaceToken failed");
2777         return {};
2778     }
2779     if (!data.WriteUint64(screenId)) {
2780         WLOGFE("Write screenId failed");
2781         return {};
2782     }
2783     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_PROPERTY),
2784         data, reply, option) != ERR_NONE) {
2785         WLOGFE("SendRequest failed");
2786         return {};
2787     }
2788     ScreenProperty screenProperty;
2789     if (!RSMarshallingHelper::Unmarshalling(reply, screenProperty)) {
2790         WLOGFE("Read screenProperty failed");
2791         return {};
2792     }
2793     return screenProperty;
2794 }
2795 
GetDisplayNode(ScreenId screenId)2796 std::shared_ptr<RSDisplayNode> ScreenSessionManagerProxy::GetDisplayNode(ScreenId screenId)
2797 {
2798     sptr<IRemoteObject> remote = Remote();
2799     if (remote == nullptr) {
2800         WLOGFE("GetDisplayNode: remote is null");
2801         return nullptr;
2802     }
2803 
2804     MessageParcel data;
2805     MessageParcel reply;
2806     MessageOption option(MessageOption::TF_SYNC);
2807     if (!data.WriteInterfaceToken(GetDescriptor())) {
2808         WLOGFE("WriteInterfaceToken failed");
2809         return nullptr;
2810     }
2811     if (!data.WriteUint64(screenId)) {
2812         WLOGFE("Write screenId failed");
2813         return nullptr;
2814     }
2815     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_NODE),
2816         data, reply, option) != ERR_NONE) {
2817         WLOGFE("SendRequest failed");
2818         return nullptr;
2819     }
2820 
2821     auto displayNode = RSDisplayNode::Unmarshalling(reply);
2822     if (!displayNode) {
2823         WLOGFE("displayNode is null");
2824         return nullptr;
2825     }
2826     return displayNode;
2827 }
2828 
GetScreenCombination(ScreenId screenId)2829 ScreenCombination ScreenSessionManagerProxy::GetScreenCombination(ScreenId screenId)
2830 {
2831     sptr<IRemoteObject> remote = Remote();
2832     if (remote == nullptr) {
2833         WLOGFE("GetScreenCombination: remote is null");
2834         return ScreenCombination::SCREEN_ALONE;
2835     }
2836 
2837     MessageParcel data;
2838     MessageParcel reply;
2839     MessageOption option(MessageOption::TF_SYNC);
2840     if (!data.WriteInterfaceToken(GetDescriptor())) {
2841         WLOGFE("WriteInterfaceToken failed");
2842         return ScreenCombination::SCREEN_ALONE;
2843     }
2844     if (!data.WriteUint64(screenId)) {
2845         WLOGFE("Write screenId failed");
2846         return ScreenCombination::SCREEN_ALONE;
2847     }
2848     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_COMBINATION),
2849         data, reply, option) != ERR_NONE) {
2850         WLOGFE("SendRequest failed");
2851         return ScreenCombination::SCREEN_ALONE;
2852     }
2853     return static_cast<ScreenCombination>(reply.ReadUint32());
2854 }
2855 
UpdateScreenDirectionInfo(ScreenId screenId,float screenComponentRotation,float rotation,float phyRotation,ScreenPropertyChangeType screenPropertyChangeType)2856 void ScreenSessionManagerProxy::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation,
2857     float rotation, float phyRotation, ScreenPropertyChangeType screenPropertyChangeType)
2858 {
2859     sptr<IRemoteObject> remote = Remote();
2860     if (remote == nullptr) {
2861         WLOGFE("UpdateScreenDirectionInfo: remote is null");
2862         return;
2863     }
2864 
2865     MessageParcel data;
2866     MessageParcel reply;
2867     MessageOption option(MessageOption::TF_SYNC);
2868     if (!data.WriteInterfaceToken(GetDescriptor())) {
2869         WLOGFE("WriteInterfaceToken failed");
2870         return;
2871     }
2872     if (!data.WriteUint64(screenId)) {
2873         WLOGFE("Write screenId failed");
2874         return;
2875     }
2876     if (!data.WriteFloat(screenComponentRotation)) {
2877         WLOGFE("Write screenComponentRotation failed");
2878         return;
2879     }
2880     if (!data.WriteFloat(rotation)) {
2881         WLOGFE("Write rotation failed");
2882         return;
2883     }
2884     if (!data.WriteFloat(phyRotation)) {
2885         WLOGFE("Write phyRotation failed");
2886         return;
2887     }
2888     if (!data.WriteUint32(static_cast<uint32_t>(screenPropertyChangeType))) {
2889         WLOGFE("Write screenPropertyChangeType failed");
2890         return;
2891     }
2892     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO),
2893         data, reply, option) != ERR_NONE) {
2894         WLOGFE("SendRequest failed");
2895         return;
2896     }
2897 }
2898 
UpdateScreenRotationProperty(ScreenId screenId,const RRect & bounds,float rotation,ScreenPropertyChangeType screenPropertyChangeType)2899 void ScreenSessionManagerProxy::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
2900     ScreenPropertyChangeType screenPropertyChangeType)
2901 {
2902     sptr<IRemoteObject> remote = Remote();
2903     if (remote == nullptr) {
2904         WLOGFE("UpdateScreenRotationProperty: remote is null");
2905         return;
2906     }
2907 
2908     MessageParcel data;
2909     MessageParcel reply;
2910     MessageOption option(MessageOption::TF_SYNC);
2911     if (!data.WriteInterfaceToken(GetDescriptor())) {
2912         WLOGFE("WriteInterfaceToken failed");
2913         return;
2914     }
2915     if (!data.WriteUint64(screenId)) {
2916         WLOGFE("Write screenId failed");
2917         return;
2918     }
2919     if (!RSMarshallingHelper::Marshalling(data, bounds)) {
2920         WLOGFE("Write bounds failed");
2921         return;
2922     }
2923     if (!data.WriteFloat(rotation)) {
2924         WLOGFE("Write rotation failed");
2925         return;
2926     }
2927     if (!data.WriteUint32(static_cast<uint32_t>(screenPropertyChangeType))) {
2928         WLOGFE("Write screenPropertyChangeType failed");
2929         return;
2930     }
2931     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY),
2932         data, reply, option) != ERR_NONE) {
2933         WLOGFE("SendRequest failed");
2934         return;
2935     }
2936 }
2937 
GetCurvedCompressionArea()2938 uint32_t ScreenSessionManagerProxy::GetCurvedCompressionArea()
2939 {
2940     sptr<IRemoteObject> remote = Remote();
2941     if (remote == nullptr) {
2942         WLOGFE("GetCurvedCompressionArea: remote is null");
2943         return 0;
2944     }
2945 
2946     MessageParcel data;
2947     MessageParcel reply;
2948     MessageOption option(MessageOption::TF_SYNC);
2949     if (!data.WriteInterfaceToken(GetDescriptor())) {
2950         WLOGFE("WriteInterfaceToken failed");
2951         return 0;
2952     }
2953     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_CURVED_SCREEN_COMPRESSION_AREA),
2954         data, reply, option) != ERR_NONE) {
2955         WLOGFE("SendRequest failed");
2956         return 0;
2957     }
2958 
2959     return reply.ReadUint32();
2960 }
2961 
GetPhyScreenProperty(ScreenId screenId)2962 ScreenProperty ScreenSessionManagerProxy::GetPhyScreenProperty(ScreenId screenId)
2963 {
2964     sptr<IRemoteObject> remote = Remote();
2965     if (remote == nullptr) {
2966         WLOGFE("GetPhyScreenProperty: remote is null");
2967         return {};
2968     }
2969 
2970     MessageParcel data;
2971     MessageParcel reply;
2972     MessageOption option(MessageOption::TF_SYNC);
2973     if (!data.WriteInterfaceToken(GetDescriptor())) {
2974         WLOGFE("WriteInterfaceToken failed");
2975         return {};
2976     }
2977     if (!data.WriteUint64(screenId)) {
2978         WLOGFE("Write screenId failed");
2979         return {};
2980     }
2981     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_PHY_SCREEN_PROPERTY),
2982         data, reply, option) != ERR_NONE) {
2983         WLOGFE("SendRequest failed");
2984         return {};
2985     }
2986     ScreenProperty screenProperty;
2987     if (!RSMarshallingHelper::Unmarshalling(reply, screenProperty)) {
2988         WLOGFE("Read screenProperty failed");
2989         return {};
2990     }
2991     return screenProperty;
2992 }
2993 
NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo> & info)2994 void ScreenSessionManagerProxy::NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo>& info)
2995 {
2996     sptr<IRemoteObject> remote = Remote();
2997     if (remote == nullptr) {
2998         WLOGFE("NotifyDisplayChangeInfoChanged: remote is null");
2999         return;
3000     }
3001 
3002     MessageOption option(MessageOption::TF_ASYNC);
3003     MessageParcel reply;
3004     MessageParcel data;
3005     if (!data.WriteInterfaceToken(GetDescriptor())) {
3006         WLOGFE("WriteInterfaceToken failed");
3007         return;
3008     }
3009     if (!info->Marshalling(data)) {
3010         WLOGFE("Write display change info failed");
3011         return;
3012     }
3013     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_CHANGE_INFO),
3014         data, reply, option) != ERR_NONE) {
3015         WLOGFE("SendRequest failed");
3016         return;
3017     }
3018 }
3019 
SetScreenPrivacyState(bool hasPrivate)3020 void ScreenSessionManagerProxy::SetScreenPrivacyState(bool hasPrivate)
3021 {
3022     sptr<IRemoteObject> remote = Remote();
3023     if (remote == nullptr) {
3024         WLOGFE("SetScreenPrivacyState: remote is null");
3025         return;
3026     }
3027 
3028     MessageParcel data;
3029     MessageParcel reply;
3030     MessageOption option(MessageOption::TF_SYNC);
3031     if (!data.WriteInterfaceToken(GetDescriptor())) {
3032         WLOGFE("WriteInterfaceToken failed");
3033         return;
3034     }
3035     if (!data.WriteBool(hasPrivate)) {
3036         WLOGFE("Write hasPrivate failed");
3037         return;
3038     }
3039     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_PRIVACY_STATE),
3040         data, reply, option) != ERR_NONE) {
3041         WLOGFE("SendRequest failed");
3042         return;
3043     }
3044 }
3045 
SetPrivacyStateByDisplayId(DisplayId id,bool hasPrivate)3046 void ScreenSessionManagerProxy::SetPrivacyStateByDisplayId(DisplayId id, bool hasPrivate)
3047 {
3048     sptr<IRemoteObject> remote = Remote();
3049     if (remote == nullptr) {
3050         WLOGFE("SetPrivacyStateByDisplayId: remote is null");
3051         return;
3052     }
3053 
3054     MessageParcel data;
3055     MessageParcel reply;
3056     MessageOption option(MessageOption::TF_SYNC);
3057     if (!data.WriteInterfaceToken(GetDescriptor())) {
3058         WLOGFE("WriteInterfaceToken failed");
3059         return;
3060     }
3061     if (!data.WriteUint64(id)) {
3062         WLOGFE("Write DisplayId failed");
3063         return;
3064     }
3065     if (!data.WriteBool(hasPrivate)) {
3066         WLOGFE("Write hasPrivate failed");
3067         return;
3068     }
3069     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREENID_PRIVACY_STATE),
3070         data, reply, option) != ERR_NONE) {
3071         WLOGFE("SendRequest failed");
3072         return;
3073     }
3074 }
3075 
SetScreenPrivacyWindowList(DisplayId id,std::vector<std::string> privacyWindowList)3076 void ScreenSessionManagerProxy::SetScreenPrivacyWindowList(DisplayId id, std::vector<std::string> privacyWindowList)
3077 {
3078     sptr<IRemoteObject> remote = Remote();
3079     if (remote == nullptr) {
3080         WLOGFE("SetScreenPrivacyWindowList: remote is null");
3081         return;
3082     }
3083 
3084     MessageParcel data;
3085     MessageParcel reply;
3086     MessageOption option(MessageOption::TF_SYNC);
3087     if (!data.WriteInterfaceToken(GetDescriptor())) {
3088         WLOGFE("WriteInterfaceToken failed");
3089         return;
3090     }
3091     if (!data.WriteUint64(id)) {
3092         WLOGFE("Write DisplayId failed");
3093         return;
3094     }
3095     if (!data.WriteStringVector(privacyWindowList)) {
3096         WLOGFE("Write privacyWindowList failed");
3097         return;
3098     }
3099     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_PRIVACY_WINDOW_LIST),
3100         data, reply, option) != ERR_NONE) {
3101         WLOGFE("SendRequest failed");
3102         return;
3103     }
3104 }
3105 
UpdateAvailableArea(ScreenId screenId,DMRect area)3106 void ScreenSessionManagerProxy::UpdateAvailableArea(ScreenId screenId, DMRect area)
3107 {
3108     sptr<IRemoteObject> remote = Remote();
3109     if (remote == nullptr) {
3110         WLOGFE("UpdateAvailableArea: remote is null");
3111         return;
3112     }
3113 
3114     MessageOption option(MessageOption::TF_ASYNC);
3115     MessageParcel reply;
3116     MessageParcel data;
3117     if (!data.WriteInterfaceToken(GetDescriptor())) {
3118         WLOGFE("WriteInterfaceToken failed");
3119         return;
3120     }
3121     if (!data.WriteUint64(screenId)) {
3122         WLOGFE("Write screenId failed");
3123         return;
3124     }
3125     if (!data.WriteInt32(area.posX_) || !data.WriteInt32(area.posY_) || !data.WriteUint32(area.width_) ||
3126         !data.WriteInt32(area.height_)) {
3127         WLOGFE("Write area failed");
3128         return;
3129     }
3130     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_AVAILABLE_AREA),
3131         data, reply, option) != ERR_NONE) {
3132         WLOGFE("SendRequest failed");
3133         return;
3134     }
3135 }
3136 
UpdateSuperFoldAvailableArea(ScreenId screenId,DMRect bArea,DMRect cArea)3137 void ScreenSessionManagerProxy::UpdateSuperFoldAvailableArea(ScreenId screenId, DMRect bArea, DMRect cArea)
3138 {
3139     sptr<IRemoteObject> remote = Remote();
3140     if (remote == nullptr) {
3141         WLOGFE("UpdateSuperFoldAvailableArea: remote is null");
3142         return;
3143     }
3144 
3145     MessageOption option(MessageOption::TF_ASYNC);
3146     MessageParcel reply;
3147     MessageParcel data;
3148     if (!data.WriteInterfaceToken(GetDescriptor())) {
3149         WLOGFE("WriteInterfaceToken failed");
3150         return;
3151     }
3152     if (!data.WriteUint64(screenId)) {
3153         WLOGFE("Write screenId failed");
3154         return;
3155     }
3156     if (!data.WriteInt32(bArea.posX_) || !data.WriteInt32(bArea.posY_) || !data.WriteUint32(bArea.width_) ||
3157         !data.WriteUint32(bArea.height_)) {
3158         WLOGFE("Write bArea failed");
3159         return;
3160     }
3161     if (!data.WriteInt32(cArea.posX_) || !data.WriteInt32(cArea.posY_) || !data.WriteUint32(cArea.width_) ||
3162         !data.WriteUint32(cArea.height_)) {
3163         WLOGFE("Write cArea failed");
3164         return;
3165     }
3166     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_SUPER_FOLD_AVAILABLE_AREA),
3167         data, reply, option) != ERR_NONE) {
3168         WLOGFE("SendRequest failed");
3169         return;
3170     }
3171 }
3172 
UpdateSuperFoldExpandAvailableArea(ScreenId screenId,DMRect area)3173 void ScreenSessionManagerProxy::UpdateSuperFoldExpandAvailableArea(ScreenId screenId, DMRect area)
3174 {
3175     sptr<IRemoteObject> remote = Remote();
3176     if (remote == nullptr) {
3177         WLOGFE("UpdateSuperFoldExpandAvailableArea: remote is null");
3178         return;
3179     }
3180 
3181     MessageOption option(MessageOption::TF_ASYNC);
3182     MessageParcel reply;
3183     MessageParcel data;
3184     if (!data.WriteInterfaceToken(GetDescriptor())) {
3185         WLOGFE("WriteInterfaceToken failed");
3186         return;
3187     }
3188     if (!data.WriteUint64(screenId)) {
3189         WLOGFE("Write screenId failed");
3190         return;
3191     }
3192     if (!data.WriteInt32(area.posX_) || !data.WriteInt32(area.posY_) || !data.WriteUint32(area.width_) ||
3193         !data.WriteUint32(area.height_)) {
3194         WLOGFE("Write area failed");
3195         return;
3196     }
3197     if (remote->SendRequest(
3198         static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_SUPER_FOLD_EXPAND_AVAILABLE_AREA),
3199         data, reply, option) != ERR_NONE) {
3200         WLOGFE("SendRequest failed");
3201         return;
3202     }
3203 }
3204 
SetScreenOffDelayTime(int32_t delay)3205 int32_t ScreenSessionManagerProxy::SetScreenOffDelayTime(int32_t delay)
3206 {
3207     sptr<IRemoteObject> remote = Remote();
3208     if (remote == nullptr) {
3209         WLOGFE("SetScreenOffDelayTime: remote is null");
3210         return 0;
3211     }
3212 
3213     MessageOption option(MessageOption::TF_SYNC);
3214     MessageParcel reply;
3215     MessageParcel data;
3216     if (!data.WriteInterfaceToken(GetDescriptor())) {
3217         WLOGFE("WriteInterfaceToken failed");
3218         return 0;
3219     }
3220     if (!data.WriteInt32(delay)) {
3221         WLOGFE("Write delay failed");
3222         return 0;
3223     }
3224     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_OFF_DELAY_TIME),
3225         data, reply, option) != ERR_NONE) {
3226         WLOGFE("SendRequest failed");
3227         return 0;
3228     }
3229     return reply.ReadInt32();
3230 }
3231 
SetCameraStatus(int32_t cameraStatus,int32_t cameraPosition)3232 void ScreenSessionManagerProxy::SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition)
3233 {
3234     sptr<IRemoteObject> remote = Remote();
3235     if (remote == nullptr) {
3236         WLOGFE("SetCameraStatus: remote is null");
3237         return;
3238     }
3239 
3240     MessageOption option(MessageOption::TF_SYNC);
3241     MessageParcel reply;
3242     MessageParcel data;
3243     if (!data.WriteInterfaceToken(GetDescriptor())) {
3244         WLOGFE("WriteInterfaceToken failed");
3245         return;
3246     }
3247     if (!data.WriteInt32(cameraStatus)) {
3248         WLOGFE("Write cameraStatus failed");
3249         return;
3250     }
3251     if (!data.WriteInt32(cameraPosition)) {
3252         WLOGFE("Write cameraPosition failed");
3253         return;
3254     }
3255     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_CAMERA_STATUS),
3256         data, reply, option) != ERR_NONE) {
3257         WLOGFE("SendRequest failed");
3258         return;
3259     }
3260 }
3261 
GetAvailableArea(DisplayId displayId,DMRect & area)3262 DMError ScreenSessionManagerProxy::GetAvailableArea(DisplayId displayId, DMRect& area)
3263 {
3264     sptr<IRemoteObject> remote = Remote();
3265     if (remote == nullptr) {
3266         WLOGFE("GetAvailableArea: remote is null");
3267         return DMError::DM_ERROR_IPC_FAILED;
3268     }
3269 
3270     MessageOption option;
3271     MessageParcel reply;
3272     MessageParcel data;
3273     if (!data.WriteInterfaceToken(GetDescriptor())) {
3274         WLOGFE("WriteInterfaceToken failed");
3275         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3276     }
3277     if (!data.WriteUint64(displayId)) {
3278         WLOGFE("Write displayId failed");
3279         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3280     }
3281     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_AVAILABLE_AREA),
3282         data, reply, option) != ERR_NONE) {
3283         WLOGFE("SendRequest failed");
3284         return DMError::DM_ERROR_IPC_FAILED;
3285     }
3286     DMError ret = static_cast<DMError>(reply.ReadInt32());
3287     int32_t posX = reply.ReadInt32();
3288     int32_t posY = reply.ReadInt32();
3289     uint32_t width = reply.ReadUint32();
3290     uint32_t height = reply.ReadUint32();
3291     area = {posX, posY, width, height};
3292     return ret;
3293 }
3294 
GetExpandAvailableArea(DisplayId displayId,DMRect & area)3295 DMError ScreenSessionManagerProxy::GetExpandAvailableArea(DisplayId displayId, DMRect& area)
3296 {
3297     sptr<IRemoteObject> remote = Remote();
3298     if (remote == nullptr) {
3299         WLOGFE("GetExpandAvailableArea: remote is null");
3300         return DMError::DM_ERROR_IPC_FAILED;
3301     }
3302 
3303     MessageOption option;
3304     MessageParcel reply;
3305     MessageParcel data;
3306     if (!data.WriteInterfaceToken(GetDescriptor())) {
3307         WLOGFE("WriteInterfaceToken failed");
3308         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3309     }
3310     if (!data.WriteUint64(displayId)) {
3311         WLOGFE("Write displayId failed");
3312         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3313     }
3314     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_EXPAND_AVAILABLE_AREA),
3315         data, reply, option) != ERR_NONE) {
3316         WLOGFE("SendRequest failed");
3317         return DMError::DM_ERROR_IPC_FAILED;
3318     }
3319     DMError ret = static_cast<DMError>(reply.ReadInt32());
3320     int32_t posX = reply.ReadInt32();
3321     int32_t posY = reply.ReadInt32();
3322     uint32_t width = reply.ReadUint32();
3323     uint32_t height = reply.ReadUint32();
3324     area = {posX, posY, width, height};
3325     return ret;
3326 }
3327 
NotifyFoldToExpandCompletion(bool foldToExpand)3328 void ScreenSessionManagerProxy::NotifyFoldToExpandCompletion(bool foldToExpand)
3329 {
3330     sptr<IRemoteObject> remote = Remote();
3331     if (remote == nullptr) {
3332         WLOGFE("NotifyFoldToExpandCompletion: remote is null");
3333         return;
3334     }
3335 
3336     MessageOption option(MessageOption::TF_ASYNC);
3337     MessageParcel reply;
3338     MessageParcel data;
3339     if (!data.WriteInterfaceToken(GetDescriptor())) {
3340         WLOGFE("WriteInterfaceToken failed");
3341         return ;
3342     }
3343     if (!data.WriteBool(foldToExpand)) {
3344         WLOGFE("Write foldToExpand failed");
3345         return;
3346     }
3347     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_FOLD_TO_EXPAND_COMPLETION),
3348         data, reply, option) != ERR_NONE) {
3349         WLOGFE("SendRequest failed");
3350         return;
3351     }
3352 }
3353 
RecordEventFromScb(std::string description,bool needRecordEvent)3354 void ScreenSessionManagerProxy::RecordEventFromScb(std::string description, bool needRecordEvent)
3355 {
3356     sptr<IRemoteObject> remote = Remote();
3357     if (remote == nullptr) {
3358         WLOGFE("RecordEventFromScb: remote is null");
3359         return;
3360     }
3361 
3362     MessageOption option(MessageOption::TF_ASYNC);
3363     MessageParcel reply;
3364     MessageParcel data;
3365     if (!data.WriteInterfaceToken(GetDescriptor())) {
3366         WLOGFE("WriteInterfaceToken failed");
3367         return ;
3368     }
3369     if (!data.WriteString(description)) {
3370         WLOGFE("Write description failed");
3371         return;
3372     }
3373     if (!data.WriteBool(needRecordEvent)) {
3374         WLOGFE("Write needRecordEvent failed");
3375         return;
3376     }
3377     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_RECORD_EVENT_FROM_SCB),
3378         data, reply, option) != ERR_NONE) {
3379         WLOGFE("SendRequest failed");
3380         return;
3381     }
3382 }
3383 
GetVirtualScreenFlag(ScreenId screenId)3384 VirtualScreenFlag ScreenSessionManagerProxy::GetVirtualScreenFlag(ScreenId screenId)
3385 {
3386     sptr<IRemoteObject> remote = Remote();
3387     if (remote == nullptr) {
3388         WLOGFE("GetVirtualScreenFlag: remote is null");
3389         return VirtualScreenFlag::DEFAULT;
3390     }
3391 
3392     if (screenId == SCREEN_ID_INVALID) {
3393         return VirtualScreenFlag::DEFAULT;
3394     }
3395     MessageOption option(MessageOption::TF_SYNC);
3396     MessageParcel reply;
3397     MessageParcel data;
3398     if (!data.WriteInterfaceToken(GetDescriptor())) {
3399         WLOGFE("WriteInterfaceToken failed");
3400         return VirtualScreenFlag::DEFAULT;
3401     }
3402     if (!data.WriteUint64(screenId)) {
3403         WLOGFE("Write screenId failed");
3404         return VirtualScreenFlag::DEFAULT;
3405     }
3406     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_VIRTUAL_SCREEN_FLAG),
3407         data, reply, option) != ERR_NONE) {
3408         WLOGFE("SendRequest failed");
3409         return VirtualScreenFlag::DEFAULT;
3410     }
3411     return static_cast<VirtualScreenFlag>(reply.ReadUint32());
3412 }
3413 
SetVirtualScreenFlag(ScreenId screenId,VirtualScreenFlag screenFlag)3414 DMError ScreenSessionManagerProxy::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
3415 {
3416     sptr<IRemoteObject> remote = Remote();
3417     if (remote == nullptr) {
3418         WLOGFE("SetVirtualScreenFlag: remote is null");
3419         return DMError::DM_ERROR_IPC_FAILED;
3420     }
3421 
3422     if (screenId == SCREEN_ID_INVALID) {
3423         return DMError::DM_ERROR_INVALID_PARAM;
3424     }
3425     if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) {
3426         return DMError::DM_ERROR_INVALID_PARAM;
3427     }
3428     MessageOption option(MessageOption::TF_SYNC);
3429     MessageParcel reply;
3430     MessageParcel data;
3431     if (!data.WriteInterfaceToken(GetDescriptor())) {
3432         WLOGFE("WriteInterfaceToken failed");
3433         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3434     }
3435     if (!data.WriteUint64(screenId) || !data.WriteUint32(static_cast<uint32_t>(screenFlag))) {
3436         WLOGFE("Write screenId or screenFlag failed");
3437         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3438     }
3439     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_FLAG),
3440         data, reply, option) != ERR_NONE) {
3441         WLOGFE("SendRequest failed");
3442         return DMError::DM_ERROR_IPC_FAILED;
3443     }
3444     return static_cast<DMError>(reply.ReadInt32());
3445 }
3446 
GetDeviceScreenConfig()3447 DeviceScreenConfig ScreenSessionManagerProxy::GetDeviceScreenConfig()
3448 {
3449     sptr<IRemoteObject> remote = Remote();
3450     if (remote == nullptr) {
3451         WLOGFE("GetDeviceScreenConfig: remote is null");
3452         return {};
3453     }
3454 
3455     MessageParcel data;
3456     MessageParcel reply;
3457     MessageOption option(MessageOption::TF_SYNC);
3458     if (!data.WriteInterfaceToken(GetDescriptor())) {
3459         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
3460         return {};
3461     }
3462     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DEVICE_SCREEN_CONFIG),
3463         data, reply, option) != ERR_NONE) {
3464         TLOGE(WmsLogTag::DMS, "SendRequest failed");
3465         return {};
3466     }
3467     DeviceScreenConfig deviceScreenConfig;
3468     if (!RSMarshallingHelper::Unmarshalling(reply, deviceScreenConfig)) {
3469         TLOGE(WmsLogTag::DMS, "Read deviceScreenConfig failed");
3470         return {};
3471     }
3472     return deviceScreenConfig;
3473 }
3474 
SetVirtualScreenRefreshRate(ScreenId screenId,uint32_t refreshInterval)3475 DMError ScreenSessionManagerProxy::SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
3476 {
3477     WLOGFI("ScreenSessionManagerProxy::SetVirtualScreenRefreshRate: ENTER");
3478     sptr<IRemoteObject> remote = Remote();
3479     if (remote == nullptr) {
3480         WLOGFE("SetVirtualScreenRefreshRate: remote is null");
3481         return DMError::DM_ERROR_IPC_FAILED;
3482     }
3483 
3484     MessageOption option(MessageOption::TF_SYNC);
3485     MessageParcel reply;
3486     MessageParcel data;
3487     if (!data.WriteInterfaceToken(GetDescriptor())) {
3488         WLOGFE("WriteInterfaceToken failed");
3489         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3490     }
3491     if (!data.WriteUint64(screenId) || !data.WriteUint32(refreshInterval)) {
3492         WLOGFE("Write screenId or refreshInterval failed");
3493         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3494     }
3495     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_REFRESH_RATE),
3496         data, reply, option) != ERR_NONE) {
3497         WLOGFE("SendRequest failed");
3498         return DMError::DM_ERROR_IPC_FAILED;
3499     }
3500     return static_cast<DMError>(reply.ReadInt32());
3501 }
3502 
SetVirtualScreenBlackList(ScreenId screenId,std::vector<uint64_t> & windowIdList,std::vector<uint64_t> surfaceIdList)3503 void ScreenSessionManagerProxy::SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList,
3504     std::vector<uint64_t> surfaceIdList)
3505 {
3506     sptr<IRemoteObject> remote = Remote();
3507     if (remote == nullptr) {
3508         WLOGFE("Remote is nullptr");
3509         return;
3510     }
3511     MessageParcel data;
3512     MessageParcel reply;
3513     MessageOption option;
3514     if (!data.WriteInterfaceToken(GetDescriptor())) {
3515         WLOGFE("WriteInterfaceToken failed");
3516         return;
3517     }
3518     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
3519         WLOGFE("Write screenId failed");
3520         return;
3521     }
3522     if (!data.WriteUInt64Vector(windowIdList)) {
3523         WLOGFE("Write windowIdList failed");
3524         return;
3525     }
3526     if (!data.WriteUInt64Vector(surfaceIdList)) {
3527         WLOGFE("Write surfaceIdList failed");
3528         return;
3529     }
3530     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_BLACK_LIST),
3531         data, reply, option) != ERR_NONE) {
3532         WLOGFE("SendRequest failed");
3533         return;
3534     }
3535 }
3536 
SetVirtualDisplayMuteFlag(ScreenId screenId,bool muteFlag)3537 void ScreenSessionManagerProxy::SetVirtualDisplayMuteFlag(ScreenId screenId, bool muteFlag)
3538 {
3539     sptr<IRemoteObject> remote = Remote();
3540     if (remote == nullptr) {
3541         WLOGFE("Remote is nullptr");
3542         return;
3543     }
3544     MessageParcel data;
3545     MessageParcel reply;
3546     MessageOption option;
3547     if (!data.WriteInterfaceToken(GetDescriptor())) {
3548         WLOGFE("WriteInterfaceToken failed");
3549         return;
3550     }
3551     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
3552         WLOGFE("Write screenId failed");
3553         return;
3554     }
3555     if (!data.WriteBool(muteFlag)) {
3556         WLOGFE("Write muteFlag failed");
3557         return;
3558     }
3559 
3560     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_DISPLAY_MUTE_FLAG),
3561         data, reply, option) != ERR_NONE) {
3562         WLOGFE("SendRequest failed");
3563         return;
3564     }
3565 }
3566 
DisablePowerOffRenderControl(ScreenId screenId)3567 void ScreenSessionManagerProxy::DisablePowerOffRenderControl(ScreenId screenId)
3568 {
3569     sptr<IRemoteObject> remote = Remote();
3570     if (remote == nullptr) {
3571         WLOGFE("Remote is nullptr");
3572         return;
3573     }
3574     MessageParcel data;
3575     MessageParcel reply;
3576     MessageOption option;
3577     if (!data.WriteInterfaceToken(GetDescriptor())) {
3578         WLOGFE("WriteInterfaceToken failed");
3579         return;
3580     }
3581     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
3582         WLOGFE("Write screenId failed");
3583         return;
3584     }
3585     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DISABLE_POWEROFF_RENDER_CONTROL),
3586         data, reply, option) != ERR_NONE) {
3587         WLOGFE("SendRequest failed");
3588         return;
3589     }
3590 }
3591 
ProxyForFreeze(const std::set<int32_t> & pidList,bool isProxy)3592 DMError ScreenSessionManagerProxy::ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy)
3593 {
3594     sptr<IRemoteObject> remote = Remote();
3595     if (remote == nullptr) {
3596         WLOGFE("Remote is nullptr");
3597         return DMError::DM_ERROR_NULLPTR;
3598     }
3599     MessageParcel reply;
3600     MessageParcel data;
3601     MessageOption option;
3602     if (!data.WriteInterfaceToken(GetDescriptor())) {
3603         WLOGFE("proxy for freeze: failed");
3604         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3605     }
3606     if (!data.WriteInt32(pidList.size())) {
3607         WLOGFE("proxy for freeze write date: failed");
3608         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3609     }
3610     for (auto it = pidList.begin(); it != pidList.end(); it++) {
3611         if (!data.WriteInt32(*it)) {
3612             WLOGFE("proxy for freeze write date: failed");
3613             return DMError::DM_ERROR_WRITE_DATA_FAILED;
3614         }
3615     }
3616     if (!data.WriteBool(isProxy)) {
3617         WLOGFE("proxy for freeze write date: failed");
3618         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3619     }
3620     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_PROXY_FOR_FREEZE),
3621         data, reply, option) != ERR_NONE) {
3622         WLOGFE("proxy for freeze send request: failed");
3623         return DMError::DM_ERROR_IPC_FAILED;
3624     }
3625     return static_cast<DMError>(reply.ReadInt32());
3626 }
3627 
ResetAllFreezeStatus()3628 DMError ScreenSessionManagerProxy::ResetAllFreezeStatus()
3629 {
3630     sptr<IRemoteObject> remote = Remote();
3631     if (remote == nullptr) {
3632         WLOGFE("Remote is nullptr");
3633         return DMError::DM_ERROR_NULLPTR;
3634     }
3635     MessageParcel reply;
3636     MessageParcel data;
3637     MessageOption option;
3638     if (!data.WriteInterfaceToken(GetDescriptor())) {
3639         WLOGFE("WriteInterfaceToken failed");
3640         return DMError::DM_ERROR_IPC_FAILED;
3641     }
3642     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_RESET_ALL_FREEZE_STATUS),
3643         data, reply, option) != ERR_NONE) {
3644         WLOGFE("SendRequest failed");
3645         return DMError::DM_ERROR_IPC_FAILED;
3646     }
3647     return static_cast<DMError>(reply.ReadInt32());
3648 }
3649 
UpdateDisplayHookInfo(int32_t uid,bool enable,const DMHookInfo & hookInfo)3650 void OHOS::Rosen::ScreenSessionManagerProxy::UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo)
3651 {
3652     sptr<IRemoteObject> remote = Remote();
3653     if (remote == nullptr) {
3654         TLOGE(WmsLogTag::DMS, "remote is nullptr");
3655         return;
3656     }
3657 
3658     MessageOption option(MessageOption::TF_ASYNC);
3659     MessageParcel reply;
3660     MessageParcel data;
3661 
3662     if (!data.WriteInterfaceToken(GetDescriptor())) {
3663         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
3664         return;
3665     }
3666 
3667     if (!data.WriteInt32(uid)) {
3668         TLOGE(WmsLogTag::DMS, "Write uid failed");
3669         return;
3670     }
3671 
3672     if (!data.WriteBool(enable)) {
3673         TLOGE(WmsLogTag::DMS, "Write enable failed");
3674         return;
3675     }
3676 
3677     if (!data.WriteUint32(hookInfo.width_) || !data.WriteUint32(hookInfo.height_) ||
3678         !data.WriteFloat(hookInfo.density_) || !data.WriteUint32(hookInfo.rotation_) ||
3679         !data.WriteBool(hookInfo.enableHookRotation_)) {
3680         TLOGE(WmsLogTag::DMS, "Write hookInfo failed");
3681         return;
3682     }
3683 
3684     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_HOOK_INFO),
3685         data, reply, option) != ERR_NONE) {
3686         TLOGE(WmsLogTag::DMS, "SendRequest failed");
3687         return;
3688     }
3689 }
3690 
GetDisplayHookInfo(int32_t uid,DMHookInfo & hookInfo)3691 void ScreenSessionManagerProxy::GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo)
3692 {
3693     sptr<IRemoteObject> remote = Remote();
3694     if (remote == nullptr) {
3695         TLOGE(WmsLogTag::DMS, "remote is nullptr");
3696         return;
3697     }
3698 
3699     MessageOption option;
3700     MessageParcel reply;
3701     MessageParcel data;
3702 
3703     if (!data.WriteInterfaceToken(GetDescriptor())) {
3704         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
3705         return;
3706     }
3707 
3708     if (!data.WriteInt32(uid)) {
3709         TLOGE(WmsLogTag::DMS, "Write uid failed");
3710         return;
3711     }
3712 
3713     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_HOOK_INFO),
3714         data, reply, option) != ERR_NONE) {
3715         TLOGE(WmsLogTag::DMS, "SendRequest failed");
3716         return;
3717     }
3718     hookInfo.width_ = reply.ReadUint32();
3719     hookInfo.height_ = reply.ReadUint32();
3720     hookInfo.density_ = reply.ReadFloat();
3721     hookInfo.rotation_ = reply.ReadUint32();
3722     hookInfo.enableHookRotation_ = reply.ReadBool();
3723 }
3724 
SetVirtualScreenSecurityExemption(ScreenId screenId,uint32_t pid,std::vector<uint64_t> & windowIdList)3725 DMError ScreenSessionManagerProxy::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
3726     std::vector<uint64_t>& windowIdList)
3727 {
3728     sptr<IRemoteObject> remote = Remote();
3729     if (remote == nullptr) {
3730         WLOGFE("Remote is nullptr");
3731         return DMError::DM_ERROR_NULLPTR;
3732     }
3733     MessageParcel reply;
3734     MessageParcel data;
3735     MessageOption option(MessageOption::TF_SYNC);
3736     if (!data.WriteInterfaceToken(GetDescriptor())) {
3737         WLOGFE("proxy for freeze: failed");
3738         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3739     }
3740     if (!data.WriteUint64(screenId)) {
3741         WLOGFE("write date: failed");
3742         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3743     }
3744     if (!data.WriteUint32(pid)) {
3745         WLOGFE("write date: failed");
3746         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3747     }
3748 
3749     if (!data.WriteUInt64Vector(windowIdList)) {
3750         WLOGFE("write date: failed");
3751         return DMError::DM_ERROR_WRITE_DATA_FAILED;
3752     }
3753     if (remote->SendRequest(
3754         static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION),
3755         data, reply, option) != ERR_NONE) {
3756         WLOGFE("send request: failed");
3757         return DMError::DM_ERROR_IPC_FAILED;
3758     }
3759     return static_cast<DMError>(reply.ReadInt32());
3760 }
3761 
GetAllDisplayPhysicalResolution()3762 std::vector<DisplayPhysicalResolution> ScreenSessionManagerProxy::GetAllDisplayPhysicalResolution()
3763 {
3764     sptr<IRemoteObject> remote = Remote();
3765     if (remote == nullptr) {
3766         TLOGE(WmsLogTag::DMS, "remote is nullptr");
3767         return std::vector<DisplayPhysicalResolution> {};
3768     }
3769     MessageOption option;
3770     MessageParcel reply;
3771     MessageParcel data;
3772     if (!data.WriteInterfaceToken(GetDescriptor())) {
3773         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
3774         return std::vector<DisplayPhysicalResolution> {};
3775     }
3776     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_PHYSICAL_DISPLAY_RESOLUTION),
3777         data, reply, option) != ERR_NONE) {
3778         TLOGE(WmsLogTag::DMS, "SendRequest failed");
3779         return std::vector<DisplayPhysicalResolution> {};
3780     }
3781     std::vector<DisplayPhysicalResolution> allPhysicalSize;
3782     int32_t displayInfoSize = 0;
3783     bool readRet = reply.ReadInt32(displayInfoSize);
3784     if (!readRet || displayInfoSize <= 0) {
3785         return std::vector<DisplayPhysicalResolution> {};
3786     }
3787     for (int32_t i = 0; i < displayInfoSize; i++) {
3788         DisplayPhysicalResolution physicalItem;
3789         physicalItem.foldDisplayMode_ = static_cast<FoldDisplayMode>(reply.ReadUint32());
3790         physicalItem.physicalWidth_ = reply.ReadUint32();
3791         physicalItem.physicalHeight_ = reply.ReadUint32();
3792         allPhysicalSize.emplace_back(physicalItem);
3793     }
3794     return allPhysicalSize;
3795 }
3796 
GetDisplayCapability(std::string & capabilitInfo)3797 DMError ScreenSessionManagerProxy::GetDisplayCapability(std::string& capabilitInfo)
3798 {
3799     sptr<IRemoteObject> remote = Remote();
3800     if (remote == nullptr) {
3801         TLOGE(WmsLogTag::DMS, "remote is nullptr");
3802         return DMError::DM_ERROR_IPC_FAILED;
3803     }
3804 
3805     MessageParcel data;
3806     MessageParcel reply;
3807     MessageOption option;
3808     if (!data.WriteInterfaceToken(GetDescriptor())) {
3809         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
3810         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3811     }
3812     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPABILITY),
3813         data, reply, option) != ERR_NONE) {
3814         TLOGE(WmsLogTag::DMS, "SendRequest failed");
3815         return DMError::DM_ERROR_IPC_FAILED;
3816     }
3817 
3818     DMError ret = static_cast<DMError>(reply.ReadInt32());
3819     capabilitInfo = reply.ReadString();
3820     return ret;
3821 }
3822 
SetVirtualScreenStatus(ScreenId screenId,VirtualScreenStatus screenStatus)3823 bool ScreenSessionManagerProxy::SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus)
3824 {
3825     sptr<IRemoteObject> remote = Remote();
3826     if (remote == nullptr) {
3827         TLOGE(WmsLogTag::DMS, "remote is nullptr");
3828         return false;
3829     }
3830 
3831     MessageOption option(MessageOption::TF_SYNC);
3832     MessageParcel reply;
3833     MessageParcel data;
3834     if (!data.WriteInterfaceToken(GetDescriptor())) {
3835         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
3836         return false;
3837     }
3838 
3839     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
3840         TLOGE(WmsLogTag::DMS, "Write screenId failed");
3841         return false;
3842     }
3843 
3844     if (!data.WriteInt32(static_cast<int32_t>(screenStatus))) {
3845         TLOGE(WmsLogTag::DMS, "Write screenStatus failed");
3846         return false;
3847     }
3848 
3849     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_STATUS),
3850         data, reply, option) != ERR_NONE) {
3851         TLOGE(WmsLogTag::DMS, "SendRequest failed");
3852         return false;
3853     }
3854 
3855     return reply.ReadBool();
3856 }
3857 
SetVirtualScreenMaxRefreshRate(ScreenId id,uint32_t refreshRate,uint32_t & actualRefreshRate)3858 DMError ScreenSessionManagerProxy::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
3859     uint32_t& actualRefreshRate)
3860 {
3861     WLOGFI("ENTER");
3862     sptr<IRemoteObject> remote = Remote();
3863     if (remote == nullptr) {
3864         WLOGFW("remote is nullptr");
3865         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
3866     }
3867 
3868     MessageParcel data;
3869     MessageParcel reply;
3870     MessageOption option;
3871 
3872     if (!data.WriteInterfaceToken(GetDescriptor())) {
3873         WLOGFE("WriteInterfaceToken failed");
3874         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3875     }
3876     if (!data.WriteUint64(static_cast<uint64_t>(id))) {
3877         WLOGFE("WriteUnit64 screenId failed");
3878         return DMError::DM_ERROR_IPC_FAILED;
3879     }
3880     if (!data.WriteUint32(refreshRate)) {
3881         WLOGFE("WriteUnit32 width failed");
3882         return DMError::DM_ERROR_IPC_FAILED;
3883     }
3884     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE),
3885         data, reply, option) != ERR_NONE) {
3886         WLOGFE("SendRequest failed");
3887         return DMError::DM_ERROR_NULLPTR;
3888     }
3889     actualRefreshRate = reply.ReadUint32();
3890     return static_cast<DMError>(reply.ReadInt32());
3891 }
3892 
GetScreenCapture(const CaptureOption & captureOption,DmErrorCode * errorCode)3893 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetScreenCapture(const CaptureOption& captureOption,
3894     DmErrorCode* errorCode)
3895 {
3896     sptr<IRemoteObject> remote = Remote();
3897     if (remote == nullptr) {
3898         WLOGFE("remote is nullptr");
3899         return nullptr;
3900     }
3901     MessageParcel data;
3902     MessageParcel reply;
3903     MessageOption option;
3904     if (!data.WriteInterfaceToken(GetDescriptor())) {
3905         WLOGFE("WriteInterfaceToken failed");
3906         return nullptr;
3907     }
3908     if (!data.WriteUint64(captureOption.displayId_) ||
3909         !data.WriteBool(captureOption.isNeedNotify_) || !data.WriteBool(captureOption.isNeedPointer_)) {
3910         WLOGFE("Write displayId or isNeedNotify or isNeedPointer failed");
3911         return nullptr;
3912     }
3913     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPTURE),
3914         data, reply, option) != ERR_NONE) {
3915         WLOGFE("SendRequest failed");
3916         return nullptr;
3917     }
3918     std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
3919     DmErrorCode replyErrorCode = static_cast<DmErrorCode>(reply.ReadInt32());
3920     if (errorCode) {
3921         *errorCode = replyErrorCode;
3922     }
3923     if (pixelMap == nullptr) {
3924         WLOGFE("Send pixelMap nullptr.");
3925         return nullptr;
3926     }
3927     return pixelMap;
3928 }
3929 
GetPrimaryDisplayInfo()3930 sptr<DisplayInfo> ScreenSessionManagerProxy::GetPrimaryDisplayInfo()
3931 {
3932     sptr<IRemoteObject> remote = Remote();
3933     if (remote == nullptr) {
3934         WLOGFW("GetPrimaryDisplayInfo: remote is nullptr");
3935         return nullptr;
3936     }
3937     MessageParcel data;
3938     MessageParcel reply;
3939     MessageOption option;
3940     if (!data.WriteInterfaceToken(GetDescriptor())) {
3941         WLOGFE("WriteInterfaceToken failed");
3942         return nullptr;
3943     }
3944     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_INFO),
3945         data, reply, option) != ERR_NONE) {
3946         WLOGFE("SendRequest failed");
3947         return nullptr;
3948     }
3949 
3950     sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
3951     if (info == nullptr) {
3952         WLOGFE("get display info.");
3953     }
3954     return info;
3955 }
3956 
GetDisplaySnapshotWithOption(const CaptureOption & captureOption,DmErrorCode * errorCode)3957 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetDisplaySnapshotWithOption(
3958     const CaptureOption& captureOption, DmErrorCode* errorCode)
3959 {
3960     WLOGFD("enter");
3961     sptr<IRemoteObject> remote = Remote();
3962     if (remote == nullptr) {
3963         WLOGFW("remote is nullptr");
3964         return nullptr;
3965     }
3966 
3967     MessageParcel data;
3968     MessageParcel reply;
3969     MessageOption option;
3970     if (!data.WriteInterfaceToken(GetDescriptor())) {
3971         WLOGFE("WriteInterfaceToken failed");
3972         return nullptr;
3973     }
3974     if (!data.WriteUint64(captureOption.displayId_) ||
3975         !data.WriteBool(captureOption.isNeedNotify_) || !data.WriteBool(captureOption.isNeedPointer_)) {
3976         WLOGFE("Write displayId or isNeedNotify or isNeedPointer failed");
3977         return nullptr;
3978     }
3979     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION),
3980         data, reply, option) != ERR_NONE) {
3981         WLOGFW("SendRequest failed");
3982         return nullptr;
3983     }
3984 
3985     std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
3986     DmErrorCode replyErrorCode = static_cast<DmErrorCode>(reply.ReadInt32());
3987     if (errorCode) {
3988         *errorCode = replyErrorCode;
3989     }
3990     if (pixelMap == nullptr) {
3991         WLOGFW("SendRequest nullptr.");
3992         return nullptr;
3993     }
3994     return pixelMap;
3995 }
3996 
SetScreenOnDelayTime(int32_t delay)3997 int32_t ScreenSessionManagerProxy::SetScreenOnDelayTime(int32_t delay)
3998 {
3999     sptr<IRemoteObject> remote = Remote();
4000     if (remote == nullptr) {
4001         WLOGFE("SetScreenOnDelayTime: remote is null");
4002         return 0;
4003     }
4004 
4005     MessageOption option(MessageOption::TF_SYNC);
4006     MessageParcel reply;
4007     MessageParcel data;
4008     if (!data.WriteInterfaceToken(GetDescriptor())) {
4009         WLOGFE("WriteInterfaceToken failed");
4010         return 0;
4011     }
4012     if (!data.WriteInt32(delay)) {
4013         WLOGFE("Write delay failed");
4014         return 0;
4015     }
4016     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ON_DELAY_TIME),
4017         data, reply, option) != ERR_NONE) {
4018         WLOGFE("SendRequest failed");
4019         return 0;
4020     }
4021     return reply.ReadInt32();
4022 }
4023 
SetScreenSkipProtectedWindow(const std::vector<ScreenId> & screenIds,bool isEnable)4024 DMError ScreenSessionManagerProxy::SetScreenSkipProtectedWindow(const std::vector<ScreenId>& screenIds, bool isEnable)
4025 {
4026     sptr<IRemoteObject> remote = Remote();
4027     if (remote == nullptr) {
4028         TLOGE(WmsLogTag::DMS, "remote is nullptr");
4029         return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
4030     }
4031     MessageParcel data;
4032     MessageParcel reply;
4033     MessageOption option;
4034     if (!data.WriteInterfaceToken(GetDescriptor())) {
4035         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
4036         return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
4037     }
4038     if (!data.WriteUInt64Vector(screenIds)) {
4039         TLOGE(WmsLogTag::DMS, "Write screenIds failed");
4040         return DMError::DM_ERROR_WRITE_DATA_FAILED;
4041     }
4042     if (!data.WriteBool(isEnable)) {
4043         TLOGE(WmsLogTag::DMS, "Write isEnable failed");
4044         return DMError::DM_ERROR_WRITE_DATA_FAILED;
4045     }
4046     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_SKIP_PROTECTED_WINDOW),
4047         data, reply, option) != ERR_NONE) {
4048         TLOGE(WmsLogTag::DMS, "SendRequest failed");
4049         return DMError::DM_ERROR_IPC_FAILED;
4050     }
4051     return static_cast<DMError>(reply.ReadInt32());
4052 }
4053 
GetIsRealScreen(ScreenId screenId)4054 bool ScreenSessionManagerProxy::GetIsRealScreen(ScreenId screenId)
4055 {
4056     sptr<IRemoteObject> remote = Remote();
4057     if (remote == nullptr) {
4058         TLOGE(WmsLogTag::DMS, "remote is nullptr");
4059         return false;
4060     }
4061     MessageOption option(MessageOption::TF_SYNC);
4062     MessageParcel reply;
4063     MessageParcel data;
4064     if (!data.WriteInterfaceToken(GetDescriptor())) {
4065         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
4066         return false;
4067     }
4068     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
4069         TLOGE(WmsLogTag::DMS, "Write screenId failed");
4070         return false;
4071     }
4072     if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_IS_REAL_SCREEN),
4073         data, reply, option) != ERR_NONE) {
4074         TLOGE(WmsLogTag::DMS, "SendRequest failed");
4075         return false;
4076     }
4077     return reply.ReadBool();
4078 }
4079 } // namespace OHOS::Rosen
4080