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