• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "zidl/screen_session_manager_client_proxy.h"
17 
18 #include "window_manager_hilog.h"
19 
20 namespace OHOS::Rosen {
21 
OnScreenConnectionChanged(SessionOption SessionOption,ScreenEvent screenEvent)22 void ScreenSessionManagerClientProxy::OnScreenConnectionChanged(SessionOption SessionOption, ScreenEvent screenEvent)
23 {
24     sptr<IRemoteObject> remote = Remote();
25     if (remote == nullptr) {
26         TLOGE(WmsLogTag::DMS, "remote is nullptr");
27         return;
28     }
29 
30     MessageParcel data;
31     MessageParcel reply;
32     MessageOption option(MessageOption::TF_SYNC);
33     if (!data.WriteInterfaceToken(GetDescriptor())) {
34         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
35         return;
36     }
37     if (!data.WriteUint64(SessionOption.rsId_)) {
38         TLOGE(WmsLogTag::DMS, "Write rsId failed");
39         return;
40     }
41     if (!data.WriteString(SessionOption.name_)) {
42         TLOGE(WmsLogTag::DMS, "Write name failed");
43         return;
44     }
45     if (!data.WriteBool(SessionOption.isExtend_)) {
46         TLOGE(WmsLogTag::DMS, "Write isExtended failed");
47         return;
48     }
49     if (!data.WriteString(SessionOption.innerName_)) {
50         TLOGE(WmsLogTag::DMS, "Write innerName failed");
51         return;
52     }
53     if (!data.WriteUint64(SessionOption.screenId_)) {
54         TLOGE(WmsLogTag::DMS, "Write screenId failed");
55         return;
56     }
57     if (!data.WriteUint8(static_cast<uint8_t>(screenEvent))) {
58         TLOGE(WmsLogTag::DMS, "Write screenEvent failed");
59         return;
60     }
61     if (remote->SendRequest(
62         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CONNECTION_CHANGED),
63         data, reply, option) != ERR_NONE) {
64         TLOGE(WmsLogTag::DMS, "SendRequest failed");
65         return;
66     }
67 }
68 
SwitchUserCallback(std::vector<int32_t> oldScbPids,int32_t currentScbPid)69 void ScreenSessionManagerClientProxy::SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid)
70 {
71     sptr<IRemoteObject> remote = Remote();
72     if (remote == nullptr) {
73         TLOGE(WmsLogTag::DMS, "remote is nullptr");
74         return;
75     }
76 
77     MessageParcel data;
78     MessageParcel reply;
79     MessageOption option(MessageOption::TF_SYNC);
80     if (!data.WriteInterfaceToken(GetDescriptor())) {
81         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
82         return;
83     }
84     if (!data.WriteInt32Vector(oldScbPids)) {
85         TLOGE(WmsLogTag::DMS, "Write oldScbPids failed");
86         return;
87     }
88     if (!data.WriteInt32(currentScbPid)) {
89         TLOGE(WmsLogTag::DMS, "Write currentScbPid failed");
90         return;
91     }
92     if (remote->SendRequest(
93         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SWITCH_USER_CMD),
94         data, reply, option) != ERR_NONE) {
95         TLOGE(WmsLogTag::DMS, "SendRequest failed");
96         return;
97     }
98 }
99 
OnScreenExtendChanged(ScreenId mainScreenId,ScreenId extendScreenId)100 void ScreenSessionManagerClientProxy::OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId)
101 {
102     sptr<IRemoteObject> remote = Remote();
103     if (remote == nullptr) {
104         TLOGE(WmsLogTag::DMS, "remote is nullptr");
105         return;
106     }
107     MessageParcel data;
108     MessageParcel reply;
109     MessageOption option(MessageOption::TF_SYNC);
110     if (!data.WriteInterfaceToken(GetDescriptor())) {
111         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
112         return;
113     }
114     if (!data.WriteUint64(mainScreenId)) {
115         TLOGE(WmsLogTag::DMS, "Write screenId failed");
116         return;
117     }
118     if (!data.WriteUint64(extendScreenId)) {
119         TLOGE(WmsLogTag::DMS, "Write screenOrientation failed");
120         return;
121     }
122     if (remote->SendRequest(
123         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_EXTEND_CHANGED),
124         data, reply, option) != ERR_NONE) {
125         TLOGE(WmsLogTag::DMS, "SendRequest failed");
126         return;
127     }
128 }
129 
OnPropertyChanged(ScreenId screenId,const ScreenProperty & property,ScreenPropertyChangeReason reason)130 void ScreenSessionManagerClientProxy::OnPropertyChanged(ScreenId screenId,
131     const ScreenProperty& property, ScreenPropertyChangeReason reason)
132 {
133     sptr<IRemoteObject> remote = Remote();
134     if (remote == nullptr) {
135         TLOGE(WmsLogTag::DMS, "remote is nullptr");
136         return;
137     }
138 
139     MessageParcel data;
140     MessageParcel reply;
141     MessageOption option(MessageOption::TF_SYNC);
142     if (!data.WriteInterfaceToken(GetDescriptor())) {
143         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
144         return;
145     }
146     if (!data.WriteUint64(screenId)) {
147         TLOGE(WmsLogTag::DMS, "Write screenId failed");
148         return;
149     }
150     if (!RSMarshallingHelper::Marshalling(data, property)) {
151         TLOGE(WmsLogTag::DMS, "Write property failed");
152         return;
153     }
154     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
155         TLOGE(WmsLogTag::DMS, "Write reason failed");
156         return;
157     }
158     if (remote->SendRequest(
159         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_PROPERTY_CHANGED),
160         data, reply, option) != ERR_NONE) {
161         TLOGE(WmsLogTag::DMS, "SendRequest failed");
162         return;
163     }
164 }
165 
OnPowerStatusChanged(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)166 void ScreenSessionManagerClientProxy::OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
167     PowerStateChangeReason reason)
168 {
169     MessageParcel data;
170     MessageParcel reply;
171     MessageOption option(MessageOption::TF_ASYNC);
172     if (!data.WriteInterfaceToken(GetDescriptor())) {
173         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
174         return;
175     }
176     if (!data.WriteUint32(static_cast<uint32_t>(event))) {
177         TLOGE(WmsLogTag::DMS, "Write event failed");
178         return;
179     }
180     if (!data.WriteUint32(static_cast<uint32_t>(status))) {
181         TLOGE(WmsLogTag::DMS, "Write status failed");
182         return;
183     }
184     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
185         TLOGE(WmsLogTag::DMS, "Write reason failed");
186         return;
187     }
188     auto remote = Remote();
189     if (remote == nullptr) {
190         TLOGE(WmsLogTag::DMS, "SendRequest failed, Remote is nullptr");
191         return;
192     }
193     if (remote->SendRequest(
194         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_POWER_STATUS_CHANGED),
195         data, reply, option) != ERR_NONE) {
196         TLOGE(WmsLogTag::DMS, "SendRequest failed");
197         return;
198     }
199 }
200 
OnSensorRotationChanged(ScreenId screenId,float sensorRotation)201 void ScreenSessionManagerClientProxy::OnSensorRotationChanged(ScreenId screenId, float sensorRotation)
202 {
203     sptr<IRemoteObject> remote = Remote();
204     if (remote == nullptr) {
205         TLOGE(WmsLogTag::DMS, "remote is nullptr");
206         return;
207     }
208 
209     MessageParcel data;
210     MessageParcel reply;
211     MessageOption option(MessageOption::TF_SYNC);
212     if (!data.WriteInterfaceToken(GetDescriptor())) {
213         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
214         return;
215     }
216     if (!data.WriteUint64(screenId)) {
217         TLOGE(WmsLogTag::DMS, "Write screenId failed");
218         return;
219     }
220     if (!data.WriteFloat(sensorRotation)) {
221         TLOGE(WmsLogTag::DMS, "Write sensorRotation failed");
222         return;
223     }
224     if (remote->SendRequest(
225         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SENSOR_ROTATION_CHANGED),
226         data, reply, option) != ERR_NONE) {
227         TLOGE(WmsLogTag::DMS, "SendRequest failed");
228         return;
229     }
230 }
231 
OnHoverStatusChanged(ScreenId screenId,int32_t hoverStatus,bool needRotate)232 void ScreenSessionManagerClientProxy::OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus, bool needRotate)
233 {
234     sptr<IRemoteObject> remote = Remote();
235     if (remote == nullptr) {
236         TLOGE(WmsLogTag::DMS, "remote is nullptr");
237         return;
238     }
239 
240     MessageParcel data;
241     MessageParcel reply;
242     MessageOption option(MessageOption::TF_SYNC);
243     if (!data.WriteInterfaceToken(GetDescriptor())) {
244         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
245         return;
246     }
247     if (!data.WriteUint64(screenId)) {
248         TLOGE(WmsLogTag::DMS, "Write screenId failed");
249         return;
250     }
251     if (!data.WriteInt32(hoverStatus)) {
252         TLOGE(WmsLogTag::DMS, "Write hoverStatus failed");
253         return;
254     }
255     if (!data.WriteBool(needRotate)) {
256         TLOGE(WmsLogTag::DMS, "Write needRotate failed");
257         return;
258     }
259     if (remote->SendRequest(
260         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_HOVER_STATUS_CHANGED),
261         data, reply, option) != ERR_NONE) {
262         TLOGE(WmsLogTag::DMS, "SendRequest failed");
263         return;
264     }
265 }
266 
OnScreenOrientationChanged(ScreenId screenId,float screenOrientation)267 void ScreenSessionManagerClientProxy::OnScreenOrientationChanged(ScreenId screenId, float screenOrientation)
268 {
269     sptr<IRemoteObject> remote = Remote();
270     if (remote == nullptr) {
271         TLOGE(WmsLogTag::DMS, "remote is nullptr");
272         return;
273     }
274 
275     MessageParcel data;
276     MessageParcel reply;
277     MessageOption option(MessageOption::TF_SYNC);
278     if (!data.WriteInterfaceToken(GetDescriptor())) {
279         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
280         return;
281     }
282     if (!data.WriteUint64(screenId)) {
283         TLOGE(WmsLogTag::DMS, "Write screenId failed");
284         return;
285     }
286     if (!data.WriteFloat(screenOrientation)) {
287         TLOGE(WmsLogTag::DMS, "Write screenOrientation failed");
288         return;
289     }
290     if (remote->SendRequest(
291         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ORIENTATION_CHANGED),
292         data, reply, option) != ERR_NONE) {
293         TLOGE(WmsLogTag::DMS, "SendRequest failed");
294         return;
295     }
296 }
297 
OnScreenRotationLockedChanged(ScreenId screenId,bool isLocked)298 void ScreenSessionManagerClientProxy::OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked)
299 {
300     sptr<IRemoteObject> remote = Remote();
301     if (remote == nullptr) {
302         TLOGE(WmsLogTag::DMS, "remote is nullptr");
303         return;
304     }
305 
306     MessageParcel data;
307     MessageParcel reply;
308     MessageOption option(MessageOption::TF_SYNC);
309     if (!data.WriteInterfaceToken(GetDescriptor())) {
310         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
311         return;
312     }
313     if (!data.WriteUint64(screenId)) {
314         TLOGE(WmsLogTag::DMS, "Write screenId failed");
315         return;
316     }
317     if (!data.WriteBool(isLocked)) {
318         TLOGE(WmsLogTag::DMS, "Write isLocked failed");
319         return;
320     }
321     if (remote->SendRequest(
322         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ROTATION_LOCKED_CHANGED),
323         data, reply, option) != ERR_NONE) {
324         TLOGE(WmsLogTag::DMS, "SendRequest failed");
325         return;
326     }
327 }
328 
OnDisplayStateChanged(DisplayId defaultDisplayId,sptr<DisplayInfo> displayInfo,const std::map<DisplayId,sptr<DisplayInfo>> & displayInfoMap,DisplayStateChangeType type)329 void ScreenSessionManagerClientProxy::OnDisplayStateChanged(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
330     const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type)
331 {
332     sptr<IRemoteObject> remote = Remote();
333     if (remote == nullptr) {
334         TLOGE(WmsLogTag::DMS, "remote is nullptr");
335         return;
336     }
337 
338     MessageParcel data;
339     MessageParcel reply;
340     MessageOption option(MessageOption::TF_SYNC);
341     if (!data.WriteInterfaceToken(GetDescriptor())) {
342         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
343         return;
344     }
345     if (!data.WriteUint64(defaultDisplayId)) {
346         TLOGE(WmsLogTag::DMS, "Write defaultDisplayId failed");
347         return;
348     }
349     if (!data.WriteStrongParcelable(displayInfo)) {
350         TLOGE(WmsLogTag::DMS, "Write displayInfo failed");
351         return;
352     }
353     auto mapSize = static_cast<uint32_t>(displayInfoMap.size());
354     if (!data.WriteUint32(mapSize)) {
355         TLOGE(WmsLogTag::DMS, "Write mapSize failed");
356         return;
357     }
358     for (auto [id, info] : displayInfoMap) {
359         if (!data.WriteUint64(id)) {
360             TLOGE(WmsLogTag::DMS, "Write id failed");
361             return;
362         }
363         if (!data.WriteStrongParcelable(info)) {
364             TLOGE(WmsLogTag::DMS, "Write info failed");
365             return;
366         }
367     }
368     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
369         TLOGE(WmsLogTag::DMS, "Write type failed");
370         return;
371     }
372     if (remote->SendRequest(
373         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_DISPLAY_STATE_CHANGED),
374         data, reply, option) != ERR_NONE) {
375         TLOGE(WmsLogTag::DMS, "SendRequest failed");
376         return;
377     }
378 }
379 
OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t> & missionIds,std::vector<uint64_t> & surfaceNodeIds,bool isBlackList)380 void ScreenSessionManagerClientProxy::OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
381     std::vector<uint64_t>& surfaceNodeIds, bool isBlackList)
382 {
383     sptr<IRemoteObject> remote = Remote();
384     if (remote == nullptr) {
385         TLOGE(WmsLogTag::DMS, "remote is nullptr");
386         return;
387     }
388 
389     MessageParcel data;
390     MessageParcel reply;
391     MessageOption option(MessageOption::TF_SYNC);
392     if (!data.WriteInterfaceToken(GetDescriptor())) {
393         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
394         return;
395     }
396     if (!data.WriteUInt64Vector(missionIds)) {
397         TLOGE(WmsLogTag::DMS, "Write missionIds failed");
398         return;
399     }
400     if (!data.WriteUInt64Vector(surfaceNodeIds)) {
401         TLOGE(WmsLogTag::DMS, "Write surfaceNodeIds failed");
402         return;
403     }
404     if (!data.WriteBool(isBlackList)) {
405         TLOGE(WmsLogTag::DMS, "Write isBlackList failed");
406         return;
407     }
408     if (remote->SendRequest(static_cast<uint32_t>(
409         ScreenSessionManagerClientMessage::TRANS_ID_GET_SURFACENODEID_FROM_MISSIONID),
410         data, reply, option) != ERR_NONE) {
411         TLOGE(WmsLogTag::DMS, "SendRequest failed");
412         return;
413     }
414     reply.ReadUInt64Vector(&surfaceNodeIds);
415 }
416 
OnSetSurfaceNodeIdsChanged(DisplayId displayId,const std::vector<uint64_t> & surfaceNodeIds)417 void ScreenSessionManagerClientProxy::OnSetSurfaceNodeIdsChanged(DisplayId displayId,
418     const std::vector<uint64_t>& surfaceNodeIds)
419 {
420     sptr<IRemoteObject> remote = Remote();
421     if (remote == nullptr) {
422         TLOGE(WmsLogTag::DMS, "remote is nullptr");
423         return;
424     }
425     MessageParcel data;
426     MessageParcel reply;
427     MessageOption option(MessageOption::TF_ASYNC);
428     if (!data.WriteInterfaceToken(GetDescriptor())) {
429         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
430         return;
431     }
432     if (!data.WriteUint64(displayId)) {
433         TLOGE(WmsLogTag::DMS, "Write displayId failed");
434         return;
435     }
436     if (!data.WriteUInt64Vector(surfaceNodeIds)) {
437         TLOGE(WmsLogTag::DMS, "Write surfaceNodeIds failed");
438         return;
439     }
440     if (remote->SendRequest(static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_SET_SURFACENODEIDS),
441         data, reply, option) != ERR_NONE) {
442         TLOGE(WmsLogTag::DMS, "SendRequest failed");
443         return;
444     }
445 }
446 
OnVirtualScreenDisconnected(DisplayId displayId)447 void ScreenSessionManagerClientProxy::OnVirtualScreenDisconnected(DisplayId displayId)
448 {
449     sptr<IRemoteObject> remote = Remote();
450     if (remote == nullptr) {
451         TLOGE(WmsLogTag::DMS, "remote is nullptr");
452         return;
453     }
454     MessageParcel data;
455     MessageParcel reply;
456     MessageOption option(MessageOption::TF_ASYNC);
457     if (!data.WriteInterfaceToken(GetDescriptor())) {
458         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
459         return;
460     }
461     if (!data.WriteUint64(displayId)) {
462         TLOGE(WmsLogTag::DMS, "Write displayId failed");
463         return;
464     }
465     if (remote->SendRequest(
466         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_VIRTUAL_SCREEN_DISCONNECTED),
467         data, reply, option) != ERR_NONE) {
468         TLOGE(WmsLogTag::DMS, "SendRequest failed");
469         return;
470     }
471 }
472 
OnUpdateFoldDisplayMode(FoldDisplayMode displayMode)473 void ScreenSessionManagerClientProxy::OnUpdateFoldDisplayMode(FoldDisplayMode displayMode)
474 {
475     sptr<IRemoteObject> remote = Remote();
476     if (remote == nullptr) {
477         TLOGE(WmsLogTag::DMS, "remote is nullptr");
478         return;
479     }
480 
481     MessageParcel data;
482     MessageParcel reply;
483     MessageOption option(MessageOption::TF_ASYNC);
484     if (!data.WriteInterfaceToken(GetDescriptor())) {
485         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
486         return;
487     }
488     if (!data.WriteUint32(static_cast<uint32_t>(displayMode))) {
489         TLOGE(WmsLogTag::DMS, "Write displayMode failed");
490         return;
491     }
492     if (remote->SendRequest(
493         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE),
494         data, reply, option) != ERR_NONE) {
495         TLOGE(WmsLogTag::DMS, "SendRequest failed");
496         return;
497     }
498 }
499 
OnScreenshot(DisplayId displayId)500 void ScreenSessionManagerClientProxy::OnScreenshot(DisplayId displayId)
501 {
502     MessageParcel data;
503     MessageParcel reply;
504     MessageOption option(MessageOption::TF_ASYNC);
505     if (!data.WriteInterfaceToken(GetDescriptor())) {
506         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
507         return;
508     }
509     if (!data.WriteUint64(displayId)) {
510         TLOGE(WmsLogTag::DMS, "Write displayId failed");
511         return;
512     }
513     auto remote = Remote();
514     if (remote == nullptr) {
515         TLOGE(WmsLogTag::DMS, "SendRequest failed, Remote is nullptr");
516         return;
517     }
518     if (remote->SendRequest(
519         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_SHOT),
520         data, reply, option) != ERR_NONE) {
521         TLOGE(WmsLogTag::DMS, "SendRequest failed");
522         return;
523     }
524 }
525 
OnImmersiveStateChanged(ScreenId screenId,bool & immersive)526 void ScreenSessionManagerClientProxy::OnImmersiveStateChanged(ScreenId screenId, bool& immersive)
527 {
528     sptr<IRemoteObject> remote = Remote();
529     if (remote == nullptr) {
530         TLOGE(WmsLogTag::DMS, "remote is nullptr");
531         return;
532     }
533 
534     MessageParcel data;
535     MessageParcel reply;
536     MessageOption option(MessageOption::TF_SYNC);
537     if (!data.WriteInterfaceToken(GetDescriptor())) {
538         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
539         return;
540     }
541     if (!data.WriteUint64(screenId)) {
542         TLOGE(WmsLogTag::DMS, "Write screenId failed");
543         return;
544     }
545     if (remote->SendRequest(
546         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_IMMERSIVE_STATE_CHANGED),
547         data, reply, option) != ERR_NONE) {
548         TLOGE(WmsLogTag::DMS, "SendRequest failed");
549         return;
550     }
551     immersive = reply.ReadBool();
552 }
553 
SetDisplayNodeScreenId(ScreenId screenId,ScreenId displayNodeScreenId)554 void ScreenSessionManagerClientProxy::SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId)
555 {
556     sptr<IRemoteObject> remote = Remote();
557     if (remote == nullptr) {
558         TLOGE(WmsLogTag::DMS, "remote is nullptr");
559         return;
560     }
561 
562     MessageParcel data;
563     MessageParcel reply;
564     MessageOption option(MessageOption::TF_ASYNC);
565     if (!data.WriteInterfaceToken(GetDescriptor())) {
566         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
567         return;
568     }
569     if (!data.WriteUint64(screenId)) {
570         TLOGE(WmsLogTag::DMS, "Write screenId failed");
571         return;
572     }
573     if (!data.WriteUint64(displayNodeScreenId)) {
574         TLOGE(WmsLogTag::DMS, "Write displayNodeScreenId failed");
575         return;
576     }
577     if (remote->SendRequest(
578         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_SET_DISPLAY_NODE_SCREEN_ID),
579         data, reply, option) != ERR_NONE) {
580         TLOGE(WmsLogTag::DMS, "SendRequest failed");
581         return;
582     }
583 }
584 
SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)585 void ScreenSessionManagerClientProxy::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
586 {
587     sptr<IRemoteObject> remote = Remote();
588     if (remote == nullptr) {
589         TLOGE(WmsLogTag::DMS, "remote is nullptr");
590         return;
591     }
592 
593     MessageParcel data;
594     MessageParcel reply;
595     MessageOption option;
596     if (!data.WriteInterfaceToken(GetDescriptor())) {
597         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
598         return;
599     }
600     if (!data.WriteUint64(screenId) || !data.WriteFloat(virtualPixelRatio)) {
601         TLOGE(WmsLogTag::DMS, "Write screenId/virtualPixelRatio failed");
602         return;
603     }
604     if (remote->SendRequest(
605         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM),
606         data, reply, option) != ERR_NONE) {
607         TLOGE(WmsLogTag::DMS, "SendRequest failed");
608         return;
609     }
610 }
611 
OnFoldStatusChangedReportUE(const std::vector<std::string> & screenFoldInfo)612 void ScreenSessionManagerClientProxy::OnFoldStatusChangedReportUE(const std::vector<std::string>& screenFoldInfo)
613 {
614     sptr<IRemoteObject> remote = Remote();
615     if (remote == nullptr) {
616         TLOGE(WmsLogTag::DMS, "remote is nullptr");
617         return;
618     }
619 
620     MessageParcel data;
621     MessageParcel reply;
622     MessageOption option(MessageOption::TF_ASYNC);
623     if (!data.WriteInterfaceToken(GetDescriptor())) {
624         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
625         return;
626     }
627     if (!data.WriteStringVector(screenFoldInfo)) {
628         TLOGE(WmsLogTag::DMS, "Write screenFoldInfo failed");
629         return;
630     }
631     if (remote->SendRequest(static_cast<uint32_t>(
632         ScreenSessionManagerClientMessage::TRANS_ID_ON_FOLDSTATUS_CHANGED_REPORT_UE),
633         data, reply, option) != ERR_NONE) {
634         TLOGE(WmsLogTag::DMS, "SendRequest failed");
635         return;
636     }
637 }
638 
ScreenCaptureNotify(ScreenId mainScreenId,int32_t uid,const std::string & clientName)639 void ScreenSessionManagerClientProxy::ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid,
640     const std::string& clientName)
641 {
642     sptr<IRemoteObject> remote = Remote();
643     if (remote == nullptr) {
644         TLOGE(WmsLogTag::DMS, "remote is nullptr");
645         return;
646     }
647     MessageParcel data;
648     MessageParcel reply;
649     MessageOption option(MessageOption::TF_SYNC);
650     if (!data.WriteInterfaceToken(GetDescriptor())) {
651         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
652         return;
653     }
654     if (!data.WriteUint64(mainScreenId) || !data.WriteInt32(uid) || !data.WriteString(clientName)) {
655         TLOGE(WmsLogTag::DMS, "Write screenId or uid or client failed");
656         return;
657     }
658     if (remote->SendRequest(
659         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CAPTURE_NOTIFY),
660         data, reply, option) != ERR_NONE) {
661         TLOGE(WmsLogTag::DMS, "SendRequest failed");
662         return;
663     }
664 }
665 
OnCameraBackSelfieChanged(ScreenId screenId,bool isCameraBackSelfie)666 void ScreenSessionManagerClientProxy::OnCameraBackSelfieChanged(ScreenId screenId, bool isCameraBackSelfie)
667 {
668     sptr<IRemoteObject> remote = Remote();
669     if (remote == nullptr) {
670         TLOGE(WmsLogTag::DMS, "remote is nullptr");
671         return;
672     }
673     MessageParcel data;
674     MessageParcel reply;
675     MessageOption option(MessageOption::TF_SYNC);
676     if (!data.WriteInterfaceToken(GetDescriptor())) {
677         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
678         return;
679     }
680     if (!data.WriteUint64(screenId)) {
681         TLOGE(WmsLogTag::DMS, "Write screenId failed");
682         return;
683     }
684     if (!data.WriteBool(isCameraBackSelfie)) {
685         TLOGE(WmsLogTag::DMS, "Write isCameraBackSelfie failed");
686         return;
687     }
688     if (remote->SendRequest(
689         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_CAMERA_BACKSELFIE_CHANGED),
690         data, reply, option) != ERR_NONE) {
691         TLOGE(WmsLogTag::DMS, "SendRequest failed");
692         return;
693     }
694 }
695 
OnSuperFoldStatusChanged(ScreenId screenId,SuperFoldStatus superFoldStatus)696 void ScreenSessionManagerClientProxy::OnSuperFoldStatusChanged(ScreenId screenId, SuperFoldStatus superFoldStatus)
697 {
698     sptr<IRemoteObject> remote = Remote();
699     if (remote == nullptr) {
700         TLOGE(WmsLogTag::DMS, "remote is nullptr");
701         return;
702     }
703     MessageParcel data;
704     MessageParcel reply;
705     MessageOption option(MessageOption::TF_SYNC);
706     if (!data.WriteInterfaceToken(GetDescriptor())) {
707         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
708         return;
709     }
710     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
711         TLOGE(WmsLogTag::DMS, "Write screenId failed");
712         return;
713     }
714     if (!data.WriteUint32(static_cast<uint32_t>(superFoldStatus))) {
715         TLOGE(WmsLogTag::DMS, "Write superFoldStatus failed");
716         return;
717     }
718     if (remote->SendRequest(
719         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SUPER_FOLD_STATUS_CHANGED),
720         data, reply, option) != ERR_NONE) {
721         TLOGE(WmsLogTag::DMS, "SendRequest failed");
722         return;
723     }
724 }
725 
OnExtendScreenConnectStatusChanged(ScreenId screenId,ExtendScreenConnectStatus extendScreenConnectStatus)726 void ScreenSessionManagerClientProxy::OnExtendScreenConnectStatusChanged(ScreenId screenId,
727     ExtendScreenConnectStatus extendScreenConnectStatus)
728 {
729     sptr<IRemoteObject> remote = Remote();
730     if (remote == nullptr) {
731         TLOGE(WmsLogTag::DMS, "remote is nullptr");
732         return;
733     }
734     MessageParcel data;
735     MessageParcel reply;
736     MessageOption option(MessageOption::TF_SYNC);
737     if (!data.WriteInterfaceToken(GetDescriptor())) {
738         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
739         return;
740     }
741     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
742         TLOGE(WmsLogTag::DMS, "Write screenId failed");
743         return;
744     }
745     if (!data.WriteUint32(static_cast<uint32_t>(extendScreenConnectStatus))) {
746         TLOGE(WmsLogTag::DMS, "Write extendScreenConnectStatus failed");
747         return;
748     }
749     if (remote->SendRequest(
750         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_EXTEND_SCREEN_CONNECT_STATUS_CHANGED),
751         data, reply, option) != ERR_NONE) {
752         TLOGE(WmsLogTag::DMS, "SendRequest failed");
753         return;
754     }
755 }
756 
OnSecondaryReflexionChanged(ScreenId screenId,bool isSecondaryReflexion)757 void ScreenSessionManagerClientProxy::OnSecondaryReflexionChanged(ScreenId screenId, bool isSecondaryReflexion)
758 {
759     sptr<IRemoteObject> remote = Remote();
760     if (remote == nullptr) {
761         TLOGE(WmsLogTag::DMS, "remote is nullptr");
762         return;
763     }
764     MessageParcel data;
765     MessageParcel reply;
766     MessageOption option(MessageOption::TF_SYNC);
767     if (!data.WriteInterfaceToken(GetDescriptor())) {
768         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
769         return;
770     }
771     if (!data.WriteUint64(static_cast<uint64_t>(screenId))) {
772         TLOGE(WmsLogTag::DMS, "Write screenId failed");
773         return;
774     }
775     if (!data.WriteUint32(static_cast<uint32_t>(isSecondaryReflexion))) {
776         TLOGE(WmsLogTag::DMS, "Write secondaryReflexion failed");
777         return;
778     }
779     if (remote->SendRequest(
780         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SECONDARY_REFLEXION_CHANGED),
781         data, reply, option) != ERR_NONE) {
782         TLOGE(WmsLogTag::DMS, "SendRequest failed");
783         return;
784     }
785 }
786 
OnCreateScreenSessionOnly(ScreenId screenId,ScreenId rsId,const std::string & name,bool isExtend)787 bool ScreenSessionManagerClientProxy::OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId,
788     const std::string& name, bool isExtend)
789 {
790     sptr<IRemoteObject> remote = Remote();
791     if (remote == nullptr) {
792         TLOGE(WmsLogTag::DMS, "remote is nullptr");
793         return false;
794     }
795     MessageParcel data;
796     MessageParcel reply;
797     MessageOption option;
798     if (!data.WriteInterfaceToken(GetDescriptor())) {
799         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
800         return false;
801     }
802     if (!data.WriteUint64(screenId) || !data.WriteUint64(rsId) || !data.WriteString(name) ||
803         !data.WriteBool(isExtend)) {
804         TLOGE(WmsLogTag::DMS, "Write parameters failed");
805         return false;
806     }
807     if (remote->SendRequest(
808         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_CREATE_SCREEN_SESSION_ONLY),
809         data, reply, option) != ERR_NONE) {
810         TLOGE(WmsLogTag::DMS, "SendRequest failed");
811         return false;
812     }
813     return reply.ReadBool();
814 }
815 
OnExtendDisplayNodeChange(ScreenId firstId,ScreenId secondId)816 bool ScreenSessionManagerClientProxy::OnExtendDisplayNodeChange(ScreenId firstId, ScreenId secondId)
817 {
818     sptr<IRemoteObject> remote = Remote();
819     if (remote == nullptr) {
820         TLOGE(WmsLogTag::DMS, "remote is nullptr");
821         return false;
822     }
823 
824     MessageParcel data;
825     MessageParcel reply;
826     MessageOption option;
827     if (!data.WriteInterfaceToken(GetDescriptor())) {
828         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
829         return false;
830     }
831     if (!data.WriteUint64(firstId) || !data.WriteUint64(secondId)) {
832         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
833         return false;
834     }
835     if (remote->SendRequest(static_cast<uint32_t>(
836         ScreenSessionManagerClientMessage::TRANS_ID_ON_EXTEND_CHANGED),
837         data, reply, option) != ERR_NONE) {
838         TLOGE(WmsLogTag::DMS, "SendRequest failed");
839         return false;
840     }
841     return reply.ReadBool();
842 }
843 
OnMainDisplayNodeChange(ScreenId mainScreenId,ScreenId extendScreenId,ScreenId extendRSId)844 bool ScreenSessionManagerClientProxy::OnMainDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId,
845     ScreenId extendRSId)
846 {
847     sptr<IRemoteObject> remote = Remote();
848     if (remote == nullptr) {
849         TLOGE(WmsLogTag::DMS, "remote is nullptr");
850         return false;
851     }
852 
853     MessageParcel data;
854     MessageParcel reply;
855     MessageOption option;
856     if (!data.WriteInterfaceToken(GetDescriptor())) {
857         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
858         return false;
859     }
860     if (!data.WriteUint64(mainScreenId) || !data.WriteUint64(extendScreenId) || !data.WriteUint64(extendRSId)) {
861         TLOGE(WmsLogTag::DMS, "Write screenId/virtualPixelRatio failed");
862         return false;
863     }
864     if (remote->SendRequest(static_cast<uint32_t>(
865         ScreenSessionManagerClientMessage::TRANS_ID_ON_MAIN_CHANGED),
866         data, reply, option) != ERR_NONE) {
867         TLOGE(WmsLogTag::DMS, "SendRequest failed");
868     }
869     return reply.ReadBool();
870 }
871 
SetScreenCombination(ScreenId mainScreenId,ScreenId extendScreenId,ScreenCombination extendCombination)872 void ScreenSessionManagerClientProxy::SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId,
873     ScreenCombination extendCombination)
874 {
875     sptr<IRemoteObject> remote = Remote();
876     if (remote == nullptr) {
877         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
878         return;
879     }
880     MessageParcel data;
881     MessageParcel reply;
882     MessageOption option;
883     if (!data.WriteInterfaceToken(GetDescriptor())) {
884         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
885         return;
886     }
887     if (!data.WriteUint64(static_cast<uint64_t>(mainScreenId))) {
888         TLOGE(WmsLogTag::DMS, "Write main screenId failed");
889         return;
890     }
891     if (!data.WriteUint64(static_cast<uint64_t>(extendScreenId))) {
892         TLOGE(WmsLogTag::DMS, "Write extend screenId failed");
893         return;
894     }
895     if (!data.WriteUint64(static_cast<uint32_t>(extendCombination))) {
896         TLOGE(WmsLogTag::DMS, "Write combination failed");
897         return;
898     }
899     if (remote->SendRequest(static_cast<uint32_t>(
900         ScreenSessionManagerClientMessage::TRANS_ID_SET_SCREEN_COMBINATION),
901         data, reply, option) != ERR_NONE) {
902         TLOGE(WmsLogTag::DMS, "SendRequest failed");
903         return;
904     }
905 }
906 
OnDumperClientScreenSessions()907 std::string ScreenSessionManagerClientProxy::OnDumperClientScreenSessions()
908 {
909     sptr<IRemoteObject> remote = Remote();
910     if (remote == nullptr) {
911         TLOGE(WmsLogTag::DMS, "remote is nullptr");
912         return "";
913     }
914     MessageParcel data;
915     MessageParcel reply;
916     MessageOption option;
917     if (!data.WriteInterfaceToken(GetDescriptor())) {
918         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
919         return "";
920     }
921     if (remote->SendRequest(static_cast<uint32_t>(
922         ScreenSessionManagerClientMessage::TRANS_ID_ON_DUMP_SCREEN_SESSION),
923         data, reply, option) != ERR_NONE) {
924         TLOGE(WmsLogTag::DMS, "SendRequest failed");
925         return "";
926     }
927     return reply.ReadString();
928 }
929 
OnBeforeScreenPropertyChanged(FoldStatus foldStatus)930 void ScreenSessionManagerClientProxy::OnBeforeScreenPropertyChanged(FoldStatus foldStatus)
931 {
932     sptr<IRemoteObject> remote = Remote();
933     if (remote == nullptr) {
934         TLOGE(WmsLogTag::DMS, "remote is nullptr");
935         return;
936     }
937     MessageParcel data;
938     MessageParcel reply;
939     MessageOption option(MessageOption::TF_SYNC);
940     if (!data.WriteInterfaceToken(GetDescriptor())) {
941         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
942         return;
943     }
944     if (!data.WriteUint32(static_cast<uint32_t>(foldStatus))) {
945         TLOGE(WmsLogTag::DMS, "Write fold status failed");
946         return;
947     }
948     if (remote->SendRequest(
949         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_BEFORE_PROPERTY_CHANGED),
950         data, reply, option) != ERR_NONE) {
951         TLOGE(WmsLogTag::DMS, "SendRequest failed");
952         return;
953     }
954 }
955 
OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent)956 void ScreenSessionManagerClientProxy::OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent)
957 {
958     sptr<IRemoteObject> remote = Remote();
959     if (remote == nullptr) {
960         TLOGE(WmsLogTag::DMS, "remote is nullptr");
961         return;
962     }
963     MessageParcel data;
964     MessageParcel reply;
965     MessageOption option(MessageOption::TF_SYNC);
966     if (!data.WriteInterfaceToken(GetDescriptor())) {
967         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed");
968         return;
969     }
970     if (!data.WriteUint32(static_cast<uint32_t>(screenModeChangeEvent))) {
971         TLOGE(WmsLogTag::DMS, "Write screen mode change event failed");
972         return;
973     }
974     if (remote->SendRequest(
975         static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_MODE_CHANGED),
976         data, reply, option) != ERR_NONE) {
977         TLOGE(WmsLogTag::DMS, "SendRequest failed");
978         return;
979     }
980 }
981 } // namespace OHOS::Rosen
982