• 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 "session/container/include/zidl/session_stage_proxy.h"
17 #include "session/container/include/zidl/session_stage_ipc_interface_code.h"
18 
19 #include <cstdint>
20 #include <ipc_types.h>
21 #include <message_option.h>
22 #include <message_parcel.h>
23 #include <securec.h>
24 
25 #include "window_manager_hilog.h"
26 #include "ws_common.h"
27 
28 namespace OHOS::Rosen {
29 namespace {
30 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStageProxy"};
31 constexpr int32_t MAX_INFO_SIZE = 50;
32 constexpr size_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M
33 
CopyBufferFromRawData(void * & buffer,size_t size,const void * data)34 bool CopyBufferFromRawData(void*& buffer, size_t size, const void* data)
35 {
36     if (data == nullptr) {
37         TLOGE(WmsLogTag::WMS_UIEXT, "data is nullptr");
38         return false;
39     }
40 
41     if (size == 0 || size >= MAX_PARCEL_CAPACITY) {
42         TLOGE(WmsLogTag::WMS_UIEXT, "size is invalid");
43         return false;
44     }
45 
46     buffer = malloc(size);
47     if (buffer == nullptr) {
48         TLOGE(WmsLogTag::WMS_UIEXT, "buffer malloc failed");
49         return false;
50     }
51 
52     if (memcpy_s(buffer, size, data, size) != EOK) {
53         free(buffer);
54         TLOGE(WmsLogTag::WMS_UIEXT, "memcpy_s failed");
55         return false;
56     }
57 
58     return true;
59 }
60 
ReadLittleStringVectorFromParcel(MessageParcel & reply,std::vector<std::string> & infos)61 bool ReadLittleStringVectorFromParcel(MessageParcel& reply, std::vector<std::string>& infos)
62 {
63     TLOGD(WmsLogTag::WMS_UIEXT, "entry");
64     if (!reply.ReadStringVector(&infos)) {
65         TLOGE(WmsLogTag::WMS_UIEXT, "Read string vector failed");
66         return false;
67     }
68     return true;
69 }
70 
ReadLargeStringVectorFromParcel(MessageParcel & reply,std::vector<std::string> & infos)71 bool ReadLargeStringVectorFromParcel(MessageParcel& reply, std::vector<std::string>& infos)
72 {
73     int32_t dataSizeInt = 0;
74     if (!reply.ReadInt32(dataSizeInt) || dataSizeInt == 0) {
75         TLOGE(WmsLogTag::WMS_UIEXT, "Read dataSize failed");
76         return false;
77     }
78 
79     size_t dataSize = static_cast<size_t>(dataSizeInt);
80     void* buffer = nullptr;
81     if (!CopyBufferFromRawData(buffer, dataSize, reply.ReadRawData(dataSize))) {
82         TLOGE(WmsLogTag::WMS_UIEXT, "Read rawData failed, dataSize: %{public}zu", dataSize);
83         return false;
84     }
85 
86     MessageParcel readParcel;
87     if (!readParcel.ParseFrom(reinterpret_cast<uintptr_t>(buffer), dataSize)) {
88         TLOGE(WmsLogTag::WMS_UIEXT, "Parse from buffer failed");
89         return false;
90     }
91 
92     int32_t infoSize = 0;
93     if (!readParcel.ReadInt32(infoSize)) {
94         TLOGE(WmsLogTag::WMS_UIEXT, "Read infoSize failed");
95         return false;
96     }
97 
98     TLOGD(WmsLogTag::WMS_UIEXT, "dataSize: %{public}zu, infoSize: %{public}d", dataSize, infoSize);
99     if (infoSize >= MAX_INFO_SIZE) {
100         TLOGE(WmsLogTag::WMS_UIEXT, "Too big infos, infoSize: %{public}d", infoSize);
101         return false;
102     }
103 
104     infos.clear();
105     infos.reserve(infoSize);
106     for (int32_t i = 0; i < infoSize; i++) {
107         infos.emplace_back(readParcel.ReadString());
108     }
109 
110     return true;
111 }
112 }
113 
SetActive(bool active)114 WSError SessionStageProxy::SetActive(bool active)
115 {
116     MessageParcel data;
117     MessageParcel reply;
118     MessageOption option(MessageOption::TF_ASYNC);
119     if (!data.WriteInterfaceToken(GetDescriptor())) {
120         WLOGFE("WriteInterfaceToken failed");
121         return WSError::WS_ERROR_IPC_FAILED;
122     }
123 
124     if (!data.WriteBool(active)) {
125         WLOGFE("Write active failed");
126         return WSError::WS_ERROR_IPC_FAILED;
127     }
128 
129     sptr<IRemoteObject> remote = Remote();
130     if (remote == nullptr) {
131         WLOGFE("remote is null");
132         return WSError::WS_ERROR_IPC_FAILED;
133     }
134 
135     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ACTIVE),
136         data, reply, option) != ERR_NONE) {
137         WLOGFE("SendRequest failed");
138         return WSError::WS_ERROR_IPC_FAILED;
139     }
140     int32_t ret = reply.ReadInt32();
141     return static_cast<WSError>(ret);
142 }
143 
UpdateDisplayId(uint64_t displayId)144 WSError SessionStageProxy::UpdateDisplayId(uint64_t displayId)
145 {
146     MessageParcel data;
147     MessageParcel reply;
148     MessageOption option(MessageOption::TF_ASYNC);
149     if (!data.WriteInterfaceToken(GetDescriptor())) {
150         WLOGFE("WriteInterfaceToken failed");
151         return WSError::WS_ERROR_IPC_FAILED;
152     }
153 
154     if (!data.WriteUint64(displayId)) {
155         WLOGFE("Write displayId failed");
156         return WSError::WS_ERROR_IPC_FAILED;
157     }
158 
159     sptr<IRemoteObject> remote = Remote();
160     if (remote == nullptr) {
161         WLOGFE("remote is null");
162         return WSError::WS_ERROR_IPC_FAILED;
163     }
164 
165     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAYID_CHANGE),
166         data, reply, option) != ERR_NONE) {
167         WLOGFE("SendRequest failed");
168         return WSError::WS_ERROR_IPC_FAILED;
169     }
170     int32_t ret = reply.ReadInt32();
171     return static_cast<WSError>(ret);
172 }
173 
UpdateRect(const WSRect & rect,SizeChangeReason reason,const SceneAnimationConfig & config,const std::map<AvoidAreaType,AvoidArea> & avoidAreas)174 WSError SessionStageProxy::UpdateRect(const WSRect& rect, SizeChangeReason reason,
175     const SceneAnimationConfig& config, const std::map<AvoidAreaType, AvoidArea>& avoidAreas)
176 {
177     MessageParcel data;
178     MessageParcel reply;
179     MessageOption option(MessageOption::TF_ASYNC);
180     if (!data.WriteInterfaceToken(GetDescriptor())) {
181         WLOGFE("WriteInterfaceToken failed");
182         return WSError::WS_ERROR_IPC_FAILED;
183     }
184 
185     if (!(data.WriteInt32(rect.posX_) && data.WriteInt32(rect.posY_) &&
186         data.WriteUint32(rect.width_) && data.WriteUint32(rect.height_))) {
187         WLOGFE("Write WindowRect failed");
188         return WSError::WS_ERROR_IPC_FAILED;
189     }
190 
191     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
192         WLOGFE("Write SessionSizeChangeReason failed");
193         return WSError::WS_ERROR_IPC_FAILED;
194     }
195 
196     const std::shared_ptr<RSTransaction>& rsTransaction = config.rsTransaction_;
197     bool hasRSTransaction = rsTransaction != nullptr;
198     if (!data.WriteBool(hasRSTransaction)) {
199         WLOGFE("Write has transaction failed");
200         return WSError::WS_ERROR_IPC_FAILED;
201     }
202     if (hasRSTransaction) {
203         auto pid = rsTransaction->GetParentPid();
204         rsTransaction->SetParentPid(getprocpid());
205         if (!data.WriteParcelable(rsTransaction.get())) {
206             WLOGFE("Write transaction sync Id failed");
207             return WSError::WS_ERROR_IPC_FAILED;
208         }
209         rsTransaction->SetParentPid(pid);
210     }
211 
212     if (!data.WriteInt32(config.animationDuration_)) {
213         TLOGE(WmsLogTag::DEFAULT, "Write animation duration failed");
214         return WSError::WS_ERROR_IPC_FAILED;
215     }
216 
217     if (!data.WriteUint32(avoidAreas.size())) {
218         TLOGE(WmsLogTag::WMS_IMMS, "Write avoid area size failed");
219         return WSError::WS_ERROR_IPC_FAILED;
220     }
221     for (const auto& [type, avoidArea] : avoidAreas) {
222         if (!data.WriteUint32(static_cast<uint32_t>(type))) {
223             TLOGE(WmsLogTag::WMS_IMMS, "Write avoid area type failed");
224             return WSError::WS_ERROR_IPC_FAILED;
225         }
226         if (!data.WriteParcelable(&avoidArea)) {
227             TLOGE(WmsLogTag::WMS_IMMS, "Write avoid area failed");
228             return WSError::WS_ERROR_IPC_FAILED;
229         }
230     }
231 
232     sptr<IRemoteObject> remote = Remote();
233     if (remote == nullptr) {
234         WLOGFE("remote is null");
235         return WSError::WS_ERROR_IPC_FAILED;
236     }
237 
238     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SIZE_CHANGE),
239         data, reply, option) != ERR_NONE) {
240         WLOGFE("SendRequest failed");
241         return WSError::WS_ERROR_IPC_FAILED;
242     }
243     int32_t ret = reply.ReadInt32();
244     return static_cast<WSError>(ret);
245 }
246 
UpdateDensity()247 void SessionStageProxy::UpdateDensity()
248 {
249     MessageParcel data;
250     MessageParcel reply;
251     MessageOption option(MessageOption::TF_ASYNC);
252     if (!data.WriteInterfaceToken(GetDescriptor())) {
253         WLOGFE("WriteInterfaceToken failed");
254         return;
255     }
256 
257     sptr<IRemoteObject> remote = Remote();
258     if (remote == nullptr) {
259         WLOGFE("remote is null");
260         return;
261     }
262 
263     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_CHANGE),
264         data, reply, option) != ERR_NONE) {
265         WLOGFE("SendRequest failed");
266         return;
267     }
268 }
269 
UpdateOrientation()270 WSError SessionStageProxy::UpdateOrientation()
271 {
272     MessageParcel data;
273     MessageParcel reply;
274     MessageOption option(MessageOption::TF_ASYNC);
275     if (!data.WriteInterfaceToken(GetDescriptor())) {
276         TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed.");
277         return WSError::WS_ERROR_IPC_FAILED;
278     }
279 
280     sptr<IRemoteObject> remote = Remote();
281     if (remote == nullptr) {
282         TLOGE(WmsLogTag::DMS, "remote is null");
283         return WSError::WS_ERROR_IPC_FAILED;
284     }
285 
286     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_ORIENTATION_CHANGE),
287         data, reply, option) != ERR_NONE) {
288         TLOGE(WmsLogTag::DMS, "SendRequest failed.");
289         return WSError::WS_ERROR_IPC_FAILED;
290     }
291 
292     WSError ret = static_cast<WSError>(reply.ReadInt32());
293     if (ret != WSError::WS_OK) {
294         TLOGE(WmsLogTag::DMS, "update orientation by ipc failed with error: %{public}d.", ret);
295     }
296     return ret;
297 }
298 
UpdateSessionViewportConfig(const SessionViewportConfig & config)299 WSError SessionStageProxy::UpdateSessionViewportConfig(const SessionViewportConfig& config)
300 {
301     MessageParcel data;
302     MessageParcel reply;
303     MessageOption option(MessageOption::TF_ASYNC);
304     if (!data.WriteInterfaceToken(GetDescriptor())) {
305         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
306         return WSError::WS_ERROR_IPC_FAILED;
307     }
308     if (!(data.WriteBool(config.isDensityFollowHost_) && data.WriteFloat(config.density_) &&
309             data.WriteUint64(config.displayId_) && data.WriteInt32(config.orientation_) &&
310             data.WriteUint32(config.transform_))) {
311         TLOGE(WmsLogTag::WMS_UIEXT, "Write config failed");
312         return WSError::WS_ERROR_IPC_FAILED;
313     }
314     sptr<IRemoteObject> remote = Remote();
315     if (remote == nullptr) {
316         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
317         return WSError::WS_ERROR_IPC_FAILED;
318     }
319     int sendCode = remote->SendRequest(
320         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_SESSION_VIEWPORT_CONFIG),
321         data, reply, option);
322     if (sendCode != ERR_NONE) {
323         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
324         return WSError::WS_ERROR_IPC_FAILED;
325     }
326     return WSError::WS_OK;
327 }
328 
HandleBackEvent()329 WSError SessionStageProxy::HandleBackEvent()
330 {
331     MessageParcel data;
332     MessageParcel reply;
333     MessageOption option(MessageOption::TF_ASYNC);
334     if (!data.WriteInterfaceToken(GetDescriptor())) {
335         WLOGFE("WriteInterfaceToken failed");
336         return WSError::WS_ERROR_IPC_FAILED;
337     }
338 
339     sptr<IRemoteObject> remote = Remote();
340     if (remote == nullptr) {
341         WLOGFE("remote is null");
342         return WSError::WS_ERROR_IPC_FAILED;
343     }
344 
345     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_HANDLE_BACK_EVENT),
346         data, reply, option) != ERR_NONE) {
347         WLOGFE("SendRequest failed");
348         return WSError::WS_ERROR_IPC_FAILED;
349     }
350     int32_t ret = reply.ReadInt32();
351     return static_cast<WSError>(ret);
352 }
353 
SwitchFreeMultiWindow(bool enable)354 WSError SessionStageProxy::SwitchFreeMultiWindow(bool enable)
355 {
356     MessageParcel data;
357     MessageParcel reply;
358     MessageOption option(MessageOption::TF_ASYNC);
359     if (!data.WriteInterfaceToken(GetDescriptor())) {
360         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
361         return WSError::WS_ERROR_IPC_FAILED;
362     }
363     if (!data.WriteBool(enable)) {
364         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write enable failed");
365         return WSError::WS_ERROR_IPC_FAILED;
366     }
367 
368     sptr<IRemoteObject> remote = Remote();
369     if (remote == nullptr) {
370         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
371         return WSError::WS_ERROR_IPC_FAILED;
372     }
373 
374     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW),
375         data, reply, option) != ERR_NONE) {
376         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
377         return WSError::WS_ERROR_IPC_FAILED;
378     }
379     int32_t ret = reply.ReadInt32();
380     return static_cast<WSError>(ret);
381 }
382 
GetUIContentRemoteObj(sptr<IRemoteObject> & uiContentRemoteObj)383 WSError SessionStageProxy::GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj)
384 {
385     MessageParcel data;
386     MessageParcel reply;
387     MessageOption option;
388     if (!data.WriteInterfaceToken(GetDescriptor())) {
389         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
390         return WSError::WS_ERROR_IPC_FAILED;
391     }
392 
393     sptr<IRemoteObject> remote = Remote();
394     if (remote == nullptr) {
395         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
396         return WSError::WS_ERROR_IPC_FAILED;
397     }
398 
399     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ),
400         data, reply, option) != ERR_NONE) {
401         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
402         return WSError::WS_ERROR_IPC_FAILED;
403     }
404     sptr<IRemoteObject> remoteObj = reply.ReadRemoteObject();
405     if (remoteObj == nullptr) {
406         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "ReadRemoteObject failed");
407         return WSError::WS_ERROR_IPC_FAILED;
408     }
409     uiContentRemoteObj = remoteObj;
410     return static_cast<WSError>(reply.ReadInt32());
411 }
412 
MarkProcessed(int32_t eventId)413 WSError SessionStageProxy::MarkProcessed(int32_t eventId)
414 {
415     return WSError::WS_DO_NOTHING;
416 }
417 
NotifyDestroy()418 WSError SessionStageProxy::NotifyDestroy()
419 {
420     MessageParcel data;
421     MessageParcel reply;
422     MessageOption option(MessageOption::TF_ASYNC);
423     if (!data.WriteInterfaceToken(GetDescriptor())) {
424         WLOGFE("WriteInterfaceToken failed");
425         return WSError::WS_ERROR_IPC_FAILED;
426     }
427 
428     sptr<IRemoteObject> remote = Remote();
429     if (remote == nullptr) {
430         WLOGFE("remote is null");
431         return WSError::WS_ERROR_IPC_FAILED;
432     }
433 
434     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DESTROY),
435         data, reply, option) != ERR_NONE) {
436         WLOGFE("SendRequest failed");
437         return WSError::WS_ERROR_IPC_FAILED;
438     }
439     int32_t ret = reply.ReadInt32();
440     return static_cast<WSError>(ret);
441 }
442 
NotifyCloseExistPipWindow()443 WSError SessionStageProxy::NotifyCloseExistPipWindow()
444 {
445     MessageParcel data;
446     MessageParcel reply;
447     MessageOption option(MessageOption::TF_ASYNC);
448     if (!data.WriteInterfaceToken(GetDescriptor())) {
449         WLOGFE("WriteInterfaceToken failed");
450         return WSError::WS_ERROR_IPC_FAILED;
451     }
452 
453     sptr<IRemoteObject> remote = Remote();
454     if (remote == nullptr) {
455         WLOGFE("remote is null");
456         return WSError::WS_ERROR_IPC_FAILED;
457     }
458 
459     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CLOSE_EXIST_PIP_WINDOW),
460         data, reply, option) != ERR_NONE) {
461         WLOGFE("SendRequest failed");
462         return WSError::WS_ERROR_IPC_FAILED;
463     }
464     int32_t ret = reply.ReadInt32();
465     return static_cast<WSError>(ret);
466 }
467 
UpdateFocus(bool focus)468 WSError SessionStageProxy::UpdateFocus(bool focus)
469 {
470     MessageParcel data;
471     MessageParcel reply;
472     MessageOption option(MessageOption::TF_ASYNC);
473     if (!data.WriteInterfaceToken(GetDescriptor())) {
474         WLOGFE("WriteInterfaceToken failed");
475         return WSError::WS_ERROR_IPC_FAILED;
476     }
477 
478     if (!data.WriteBool(focus)) {
479         WLOGFE("Write focus failed");
480         return WSError::WS_ERROR_IPC_FAILED;
481     }
482 
483     sptr<IRemoteObject> remote = Remote();
484     if (remote == nullptr) {
485         WLOGFE("remote is null");
486         return WSError::WS_ERROR_IPC_FAILED;
487     }
488 
489     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOCUS_CHANGE),
490         data, reply, option) != ERR_NONE) {
491         WLOGFW("SendRequest failed");
492         return WSError::WS_ERROR_IPC_FAILED;
493     }
494     int32_t ret = reply.ReadInt32();
495     return static_cast<WSError>(ret);
496 }
497 
NotifyTransferComponentData(const AAFwk::WantParams & wantParams)498 WSError SessionStageProxy::NotifyTransferComponentData(const AAFwk::WantParams& wantParams)
499 {
500     MessageParcel data;
501     MessageParcel reply;
502     MessageOption option(MessageOption::TF_ASYNC);
503     if (!data.WriteInterfaceToken(GetDescriptor())) {
504         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
505         return WSError::WS_ERROR_IPC_FAILED;
506     }
507 
508     if (!data.WriteParcelable(&wantParams)) {
509         TLOGE(WmsLogTag::WMS_UIEXT, "wantParams write failed.");
510         return WSError::WS_ERROR_IPC_FAILED;
511     }
512 
513     sptr<IRemoteObject> remote = Remote();
514     if (remote == nullptr) {
515         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
516         return WSError::WS_ERROR_IPC_FAILED;
517     }
518 
519     int sendCode = remote->SendRequest(
520         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA),
521         data, reply, option);
522     if (sendCode != ERR_NONE) {
523         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
524         return WSError::WS_ERROR_IPC_FAILED;
525     }
526     int32_t ret = reply.ReadInt32();
527     return static_cast<WSError>(ret);
528 }
529 
NotifyTransferComponentDataSync(const AAFwk::WantParams & wantParams,AAFwk::WantParams & reWantParams)530 WSErrorCode SessionStageProxy::NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams,
531                                                                AAFwk::WantParams& reWantParams)
532 {
533     MessageParcel data;
534     MessageParcel reply;
535     MessageOption option(MessageOption::TF_SYNC);
536     if (!data.WriteInterfaceToken(GetDescriptor())) {
537         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
538         return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
539     }
540 
541     if (!data.WriteParcelable(&wantParams)) {
542         TLOGE(WmsLogTag::WMS_UIEXT, "wantParams write failed.");
543         return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
544     }
545 
546     sptr<IRemoteObject> remote = Remote();
547     if (remote == nullptr) {
548         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
549         return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
550     }
551 
552     int sendCode = remote->SendRequest(
553         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA_SYNC),
554         data, reply, option);
555     if (sendCode != ERR_NONE) {
556         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
557         return static_cast<WSErrorCode>(sendCode);
558     }
559 
560     std::shared_ptr<AAFwk::WantParams> readWantParams(reply.ReadParcelable<AAFwk::WantParams>());
561     if (readWantParams == nullptr) {
562         TLOGE(WmsLogTag::WMS_UIEXT, "readWantParams is nullptr");
563         return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
564     }
565 
566     reWantParams = *readWantParams;
567     return WSErrorCode::WS_OK;
568 }
569 
NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,const std::shared_ptr<RSTransaction> & rsTransaction)570 void SessionStageProxy::NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,
571                                                      const std::shared_ptr<RSTransaction>& rsTransaction)
572 {
573     MessageParcel data;
574     MessageParcel reply;
575     MessageOption option(MessageOption::TF_ASYNC);
576     if (!data.WriteInterfaceToken(GetDescriptor())) {
577         TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
578         return;
579     }
580 
581     if (!data.WriteParcelable(info.GetRefPtr())) {
582         TLOGE(WmsLogTag::WMS_KEYBOARD, "occupied info write failed.");
583         return;
584     }
585 
586     bool hasRSTransaction = rsTransaction != nullptr;
587     if (!data.WriteBool(hasRSTransaction)) {
588         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write has transaction failed");
589         return;
590     }
591     if (hasRSTransaction) {
592         if (!data.WriteParcelable(rsTransaction.get())) {
593             TLOGE(WmsLogTag::WMS_KEYBOARD, "Write transaction sync Id failed");
594             return;
595         }
596     }
597 
598     sptr<IRemoteObject> remote = Remote();
599     if (remote == nullptr) {
600         TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
601         return;
602     }
603 
604     if (remote->SendRequest(
605         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_OCCUPIED_AREA_CHANGE_INFO),
606         data, reply, option) != ERR_NONE) {
607         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
608         return;
609     }
610     return;
611 }
612 
UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)613 WSError SessionStageProxy::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
614 {
615     MessageParcel data;
616     MessageParcel reply;
617     MessageOption option(MessageOption::TF_ASYNC);
618     if (!data.WriteInterfaceToken(GetDescriptor())) {
619         TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
620         return WSError::WS_ERROR_IPC_FAILED;
621     }
622     if (!data.WriteStrongParcelable(avoidArea)) {
623         TLOGE(WmsLogTag::WMS_IMMS, "Write AvoidArea failed");
624         return WSError::WS_ERROR_IPC_FAILED;
625     }
626     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
627         TLOGE(WmsLogTag::WMS_IMMS, "Write AvoidAreaType failed");
628         return WSError::WS_ERROR_IPC_FAILED;
629     }
630     sptr<IRemoteObject> remote = Remote();
631     if (remote == nullptr) {
632         TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
633         return WSError::WS_ERROR_IPC_FAILED;
634     }
635     int sendCode = remote->SendRequest(
636         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_AVOID_AREA), data, reply, option);
637     if (sendCode != ERR_NONE) {
638         TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed, code: %{public}d", sendCode);
639         return WSError::WS_ERROR_IPC_FAILED;
640     }
641     return WSError::WS_OK;
642 }
643 
DumpSessionElementInfo(const std::vector<std::string> & params)644 void SessionStageProxy::DumpSessionElementInfo(const std::vector<std::string>& params)
645 {
646     MessageParcel data;
647     MessageParcel reply;
648     MessageOption option(MessageOption::TF_ASYNC);
649     if (!data.WriteInterfaceToken(GetDescriptor())) {
650         WLOGFE("WriteInterfaceToken failed");
651         return;
652     }
653     if (!data.WriteStringVector(params)) {
654         WLOGFE("Write params failed");
655         return;
656     }
657     sptr<IRemoteObject> remote = Remote();
658     if (remote == nullptr) {
659         WLOGFE("remote is null");
660         return;
661     }
662     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_DUMP_SESSSION_ELEMENT_INFO),
663         data, reply, option) != ERR_NONE) {
664         WLOGFE("SendRequest failed");
665         return;
666     }
667 }
668 
NotifyScreenshot()669 void SessionStageProxy::NotifyScreenshot()
670 {
671     MessageParcel data;
672     MessageParcel reply;
673     MessageOption option(MessageOption::TF_ASYNC);
674     if (!data.WriteInterfaceToken(GetDescriptor())) {
675         WLOGFE("WriteInterfaceToken failed");
676         return;
677     }
678     sptr<IRemoteObject> remote = Remote();
679     if (remote == nullptr) {
680         WLOGFE("remote is null");
681         return;
682     }
683     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SCREEN_SHOT),
684         data, reply, option) != ERR_NONE) {
685         WLOGFE("SendRequest failed");
686         return;
687     }
688 }
689 
NotifyTouchOutside()690 WSError SessionStageProxy::NotifyTouchOutside()
691 {
692     MessageParcel data;
693     MessageParcel reply;
694     MessageOption option(MessageOption::TF_ASYNC);
695     if (!data.WriteInterfaceToken(GetDescriptor())) {
696         WLOGFE("WriteInterfaceToken failed");
697         return WSError::WS_ERROR_IPC_FAILED;
698     }
699     sptr<IRemoteObject> remote = Remote();
700     if (remote == nullptr) {
701         WLOGFE("remote is null");
702         return WSError::WS_ERROR_IPC_FAILED;
703     }
704     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TOUCH_OUTSIDE),
705         data, reply, option) != ERR_NONE) {
706         WLOGFE("SendRequest failed");
707         return WSError::WS_ERROR_IPC_FAILED;
708     }
709     return WSError::WS_OK;
710 }
711 
NotifyWindowVisibility(bool isVisible)712 WSError SessionStageProxy::NotifyWindowVisibility(bool isVisible)
713 {
714     MessageParcel data;
715     MessageParcel reply;
716     MessageOption option(MessageOption::TF_ASYNC);
717     if (!data.WriteInterfaceToken(GetDescriptor())) {
718         WLOGFE("WriteInterfaceToken failed");
719         return WSError::WS_ERROR_IPC_FAILED;
720     }
721 
722     if (!data.WriteBool(isVisible)) {
723         WLOGFE("Write window visible failed");
724         return WSError::WS_ERROR_IPC_FAILED;
725     }
726     uint32_t messageCode = static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_VISIBILITY_CHANGE);
727 
728     sptr<IRemoteObject> remote = Remote();
729     if (remote == nullptr) {
730         WLOGFE("remote is null");
731         return WSError::WS_ERROR_IPC_FAILED;
732     }
733     if (remote->SendRequest(messageCode, data, reply, option) != ERR_NONE) {
734         WLOGFE("SendRequest failed");
735         return WSError::WS_ERROR_IPC_FAILED;
736     }
737     int32_t ret = reply.ReadInt32();
738     return static_cast<WSError>(ret);
739 }
740 
UpdateWindowMode(WindowMode mode)741 WSError SessionStageProxy::UpdateWindowMode(WindowMode mode)
742 {
743     MessageParcel data;
744     MessageParcel reply;
745     MessageOption option(MessageOption::TF_ASYNC);
746     if (!data.WriteInterfaceToken(GetDescriptor())) {
747         WLOGFE("WriteInterfaceToken failed");
748         return WSError::WS_ERROR_IPC_FAILED;
749     }
750 
751     if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
752         WLOGFE("Write mode failed");
753         return WSError::WS_ERROR_IPC_FAILED;
754     }
755 
756     sptr<IRemoteObject> remote = Remote();
757     if (remote == nullptr) {
758         WLOGFE("remote is null");
759         return WSError::WS_ERROR_IPC_FAILED;
760     }
761     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_MODE_CHANGE),
762         data, reply, option) != ERR_NONE) {
763         WLOGFE("SendRequest failed");
764         return WSError::WS_ERROR_IPC_FAILED;
765     }
766     int32_t ret = reply.ReadInt32();
767     return static_cast<WSError>(ret);
768 }
769 
NotifyForegroundInteractiveStatus(bool interactive)770 void SessionStageProxy::NotifyForegroundInteractiveStatus(bool interactive)
771 {
772     MessageParcel data;
773     MessageParcel reply;
774     MessageOption option(MessageOption::TF_ASYNC);
775     if (!data.WriteInterfaceToken(GetDescriptor())) {
776         WLOGFE("WriteInterfaceToken failed");
777         return;
778     }
779 
780     if (!data.WriteBool(interactive)) {
781         WLOGFE("Write interactive failed");
782         return;
783     }
784 
785     sptr<IRemoteObject> remote = Remote();
786     if (remote == nullptr) {
787         WLOGFE("remote is null");
788         return;
789     }
790     if (remote->SendRequest(
791         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS),
792         data, reply, option) != ERR_NONE) {
793         WLOGFE("SendRequest failed");
794     }
795 }
796 
UpdateMaximizeMode(MaximizeMode mode)797 WSError SessionStageProxy::UpdateMaximizeMode(MaximizeMode mode)
798 {
799     MessageParcel data;
800     MessageParcel reply;
801     MessageOption option(MessageOption::TF_ASYNC);
802     if (!data.WriteInterfaceToken(GetDescriptor())) {
803         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
804         return WSError::WS_ERROR_IPC_FAILED;
805     }
806 
807     if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
808         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write mode failed");
809         return WSError::WS_ERROR_IPC_FAILED;
810     }
811 
812     sptr<IRemoteObject> remote = Remote();
813     if (remote == nullptr) {
814         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
815         return WSError::WS_ERROR_IPC_FAILED;
816     }
817     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_MAXIMIZE_MODE_CHANGE),
818         data, reply, option) != ERR_NONE) {
819         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
820         return WSError::WS_ERROR_IPC_FAILED;
821     }
822     int32_t ret = reply.ReadInt32();
823     return static_cast<WSError>(ret);
824 }
825 
NotifySessionForeground(uint32_t reason,bool withAnimation)826 void  SessionStageProxy::NotifySessionForeground(uint32_t reason, bool withAnimation)
827 {
828     MessageParcel data;
829     MessageParcel reply;
830     MessageOption option(MessageOption::TF_ASYNC);
831     if (!data.WriteInterfaceToken(GetDescriptor())) {
832         WLOGFE("WriteInterfaceToken failed");
833         return;
834     }
835 
836     if (!data.WriteUint32(reason)) {
837         WLOGFE("Write reason failed");
838         return;
839     }
840     if (!data.WriteBool(withAnimation)) {
841         WLOGFE("Write withAnimation failed");
842         return;
843     }
844     sptr<IRemoteObject> remote = Remote();
845     if (remote == nullptr) {
846         WLOGFE("remote is null");
847         return;
848     }
849     if (remote->SendRequest(
850         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FOREGROUND),
851         data, reply, option) != ERR_NONE) {
852         WLOGFE("Send NotifySessionForeground Request failed");
853     }
854 }
855 
NotifySessionFullScreen(bool fullScreen)856 void SessionStageProxy::NotifySessionFullScreen(bool fullScreen)
857 {
858     sptr<IRemoteObject> remote = Remote();
859     if (remote == nullptr) {
860         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
861         return;
862     }
863     MessageParcel data;
864     MessageParcel reply;
865     MessageOption option(MessageOption::TF_ASYNC);
866     if (!data.WriteInterfaceToken(GetDescriptor())) {
867         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
868         return;
869     }
870     if (!data.WriteBool(fullScreen)) {
871         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write fullScreen failed");
872         return;
873     }
874     if (remote->SendRequest(
875         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN),
876         data, reply, option) != ERR_NONE) {
877         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Send Request failed");
878     }
879 }
880 
NotifySessionBackground(uint32_t reason,bool withAnimation,bool isFromInnerkits)881 void SessionStageProxy::NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits)
882 {
883     MessageParcel data;
884     MessageParcel reply;
885     MessageOption option(MessageOption::TF_ASYNC);
886     if (!data.WriteInterfaceToken(GetDescriptor())) {
887         WLOGFE("WriteInterfaceToken failed");
888         return;
889     }
890 
891     if (!data.WriteUint32(reason)) {
892         WLOGFE("Write reason failed");
893         return;
894     }
895     if (!data.WriteBool(withAnimation)) {
896         WLOGFE("Write withAnimation failed");
897         return;
898     }
899     if (!data.WriteBool(isFromInnerkits)) {
900         WLOGFE("Write isFromInnerkits failed");
901         return;
902     }
903     sptr<IRemoteObject> remote = Remote();
904     if (remote == nullptr) {
905         WLOGFE("remote is null");
906         return;
907     }
908     if (remote->SendRequest(
909         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_BACKGROUND),
910         data, reply, option) != ERR_NONE) {
911         WLOGFE("Send NotifySessionBackground Request failed");
912         return;
913     }
914 }
915 
UpdateTitleInTargetPos(bool isShow,int32_t height)916 WSError SessionStageProxy::UpdateTitleInTargetPos(bool isShow, int32_t height)
917 {
918     MessageParcel data;
919     MessageParcel reply;
920     MessageOption option(MessageOption::TF_ASYNC);
921     if (!data.WriteInterfaceToken(GetDescriptor())) {
922         TLOGE(WmsLogTag::WMS_DECOR, "WriteInterfaceToken failed");
923         return WSError::WS_ERROR_IPC_FAILED;
924     }
925 
926     if (!data.WriteBool(isShow)) {
927         TLOGE(WmsLogTag::WMS_DECOR, "Write isShow failed");
928         return WSError::WS_ERROR_IPC_FAILED;
929     }
930 
931     if (!data.WriteUint32(height)) {
932         TLOGE(WmsLogTag::WMS_DECOR, "Write height failed");
933         return WSError::WS_ERROR_IPC_FAILED;
934     }
935 
936     sptr<IRemoteObject> remote = Remote();
937     if (remote == nullptr) {
938         TLOGE(WmsLogTag::WMS_DECOR, "remote is null");
939         return WSError::WS_ERROR_IPC_FAILED;
940     }
941     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TITLE_POSITION_CHANGE),
942         data, reply, option) != ERR_NONE) {
943         TLOGE(WmsLogTag::WMS_DECOR, "SendRequest failed");
944         return WSError::WS_ERROR_IPC_FAILED;
945     }
946     int32_t ret = reply.ReadInt32();
947     return static_cast<WSError>(ret);
948 }
949 
NotifyTransformChange(const Transform & transform)950 void SessionStageProxy::NotifyTransformChange(const Transform& transform)
951 {
952     MessageParcel data;
953     MessageParcel reply;
954     MessageOption option(MessageOption::TF_ASYNC);
955     if (!data.WriteInterfaceToken(GetDescriptor())) {
956         WLOGFE("WriteInterfaceToken failed");
957         return;
958     }
959 
960     if (!transform.Marshalling(data)) {
961         WLOGFE("Transform marshalling failed");
962         return;
963     }
964 
965     sptr<IRemoteObject> remote = Remote();
966     if (remote == nullptr) {
967         WLOGFE("remote is null");
968         return;
969     }
970     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFORM_CHANGE),
971                             data, reply, option) != ERR_NONE) {
972         WLOGFE("Send NotifyTransformChange Requset failed");
973     }
974 }
975 
NotifySingleHandTransformChange(const SingleHandTransform & singleHandTransform)976 void SessionStageProxy::NotifySingleHandTransformChange(const SingleHandTransform& singleHandTransform)
977 {
978     MessageParcel data;
979     MessageParcel reply;
980     MessageOption option(MessageOption::TF_ASYNC);
981     if (!data.WriteInterfaceToken(GetDescriptor())) {
982         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
983         return;
984     }
985 
986     if (!singleHandTransform.Marshalling(data)) {
987         TLOGE(WmsLogTag::WMS_LAYOUT, "singleHandTransform marshalling failed");
988         return;
989     }
990 
991     sptr<IRemoteObject> remote = Remote();
992     if (remote == nullptr) {
993         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
994         return;
995     }
996     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SINGLE_HAND_TRANSFORM),
997                             data, reply, option) != ERR_NONE) {
998         TLOGE(WmsLogTag::WMS_LAYOUT, "Send Requset failed");
999     }
1000 }
1001 
NotifyDensityFollowHost(bool isFollowHost,float densityValue)1002 WSError SessionStageProxy::NotifyDensityFollowHost(bool isFollowHost, float densityValue)
1003 {
1004     MessageParcel data;
1005     MessageParcel reply;
1006     MessageOption option(MessageOption::TF_ASYNC);
1007     if (!data.WriteInterfaceToken(GetDescriptor())) {
1008         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1009         return WSError::WS_ERROR_IPC_FAILED;
1010     }
1011 
1012     if (!data.WriteBool(isFollowHost)) {
1013         TLOGE(WmsLogTag::WMS_UIEXT, "Write isFollowHost failed");
1014         return WSError::WS_ERROR_IPC_FAILED;
1015     }
1016 
1017     if (!data.WriteFloat(densityValue)) {
1018         TLOGE(WmsLogTag::WMS_UIEXT, "Write densityValue failed");
1019         return WSError::WS_ERROR_IPC_FAILED;
1020     }
1021 
1022     sptr<IRemoteObject> remote = Remote();
1023     if (remote == nullptr) {
1024         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1025         return WSError::WS_ERROR_IPC_FAILED;
1026     }
1027     int sendCode = remote->SendRequest(
1028         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST), data, reply, option);
1029     if (sendCode != ERR_NONE) {
1030         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1031         return WSError::WS_ERROR_IPC_FAILED;
1032     }
1033 
1034     return WSError::WS_OK;
1035 }
1036 
NotifyDialogStateChange(bool isForeground)1037 WSError SessionStageProxy::NotifyDialogStateChange(bool isForeground)
1038 {
1039     MessageParcel data;
1040     MessageParcel reply;
1041     MessageOption option(MessageOption::TF_ASYNC);
1042     if (!data.WriteInterfaceToken(GetDescriptor())) {
1043         WLOGFE("WriteInterfaceToken failed");
1044         return WSError::WS_ERROR_IPC_FAILED;
1045     }
1046 
1047     if (!data.WriteBool(isForeground)) {
1048         WLOGFE("Write isForeground failed");
1049         return WSError::WS_ERROR_IPC_FAILED;
1050     }
1051 
1052     sptr<IRemoteObject> remote = Remote();
1053     if (remote == nullptr) {
1054         WLOGFE("remote is null");
1055         return WSError::WS_ERROR_IPC_FAILED;
1056     }
1057     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE),
1058         data, reply, option) != ERR_NONE) {
1059         WLOGFE("SendRequest failed");
1060         return WSError::WS_ERROR_IPC_FAILED;
1061     }
1062     return WSError::WS_OK;
1063 }
1064 
SetPipActionEvent(const std::string & action,int32_t status)1065 WSError SessionStageProxy::SetPipActionEvent(const std::string& action, int32_t status)
1066 {
1067     MessageParcel data;
1068     MessageParcel reply;
1069     MessageOption option(MessageOption::TF_ASYNC);
1070     if (!data.WriteInterfaceToken(GetDescriptor())) {
1071         WLOGFE("WriteInterfaceToken failed");
1072         return WSError::WS_ERROR_IPC_FAILED;
1073     }
1074 
1075     if (!data.WriteString(action)) {
1076         WLOGFE("Write params failed");
1077         return WSError::WS_ERROR_IPC_FAILED;
1078     }
1079 
1080     if (!data.WriteInt32(status)) {
1081         WLOGFE("Write status failed");
1082         return WSError::WS_ERROR_IPC_FAILED;
1083     }
1084 
1085     sptr<IRemoteObject> remote = Remote();
1086     if (remote == nullptr) {
1087         WLOGFE("remote is null");
1088         return WSError::WS_ERROR_IPC_FAILED;
1089     }
1090     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_ACTION_EVENT),
1091         data, reply, option) != ERR_NONE) {
1092         WLOGFE("SendRequest failed");
1093         return WSError::WS_ERROR_IPC_FAILED;
1094     }
1095     return WSError::WS_OK;
1096 }
1097 
NotifyPipWindowSizeChange(double width,double height,double scale)1098 WSError SessionStageProxy::NotifyPipWindowSizeChange(double width, double height, double scale)
1099 {
1100     MessageParcel data;
1101     MessageParcel reply;
1102     MessageOption option(MessageOption::TF_ASYNC);
1103     if (!data.WriteInterfaceToken(GetDescriptor())) {
1104         WLOGFE("WriteInterfaceToken failed");
1105         return WSError::WS_ERROR_IPC_FAILED;
1106     }
1107 
1108     if (!data.WriteDouble(width)) {
1109         WLOGFE("Write width failed");
1110         return WSError::WS_ERROR_IPC_FAILED;
1111     }
1112 
1113     if (!data.WriteDouble(height)) {
1114         WLOGFE("Write height failed");
1115         return WSError::WS_ERROR_IPC_FAILED;
1116     }
1117 
1118     if (!data.WriteDouble(scale)) {
1119         WLOGFE("Write scale failed");
1120         return WSError::WS_ERROR_IPC_FAILED;
1121     }
1122 
1123     sptr<IRemoteObject> remote = Remote();
1124     if (remote == nullptr) {
1125         WLOGFE("remote is null");
1126         return WSError::WS_ERROR_IPC_FAILED;
1127     }
1128 
1129     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE),
1130         data, reply, option) != ERR_NONE) {
1131         WLOGFE("SendRequest failed");
1132         return WSError::WS_ERROR_IPC_FAILED;
1133     }
1134     return WSError::WS_OK;
1135 }
1136 
SetPiPControlEvent(WsPiPControlType controlType,WsPiPControlStatus status)1137 WSError SessionStageProxy::SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status)
1138 {
1139     TLOGI(WmsLogTag::WMS_PIP, "controlType:%{public}u, enabled:%{public}d", controlType, status);
1140     MessageParcel data;
1141     MessageParcel reply;
1142     MessageOption option(MessageOption::TF_ASYNC);
1143     if (!data.WriteInterfaceToken(GetDescriptor())) {
1144         TLOGE(WmsLogTag::WMS_PIP, "WriteInterfaceToken failed");
1145         return WSError::WS_ERROR_IPC_FAILED;
1146     }
1147 
1148     if (!data.WriteUint32(static_cast<uint32_t>(controlType))) {
1149         TLOGE(WmsLogTag::WMS_PIP, "Write params failed");
1150         return WSError::WS_ERROR_IPC_FAILED;
1151     }
1152 
1153     if (!data.WriteInt32(static_cast<int32_t>(status))) {
1154         TLOGE(WmsLogTag::WMS_PIP, "Write status failed");
1155         return WSError::WS_ERROR_IPC_FAILED;
1156     }
1157 
1158     sptr<IRemoteObject> remote = Remote();
1159     if (remote == nullptr) {
1160         TLOGE(WmsLogTag::WMS_PIP, "remote is null");
1161         return WSError::WS_ERROR_IPC_FAILED;
1162     }
1163     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_CONTROL_EVENT),
1164         data, reply, option) != ERR_NONE) {
1165         TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
1166         return WSError::WS_ERROR_IPC_FAILED;
1167     }
1168     return WSError::WS_OK;
1169 }
1170 
NotifyDisplayMove(DisplayId from,DisplayId to)1171 void SessionStageProxy::NotifyDisplayMove(DisplayId from, DisplayId to)
1172 {
1173     MessageParcel data;
1174     MessageParcel reply;
1175     MessageOption option(MessageOption::TF_ASYNC);
1176     if (!data.WriteInterfaceToken(GetDescriptor())) {
1177         WLOGFE("WriteInterfaceToken failed");
1178         return;
1179     }
1180 
1181     if (!data.WriteUint64(from)) {
1182         WLOGFE("Write from id failed");
1183         return;
1184     }
1185 
1186     if (!data.WriteUint64(to)) {
1187         WLOGFE("Write to id failed");
1188         return;
1189     }
1190 
1191     sptr<IRemoteObject> remote = Remote();
1192     if (remote == nullptr) {
1193         WLOGFE("remote is null");
1194         return;
1195     }
1196     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE),
1197         data, reply, option) != ERR_NONE) {
1198         WLOGFE("SendRequest notify display move failed");
1199         return;
1200     }
1201 }
1202 
NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo & keyboardPanelInfo)1203 void SessionStageProxy::NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo)
1204 {
1205     MessageParcel data;
1206     MessageParcel reply;
1207     MessageOption option(MessageOption::TF_ASYNC);
1208     if (!data.WriteInterfaceToken(GetDescriptor())) {
1209         TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
1210         return;
1211     }
1212 
1213     if (!data.WriteParcelable(&keyboardPanelInfo)) {
1214         TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardPanelInfo marshalling failed");
1215         return;
1216     }
1217 
1218     sptr<IRemoteObject> remote = Remote();
1219     if (remote == nullptr) {
1220         TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
1221         return;
1222     }
1223     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE),
1224         data, reply, option) != ERR_NONE) {
1225         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest notify keyboard panel info change failed");
1226         return;
1227     }
1228 }
1229 
CompatibleFullScreenRecover()1230 WSError SessionStageProxy::CompatibleFullScreenRecover()
1231 {
1232     sptr<IRemoteObject> remote = Remote();
1233     if (remote == nullptr) {
1234         TLOGE(WmsLogTag::WMS_SCB, "remote is null");
1235         return WSError::WS_ERROR_IPC_FAILED;
1236     }
1237     MessageParcel data;
1238     MessageParcel reply;
1239     MessageOption option(MessageOption::TF_ASYNC);
1240     if (!data.WriteInterfaceToken(GetDescriptor())) {
1241         TLOGE(WmsLogTag::WMS_SCB, "WriteInterfaceToken failed");
1242         return WSError::WS_ERROR_IPC_FAILED;
1243     }
1244 
1245     if (remote->SendRequest(
1246         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_COMPATIBLE_FULLSCREEN_RECOVER),
1247         data, reply, option) != ERR_NONE) {
1248         TLOGE(WmsLogTag::WMS_SCB, "SendRequest failed");
1249         return WSError::WS_ERROR_IPC_FAILED;
1250     }
1251     int32_t ret = reply.ReadInt32();
1252     return static_cast<WSError>(ret);
1253 }
1254 
CompatibleFullScreenMinimize()1255 WSError SessionStageProxy::CompatibleFullScreenMinimize()
1256 {
1257     sptr<IRemoteObject> remote = Remote();
1258     if (remote == nullptr) {
1259         TLOGE(WmsLogTag::WMS_SCB, "remote is null");
1260         return WSError::WS_ERROR_IPC_FAILED;
1261     }
1262     MessageParcel data;
1263     MessageParcel reply;
1264     MessageOption option(MessageOption::TF_ASYNC);
1265     if (!data.WriteInterfaceToken(GetDescriptor())) {
1266         TLOGE(WmsLogTag::WMS_SCB, "WriteInterfaceToken failed");
1267         return WSError::WS_ERROR_IPC_FAILED;
1268     }
1269 
1270     if (remote->SendRequest(
1271         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_COMPATIBLE_FULLSCREEN_MINIMIZE),
1272         data, reply, option) != ERR_NONE) {
1273         TLOGE(WmsLogTag::WMS_SCB, "SendRequest failed");
1274         return WSError::WS_ERROR_IPC_FAILED;
1275     }
1276     int32_t ret = reply.ReadInt32();
1277     return static_cast<WSError>(ret);
1278 }
1279 
CompatibleFullScreenClose()1280 WSError SessionStageProxy::CompatibleFullScreenClose()
1281 {
1282     sptr<IRemoteObject> remote = Remote();
1283     if (remote == nullptr) {
1284         TLOGE(WmsLogTag::WMS_SCB, "remote is null");
1285         return WSError::WS_ERROR_IPC_FAILED;
1286     }
1287     MessageParcel data;
1288     MessageParcel reply;
1289     MessageOption option(MessageOption::TF_ASYNC);
1290     if (!data.WriteInterfaceToken(GetDescriptor())) {
1291         TLOGE(WmsLogTag::WMS_SCB, "WriteInterfaceToken failed");
1292         return WSError::WS_ERROR_IPC_FAILED;
1293     }
1294 
1295     if (remote->SendRequest(
1296         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_COMPATIBLE_FULLSCREEN_CLOSE),
1297         data, reply, option) != ERR_NONE) {
1298         TLOGE(WmsLogTag::WMS_SCB, "SendRequest failed");
1299         return WSError::WS_ERROR_IPC_FAILED;
1300     }
1301     int32_t ret = reply.ReadInt32();
1302     return static_cast<WSError>(ret);
1303 }
1304 
PcAppInPadNormalClose()1305 WSError SessionStageProxy::PcAppInPadNormalClose()
1306 {
1307     sptr<IRemoteObject> remote = Remote();
1308     if (remote == nullptr) {
1309         TLOGE(WmsLogTag::WMS_COMPAT, "remote is null");
1310         return WSError::WS_ERROR_IPC_FAILED;
1311     }
1312     MessageParcel data;
1313     MessageParcel reply;
1314     MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER);
1315     if (!data.WriteInterfaceToken(GetDescriptor())) {
1316         TLOGE(WmsLogTag::WMS_COMPAT, "WriteInterfaceToken failed");
1317         return WSError::WS_ERROR_IPC_FAILED;
1318     }
1319 
1320     if (remote->SendRequest(
1321         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_PCAPPINPADNORMAL_CLOSE),
1322         data, reply, option) != ERR_NONE) {
1323         TLOGE(WmsLogTag::WMS_COMPAT, "SendRequest failed");
1324         return WSError::WS_ERROR_IPC_FAILED;
1325     }
1326     return WSError::WS_OK;
1327 }
1328 
NotifyCompatibleModeEnableInPad(bool enable)1329 WSError SessionStageProxy::NotifyCompatibleModeEnableInPad(bool enable)
1330 {
1331     sptr<IRemoteObject> remote = Remote();
1332     if (remote == nullptr) {
1333         TLOGE(WmsLogTag::WMS_SCB, "remote is null");
1334         return WSError::WS_ERROR_IPC_FAILED;
1335     }
1336     MessageParcel data;
1337     MessageParcel reply;
1338     MessageOption option(MessageOption::TF_ASYNC);
1339     if (!data.WriteInterfaceToken(GetDescriptor())) {
1340         TLOGE(WmsLogTag::WMS_SCB, "WriteInterfaceToken failed");
1341         return WSError::WS_ERROR_IPC_FAILED;
1342     }
1343     if (!data.WriteBool(enable)) {
1344         TLOGE(WmsLogTag::DEFAULT, "Write enable failed");
1345         return WSError::WS_ERROR_IPC_FAILED;
1346     }
1347 
1348     if (remote->SendRequest(
1349         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_COMPATIBLE_MODE_ENABLE),
1350         data, reply, option) != ERR_NONE) {
1351         TLOGE(WmsLogTag::WMS_SCB, "SendRequest failed");
1352         return WSError::WS_ERROR_IPC_FAILED;
1353     }
1354     return WSError::WS_OK;
1355 }
1356 
SetUniqueVirtualPixelRatio(bool useUniqueDensity,float virtualPixelRatio)1357 void SessionStageProxy::SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio)
1358 {
1359     sptr<IRemoteObject> remote = Remote();
1360     if (remote == nullptr) {
1361         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is nullptr");
1362         return;
1363     }
1364 
1365     MessageParcel data;
1366     MessageParcel reply;
1367     MessageOption option(MessageOption::TF_ASYNC);
1368     if (!data.WriteInterfaceToken(GetDescriptor())) {
1369         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
1370         return;
1371     }
1372     if (!data.WriteBool(useUniqueDensity)) {
1373         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write useUniqueDensity failed");
1374         return;
1375     }
1376     if (!data.WriteFloat(virtualPixelRatio)) {
1377         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write virtualPixelRatio failed");
1378         return;
1379     }
1380 
1381     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_UNIQUE),
1382         data, reply, option) != ERR_NONE) {
1383         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
1384         return;
1385     }
1386 }
1387 
NotifyDumpInfo(const std::vector<std::string> & params,std::vector<std::string> & info)1388 WSError SessionStageProxy::NotifyDumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
1389 {
1390     sptr<IRemoteObject> remote = Remote();
1391     if (remote == nullptr) {
1392         TLOGE(WmsLogTag::WMS_UIEXT, "remote is nullptr");
1393         return WSError::WS_ERROR_NULLPTR;
1394     }
1395     MessageParcel data;
1396     MessageParcel reply;
1397     MessageOption option(MessageOption::TF_SYNC);
1398     if (!data.WriteInterfaceToken(GetDescriptor())) {
1399         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1400         return WSError::WS_ERROR_IPC_FAILED;
1401     }
1402     if (!data.WriteStringVector(params)) {
1403         TLOGE(WmsLogTag::WMS_UIEXT, "Write params failed");
1404         return WSError::WS_ERROR_IPC_FAILED;
1405     }
1406     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DUMP_INFO),
1407         data, reply, option);
1408     if (sendCode != ERR_NONE) {
1409         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1410         return WSError::WS_ERROR_IPC_FAILED;
1411     }
1412 
1413     bool isLittleSize = false;
1414     if (!reply.ReadBool(isLittleSize)) {
1415         TLOGE(WmsLogTag::WMS_UIEXT, "ReadBool failed");
1416         return WSError::WS_ERROR_IPC_FAILED;
1417     }
1418 
1419     bool readResult = isLittleSize ? ReadLittleStringVectorFromParcel(reply, info) :
1420         ReadLargeStringVectorFromParcel(reply, info);
1421     if (!readResult) {
1422         TLOGE(WmsLogTag::WMS_UIEXT, "Read data failed");
1423         return WSError::WS_ERROR_IPC_FAILED;
1424     }
1425 
1426     int32_t ret = 0;
1427     if (!reply.ReadInt32(ret)) {
1428         TLOGE(WmsLogTag::WMS_UIEXT, "Read int32 failed");
1429         return WSError::WS_ERROR_IPC_FAILED;
1430     }
1431     return static_cast<WSError>(ret);
1432 }
1433 
SendExtensionData(MessageParcel & data,MessageParcel & reply,MessageOption & option)1434 WSError SessionStageProxy::SendExtensionData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
1435 {
1436     sptr<IRemoteObject> remote = Remote();
1437     if (remote == nullptr) {
1438         TLOGE(WmsLogTag::WMS_UIEXT, "remote is nullptr");
1439         return WSError::WS_ERROR_NULLPTR;
1440     }
1441 
1442     auto ret = remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_EXTENSION_DATA), data,
1443                                    reply, option);
1444     if (ret != ERR_NONE) {
1445         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, ret: %{public}d", ret);
1446         return WSError::WS_ERROR_IPC_FAILED;
1447     }
1448     return WSError::WS_OK;
1449 }
1450 
SetDragActivated(bool dragActivated)1451 WSError SessionStageProxy::SetDragActivated(bool dragActivated)
1452 {
1453     MessageParcel data;
1454     MessageParcel reply;
1455     MessageOption option(MessageOption::TF_ASYNC);
1456     if (!data.WriteInterfaceToken(GetDescriptor())) {
1457         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1458         return WSError::WS_ERROR_IPC_FAILED;
1459     }
1460     if (!data.WriteBool(dragActivated)) {
1461         TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1462         return WSError::WS_ERROR_IPC_FAILED;
1463     }
1464     sptr<IRemoteObject> remote = Remote();
1465     if (remote == nullptr) {
1466         TLOGE(WmsLogTag::WMS_LAYOUT, "Remote is null");
1467         return WSError::WS_ERROR_IPC_FAILED;
1468     }
1469     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_DRAG_ACTIVATED),
1470                             data, reply, option) != ERR_NONE) {
1471         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1472         return WSError::WS_ERROR_IPC_FAILED;
1473     }
1474     return WSError::WS_OK;
1475 }
1476 
SetSplitButtonVisible(bool isVisible)1477 WSError SessionStageProxy::SetSplitButtonVisible(bool isVisible)
1478 {
1479     MessageParcel data;
1480     MessageParcel reply;
1481     MessageOption option(MessageOption::TF_ASYNC);
1482     if (!data.WriteInterfaceToken(GetDescriptor())) {
1483         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1484         return WSError::WS_ERROR_IPC_FAILED;
1485     }
1486     if (!data.WriteBool(isVisible)) {
1487         TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1488         return WSError::WS_ERROR_IPC_FAILED;
1489     }
1490     sptr<IRemoteObject> remote = Remote();
1491     if (remote == nullptr) {
1492         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1493         return WSError::WS_ERROR_IPC_FAILED;
1494     }
1495     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_SPLIT_BUTTON_VISIBLE),
1496         data, reply, option) != ERR_NONE) {
1497         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1498         return WSError::WS_ERROR_IPC_FAILED;
1499     }
1500     return WSError::WS_OK;
1501 }
1502 
SetEnableDragBySystem(bool dragEnable)1503 WSError SessionStageProxy::SetEnableDragBySystem(bool dragEnable)
1504 {
1505     MessageParcel data;
1506     MessageParcel reply;
1507     MessageOption option(MessageOption::TF_ASYNC);
1508     if (!data.WriteInterfaceToken(GetDescriptor())) {
1509         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1510         return WSError::WS_ERROR_IPC_FAILED;
1511     }
1512     if (!data.WriteBool(dragEnable)) {
1513         TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1514         return WSError::WS_ERROR_IPC_FAILED;
1515     }
1516     sptr<IRemoteObject> remote = Remote();
1517     if (remote == nullptr) {
1518         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1519         return WSError::WS_ERROR_IPC_FAILED;
1520     }
1521     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM),
1522         data, reply, option) != ERR_NONE) {
1523         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1524         return WSError::WS_ERROR_IPC_FAILED;
1525     }
1526     return WSError::WS_OK;
1527 }
1528 
SetFullScreenWaterfallMode(bool isWaterfallMode)1529 WSError SessionStageProxy::SetFullScreenWaterfallMode(bool isWaterfallMode)
1530 {
1531     MessageParcel data;
1532     MessageParcel reply;
1533     MessageOption option(MessageOption::TF_ASYNC);
1534     if (!data.WriteInterfaceToken(GetDescriptor())) {
1535         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1536         return WSError::WS_ERROR_IPC_FAILED;
1537     }
1538     if (!data.WriteBool(isWaterfallMode)) {
1539         TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1540         return WSError::WS_ERROR_IPC_FAILED;
1541     }
1542     sptr<IRemoteObject> remote = Remote();
1543     if (remote == nullptr) {
1544         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1545         return WSError::WS_ERROR_IPC_FAILED;
1546     }
1547     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_FULLSCREEN_WATERFALL_MODE),
1548         data, reply, option) != ERR_NONE) {
1549         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1550         return WSError::WS_ERROR_IPC_FAILED;
1551     }
1552     return WSError::WS_OK;
1553 }
1554 
SetSupportEnterWaterfallMode(bool isSupportEnter)1555 WSError SessionStageProxy::SetSupportEnterWaterfallMode(bool isSupportEnter)
1556 {
1557     MessageParcel data;
1558     MessageParcel reply;
1559     MessageOption option(MessageOption::TF_ASYNC);
1560     if (!data.WriteInterfaceToken(GetDescriptor())) {
1561         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
1562         return WSError::WS_ERROR_IPC_FAILED;
1563     }
1564     if (!data.WriteBool(isSupportEnter)) {
1565         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write params failed");
1566         return WSError::WS_ERROR_IPC_FAILED;
1567     }
1568     sptr<IRemoteObject> remote = Remote();
1569     if (remote == nullptr) {
1570         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
1571         return WSError::WS_ERROR_IPC_FAILED;
1572     }
1573     if (remote->SendRequest(static_cast<uint32_t>(
1574         SessionStageInterfaceCode::TRANS_ID_SET_SUPPORT_ENTER_WATERFALL_MODE),
1575         data, reply, option) != ERR_NONE) {
1576         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
1577         return WSError::WS_ERROR_IPC_FAILED;
1578     }
1579     return WSError::WS_OK;
1580 }
1581 
SendContainerModalEvent(const std::string & eventName,const std::string & eventValue)1582 WSError SessionStageProxy::SendContainerModalEvent(const std::string& eventName, const std::string& eventValue)
1583 {
1584     MessageParcel data;
1585     MessageParcel reply;
1586     MessageOption option(MessageOption::TF_ASYNC);
1587     if (!data.WriteInterfaceToken(GetDescriptor())) {
1588         TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed");
1589         return WSError::WS_ERROR_IPC_FAILED;
1590     }
1591     if (!data.WriteString(eventName)) {
1592         TLOGE(WmsLogTag::WMS_EVENT, "Write params failed");
1593         return WSError::WS_ERROR_IPC_FAILED;
1594     }
1595     if (!data.WriteString(eventValue)) {
1596         TLOGE(WmsLogTag::WMS_EVENT, "Write params failed");
1597         return WSError::WS_ERROR_IPC_FAILED;
1598     }
1599     sptr<IRemoteObject> remote = Remote();
1600     if (remote == nullptr) {
1601         TLOGE(WmsLogTag::WMS_EVENT, "remote is null");
1602         return WSError::WS_ERROR_IPC_FAILED;
1603     }
1604     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_CONTAINER_MODAL_EVENT),
1605         data, reply, option) != ERR_NONE) {
1606         TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed");
1607         return WSError::WS_ERROR_IPC_FAILED;
1608     }
1609     return WSError::WS_OK;
1610 }
1611 
NotifyHighlightChange(bool isHighlight)1612 WSError SessionStageProxy::NotifyHighlightChange(bool isHighlight)
1613 {
1614     MessageParcel data;
1615     MessageParcel reply;
1616     MessageOption option(MessageOption::TF_ASYNC);
1617     if (!data.WriteInterfaceToken(GetDescriptor())) {
1618         TLOGE(WmsLogTag::WMS_FOCUS, "Write interfaceToken failed");
1619         return WSError::WS_ERROR_IPC_FAILED;
1620     }
1621 
1622     if (!data.WriteBool(isHighlight)) {
1623         TLOGE(WmsLogTag::WMS_FOCUS, "Write isHighlight failed");
1624         return WSError::WS_ERROR_IPC_FAILED;
1625     }
1626 
1627     sptr<IRemoteObject> remote = Remote();
1628     if (remote == nullptr) {
1629         TLOGE(WmsLogTag::WMS_FOCUS, "remote is null");
1630         return WSError::WS_ERROR_IPC_FAILED;
1631     }
1632 
1633     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_HIGHLIGHT_CHANGE),
1634                             data, reply, option) != ERR_NONE) {
1635         TLOGE(WmsLogTag::WMS_FOCUS, "SendRequest failed");
1636         return WSError::WS_ERROR_IPC_FAILED;
1637     }
1638     return WSError::WS_OK;
1639 }
1640 
NotifyWindowCrossAxisChange(CrossAxisState state)1641 void SessionStageProxy::NotifyWindowCrossAxisChange(CrossAxisState state)
1642 {
1643     MessageParcel data;
1644     MessageParcel reply;
1645     MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER);
1646     if (!data.WriteInterfaceToken(GetDescriptor())) {
1647         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
1648         return;
1649     }
1650     if (!data.WriteUint32(static_cast<uint32_t>(state))) {
1651         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write params failed");
1652         return;
1653     }
1654     sptr<IRemoteObject> remote = Remote();
1655     if (remote == nullptr) {
1656         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
1657         return;
1658     }
1659     if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CROSS_AXIS),
1660         data, reply, option) != ERR_NONE) {
1661         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
1662         return;
1663     }
1664 }
1665 
NotifyWindowAttachStateChange(bool isAttach)1666 WSError SessionStageProxy::NotifyWindowAttachStateChange(bool isAttach)
1667 {
1668     MessageParcel data;
1669     MessageParcel reply;
1670     MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER);
1671     if (!data.WriteInterfaceToken(GetDescriptor())) {
1672         TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
1673         return WSError::WS_ERROR_IPC_FAILED;
1674     }
1675     if (!data.WriteBool(isAttach)) {
1676         TLOGE(WmsLogTag::WMS_SUB, "Write params failed");
1677         return WSError::WS_ERROR_IPC_FAILED;
1678     }
1679     sptr<IRemoteObject> remote = Remote();
1680     if (remote == nullptr) {
1681         TLOGE(WmsLogTag::WMS_SUB, "remote is null");
1682         return WSError::WS_ERROR_IPC_FAILED;
1683     }
1684     if (remote->SendRequest(
1685         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE),
1686         data, reply, option) != ERR_NONE) {
1687         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
1688         return WSError::WS_ERROR_IPC_FAILED;
1689     }
1690     return WSError::WS_OK;
1691 }
1692 
NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo & keyboardPanelInfo)1693 void SessionStageProxy::NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo& keyboardPanelInfo)
1694 {
1695     MessageParcel data;
1696     MessageParcel reply;
1697     MessageOption option(MessageOption::TF_ASYNC);
1698     if (!data.WriteInterfaceToken(GetDescriptor())) {
1699         TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
1700         return;
1701     }
1702 
1703     if (!data.WriteParcelable(&keyboardPanelInfo)) {
1704         TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardPanelInfo marshalling failed");
1705         return;
1706     }
1707 
1708     sptr<IRemoteObject> remote = Remote();
1709     if (remote == nullptr) {
1710         TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
1711         return;
1712     }
1713     if (remote->SendRequest(
1714         static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_ANIMATION_COMPLETED),
1715         data, reply, option) != ERR_NONE) {
1716         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
1717     }
1718 }
1719 } // namespace OHOS::Rosen
1720