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
TryToCancelScreenOff()950 bool OHOS::Rosen::ScreenSessionManagerProxy::TryToCancelScreenOff()
951 {
952 sptr<IRemoteObject> remote = Remote();
953 if (remote == nullptr) {
954 WLOGFE("[UL_POWER]TryToCancelScreenOff remote is nullptr");
955 return false;
956 }
957
958 MessageParcel data;
959 MessageParcel reply;
960 MessageOption option;
961
962 if (!data.WriteInterfaceToken(GetDescriptor())) {
963 WLOGFE("[UL_POWER]TryToCancelScreenOff: WriteInterfaceToken failed");
964 return false;
965 }
966 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF),
967 data, reply, option) != ERR_NONE) {
968 WLOGFW("[UL_POWER]TryToCancelScreenOff: SendRequest failed");
969 return false;
970 }
971 return reply.ReadBool();
972 }
973
CreateVirtualScreen(VirtualScreenOption virtualOption,const sptr<IRemoteObject> & displayManagerAgent)974 ScreenId ScreenSessionManagerProxy::CreateVirtualScreen(VirtualScreenOption virtualOption,
975 const sptr<IRemoteObject>& displayManagerAgent)
976 {
977 WLOGFI("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: ENTER");
978 sptr<IRemoteObject> remote = Remote();
979 if (remote == nullptr) {
980 WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: remote is nullptr");
981 return SCREEN_ID_INVALID;
982 }
983
984 MessageParcel data;
985 MessageParcel reply;
986 MessageOption option;
987 if (!data.WriteInterfaceToken(GetDescriptor())) {
988 WLOGFE("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: WriteInterfaceToken failed");
989 return SCREEN_ID_INVALID;
990 }
991 bool res = data.WriteString(virtualOption.name_) && data.WriteUint32(virtualOption.width_) &&
992 data.WriteUint32(virtualOption.height_) && data.WriteFloat(virtualOption.density_) &&
993 data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_) &&
994 data.WriteUInt64Vector(virtualOption.missionIds_);
995 if (virtualOption.surface_ != nullptr && virtualOption.surface_->GetProducer() != nullptr) {
996 res = res &&
997 data.WriteBool(true) &&
998 data.WriteRemoteObject(virtualOption.surface_->GetProducer()->AsObject());
999 } else {
1000 WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: surface is nullptr");
1001 res = res && data.WriteBool(false);
1002 }
1003 if (displayManagerAgent != nullptr) {
1004 res = res &&
1005 data.WriteRemoteObject(displayManagerAgent);
1006 }
1007 if (!res) {
1008 WLOGFE("SCB: ScreenSessionManagerProxy::Write data failed");
1009 return SCREEN_ID_INVALID;
1010 }
1011 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN),
1012 data, reply, option) != ERR_NONE) {
1013 WLOGFW("SCB: ScreenSessionManagerProxy::CreateVirtualScreen: SendRequest failed");
1014 return SCREEN_ID_INVALID;
1015 }
1016
1017 ScreenId screenId = static_cast<ScreenId>(reply.ReadUint64());
1018 return screenId;
1019 }
1020
SetVirtualScreenSurface(ScreenId screenId,sptr<IBufferProducer> surface)1021 DMError ScreenSessionManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface)
1022 {
1023 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: ENTER");
1024 sptr<IRemoteObject> remote = Remote();
1025 if (remote == nullptr) {
1026 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: remote is nullptr");
1027 return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1028 }
1029
1030 MessageParcel data;
1031 MessageParcel reply;
1032 MessageOption option;
1033 if (!data.WriteInterfaceToken(GetDescriptor())) {
1034 WLOGFE("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: WriteInterfaceToken failed");
1035 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1036 }
1037 bool res = data.WriteUint64(static_cast<uint64_t>(screenId));
1038 if (surface != nullptr) {
1039 res = res &&
1040 data.WriteBool(true) &&
1041 data.WriteRemoteObject(surface->AsObject());
1042 } else {
1043 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: surface is nullptr");
1044 res = res && data.WriteBool(false);
1045 }
1046 if (!res) {
1047 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: Write screenId/surface failed");
1048 return DMError::DM_ERROR_IPC_FAILED;
1049 }
1050 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE),
1051 data, reply, option) != ERR_NONE) {
1052 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualScreenSurface: SendRequest failed");
1053 return DMError::DM_ERROR_IPC_FAILED;
1054 }
1055 return static_cast<DMError>(reply.ReadInt32());
1056 }
1057
SetVirtualMirrorScreenCanvasRotation(ScreenId screenId,bool canvasRotation)1058 DMError ScreenSessionManagerProxy::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation)
1059 {
1060 WLOGFW("SCB: ScreenSessionManagerProxy::SetVirtualMirrorScreenCanvasRotation: ENTER");
1061 sptr<IRemoteObject> remote = Remote();
1062 if (remote == nullptr) {
1063 WLOGFW("SCB: SetVirtualMirrorScreenCanvasRotation: remote is nullptr");
1064 return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1065 }
1066
1067 MessageParcel data;
1068 MessageParcel reply;
1069 MessageOption option;
1070 if (!data.WriteInterfaceToken(GetDescriptor())) {
1071 WLOGFE("SCB: SetVirtualMirrorScreenCanvasRotation: WriteInterfaceToken failed");
1072 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1073 }
1074 bool res = data.WriteUint64(static_cast<uint64_t>(screenId)) && data.WriteBool(canvasRotation);
1075 if (!res) {
1076 WLOGFW("SCB:SetVirtualMirrorScreenCanvasRotation: Write screenId/canvasRotation failed");
1077 return DMError::DM_ERROR_IPC_FAILED;
1078 }
1079 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_CANVAS_ROTATION),
1080 data, reply, option) != ERR_NONE) {
1081 WLOGFW("SCB:SetVirtualMirrorScreenCanvasRotation: SendRequest failed");
1082 return DMError::DM_ERROR_IPC_FAILED;
1083 }
1084 return static_cast<DMError>(reply.ReadInt32());
1085 }
1086
SetVirtualMirrorScreenScaleMode(ScreenId screenId,ScreenScaleMode scaleMode)1087 DMError ScreenSessionManagerProxy::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
1088 {
1089 sptr<IRemoteObject> remote = Remote();
1090 if (remote == nullptr) {
1091 WLOGFW("SetVirtualMirrorScreenScaleMode: remote is nullptr");
1092 return DMError::DM_ERROR_IPC_FAILED;
1093 }
1094
1095 if (screenId == SCREEN_ID_INVALID) {
1096 return DMError::DM_ERROR_INVALID_PARAM;
1097 }
1098 MessageParcel data;
1099 MessageParcel reply;
1100 MessageOption option;
1101 if (!data.WriteInterfaceToken(GetDescriptor())) {
1102 WLOGFE("WriteInterfaceToken failed");
1103 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1104 }
1105 bool res = data.WriteUint64(static_cast<uint64_t>(screenId)) && data.WriteUint32(static_cast<uint32_t>(scaleMode));
1106 if (!res) {
1107 WLOGFE("Write screenId/scaleMode failed");
1108 return DMError::DM_ERROR_WRITE_DATA_FAILED;
1109 }
1110 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE),
1111 data, reply, option) != ERR_NONE) {
1112 WLOGFW("SendRequest failed");
1113 return DMError::DM_ERROR_IPC_FAILED;
1114 }
1115 return static_cast<DMError>(reply.ReadInt32());
1116 }
1117
ResizeVirtualScreen(ScreenId screenId,uint32_t width,uint32_t height)1118 DMError ScreenSessionManagerProxy::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)
1119 {
1120 WLOGFI("ScreenSessionManagerProxy::ResizeVirtualScreen: ENTER");
1121 sptr<IRemoteObject> remote = Remote();
1122 if (remote == nullptr) {
1123 WLOGFW("ScreenSessionManagerProxy::ResizeVirtualScreen: remote is nullptr");
1124 return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1125 }
1126
1127 MessageParcel data;
1128 MessageParcel reply;
1129 MessageOption option;
1130
1131 if (!data.WriteInterfaceToken(GetDescriptor())) {
1132 WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteInterfaceToken failed");
1133 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1134 }
1135 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
1136 WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteUnit64 screenId failed");
1137 return DMError::DM_ERROR_IPC_FAILED;
1138 }
1139 if (!data.WriteUint32(width)) {
1140 WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteUnit32 width failed");
1141 return DMError::DM_ERROR_IPC_FAILED;
1142 }
1143 if (!data.WriteUint32(height)) {
1144 WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen: WriteUnit32 height failed");
1145 return DMError::DM_ERROR_IPC_FAILED;
1146 }
1147 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_RESIZE_VIRTUAL_SCREEN),
1148 data, reply, option) != ERR_NONE) {
1149 WLOGFE("ScreenSessionManagerProxy::ResizeVirtualScreen fail: SendRequest failed");
1150 return DMError::DM_ERROR_NULLPTR;
1151 }
1152 return static_cast<DMError>(reply.ReadInt32());
1153 }
1154
DestroyVirtualScreen(ScreenId screenId)1155 DMError ScreenSessionManagerProxy::DestroyVirtualScreen(ScreenId screenId)
1156 {
1157 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: ENTER");
1158 sptr<IRemoteObject> remote = Remote();
1159 if (remote == nullptr) {
1160 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: remote is nullptr");
1161 return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
1162 }
1163
1164 MessageParcel data;
1165 MessageParcel reply;
1166 MessageOption option;
1167 if (!data.WriteInterfaceToken(GetDescriptor())) {
1168 WLOGFE("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: WriteInterfaceToken failed");
1169 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1170 }
1171 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
1172 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: WriteUint64 screenId failed");
1173 return DMError::DM_ERROR_IPC_FAILED;
1174 }
1175 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN),
1176 data, reply, option) != ERR_NONE) {
1177 WLOGFW("SCB: ScreenSessionManagerProxy::DestroyVirtualScreen: SendRequest failed");
1178 return DMError::DM_ERROR_IPC_FAILED;
1179 }
1180 return static_cast<DMError>(reply.ReadInt32());
1181 }
1182
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenIds,ScreenId & screenGroupId)1183 DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId,
1184 std::vector<ScreenId> mirrorScreenIds, ScreenId& screenGroupId)
1185 {
1186 WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: ENTER");
1187 sptr<IRemoteObject> remote = Remote();
1188 if (remote == nullptr) {
1189 WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: remote is null");
1190 return DMError::DM_ERROR_NULLPTR;
1191 }
1192
1193 MessageParcel data;
1194 MessageParcel reply;
1195 MessageOption option;
1196 if (!data.WriteInterfaceToken(GetDescriptor())) {
1197 WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: WriteInterfaceToken failed");
1198 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1199 }
1200 bool res = data.WriteUint64(static_cast<uint64_t>(mainScreenId)) &&
1201 data.WriteUInt64Vector(mirrorScreenIds);
1202 if (!res) {
1203 WLOGFE("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: data write failed");
1204 return DMError::DM_ERROR_IPC_FAILED;
1205 }
1206 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR),
1207 data, reply, option) != ERR_NONE) {
1208 WLOGFW("SCB: ScreenSessionManagerProxy::MakeMirror: create mirror fail: SendRequest failed");
1209 return DMError::DM_ERROR_IPC_FAILED;
1210 }
1211 DMError ret = static_cast<DMError>(reply.ReadInt32());
1212 screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
1213 return ret;
1214 }
1215
StopMirror(const std::vector<ScreenId> & mirrorScreenIds)1216 DMError ScreenSessionManagerProxy::StopMirror(const std::vector<ScreenId>& mirrorScreenIds)
1217 {
1218 sptr<IRemoteObject> remote = Remote();
1219 if (remote == nullptr) {
1220 WLOGFW("StopMirror fail: remote is null");
1221 return DMError::DM_ERROR_NULLPTR;
1222 }
1223
1224 MessageParcel data;
1225 MessageParcel reply;
1226 MessageOption option;
1227 if (!data.WriteInterfaceToken(GetDescriptor())) {
1228 WLOGFE("StopMirror fail: WriteInterfaceToken failed");
1229 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1230 }
1231 bool res = data.WriteUInt64Vector(mirrorScreenIds);
1232 if (!res) {
1233 WLOGFE("StopMirror fail: data write failed");
1234 return DMError::DM_ERROR_IPC_FAILED;
1235 }
1236 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR),
1237 data, reply, option) != ERR_NONE) {
1238 WLOGFW("StopMirror fail: SendRequest failed");
1239 return DMError::DM_ERROR_IPC_FAILED;
1240 }
1241 return static_cast<DMError>(reply.ReadInt32());
1242 }
1243
DisableMirror(bool disableOrNot)1244 DMError ScreenSessionManagerProxy::DisableMirror(bool disableOrNot)
1245 {
1246 WLOGFI("SCB: ScreenSessionManagerProxy::DisableMirror %{public}d", disableOrNot);
1247 sptr<IRemoteObject> remote = Remote();
1248 if (remote == nullptr) {
1249 WLOGFW("DisableMirror fail: remote is null");
1250 return DMError::DM_ERROR_NULLPTR;
1251 }
1252
1253 MessageParcel data;
1254 MessageParcel reply;
1255 MessageOption option;
1256 if (!data.WriteInterfaceToken(GetDescriptor())) {
1257 WLOGFE("DisableMirror fail: WriteinterfaceToken failed");
1258 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1259 }
1260 if (!data.WriteBool(disableOrNot)) {
1261 WLOGFE("DisableMirror fail: data write failed");
1262 return DMError::DM_ERROR_IPC_FAILED;
1263 }
1264 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_DISABLE_MIRROR),
1265 data, reply, option) != ERR_NONE) {
1266 WLOGFW("DisableMirror fail: SendRequest failed");
1267 return DMError::DM_ERROR_IPC_FAILED;
1268 }
1269 return static_cast<DMError>(reply.ReadInt32());
1270 }
1271
MakeExpand(std::vector<ScreenId> screenId,std::vector<Point> startPoint,ScreenId & screenGroupId)1272 DMError ScreenSessionManagerProxy::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
1273 ScreenId& screenGroupId)
1274 {
1275 WLOGFW("SCB: ScreenSessionManagerProxy::MakeExpand: ENTER");
1276 sptr<IRemoteObject> remote = Remote();
1277 if (remote == nullptr) {
1278 WLOGFW("SCB: ScreenSessionManagerProxy::MakeExpand: remote is null");
1279 return DMError::DM_ERROR_IPC_FAILED;
1280 }
1281
1282 MessageParcel data;
1283 MessageParcel reply;
1284 MessageOption option;
1285 if (!data.WriteInterfaceToken(GetDescriptor())) {
1286 WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: WriteInterfaceToken failed");
1287 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1288 }
1289 if (!data.WriteUInt64Vector(screenId)) {
1290 WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: write screenId failed");
1291 return DMError::DM_ERROR_IPC_FAILED;
1292 }
1293 if (!MarshallingHelper::MarshallingVectorObj<Point>(data, startPoint, [](Parcel& parcel, const Point& point) {
1294 return parcel.WriteInt32(point.posX_) && parcel.WriteInt32(point.posY_);
1295 })) {
1296 WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: write startPoint failed");
1297 return DMError::DM_ERROR_IPC_FAILED;
1298 }
1299 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND),
1300 data, reply, option) != ERR_NONE) {
1301 WLOGFE("SCB: ScreenSessionManagerProxy::MakeExpand: SendRequest failed");
1302 return DMError::DM_ERROR_IPC_FAILED;
1303 }
1304 DMError ret = static_cast<DMError>(reply.ReadInt32());
1305 screenGroupId = static_cast<ScreenId>(reply.ReadUint64());
1306 return ret;
1307 }
1308
StopExpand(const std::vector<ScreenId> & expandScreenIds)1309 DMError ScreenSessionManagerProxy::StopExpand(const std::vector<ScreenId>& expandScreenIds)
1310 {
1311 sptr<IRemoteObject> remote = Remote();
1312 if (remote == nullptr) {
1313 WLOGFW("StopExpand fail: remote is null");
1314 return DMError::DM_ERROR_NULLPTR;
1315 }
1316
1317 MessageParcel data;
1318 MessageParcel reply;
1319 MessageOption option;
1320 if (!data.WriteInterfaceToken(GetDescriptor())) {
1321 WLOGFE("StopExpand fail: WriteInterfaceToken failed");
1322 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1323 }
1324 bool res = data.WriteUInt64Vector(expandScreenIds);
1325 if (!res) {
1326 WLOGFE("StopExpand fail: data write failed");
1327 return DMError::DM_ERROR_IPC_FAILED;
1328 }
1329 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND),
1330 data, reply, option) != ERR_NONE) {
1331 WLOGFW("StopExpand fail: SendRequest failed");
1332 return DMError::DM_ERROR_IPC_FAILED;
1333 }
1334 return static_cast<DMError>(reply.ReadInt32());
1335 }
1336
GetScreenGroupInfoById(ScreenId screenId)1337 sptr<ScreenGroupInfo> ScreenSessionManagerProxy::GetScreenGroupInfoById(ScreenId screenId)
1338 {
1339 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: ENTER!");
1340 sptr<IRemoteObject> remote = Remote();
1341 if (remote == nullptr) {
1342 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: remote is nullptr");
1343 return nullptr;
1344 }
1345
1346 MessageParcel data;
1347 MessageParcel reply;
1348 MessageOption option;
1349 if (!data.WriteInterfaceToken(GetDescriptor())) {
1350 WLOGFE("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: WriteInterfaceToken failed");
1351 return nullptr;
1352 }
1353 if (!data.WriteUint64(screenId)) {
1354 WLOGFE("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: Write screenId failed");
1355 return nullptr;
1356 }
1357 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID),
1358 data, reply, option) != ERR_NONE) {
1359 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById: SendRequest failed");
1360 return nullptr;
1361 }
1362
1363 sptr<ScreenGroupInfo> info = reply.ReadStrongParcelable<ScreenGroupInfo>();
1364 if (info == nullptr) {
1365 WLOGFW("SCB: ScreenSessionManagerProxy::GetScreenGroupInfoById SendRequest nullptr.");
1366 return nullptr;
1367 }
1368 return info;
1369 }
1370
RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)1371 void ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
1372 {
1373 WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: ENTER!");
1374 sptr<IRemoteObject> remote = Remote();
1375 if (remote == nullptr) {
1376 WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup:remote is null");
1377 return;
1378 }
1379
1380 MessageParcel data;
1381 MessageParcel reply;
1382 MessageOption option(MessageOption::TF_ASYNC);
1383 if (!data.WriteInterfaceToken(GetDescriptor())) {
1384 WLOGFE("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: WriteInterfaceToken failed");
1385 return;
1386 }
1387 bool res = data.WriteUInt64Vector(screens);
1388 if (!res) {
1389 WLOGFE("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup: write screens failed.");
1390 return;
1391 }
1392 if (remote->SendRequest(static_cast<uint32_t>(
1393 DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP),
1394 data, reply, option) != ERR_NONE) {
1395 WLOGFW("SCB: ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup:: SendRequest failed");
1396 }
1397 }
1398
GetDisplaySnapshot(DisplayId displayId,DmErrorCode * errorCode,bool isUseDma)1399 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetDisplaySnapshot(DisplayId displayId,
1400 DmErrorCode* errorCode, bool isUseDma)
1401 {
1402 WLOGFD("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot enter");
1403 sptr<IRemoteObject> remote = Remote();
1404 if (remote == nullptr) {
1405 WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: remote is nullptr");
1406 return nullptr;
1407 }
1408
1409 MessageParcel data;
1410 MessageParcel reply;
1411 MessageOption option;
1412 if (!data.WriteInterfaceToken(GetDescriptor())) {
1413 WLOGFE("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: WriteInterfaceToken failed");
1414 return nullptr;
1415 }
1416
1417 if (!data.WriteUint64(displayId)) {
1418 WLOGFE("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: Write displayId failed");
1419 return nullptr;
1420 }
1421
1422 if (!data.WriteBool(isUseDma)) {
1423 WLOGFE("isUseDma fail: data write failed");
1424 return nullptr;
1425 }
1426
1427 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT),
1428 data, reply, option) != ERR_NONE) {
1429 WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: SendRequest failed");
1430 return nullptr;
1431 }
1432
1433 std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
1434 DmErrorCode replyErrorCode = static_cast<DmErrorCode>(reply.ReadInt32());
1435 if (errorCode) {
1436 *errorCode = replyErrorCode;
1437 }
1438 if (pixelMap == nullptr) {
1439 WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: SendRequest nullptr.");
1440 return nullptr;
1441 }
1442 return pixelMap;
1443 }
1444
GetSnapshotByPicker(Media::Rect & rect,DmErrorCode * errorCode)1445 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetSnapshotByPicker(Media::Rect &rect,
1446 DmErrorCode* errorCode)
1447 {
1448 WLOGFD("enter");
1449 sptr<IRemoteObject> remote = Remote();
1450 *errorCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL;
1451 if (remote == nullptr) {
1452 WLOGFE("remote is nullptr");
1453 return nullptr;
1454 }
1455 MessageParcel data;
1456 MessageParcel reply;
1457 MessageOption option;
1458 if (!data.WriteInterfaceToken(GetDescriptor())) {
1459 WLOGFE("WriteInterfaceToken failed");
1460 return nullptr;
1461 }
1462 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SNAPSHOT_BY_PICKER),
1463 data, reply, option) != ERR_NONE) {
1464 WLOGFW("SendRequest failed");
1465 return nullptr;
1466 }
1467 std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>()); // need't to check nullptr
1468 *errorCode = static_cast<DmErrorCode>(reply.ReadInt32());
1469 rect.left = reply.ReadInt32();
1470 rect.top = reply.ReadInt32();
1471 rect.width = reply.ReadInt32();
1472 rect.height = reply.ReadInt32();
1473 return pixelMap;
1474 }
1475
GetDisplayInfoById(DisplayId displayId)1476 sptr<DisplayInfo> ScreenSessionManagerProxy::GetDisplayInfoById(DisplayId displayId)
1477 {
1478 sptr<IRemoteObject> remote = Remote();
1479 if (remote == nullptr) {
1480 WLOGFW("GetDisplayInfoById: remote is nullptr");
1481 return nullptr;
1482 }
1483
1484 MessageParcel data;
1485 MessageParcel reply;
1486 MessageOption option;
1487 if (!data.WriteInterfaceToken(GetDescriptor())) {
1488 WLOGFE("GetDisplayInfoById: WriteInterfaceToken failed");
1489 return nullptr;
1490 }
1491 if (!data.WriteUint64(displayId)) {
1492 WLOGFW("GetDisplayInfoById: WriteUint64 displayId failed");
1493 return nullptr;
1494 }
1495 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID),
1496 data, reply, option) != ERR_NONE) {
1497 WLOGFW("GetDisplayInfoById: SendRequest failed");
1498 return nullptr;
1499 }
1500
1501 sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
1502 if (info == nullptr) {
1503 WLOGFW("DisplayManagerProxy::GetDisplayInfoById SendRequest nullptr.");
1504 return nullptr;
1505 }
1506 return info;
1507 }
1508
GetDisplayInfoByScreen(ScreenId screenId)1509 sptr<DisplayInfo> ScreenSessionManagerProxy::GetDisplayInfoByScreen(ScreenId screenId)
1510 {
1511 sptr<IRemoteObject> remote = Remote();
1512 if (remote == nullptr) {
1513 WLOGFE("fail to get displayInfo by screenId: remote is null");
1514 return nullptr;
1515 }
1516
1517 MessageParcel data;
1518 MessageParcel reply;
1519 MessageOption option;
1520 if (!data.WriteInterfaceToken(GetDescriptor())) {
1521 WLOGFE("fail to get displayInfo by screenId: WriteInterfaceToken failed");
1522 return nullptr;
1523 }
1524 if (!data.WriteUint64(screenId)) {
1525 WLOGFW("fail to get displayInfo by screenId: WriteUint64 displayId failed");
1526 return nullptr;
1527 }
1528 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN),
1529 data, reply, option) != ERR_NONE) {
1530 WLOGFW("fail to get displayInfo by screenId: SendRequest failed");
1531 return nullptr;
1532 }
1533
1534 sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
1535 if (info == nullptr) {
1536 WLOGFW("fail to get displayInfo by screenId: SendRequest null");
1537 return nullptr;
1538 }
1539 return info;
1540 }
1541
GetAllDisplayIds()1542 std::vector<DisplayId> ScreenSessionManagerProxy::GetAllDisplayIds()
1543 {
1544 std::vector<DisplayId> allDisplayIds;
1545 sptr<IRemoteObject> remote = Remote();
1546 if (remote == nullptr) {
1547 WLOGFE("GetAllDisplayIds: remote is null");
1548 return allDisplayIds;
1549 }
1550
1551 MessageParcel data;
1552 MessageParcel reply;
1553 MessageOption option;
1554 if (!data.WriteInterfaceToken(GetDescriptor())) {
1555 WLOGFE("WriteInterfaceToken failed");
1556 return allDisplayIds;
1557 }
1558 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS),
1559 data, reply, option) != ERR_NONE) {
1560 WLOGFW("SendRequest failed");
1561 return allDisplayIds;
1562 }
1563 reply.ReadUInt64Vector(&allDisplayIds);
1564 return allDisplayIds;
1565 }
1566
GetScreenInfoById(ScreenId screenId)1567 sptr<ScreenInfo> ScreenSessionManagerProxy::GetScreenInfoById(ScreenId screenId)
1568 {
1569 sptr<IRemoteObject> remote = Remote();
1570 if (remote == nullptr) {
1571 WLOGFW("GetScreenInfoById: remote is nullptr");
1572 return nullptr;
1573 }
1574
1575 MessageParcel data;
1576 MessageParcel reply;
1577 MessageOption option;
1578 if (!data.WriteInterfaceToken(GetDescriptor())) {
1579 WLOGFE("GetScreenInfoById: WriteInterfaceToken failed");
1580 return nullptr;
1581 }
1582 if (!data.WriteUint64(screenId)) {
1583 WLOGFE("GetScreenInfoById: Write screenId failed");
1584 return nullptr;
1585 }
1586 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID),
1587 data, reply, option) != ERR_NONE) {
1588 WLOGFW("GetScreenInfoById: SendRequest failed");
1589 return nullptr;
1590 }
1591
1592 sptr<ScreenInfo> info = reply.ReadStrongParcelable<ScreenInfo>();
1593 if (info == nullptr) {
1594 WLOGFW("GetScreenInfoById SendRequest nullptr.");
1595 return nullptr;
1596 }
1597 for (auto& mode : info->GetModes()) {
1598 WLOGFD("info modes is id: %{public}u, width: %{public}u, height: %{public}u, refreshRate: %{public}u",
1599 mode->id_, mode->width_, mode->height_, mode->refreshRate_);
1600 }
1601 return info;
1602 }
1603
GetAllScreenInfos(std::vector<sptr<ScreenInfo>> & screenInfos)1604 DMError ScreenSessionManagerProxy::GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos)
1605 {
1606 sptr<IRemoteObject> remote = Remote();
1607 if (remote == nullptr) {
1608 WLOGFW("GetAllScreenInfos: remote is nullptr");
1609 return DMError::DM_ERROR_NULLPTR;
1610 }
1611
1612 MessageParcel data;
1613 MessageParcel reply;
1614 MessageOption option;
1615 if (!data.WriteInterfaceToken(GetDescriptor())) {
1616 WLOGFE("GetAllScreenInfos: WriteInterfaceToken failed");
1617 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1618 }
1619 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS),
1620 data, reply, option) != ERR_NONE) {
1621 WLOGFW("GetAllScreenInfos: SendRequest failed");
1622 return DMError::DM_ERROR_IPC_FAILED;
1623 }
1624 DMError ret = static_cast<DMError>(reply.ReadInt32());
1625 MarshallingHelper::UnmarshallingVectorParcelableObj<ScreenInfo>(reply, screenInfos);
1626 return ret;
1627 }
1628
GetScreenSupportedColorGamuts(ScreenId screenId,std::vector<ScreenColorGamut> & colorGamuts)1629 DMError ScreenSessionManagerProxy::GetScreenSupportedColorGamuts(ScreenId screenId,
1630 std::vector<ScreenColorGamut>& colorGamuts)
1631 {
1632 sptr<IRemoteObject> remote = Remote();
1633 if (remote == nullptr) {
1634 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: remote is nullptr");
1635 return DMError::DM_ERROR_NULLPTR;
1636 }
1637
1638 MessageParcel data;
1639 MessageParcel reply;
1640 MessageOption option;
1641 if (!data.WriteInterfaceToken(GetDescriptor())) {
1642 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteInterfaceToken failed");
1643 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1644 }
1645 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
1646 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteUint64 screenId failed");
1647 return DMError::DM_ERROR_IPC_FAILED;
1648 }
1649 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS),
1650 data, reply, option) != ERR_NONE) {
1651 WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: SendRequest failed");
1652 return DMError::DM_ERROR_IPC_FAILED;
1653 }
1654 DMError ret = static_cast<DMError>(reply.ReadInt32());
1655 if (ret != DMError::DM_OK) {
1656 return ret;
1657 }
1658 MarshallingHelper::UnmarshallingVectorObj<ScreenColorGamut>(reply, colorGamuts,
1659 [](Parcel& parcel, ScreenColorGamut& color) {
1660 uint32_t value;
1661 bool res = parcel.ReadUint32(value);
1662 color = static_cast<ScreenColorGamut>(value);
1663 return res;
1664 }
1665 );
1666 return ret;
1667 }
1668
SetOrientation(ScreenId screenId,Orientation orientation)1669 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetOrientation(ScreenId screenId, Orientation orientation)
1670 {
1671 sptr<IRemoteObject> remote = Remote();
1672 if (remote == nullptr) {
1673 WLOGFW("fail to set orientation: remote is null");
1674 return DMError::DM_ERROR_NULLPTR;
1675 }
1676
1677 MessageParcel data;
1678 MessageParcel reply;
1679 MessageOption option;
1680 if (!data.WriteInterfaceToken(GetDescriptor())) {
1681 WLOGFE("fail to set orientation: WriteInterfaceToken failed");
1682 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1683 }
1684 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
1685 WLOGFW("fail to set orientation: Write screenId failed");
1686 return DMError::DM_ERROR_IPC_FAILED;
1687 }
1688 if (!data.WriteUint32(static_cast<uint32_t>(orientation))) {
1689 WLOGFW("fail to set orientation: Write orientation failed");
1690 return DMError::DM_ERROR_IPC_FAILED;
1691 }
1692 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_ORIENTATION),
1693 data, reply, option) != ERR_NONE) {
1694 WLOGFW("fail to set orientation: SendRequest failed");
1695 return DMError::DM_ERROR_IPC_FAILED;
1696 }
1697 return static_cast<DMError>(reply.ReadInt32());
1698 }
1699
SetScreenRotationLocked(bool isLocked)1700 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetScreenRotationLocked(bool isLocked)
1701 {
1702 sptr<IRemoteObject> remote = Remote();
1703 if (remote == nullptr) {
1704 WLOGFW("remote is null");
1705 return DMError::DM_ERROR_NULLPTR;
1706 }
1707
1708 MessageParcel data;
1709 MessageParcel reply;
1710 MessageOption option;
1711 if (!data.WriteInterfaceToken(GetDescriptor())) {
1712 WLOGFE("WriteInterfaceToken failed");
1713 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1714 }
1715 if (!data.WriteBool(isLocked)) {
1716 WLOGFE("write isLocked failed");
1717 return DMError::DM_ERROR_IPC_FAILED;
1718 }
1719 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED),
1720 data, reply, option) != ERR_NONE) {
1721 WLOGFE("SendRequest failed");
1722 return DMError::DM_ERROR_IPC_FAILED;
1723 }
1724 return static_cast<DMError>(reply.ReadInt32());
1725 }
1726
SetScreenRotationLockedFromJs(bool isLocked)1727 DMError OHOS::Rosen::ScreenSessionManagerProxy::SetScreenRotationLockedFromJs(bool isLocked)
1728 {
1729 sptr<IRemoteObject> remote = Remote();
1730 if (remote == nullptr) {
1731 WLOGFW("remote is null");
1732 return DMError::DM_ERROR_NULLPTR;
1733 }
1734
1735 MessageParcel data;
1736 MessageParcel reply;
1737 MessageOption option;
1738 if (!data.WriteInterfaceToken(GetDescriptor())) {
1739 WLOGFE("WriteInterfaceToken failed");
1740 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1741 }
1742 if (!data.WriteBool(isLocked)) {
1743 WLOGFE("write isLocked failed");
1744 return DMError::DM_ERROR_IPC_FAILED;
1745 }
1746 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS),
1747 data, reply, option) != ERR_NONE) {
1748 WLOGFE("SendRequest failed");
1749 return DMError::DM_ERROR_IPC_FAILED;
1750 }
1751 return static_cast<DMError>(reply.ReadInt32());
1752 }
1753
IsScreenRotationLocked(bool & isLocked)1754 DMError OHOS::Rosen::ScreenSessionManagerProxy::IsScreenRotationLocked(bool& isLocked)
1755 {
1756 sptr<IRemoteObject> remote = Remote();
1757 if (remote == nullptr) {
1758 WLOGFW("remote is nullptr");
1759 return DMError::DM_ERROR_NULLPTR;
1760 }
1761
1762 MessageParcel data;
1763 MessageParcel reply;
1764 MessageOption option;
1765 if (!data.WriteInterfaceToken(GetDescriptor())) {
1766 WLOGFE("WriteInterfaceToken failed");
1767 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1768 }
1769 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED),
1770 data, reply, option) != ERR_NONE) {
1771 WLOGFW("SendRequest failed");
1772 return DMError::DM_ERROR_IPC_FAILED;
1773 }
1774 DMError ret = static_cast<DMError>(reply.ReadInt32());
1775 isLocked = reply.ReadBool();
1776 return ret;
1777 }
1778
GetCutoutInfo(DisplayId displayId)1779 sptr<CutoutInfo> ScreenSessionManagerProxy::GetCutoutInfo(DisplayId displayId)
1780 {
1781 sptr<IRemoteObject> remote = Remote();
1782 if (remote == nullptr) {
1783 WLOGFW("get cutout info : remote is null");
1784 return nullptr;
1785 }
1786 MessageParcel data;
1787 MessageParcel reply;
1788 MessageOption option;
1789 if (!data.WriteInterfaceToken(GetDescriptor())) {
1790 WLOGFE("get cutout info : failed");
1791 return nullptr;
1792 }
1793 if (!data.WriteUint64(displayId)) {
1794 WLOGFE("get cutout info: write displayId failed");
1795 return nullptr;
1796 }
1797 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO),
1798 data, reply, option) != ERR_NONE) {
1799 WLOGFW("GetCutoutInfo: GetCutoutInfo failed");
1800 return nullptr;
1801 }
1802 sptr<CutoutInfo> info = reply.ReadParcelable<CutoutInfo>();
1803 return info;
1804 }
1805
HasImmersiveWindow(bool & immersive)1806 DMError ScreenSessionManagerProxy::HasImmersiveWindow(bool& immersive)
1807 {
1808 sptr<IRemoteObject> remote = Remote();
1809 if (remote == nullptr) {
1810 WLOGFW("remote is nullptr");
1811 return DMError::DM_ERROR_NULLPTR;
1812 }
1813
1814 MessageParcel data;
1815 MessageParcel reply;
1816 MessageOption option;
1817 if (!data.WriteInterfaceToken(GetDescriptor())) {
1818 WLOGFE("WriteInterfaceToken failed");
1819 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1820 }
1821
1822 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_HAS_IMMERSIVE_WINDOW),
1823 data, reply, option) != ERR_NONE) {
1824 WLOGFW("SendRequest failed");
1825 return DMError::DM_ERROR_IPC_FAILED;
1826 }
1827 DMError ret = static_cast<DMError>(reply.ReadInt32());
1828 immersive = reply.ReadBool();
1829 return ret;
1830 }
1831
ConvertScreenIdToRsScreenId(ScreenId screenId,ScreenId & rsScreenId)1832 bool OHOS::Rosen::ScreenSessionManagerProxy::ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId)
1833 {
1834 sptr<IRemoteObject> remote = Remote();
1835 if (remote == nullptr) {
1836 WLOGFW("remote is nullptr");
1837 return false;
1838 }
1839
1840 MessageParcel data;
1841 MessageParcel reply;
1842 MessageOption option;
1843 if (!data.WriteInterfaceToken(GetDescriptor())) {
1844 WLOGFE("WriteInterfaceToken failed");
1845 return false;
1846 }
1847
1848 if (!data.WriteUint64(screenId)) {
1849 return false;
1850 }
1851
1852 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_CONVERT_SCREENID_TO_RSSCREENID),
1853 data, reply, option) != ERR_NONE) {
1854 WLOGFW("SendRequest failed");
1855 return false;
1856 }
1857 bool ret = reply.ReadBool();
1858 rsScreenId = static_cast<ScreenId>(reply.ReadUint64());
1859 return ret;
1860 }
1861
HasPrivateWindow(DisplayId displayId,bool & hasPrivateWindow)1862 DMError OHOS::Rosen::ScreenSessionManagerProxy::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow)
1863 {
1864 sptr<IRemoteObject> remote = Remote();
1865 if (remote == nullptr) {
1866 WLOGFW("remote is nullptr");
1867 return DMError::DM_ERROR_NULLPTR;
1868 }
1869
1870 MessageParcel data;
1871 MessageParcel reply;
1872 MessageOption option;
1873 if (!data.WriteInterfaceToken(GetDescriptor())) {
1874 WLOGFE("WriteInterfaceToken failed");
1875 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1876 }
1877
1878 if (!data.WriteUint64(displayId)) {
1879 return DMError::DM_ERROR_IPC_FAILED;
1880 }
1881
1882 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW),
1883 data, reply, option) != ERR_NONE) {
1884 WLOGFW("SendRequest failed");
1885 return DMError::DM_ERROR_IPC_FAILED;
1886 }
1887 DMError ret = static_cast<DMError>(reply.ReadInt32());
1888 hasPrivateWindow = reply.ReadBool();
1889 return ret;
1890 }
1891
DumpAllScreensInfo(std::string & dumpInfo)1892 void ScreenSessionManagerProxy::DumpAllScreensInfo(std::string& dumpInfo)
1893 {
1894 sptr<IRemoteObject> remote = Remote();
1895 if (remote == nullptr) {
1896 WLOGFW("remote is null");
1897 return;
1898 }
1899 MessageParcel data;
1900 MessageParcel reply;
1901 MessageOption option;
1902 if (!data.WriteInterfaceToken(GetDescriptor())) {
1903 WLOGFE("failed");
1904 return;
1905 }
1906 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_ALL_SCREEN),
1907 data, reply, option) != ERR_NONE) {
1908 WLOGFW("failed");
1909 return;
1910 }
1911 dumpInfo = reply.ReadString();
1912 }
1913
DumpSpecialScreenInfo(ScreenId id,std::string & dumpInfo)1914 void ScreenSessionManagerProxy::DumpSpecialScreenInfo(ScreenId id, std::string& dumpInfo)
1915 {
1916 sptr<IRemoteObject> remote = Remote();
1917 if (remote == nullptr) {
1918 WLOGFW("remote is null");
1919 return;
1920 }
1921 MessageParcel data;
1922 MessageParcel reply;
1923 MessageOption option;
1924 if (!data.WriteInterfaceToken(GetDescriptor())) {
1925 WLOGFE("failed");
1926 return;
1927 }
1928 if (!data.WriteUint64(id)) {
1929 WLOGFE("write ScreenId failed");
1930 return;
1931 }
1932 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_DUMP_SPECIAL_SCREEN),
1933 data, reply, option) != ERR_NONE) {
1934 WLOGFW("failed");
1935 return;
1936 }
1937 dumpInfo = reply.ReadString();
1938 }
1939
1940 //Fold Screen
SetFoldDisplayMode(const FoldDisplayMode displayMode)1941 void ScreenSessionManagerProxy::SetFoldDisplayMode(const FoldDisplayMode displayMode)
1942 {
1943 sptr<IRemoteObject> remote = Remote();
1944 if (remote == nullptr) {
1945 WLOGFW("remote is null");
1946 return;
1947 }
1948 MessageParcel data;
1949 MessageParcel reply;
1950 MessageOption option;
1951 if (!data.WriteInterfaceToken(GetDescriptor())) {
1952 WLOGFE("WriteInterfaceToken Failed");
1953 return;
1954 }
1955 if (!data.WriteUint32(static_cast<uint32_t>(displayMode))) {
1956 WLOGFE("Write displayMode failed");
1957 return;
1958 }
1959 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE),
1960 data, reply, option) != ERR_NONE) {
1961 WLOGFE("Send TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE request failed");
1962 }
1963 }
1964
1965 //SetFoldDisplayModeFromJs add DMError to return DMErrorCode for js
SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode)1966 DMError ScreenSessionManagerProxy::SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode)
1967 {
1968 sptr<IRemoteObject> remote = Remote();
1969 if (remote == nullptr) {
1970 WLOGFW("remote is null");
1971 return DMError::DM_ERROR_NULLPTR;
1972 }
1973 MessageParcel data;
1974 MessageParcel reply;
1975 MessageOption option;
1976 if (!data.WriteInterfaceToken(GetDescriptor())) {
1977 WLOGFE("WriteInterfaceToken Failed");
1978 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
1979 }
1980 if (!data.WriteUint32(static_cast<uint32_t>(displayMode))) {
1981 WLOGFE("Write displayMode failed");
1982 return DMError::DM_ERROR_IPC_FAILED;
1983 }
1984 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE_FROM_JS),
1985 data, reply, option) != ERR_NONE) {
1986 WLOGFE("Send request failed");
1987 return DMError::DM_ERROR_IPC_FAILED;
1988 }
1989
1990 DMError ret = static_cast<DMError>(reply.ReadInt32());
1991 return ret;
1992 }
1993
SetDisplayScale(ScreenId screenId,float scaleX,float scaleY,float pivotX,float pivotY)1994 void ScreenSessionManagerProxy::SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX,
1995 float pivotY)
1996 {
1997 sptr<IRemoteObject> remote = Remote();
1998 if (remote == nullptr) {
1999 WLOGFW("remote is null");
2000 return;
2001 }
2002 MessageParcel data;
2003 MessageParcel reply;
2004 MessageOption option;
2005 if (!data.WriteInterfaceToken(GetDescriptor())) {
2006 WLOGFE("WriteInterfaceToken Failed");
2007 return;
2008 }
2009 if (!(data.WriteUint64(static_cast<uint64_t>(screenId)) && data.WriteFloat(scaleX) && data.WriteFloat(scaleY) &&
2010 data.WriteFloat(pivotX) && data.WriteFloat(pivotY))) {
2011 WLOGFE("Write screen scale info failed");
2012 return;
2013 }
2014 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE),
2015 data, reply, option) != ERR_NONE) {
2016 WLOGFE("Send TRANS_ID_SCENE_BOARD_SET_DISPLAY_SCALE request failed");
2017 }
2018 }
2019
SetFoldStatusLocked(bool locked)2020 void ScreenSessionManagerProxy::SetFoldStatusLocked(bool locked)
2021 {
2022 sptr<IRemoteObject> remote = Remote();
2023 if (remote == nullptr) {
2024 WLOGFW("remote is null");
2025 return;
2026 }
2027 MessageParcel data;
2028 MessageParcel reply;
2029 MessageOption option;
2030 if (!data.WriteInterfaceToken(GetDescriptor())) {
2031 WLOGFE("WriteInterfaceToken Failed");
2032 return;
2033 }
2034 if (!data.WriteUint32(static_cast<uint32_t>(locked))) {
2035 WLOGFE("Write lock fold display status failed");
2036 return;
2037 }
2038 if (remote->SendRequest(static_cast<uint32_t>(
2039 DisplayManagerMessage::TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS),
2040 data, reply, option) != ERR_NONE) {
2041 WLOGFE("Send TRANS_ID_SCENE_BOARD_LOCK_FOLD_DISPLAY_STATUS request failed");
2042 }
2043 }
2044
2045 // SetFoldStatusLockedFromJs add DMError to return DMErrorCode for js
SetFoldStatusLockedFromJs(bool locked)2046 DMError ScreenSessionManagerProxy::SetFoldStatusLockedFromJs(bool locked)
2047 {
2048 sptr<IRemoteObject> remote = Remote();
2049 if (remote == nullptr) {
2050 WLOGFW("remote is null");
2051 return DMError::DM_ERROR_NULLPTR;
2052 }
2053 MessageParcel data;
2054 MessageParcel reply;
2055 MessageOption option;
2056 if (!data.WriteInterfaceToken(GetDescriptor())) {
2057 WLOGFE("WriteInterfaceToken Failed");
2058 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2059 }
2060 if (!data.WriteUint32(static_cast<uint32_t>(locked))) {
2061 WLOGFE("Write lock fold display status failed");
2062 return DMError::DM_ERROR_IPC_FAILED;
2063 }
2064 if (remote->SendRequest(static_cast<uint32_t>(
2065 DisplayManagerMessage::TRANS_ID_SET_LOCK_FOLD_DISPLAY_STATUS_FROM_JS),
2066 data, reply, option) != ERR_NONE) {
2067 WLOGFE("Send request failed");
2068 return DMError::DM_ERROR_IPC_FAILED;
2069 }
2070
2071 DMError ret = static_cast<DMError>(reply.ReadInt32());
2072 return ret;
2073 }
2074
GetFoldDisplayMode()2075 FoldDisplayMode ScreenSessionManagerProxy::GetFoldDisplayMode()
2076 {
2077 sptr<IRemoteObject> remote = Remote();
2078 if (remote == nullptr) {
2079 WLOGFW("remote is null");
2080 return FoldDisplayMode::UNKNOWN;
2081 }
2082 MessageParcel data;
2083 MessageParcel reply;
2084 MessageOption option;
2085 if (!data.WriteInterfaceToken(GetDescriptor())) {
2086 WLOGFE("WriteInterfaceToken Failed");
2087 return FoldDisplayMode::UNKNOWN;
2088 }
2089 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE),
2090 data, reply, option) != ERR_NONE) {
2091 WLOGFE("Send TRANS_ID_SCENE_BOARD_GET_FOLD_DISPLAY_MODE request failed");
2092 return FoldDisplayMode::UNKNOWN;
2093 }
2094 return static_cast<FoldDisplayMode>(reply.ReadUint32());
2095 }
2096
IsFoldable()2097 bool ScreenSessionManagerProxy::IsFoldable()
2098 {
2099 sptr<IRemoteObject> remote = Remote();
2100 if (remote == nullptr) {
2101 WLOGFW("remote is null");
2102 return false;
2103 }
2104
2105 MessageParcel data;
2106 MessageParcel reply;
2107 MessageOption option;
2108 if (!data.WriteInterfaceToken(GetDescriptor())) {
2109 WLOGFE("WriteInterfaceToken failed");
2110 return false;
2111 }
2112 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_IS_FOLDABLE),
2113 data, reply, option) != ERR_NONE) {
2114 WLOGFE("SendRequest failed");
2115 return false;
2116 }
2117 return reply.ReadBool();
2118 }
2119
IsCaptured()2120 bool ScreenSessionManagerProxy::IsCaptured()
2121 {
2122 sptr<IRemoteObject> remote = Remote();
2123 if (remote == nullptr) {
2124 WLOGFW("remote is null");
2125 return false;
2126 }
2127
2128 MessageParcel data;
2129 MessageParcel reply;
2130 MessageOption option;
2131 if (!data.WriteInterfaceToken(GetDescriptor())) {
2132 WLOGFE("WriteInterfaceToken failed");
2133 return false;
2134 }
2135 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DEVICE_IS_CAPTURE),
2136 data, reply, option) != ERR_NONE) {
2137 WLOGFE("SendRequest failed");
2138 return false;
2139 }
2140 return reply.ReadBool();
2141 }
2142
GetFoldStatus()2143 FoldStatus ScreenSessionManagerProxy::GetFoldStatus()
2144 {
2145 sptr<IRemoteObject> remote = Remote();
2146 if (remote == nullptr) {
2147 WLOGFW("remote is null");
2148 return FoldStatus::UNKNOWN;
2149 }
2150
2151 MessageParcel data;
2152 MessageParcel reply;
2153 MessageOption option;
2154 if (!data.WriteInterfaceToken(GetDescriptor())) {
2155 WLOGFE("WriteInterfaceToken failed");
2156 return FoldStatus::UNKNOWN;
2157 }
2158 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_FOLD_STATUS),
2159 data, reply, option) != ERR_NONE) {
2160 WLOGFE("SendRequest failed");
2161 return FoldStatus::UNKNOWN;
2162 }
2163 return static_cast<FoldStatus>(reply.ReadUint32());
2164 }
2165
GetCurrentFoldCreaseRegion()2166 sptr<FoldCreaseRegion> ScreenSessionManagerProxy::GetCurrentFoldCreaseRegion()
2167 {
2168 sptr<IRemoteObject> remote = Remote();
2169 if (remote == nullptr) {
2170 WLOGFW("remote is null");
2171 return nullptr;
2172 }
2173
2174 MessageParcel data;
2175 MessageParcel reply;
2176 MessageOption option;
2177 if (!data.WriteInterfaceToken(GetDescriptor())) {
2178 WLOGFE("WriteInterfaceToken failed");
2179 return nullptr;
2180 }
2181 if (remote->SendRequest(
2182 static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_GET_CURRENT_FOLD_CREASE_REGION),
2183 data, reply, option) != ERR_NONE) {
2184 WLOGFE("SendRequest failed");
2185 return nullptr;
2186 }
2187 return reply.ReadStrongParcelable<FoldCreaseRegion>();
2188 }
2189
MakeUniqueScreen(const std::vector<ScreenId> & screenIds)2190 DMError ScreenSessionManagerProxy::MakeUniqueScreen(const std::vector<ScreenId>& screenIds)
2191 {
2192 WLOGFI("ScreenSessionManagerProxy::MakeUniqueScreen");
2193 sptr<IRemoteObject> remote = Remote();
2194 if (remote == nullptr) {
2195 WLOGFW("make unique screen failed: remote is null");
2196 return DMError::DM_ERROR_NULLPTR;
2197 }
2198
2199 MessageParcel data;
2200 MessageParcel reply;
2201 MessageOption option;
2202 if (!data.WriteInterfaceToken(GetDescriptor())) {
2203 WLOGFE("MakeUniqueScreen writeInterfaceToken failed");
2204 return DMError::DM_ERROR_NULLPTR;
2205 }
2206 if (!data.WriteUint32(screenIds.size())) {
2207 WLOGFE("MakeUniqueScreen write screenIds size failed");
2208 return DMError::DM_ERROR_INVALID_PARAM;
2209 }
2210 bool res = data.WriteUInt64Vector(screenIds);
2211 if (!res) {
2212 WLOGFE("MakeUniqueScreen fail: write screens failed");
2213 return DMError::DM_ERROR_NULLPTR;
2214 }
2215 if (remote->SendRequest(
2216 static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN),
2217 data, reply, option) != ERR_NONE) {
2218 WLOGFE("MakeUniqueScreen fail: SendRequest failed");
2219 return DMError::DM_ERROR_NULLPTR;
2220 }
2221 return static_cast<DMError>(reply.ReadInt32());
2222 }
2223
SetClient(const sptr<IScreenSessionManagerClient> & client)2224 void ScreenSessionManagerProxy::SetClient(const sptr<IScreenSessionManagerClient>& client)
2225 {
2226 sptr<IRemoteObject> remote = Remote();
2227 if (remote == nullptr) {
2228 WLOGFE("SetClient: remote is null");
2229 return;
2230 }
2231
2232 MessageParcel data;
2233 MessageParcel reply;
2234 MessageOption option(MessageOption::TF_SYNC);
2235 if (!data.WriteInterfaceToken(GetDescriptor())) {
2236 WLOGFE("WriteInterfaceToken failed");
2237 return;
2238 }
2239 if (!client || !data.WriteRemoteObject(client->AsObject())) {
2240 WLOGFE("WriteRemoteObject failed");
2241 return;
2242 }
2243 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_CLIENT),
2244 data, reply, option) != ERR_NONE) {
2245 WLOGFE("SendRequest failed");
2246 return;
2247 }
2248 }
2249
SwitchUser()2250 void ScreenSessionManagerProxy::SwitchUser()
2251 {
2252 sptr<IRemoteObject> remote = Remote();
2253 if (remote == nullptr) {
2254 WLOGFE("SwitchUser: remote is null");
2255 return;
2256 }
2257
2258 MessageParcel data;
2259 MessageParcel reply;
2260 MessageOption option(MessageOption::TF_SYNC);
2261 if (!data.WriteInterfaceToken(GetDescriptor())) {
2262 WLOGFE("WriteInterfaceToken failed");
2263 return;
2264 }
2265 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SWITCH_USER),
2266 data, reply, option) != ERR_NONE) {
2267 WLOGFE("SendRequest failed");
2268 return;
2269 }
2270 }
2271
GetScreenProperty(ScreenId screenId)2272 ScreenProperty ScreenSessionManagerProxy::GetScreenProperty(ScreenId screenId)
2273 {
2274 sptr<IRemoteObject> remote = Remote();
2275 if (remote == nullptr) {
2276 WLOGFE("GetScreenProperty: remote is null");
2277 return {};
2278 }
2279
2280 MessageParcel data;
2281 MessageParcel reply;
2282 MessageOption option(MessageOption::TF_SYNC);
2283 if (!data.WriteInterfaceToken(GetDescriptor())) {
2284 WLOGFE("WriteInterfaceToken failed");
2285 return {};
2286 }
2287 if (!data.WriteUint64(screenId)) {
2288 WLOGFE("Write screenId failed");
2289 return {};
2290 }
2291 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_SCREEN_PROPERTY),
2292 data, reply, option) != ERR_NONE) {
2293 WLOGFE("SendRequest failed");
2294 return {};
2295 }
2296 ScreenProperty screenProperty;
2297 if (!RSMarshallingHelper::Unmarshalling(reply, screenProperty)) {
2298 WLOGFE("Read screenProperty failed");
2299 return {};
2300 }
2301 return screenProperty;
2302 }
2303
GetDisplayNode(ScreenId screenId)2304 std::shared_ptr<RSDisplayNode> ScreenSessionManagerProxy::GetDisplayNode(ScreenId screenId)
2305 {
2306 sptr<IRemoteObject> remote = Remote();
2307 if (remote == nullptr) {
2308 WLOGFE("GetDisplayNode: remote is null");
2309 return nullptr;
2310 }
2311
2312 MessageParcel data;
2313 MessageParcel reply;
2314 MessageOption option(MessageOption::TF_SYNC);
2315 if (!data.WriteInterfaceToken(GetDescriptor())) {
2316 WLOGFE("WriteInterfaceToken failed");
2317 return nullptr;
2318 }
2319 if (!data.WriteUint64(screenId)) {
2320 WLOGFE("Write screenId failed");
2321 return nullptr;
2322 }
2323 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_NODE),
2324 data, reply, option) != ERR_NONE) {
2325 WLOGFE("SendRequest failed");
2326 return nullptr;
2327 }
2328
2329 auto displayNode = RSDisplayNode::Unmarshalling(reply);
2330 if (!displayNode) {
2331 WLOGFE("displayNode is null");
2332 return nullptr;
2333 }
2334 return displayNode;
2335 }
2336
UpdateScreenDirectionInfo(ScreenId screenId,float screenComponentRotation,float rotation,float phyRotation,ScreenPropertyChangeType screenPropertyChangeType)2337 void ScreenSessionManagerProxy::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation,
2338 float rotation, float phyRotation, ScreenPropertyChangeType screenPropertyChangeType)
2339 {
2340 sptr<IRemoteObject> remote = Remote();
2341 if (remote == nullptr) {
2342 WLOGFE("UpdateScreenDirectionInfo: 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 (!data.WriteFloat(screenComponentRotation)) {
2358 WLOGFE("Write screenComponentRotation failed");
2359 return;
2360 }
2361 if (!data.WriteFloat(rotation)) {
2362 WLOGFE("Write rotation failed");
2363 return;
2364 }
2365 if (!data.WriteFloat(phyRotation)) {
2366 WLOGFE("Write phyRotation failed");
2367 return;
2368 }
2369 if (!data.WriteUint32(static_cast<uint32_t>(screenPropertyChangeType))) {
2370 WLOGFE("Write screenPropertyChangeType failed");
2371 return;
2372 }
2373 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO),
2374 data, reply, option) != ERR_NONE) {
2375 WLOGFE("SendRequest failed");
2376 return;
2377 }
2378 }
2379
UpdateScreenRotationProperty(ScreenId screenId,const RRect & bounds,float rotation,ScreenPropertyChangeType screenPropertyChangeType)2380 void ScreenSessionManagerProxy::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
2381 ScreenPropertyChangeType screenPropertyChangeType)
2382 {
2383 sptr<IRemoteObject> remote = Remote();
2384 if (remote == nullptr) {
2385 WLOGFE("UpdateScreenRotationProperty: remote is null");
2386 return;
2387 }
2388
2389 MessageParcel data;
2390 MessageParcel reply;
2391 MessageOption option(MessageOption::TF_SYNC);
2392 if (!data.WriteInterfaceToken(GetDescriptor())) {
2393 WLOGFE("WriteInterfaceToken failed");
2394 return;
2395 }
2396 if (!data.WriteUint64(screenId)) {
2397 WLOGFE("Write screenId failed");
2398 return;
2399 }
2400 if (!RSMarshallingHelper::Marshalling(data, bounds)) {
2401 WLOGFE("Write bounds failed");
2402 return;
2403 }
2404 if (!data.WriteFloat(rotation)) {
2405 WLOGFE("Write rotation failed");
2406 return;
2407 }
2408 if (!data.WriteUint32(static_cast<uint32_t>(screenPropertyChangeType))) {
2409 WLOGFE("Write screenPropertyChangeType failed");
2410 return;
2411 }
2412 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY),
2413 data, reply, option) != ERR_NONE) {
2414 WLOGFE("SendRequest failed");
2415 return;
2416 }
2417 }
2418
GetCurvedCompressionArea()2419 uint32_t ScreenSessionManagerProxy::GetCurvedCompressionArea()
2420 {
2421 sptr<IRemoteObject> remote = Remote();
2422 if (remote == nullptr) {
2423 WLOGFE("GetCurvedCompressionArea: remote is null");
2424 return 0;
2425 }
2426
2427 MessageParcel data;
2428 MessageParcel reply;
2429 MessageOption option(MessageOption::TF_SYNC);
2430 if (!data.WriteInterfaceToken(GetDescriptor())) {
2431 WLOGFE("WriteInterfaceToken failed");
2432 return 0;
2433 }
2434 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_CURVED_SCREEN_COMPRESSION_AREA),
2435 data, reply, option) != ERR_NONE) {
2436 WLOGFE("SendRequest failed");
2437 return 0;
2438 }
2439
2440 return reply.ReadUint32();
2441 }
2442
GetPhyScreenProperty(ScreenId screenId)2443 ScreenProperty ScreenSessionManagerProxy::GetPhyScreenProperty(ScreenId screenId)
2444 {
2445 sptr<IRemoteObject> remote = Remote();
2446 if (remote == nullptr) {
2447 WLOGFE("GetPhyScreenProperty: remote is null");
2448 return {};
2449 }
2450
2451 MessageParcel data;
2452 MessageParcel reply;
2453 MessageOption option(MessageOption::TF_SYNC);
2454 if (!data.WriteInterfaceToken(GetDescriptor())) {
2455 WLOGFE("WriteInterfaceToken failed");
2456 return {};
2457 }
2458 if (!data.WriteUint64(screenId)) {
2459 WLOGFE("Write screenId failed");
2460 return {};
2461 }
2462 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_PHY_SCREEN_PROPERTY),
2463 data, reply, option) != ERR_NONE) {
2464 WLOGFE("SendRequest failed");
2465 return {};
2466 }
2467 ScreenProperty screenProperty;
2468 if (!RSMarshallingHelper::Unmarshalling(reply, screenProperty)) {
2469 WLOGFE("Read screenProperty failed");
2470 return {};
2471 }
2472 return screenProperty;
2473 }
2474
NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo> & info)2475 void ScreenSessionManagerProxy::NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo>& info)
2476 {
2477 sptr<IRemoteObject> remote = Remote();
2478 if (remote == nullptr) {
2479 WLOGFE("NotifyDisplayChangeInfoChanged: remote is null");
2480 return;
2481 }
2482
2483 MessageOption option(MessageOption::TF_ASYNC);
2484 MessageParcel reply;
2485 MessageParcel data;
2486 if (!data.WriteInterfaceToken(GetDescriptor())) {
2487 WLOGFE("WriteInterfaceToken failed");
2488 return;
2489 }
2490 if (!info->Marshalling(data)) {
2491 WLOGFE("Write display change info failed");
2492 return;
2493 }
2494 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_CHANGE_INFO),
2495 data, reply, option) != ERR_NONE) {
2496 WLOGFE("SendRequest failed");
2497 return;
2498 }
2499 }
2500
SetScreenPrivacyState(bool hasPrivate)2501 void ScreenSessionManagerProxy::SetScreenPrivacyState(bool hasPrivate)
2502 {
2503 sptr<IRemoteObject> remote = Remote();
2504 if (remote == nullptr) {
2505 WLOGFE("SetScreenPrivacyState: remote is null");
2506 return;
2507 }
2508
2509 MessageParcel data;
2510 MessageParcel reply;
2511 MessageOption option(MessageOption::TF_SYNC);
2512 if (!data.WriteInterfaceToken(GetDescriptor())) {
2513 WLOGFE("WriteInterfaceToken failed");
2514 return;
2515 }
2516 if (!data.WriteBool(hasPrivate)) {
2517 WLOGFE("Write hasPrivate failed");
2518 return;
2519 }
2520 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_PRIVACY_STATE),
2521 data, reply, option) != ERR_NONE) {
2522 WLOGFE("SendRequest failed");
2523 return;
2524 }
2525 }
2526
SetPrivacyStateByDisplayId(DisplayId id,bool hasPrivate)2527 void ScreenSessionManagerProxy::SetPrivacyStateByDisplayId(DisplayId id, bool hasPrivate)
2528 {
2529 sptr<IRemoteObject> remote = Remote();
2530 if (remote == nullptr) {
2531 WLOGFE("SetPrivacyStateByDisplayId: remote is null");
2532 return;
2533 }
2534
2535 MessageParcel data;
2536 MessageParcel reply;
2537 MessageOption option(MessageOption::TF_SYNC);
2538 if (!data.WriteInterfaceToken(GetDescriptor())) {
2539 WLOGFE("WriteInterfaceToken failed");
2540 return;
2541 }
2542 if (!data.WriteUint64(id)) {
2543 WLOGFE("Write DisplayId failed");
2544 return;
2545 }
2546 if (!data.WriteBool(hasPrivate)) {
2547 WLOGFE("Write hasPrivate failed");
2548 return;
2549 }
2550 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREENID_PRIVACY_STATE),
2551 data, reply, option) != ERR_NONE) {
2552 WLOGFE("SendRequest failed");
2553 return;
2554 }
2555 }
2556
SetScreenPrivacyWindowList(DisplayId id,std::vector<std::string> privacyWindowList)2557 void ScreenSessionManagerProxy::SetScreenPrivacyWindowList(DisplayId id, std::vector<std::string> privacyWindowList)
2558 {
2559 sptr<IRemoteObject> remote = Remote();
2560 if (remote == nullptr) {
2561 WLOGFE("SetScreenPrivacyWindowList: remote is null");
2562 return;
2563 }
2564
2565 MessageParcel data;
2566 MessageParcel reply;
2567 MessageOption option(MessageOption::TF_SYNC);
2568 if (!data.WriteInterfaceToken(GetDescriptor())) {
2569 WLOGFE("WriteInterfaceToken failed");
2570 return;
2571 }
2572 if (!data.WriteUint64(id)) {
2573 WLOGFE("Write DisplayId failed");
2574 return;
2575 }
2576 if (!data.WriteStringVector(privacyWindowList)) {
2577 WLOGFE("Write privacyWindowList failed");
2578 return;
2579 }
2580 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_PRIVACY_WINDOW_LIST),
2581 data, reply, option) != ERR_NONE) {
2582 WLOGFE("SendRequest failed");
2583 return;
2584 }
2585 }
2586
UpdateAvailableArea(ScreenId screenId,DMRect area)2587 void ScreenSessionManagerProxy::UpdateAvailableArea(ScreenId screenId, DMRect area)
2588 {
2589 sptr<IRemoteObject> remote = Remote();
2590 if (remote == nullptr) {
2591 WLOGFE("UpdateAvailableArea: remote is null");
2592 return;
2593 }
2594
2595 MessageOption option(MessageOption::TF_ASYNC);
2596 MessageParcel reply;
2597 MessageParcel data;
2598 if (!data.WriteInterfaceToken(GetDescriptor())) {
2599 WLOGFE("WriteInterfaceToken failed");
2600 return;
2601 }
2602 if (!data.WriteUint64(screenId)) {
2603 WLOGFE("Write screenId failed");
2604 return;
2605 }
2606 if (!data.WriteInt32(area.posX_) || !data.WriteInt32(area.posY_) || !data.WriteUint32(area.width_) ||
2607 !data.WriteInt32(area.height_)) {
2608 WLOGFE("Write area failed");
2609 return;
2610 }
2611 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_UPDATE_AVAILABLE_AREA),
2612 data, reply, option) != ERR_NONE) {
2613 WLOGFE("SendRequest failed");
2614 return;
2615 }
2616 }
2617
SetScreenOffDelayTime(int32_t delay)2618 int32_t ScreenSessionManagerProxy::SetScreenOffDelayTime(int32_t delay)
2619 {
2620 sptr<IRemoteObject> remote = Remote();
2621 if (remote == nullptr) {
2622 WLOGFE("SetScreenOffDelayTime: remote is null");
2623 return 0;
2624 }
2625
2626 MessageOption option(MessageOption::TF_SYNC);
2627 MessageParcel reply;
2628 MessageParcel data;
2629 if (!data.WriteInterfaceToken(GetDescriptor())) {
2630 WLOGFE("WriteInterfaceToken failed");
2631 return 0;
2632 }
2633 if (!data.WriteInt32(delay)) {
2634 WLOGFE("Write delay failed");
2635 return 0;
2636 }
2637 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_OFF_DELAY_TIME),
2638 data, reply, option) != ERR_NONE) {
2639 WLOGFE("SendRequest failed");
2640 return 0;
2641 }
2642 return reply.ReadInt32();
2643 }
2644
SetCameraStatus(int32_t cameraStatus,int32_t cameraPosition)2645 void ScreenSessionManagerProxy::SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition)
2646 {
2647 sptr<IRemoteObject> remote = Remote();
2648 if (remote == nullptr) {
2649 WLOGFE("SetCameraStatus: remote is null");
2650 return;
2651 }
2652
2653 MessageOption option(MessageOption::TF_SYNC);
2654 MessageParcel reply;
2655 MessageParcel data;
2656 if (!data.WriteInterfaceToken(GetDescriptor())) {
2657 WLOGFE("WriteInterfaceToken failed");
2658 return;
2659 }
2660 if (!data.WriteInt32(cameraStatus)) {
2661 WLOGFE("Write cameraStatus failed");
2662 return;
2663 }
2664 if (!data.WriteInt32(cameraPosition)) {
2665 WLOGFE("Write cameraPosition failed");
2666 return;
2667 }
2668 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_CAMERA_STATUS),
2669 data, reply, option) != ERR_NONE) {
2670 WLOGFE("SendRequest failed");
2671 return;
2672 }
2673 }
2674
GetAvailableArea(DisplayId displayId,DMRect & area)2675 DMError ScreenSessionManagerProxy::GetAvailableArea(DisplayId displayId, DMRect& area)
2676 {
2677 sptr<IRemoteObject> remote = Remote();
2678 if (remote == nullptr) {
2679 WLOGFE("GetAvailableArea: remote is null");
2680 return DMError::DM_ERROR_IPC_FAILED;
2681 }
2682
2683 MessageOption option;
2684 MessageParcel reply;
2685 MessageParcel data;
2686 if (!data.WriteInterfaceToken(GetDescriptor())) {
2687 WLOGFE("WriteInterfaceToken failed");
2688 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2689 }
2690 if (!data.WriteUint64(displayId)) {
2691 WLOGFE("Write displayId failed");
2692 return DMError::DM_ERROR_WRITE_DATA_FAILED;
2693 }
2694 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_AVAILABLE_AREA),
2695 data, reply, option) != ERR_NONE) {
2696 WLOGFE("SendRequest failed");
2697 return DMError::DM_ERROR_IPC_FAILED;
2698 }
2699 DMError ret = static_cast<DMError>(reply.ReadInt32());
2700 int32_t posX = reply.ReadInt32();
2701 int32_t posY = reply.ReadInt32();
2702 uint32_t width = reply.ReadUint32();
2703 uint32_t height = reply.ReadUint32();
2704 area = {posX, posY, width, height};
2705 return ret;
2706 }
2707
NotifyFoldToExpandCompletion(bool foldToExpand)2708 void ScreenSessionManagerProxy::NotifyFoldToExpandCompletion(bool foldToExpand)
2709 {
2710 sptr<IRemoteObject> remote = Remote();
2711 if (remote == nullptr) {
2712 WLOGFE("NotifyFoldToExpandCompletion: remote is null");
2713 return;
2714 }
2715
2716 MessageOption option(MessageOption::TF_ASYNC);
2717 MessageParcel reply;
2718 MessageParcel data;
2719 if (!data.WriteInterfaceToken(GetDescriptor())) {
2720 WLOGFE("WriteInterfaceToken failed");
2721 return ;
2722 }
2723 if (!data.WriteBool(foldToExpand)) {
2724 WLOGFE("Write foldToExpand failed");
2725 return;
2726 }
2727 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_FOLD_TO_EXPAND_COMPLETION),
2728 data, reply, option) != ERR_NONE) {
2729 WLOGFE("SendRequest failed");
2730 return;
2731 }
2732 }
2733
GetVirtualScreenFlag(ScreenId screenId)2734 VirtualScreenFlag ScreenSessionManagerProxy::GetVirtualScreenFlag(ScreenId screenId)
2735 {
2736 sptr<IRemoteObject> remote = Remote();
2737 if (remote == nullptr) {
2738 WLOGFE("GetVirtualScreenFlag: remote is null");
2739 return VirtualScreenFlag::DEFAULT;
2740 }
2741
2742 if (screenId == SCREEN_ID_INVALID) {
2743 return VirtualScreenFlag::DEFAULT;
2744 }
2745 MessageOption option(MessageOption::TF_SYNC);
2746 MessageParcel reply;
2747 MessageParcel data;
2748 if (!data.WriteInterfaceToken(GetDescriptor())) {
2749 WLOGFE("WriteInterfaceToken failed");
2750 return VirtualScreenFlag::DEFAULT;
2751 }
2752 if (!data.WriteUint64(screenId)) {
2753 WLOGFE("Write screenId failed");
2754 return VirtualScreenFlag::DEFAULT;
2755 }
2756 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_VIRTUAL_SCREEN_FLAG),
2757 data, reply, option) != ERR_NONE) {
2758 WLOGFE("SendRequest failed");
2759 return VirtualScreenFlag::DEFAULT;
2760 }
2761 return static_cast<VirtualScreenFlag>(reply.ReadUint32());
2762 }
2763
SetVirtualScreenFlag(ScreenId screenId,VirtualScreenFlag screenFlag)2764 DMError ScreenSessionManagerProxy::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
2765 {
2766 sptr<IRemoteObject> remote = Remote();
2767 if (remote == nullptr) {
2768 WLOGFE("SetVirtualScreenFlag: remote is null");
2769 return DMError::DM_ERROR_IPC_FAILED;
2770 }
2771
2772 if (screenId == SCREEN_ID_INVALID) {
2773 return DMError::DM_ERROR_INVALID_PARAM;
2774 }
2775 if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) {
2776 return DMError::DM_ERROR_INVALID_PARAM;
2777 }
2778 MessageOption option(MessageOption::TF_SYNC);
2779 MessageParcel reply;
2780 MessageParcel data;
2781 if (!data.WriteInterfaceToken(GetDescriptor())) {
2782 WLOGFE("WriteInterfaceToken failed");
2783 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2784 }
2785 if (!data.WriteUint64(screenId) || !data.WriteUint32(static_cast<uint32_t>(screenFlag))) {
2786 WLOGFE("Write screenId or screenFlag failed");
2787 return DMError::DM_ERROR_WRITE_DATA_FAILED;
2788 }
2789 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_FLAG),
2790 data, reply, option) != ERR_NONE) {
2791 WLOGFE("SendRequest failed");
2792 return DMError::DM_ERROR_IPC_FAILED;
2793 }
2794 return static_cast<DMError>(reply.ReadInt32());
2795 }
2796
SetVirtualScreenRefreshRate(ScreenId screenId,uint32_t refreshInterval)2797 DMError ScreenSessionManagerProxy::SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
2798 {
2799 WLOGFI("ScreenSessionManagerProxy::SetVirtualScreenRefreshRate: ENTER");
2800 MessageOption option(MessageOption::TF_SYNC);
2801 MessageParcel reply;
2802 MessageParcel data;
2803 if (!data.WriteInterfaceToken(GetDescriptor())) {
2804 WLOGFE("WriteInterfaceToken failed");
2805 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2806 }
2807 if (!data.WriteUint64(screenId) || !data.WriteUint32(refreshInterval)) {
2808 WLOGFE("Write screenId or refreshInterval failed");
2809 return DMError::DM_ERROR_WRITE_DATA_FAILED;
2810 }
2811 if (Remote()->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_REFRESH_RATE),
2812 data, reply, option) != ERR_NONE) {
2813 WLOGFE("SendRequest failed");
2814 return DMError::DM_ERROR_IPC_FAILED;
2815 }
2816 return static_cast<DMError>(reply.ReadInt32());
2817 }
2818
GetDeviceScreenConfig()2819 DeviceScreenConfig ScreenSessionManagerProxy::GetDeviceScreenConfig()
2820 {
2821 sptr<IRemoteObject> remote = Remote();
2822 if (remote == nullptr) {
2823 WLOGFE("GetDeviceScreenConfig: remote is null");
2824 return {};
2825 }
2826
2827 MessageParcel data;
2828 MessageParcel reply;
2829 MessageOption option(MessageOption::TF_SYNC);
2830 if (!data.WriteInterfaceToken(GetDescriptor())) {
2831 TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
2832 return {};
2833 }
2834 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DEVICE_SCREEN_CONFIG),
2835 data, reply, option) != ERR_NONE) {
2836 TLOGE(WmsLogTag::DMS, "SendRequest failed");
2837 return {};
2838 }
2839 DeviceScreenConfig deviceScreenConfig;
2840 if (!RSMarshallingHelper::Unmarshalling(reply, deviceScreenConfig)) {
2841 TLOGE(WmsLogTag::DMS, "Read deviceScreenConfig failed");
2842 return {};
2843 }
2844 return deviceScreenConfig;
2845 }
2846
ProxyForFreeze(const std::set<int32_t> & pidList,bool isProxy)2847 DMError ScreenSessionManagerProxy::ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy)
2848 {
2849 sptr<IRemoteObject> remote = Remote();
2850 if (remote == nullptr) {
2851 WLOGFE("Remote is nullptr");
2852 return DMError::DM_ERROR_NULLPTR;
2853 }
2854 MessageParcel reply;
2855 MessageParcel data;
2856 MessageOption option;
2857 if (!data.WriteInterfaceToken(GetDescriptor())) {
2858 WLOGFE("proxy for freeze: failed");
2859 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
2860 }
2861 if (!data.WriteInt32(pidList.size())) {
2862 WLOGFE("proxy for freeze write date: failed");
2863 return DMError::DM_ERROR_WRITE_DATA_FAILED;
2864 }
2865 for (auto it = pidList.begin(); it != pidList.end(); it++) {
2866 if (!data.WriteInt32(*it)) {
2867 WLOGFE("proxy for freeze write date: failed");
2868 return DMError::DM_ERROR_WRITE_DATA_FAILED;
2869 }
2870 }
2871 if (!data.WriteBool(isProxy)) {
2872 WLOGFE("proxy for freeze write date: failed");
2873 return DMError::DM_ERROR_WRITE_DATA_FAILED;
2874 }
2875 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_PROXY_FOR_FREEZE),
2876 data, reply, option) != ERR_NONE) {
2877 WLOGFE("proxy for freeze send request: failed");
2878 return DMError::DM_ERROR_IPC_FAILED;
2879 }
2880 return static_cast<DMError>(reply.ReadInt32());
2881 }
2882
ResetAllFreezeStatus()2883 DMError ScreenSessionManagerProxy::ResetAllFreezeStatus()
2884 {
2885 sptr<IRemoteObject> remote = Remote();
2886 if (remote == nullptr) {
2887 WLOGFE("Remote is nullptr");
2888 return DMError::DM_ERROR_NULLPTR;
2889 }
2890 MessageParcel reply;
2891 MessageParcel data;
2892 MessageOption option;
2893 if (!data.WriteInterfaceToken(GetDescriptor())) {
2894 WLOGFE("WriteInterfaceToken failed");
2895 return DMError::DM_ERROR_IPC_FAILED;
2896 }
2897 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_RESET_ALL_FREEZE_STATUS),
2898 data, reply, option) != ERR_NONE) {
2899 WLOGFE("SendRequest failed");
2900 return DMError::DM_ERROR_IPC_FAILED;
2901 }
2902 return static_cast<DMError>(reply.ReadInt32());
2903 }
2904
SetVirtualScreenBlackList(ScreenId screenId,std::vector<uint64_t> & windowIdList)2905 void ScreenSessionManagerProxy::SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList)
2906 {
2907 sptr<IRemoteObject> remote = Remote();
2908 if (remote == nullptr) {
2909 WLOGFE("Remote is nullptr");
2910 return;
2911 }
2912 MessageParcel data;
2913 MessageParcel reply;
2914 MessageOption option;
2915 if (!data.WriteInterfaceToken(GetDescriptor())) {
2916 WLOGFE("WriteInterfaceToken failed");
2917 return;
2918 }
2919 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
2920 WLOGFE("Write screenId failed");
2921 return;
2922 }
2923 if (!data.WriteUInt64Vector(windowIdList)) {
2924 WLOGFE("Write windowIdList failed");
2925 return;
2926 }
2927 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_BLACK_LIST),
2928 data, reply, option) != ERR_NONE) {
2929 WLOGFE("SendRequest failed");
2930 return;
2931 }
2932 }
2933
DisablePowerOffRenderControl(ScreenId screenId)2934 void ScreenSessionManagerProxy::DisablePowerOffRenderControl(ScreenId screenId)
2935 {
2936 sptr<IRemoteObject> remote = Remote();
2937 if (remote == nullptr) {
2938 WLOGFE("Remote is nullptr");
2939 return;
2940 }
2941 MessageParcel data;
2942 MessageParcel reply;
2943 MessageOption option;
2944 if (!data.WriteInterfaceToken(GetDescriptor())) {
2945 WLOGFE("WriteInterfaceToken failed");
2946 return;
2947 }
2948 if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
2949 WLOGFE("Write screenId failed");
2950 return;
2951 }
2952 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_DISABLE_POWEROFF_RENDER_CONTROL),
2953 data, reply, option) != ERR_NONE) {
2954 WLOGFE("SendRequest failed");
2955 return;
2956 }
2957 }
2958
UpdateDisplayHookInfo(int32_t uid,bool enable,const DMHookInfo & hookInfo)2959 void OHOS::Rosen::ScreenSessionManagerProxy::UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo)
2960 {
2961 sptr<IRemoteObject> remote = Remote();
2962 if (remote == nullptr) {
2963 TLOGE(WmsLogTag::DMS, "remote is nullptr");
2964 return;
2965 }
2966
2967 MessageOption option(MessageOption::TF_ASYNC);
2968 MessageParcel reply;
2969 MessageParcel data;
2970
2971 if (!data.WriteInterfaceToken(GetDescriptor())) {
2972 TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
2973 return;
2974 }
2975
2976 if (!data.WriteInt32(uid)) {
2977 TLOGE(WmsLogTag::DMS, "Write uid failed");
2978 return;
2979 }
2980
2981 if (!data.WriteBool(enable)) {
2982 TLOGE(WmsLogTag::DMS, "Write enable failed");
2983 return;
2984 }
2985
2986 if (!data.WriteUint32(hookInfo.width_) || !data.WriteUint32(hookInfo.height_) ||
2987 !data.WriteFloat(hookInfo.density_) || !data.WriteUint32(hookInfo.rotation_) ||
2988 !data.WriteBool(hookInfo.enableHookRotation_)) {
2989 TLOGE(WmsLogTag::DMS, "Write hookInfo failed");
2990 return;
2991 }
2992
2993 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_HOOK_INFO),
2994 data, reply, option) != ERR_NONE) {
2995 TLOGE(WmsLogTag::DMS, "SendRequest failed");
2996 return;
2997 }
2998 }
SetVirtualScreenSecurityExemption(ScreenId screenId,uint32_t pid,std::vector<uint64_t> & windowIdList)2999 DMError ScreenSessionManagerProxy::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
3000 std::vector<uint64_t>& windowIdList)
3001 {
3002 sptr<IRemoteObject> remote = Remote();
3003 if (remote == nullptr) {
3004 WLOGFE("Remote is nullptr");
3005 return DMError::DM_ERROR_NULLPTR;
3006 }
3007 MessageParcel reply;
3008 MessageParcel data;
3009 MessageOption option(MessageOption::TF_SYNC);
3010 if (!data.WriteInterfaceToken(GetDescriptor())) {
3011 WLOGFE("proxy for freeze: failed");
3012 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3013 }
3014 if (!data.WriteUint64(screenId)) {
3015 WLOGFE("write date: failed");
3016 return DMError::DM_ERROR_WRITE_DATA_FAILED;
3017 }
3018 if (!data.WriteUint32(pid)) {
3019 WLOGFE("write date: failed");
3020 return DMError::DM_ERROR_WRITE_DATA_FAILED;
3021 }
3022
3023 if (!data.WriteUInt64Vector(windowIdList)) {
3024 WLOGFE("write date: failed");
3025 return DMError::DM_ERROR_WRITE_DATA_FAILED;
3026 }
3027 if (remote->SendRequest(
3028 static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION),
3029 data, reply, option) != ERR_NONE) {
3030 WLOGFE("send request: failed");
3031 return DMError::DM_ERROR_IPC_FAILED;
3032 }
3033 return static_cast<DMError>(reply.ReadInt32());
3034 }
3035
GetAllDisplayPhysicalResolution()3036 std::vector<DisplayPhysicalResolution> ScreenSessionManagerProxy::GetAllDisplayPhysicalResolution()
3037 {
3038 sptr<IRemoteObject> remote = Remote();
3039 if (remote == nullptr) {
3040 TLOGE(WmsLogTag::DMS, "remote is nullptr");
3041 return std::vector<DisplayPhysicalResolution> {};
3042 }
3043 MessageOption option;
3044 MessageParcel reply;
3045 MessageParcel data;
3046 if (!data.WriteInterfaceToken(GetDescriptor())) {
3047 TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
3048 return std::vector<DisplayPhysicalResolution> {};
3049 }
3050 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_ALL_PHYSICAL_DISPLAY_RESOLUTION),
3051 data, reply, option) != ERR_NONE) {
3052 TLOGE(WmsLogTag::DMS, "SendRequest failed");
3053 return std::vector<DisplayPhysicalResolution> {};
3054 }
3055 std::vector<DisplayPhysicalResolution> allPhysicalSize;
3056 int32_t displayInfoSize = 0;
3057 bool readRet = reply.ReadInt32(displayInfoSize);
3058 if (!readRet || displayInfoSize <= 0) {
3059 return std::vector<DisplayPhysicalResolution> {};
3060 }
3061 for (int32_t i = 0; i < displayInfoSize; i++) {
3062 DisplayPhysicalResolution physicalItem;
3063 physicalItem.foldDisplayMode_ = static_cast<FoldDisplayMode>(reply.ReadUint32());
3064 physicalItem.physicalWidth_ = reply.ReadUint32();
3065 physicalItem.physicalHeight_ = reply.ReadUint32();
3066 allPhysicalSize.emplace_back(physicalItem);
3067 }
3068 return allPhysicalSize;
3069 }
3070
SetVirtualScreenMaxRefreshRate(ScreenId id,uint32_t refreshRate,uint32_t & actualRefreshRate)3071 DMError ScreenSessionManagerProxy::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
3072 uint32_t& actualRefreshRate)
3073 {
3074 WLOGFI("ENTER");
3075 sptr<IRemoteObject> remote = Remote();
3076 if (remote == nullptr) {
3077 WLOGFW("remote is nullptr");
3078 return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
3079 }
3080
3081 MessageParcel data;
3082 MessageParcel reply;
3083 MessageOption option;
3084
3085 if (!data.WriteInterfaceToken(GetDescriptor())) {
3086 WLOGFE("WriteInterfaceToken failed");
3087 return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
3088 }
3089 if (!data.WriteUint64(static_cast<uint64_t>(id))) {
3090 WLOGFE("WriteUnit64 screenId failed");
3091 return DMError::DM_ERROR_IPC_FAILED;
3092 }
3093 if (!data.WriteUint32(refreshRate)) {
3094 WLOGFE("WriteUnit32 width failed");
3095 return DMError::DM_ERROR_IPC_FAILED;
3096 }
3097 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE),
3098 data, reply, option) != ERR_NONE) {
3099 WLOGFE("SendRequest failed");
3100 return DMError::DM_ERROR_NULLPTR;
3101 }
3102 actualRefreshRate = reply.ReadUint32();
3103 return static_cast<DMError>(reply.ReadInt32());
3104 }
GetScreenCapture(const CaptureOption & captureOption,DmErrorCode * errorCode)3105 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetScreenCapture(const CaptureOption& captureOption,
3106 DmErrorCode* errorCode)
3107 {
3108 sptr<IRemoteObject> remote = Remote();
3109 if (remote == nullptr) {
3110 WLOGFE("remote is nullptr");
3111 return nullptr;
3112 }
3113 MessageParcel data;
3114 MessageParcel reply;
3115 MessageOption option;
3116 if (!data.WriteInterfaceToken(GetDescriptor())) {
3117 WLOGFE("WriteInterfaceToken failed");
3118 return nullptr;
3119 }
3120 if (!data.WriteUint64(captureOption.displayId_) ||
3121 !data.WriteBool(captureOption.isNeedNotify_) || !data.WriteBool(captureOption.isNeedPointer_)) {
3122 WLOGFE("Write displayId or isNeedNotify or isNeedPointer failed");
3123 return nullptr;
3124 }
3125 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPTURE),
3126 data, reply, option) != ERR_NONE) {
3127 WLOGFE("SendRequest failed");
3128 return nullptr;
3129 }
3130 std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
3131 DmErrorCode replyErrorCode = static_cast<DmErrorCode>(reply.ReadInt32());
3132 if (errorCode) {
3133 *errorCode = replyErrorCode;
3134 }
3135 if (pixelMap == nullptr) {
3136 WLOGFE("Send pixelMap nullptr.");
3137 return nullptr;
3138 }
3139 return pixelMap;
3140 }
3141
GetPrimaryDisplayInfo()3142 sptr<DisplayInfo> ScreenSessionManagerProxy::GetPrimaryDisplayInfo()
3143 {
3144 sptr<IRemoteObject> remote = Remote();
3145 if (remote == nullptr) {
3146 WLOGFW("GetPrimaryDisplayInfo: remote is nullptr");
3147 return nullptr;
3148 }
3149 MessageParcel data;
3150 MessageParcel reply;
3151 MessageOption option;
3152 if (!data.WriteInterfaceToken(GetDescriptor())) {
3153 WLOGFE("WriteInterfaceToken failed");
3154 return nullptr;
3155 }
3156 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_PRIMARY_DISPLAY_INFO),
3157 data, reply, option) != ERR_NONE) {
3158 WLOGFE("SendRequest failed");
3159 return nullptr;
3160 }
3161
3162 sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
3163 if (info == nullptr) {
3164 WLOGFE("get display info.");
3165 }
3166 return info;
3167 }
3168
GetDisplaySnapshotWithOption(const CaptureOption & captureOption,DmErrorCode * errorCode)3169 std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetDisplaySnapshotWithOption(
3170 const CaptureOption& captureOption, DmErrorCode* errorCode)
3171 {
3172 WLOGFD("enter");
3173 sptr<IRemoteObject> remote = Remote();
3174 if (remote == nullptr) {
3175 WLOGFW("remote is nullptr");
3176 return nullptr;
3177 }
3178
3179 MessageParcel data;
3180 MessageParcel reply;
3181 MessageOption option;
3182 if (!data.WriteInterfaceToken(GetDescriptor())) {
3183 WLOGFE("WriteInterfaceToken failed");
3184 return nullptr;
3185 }
3186 if (!data.WriteUint64(captureOption.displayId_) ||
3187 !data.WriteBool(captureOption.isNeedNotify_) || !data.WriteBool(captureOption.isNeedPointer_)) {
3188 WLOGFE("Write displayId or isNeedNotify or isNeedPointer failed");
3189 return nullptr;
3190 }
3191 if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION),
3192 data, reply, option) != ERR_NONE) {
3193 WLOGFW("SendRequest failed");
3194 return nullptr;
3195 }
3196
3197 std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
3198 DmErrorCode replyErrorCode = static_cast<DmErrorCode>(reply.ReadInt32());
3199 if (errorCode) {
3200 *errorCode = replyErrorCode;
3201 }
3202 if (pixelMap == nullptr) {
3203 WLOGFW("SendRequest nullptr.");
3204 return nullptr;
3205 }
3206 return pixelMap;
3207 }
3208 } // namespace OHOS::Rosen
3209