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