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
UpdateGlobalDisplayRectFromServer(const WSRect & rect,SizeChangeReason reason)247 WSError SessionStageProxy::UpdateGlobalDisplayRectFromServer(const WSRect& rect, SizeChangeReason reason)
248 {
249 MessageParcel data;
250 if (!data.WriteInterfaceToken(GetDescriptor())) {
251 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to write interface token");
252 return WSError::WS_ERROR_IPC_FAILED;
253 }
254 if (!data.WriteInt32(rect.posX_) || !data.WriteInt32(rect.posY_) ||
255 !data.WriteInt32(rect.width_) || !data.WriteInt32(rect.height_)) {
256 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to write rect");
257 return WSError::WS_ERROR_IPC_FAILED;
258 }
259 if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
260 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to write reason");
261 return WSError::WS_ERROR_IPC_FAILED;
262 }
263 sptr<IRemoteObject> remote = Remote();
264 if (!remote) {
265 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is nullptr");
266 return WSError::WS_ERROR_IPC_FAILED;
267 }
268 MessageParcel reply;
269 MessageOption option(MessageOption::TF_ASYNC);
270 int sendRet = remote->SendRequest(
271 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_GLOBAL_DISPLAY_RECT), data, reply, option);
272 if (sendRet != ERR_NONE) {
273 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to send request, error = %{public}d", sendRet);
274 return WSError::WS_ERROR_IPC_FAILED;
275 }
276 return WSError::WS_OK;
277 }
278
UpdateDensity()279 void SessionStageProxy::UpdateDensity()
280 {
281 MessageParcel data;
282 MessageParcel reply;
283 MessageOption option(MessageOption::TF_ASYNC);
284 if (!data.WriteInterfaceToken(GetDescriptor())) {
285 WLOGFE("WriteInterfaceToken failed");
286 return;
287 }
288
289 sptr<IRemoteObject> remote = Remote();
290 if (remote == nullptr) {
291 WLOGFE("remote is null");
292 return;
293 }
294
295 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_CHANGE),
296 data, reply, option) != ERR_NONE) {
297 WLOGFE("SendRequest failed");
298 return;
299 }
300 }
301
UpdateOrientation()302 WSError SessionStageProxy::UpdateOrientation()
303 {
304 MessageParcel data;
305 MessageParcel reply;
306 MessageOption option(MessageOption::TF_ASYNC);
307 if (!data.WriteInterfaceToken(GetDescriptor())) {
308 TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed.");
309 return WSError::WS_ERROR_IPC_FAILED;
310 }
311
312 sptr<IRemoteObject> remote = Remote();
313 if (remote == nullptr) {
314 TLOGE(WmsLogTag::DMS, "remote is null");
315 return WSError::WS_ERROR_IPC_FAILED;
316 }
317
318 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_ORIENTATION_CHANGE),
319 data, reply, option) != ERR_NONE) {
320 TLOGE(WmsLogTag::DMS, "SendRequest failed.");
321 return WSError::WS_ERROR_IPC_FAILED;
322 }
323
324 WSError ret = static_cast<WSError>(reply.ReadInt32());
325 if (ret != WSError::WS_OK) {
326 TLOGE(WmsLogTag::DMS, "update orientation by ipc failed with error: %{public}d.", ret);
327 }
328 return ret;
329 }
330
UpdateSessionViewportConfig(const SessionViewportConfig & config)331 WSError SessionStageProxy::UpdateSessionViewportConfig(const SessionViewportConfig& config)
332 {
333 MessageParcel data;
334 MessageParcel reply;
335 MessageOption option(MessageOption::TF_ASYNC);
336 if (!data.WriteInterfaceToken(GetDescriptor())) {
337 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
338 return WSError::WS_ERROR_IPC_FAILED;
339 }
340 if (!(data.WriteBool(config.isDensityFollowHost_) && data.WriteFloat(config.density_) &&
341 data.WriteUint64(config.displayId_) && data.WriteInt32(config.orientation_) &&
342 data.WriteUint32(config.transform_))) {
343 TLOGE(WmsLogTag::WMS_UIEXT, "Write config failed");
344 return WSError::WS_ERROR_IPC_FAILED;
345 }
346 sptr<IRemoteObject> remote = Remote();
347 if (remote == nullptr) {
348 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
349 return WSError::WS_ERROR_IPC_FAILED;
350 }
351 int sendCode = remote->SendRequest(
352 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_SESSION_VIEWPORT_CONFIG),
353 data, reply, option);
354 if (sendCode != ERR_NONE) {
355 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
356 return WSError::WS_ERROR_IPC_FAILED;
357 }
358 return WSError::WS_OK;
359 }
360
HandleBackEvent()361 WSError SessionStageProxy::HandleBackEvent()
362 {
363 MessageParcel data;
364 MessageParcel reply;
365 MessageOption option(MessageOption::TF_ASYNC);
366 if (!data.WriteInterfaceToken(GetDescriptor())) {
367 WLOGFE("WriteInterfaceToken failed");
368 return WSError::WS_ERROR_IPC_FAILED;
369 }
370
371 sptr<IRemoteObject> remote = Remote();
372 if (remote == nullptr) {
373 WLOGFE("remote is null");
374 return WSError::WS_ERROR_IPC_FAILED;
375 }
376
377 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_HANDLE_BACK_EVENT),
378 data, reply, option) != ERR_NONE) {
379 WLOGFE("SendRequest failed");
380 return WSError::WS_ERROR_IPC_FAILED;
381 }
382 int32_t ret = reply.ReadInt32();
383 return static_cast<WSError>(ret);
384 }
385
SwitchFreeMultiWindow(bool enable)386 WSError SessionStageProxy::SwitchFreeMultiWindow(bool enable)
387 {
388 MessageParcel data;
389 MessageParcel reply;
390 MessageOption option(MessageOption::TF_ASYNC);
391 if (!data.WriteInterfaceToken(GetDescriptor())) {
392 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
393 return WSError::WS_ERROR_IPC_FAILED;
394 }
395 if (!data.WriteBool(enable)) {
396 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write enable failed");
397 return WSError::WS_ERROR_IPC_FAILED;
398 }
399
400 sptr<IRemoteObject> remote = Remote();
401 if (remote == nullptr) {
402 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
403 return WSError::WS_ERROR_IPC_FAILED;
404 }
405
406 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW),
407 data, reply, option) != ERR_NONE) {
408 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
409 return WSError::WS_ERROR_IPC_FAILED;
410 }
411 int32_t ret = reply.ReadInt32();
412 return static_cast<WSError>(ret);
413 }
414
GetUIContentRemoteObj(sptr<IRemoteObject> & uiContentRemoteObj)415 WSError SessionStageProxy::GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj)
416 {
417 MessageParcel data;
418 MessageParcel reply;
419 MessageOption option;
420 if (!data.WriteInterfaceToken(GetDescriptor())) {
421 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
422 return WSError::WS_ERROR_IPC_FAILED;
423 }
424
425 sptr<IRemoteObject> remote = Remote();
426 if (remote == nullptr) {
427 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
428 return WSError::WS_ERROR_IPC_FAILED;
429 }
430
431 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ),
432 data, reply, option) != ERR_NONE) {
433 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
434 return WSError::WS_ERROR_IPC_FAILED;
435 }
436 sptr<IRemoteObject> remoteObj = reply.ReadRemoteObject();
437 if (remoteObj == nullptr) {
438 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "ReadRemoteObject failed");
439 return WSError::WS_ERROR_IPC_FAILED;
440 }
441 uiContentRemoteObj = remoteObj;
442 return static_cast<WSError>(reply.ReadInt32());
443 }
444
MarkProcessed(int32_t eventId)445 WSError SessionStageProxy::MarkProcessed(int32_t eventId)
446 {
447 return WSError::WS_DO_NOTHING;
448 }
449
NotifyDestroy()450 WSError SessionStageProxy::NotifyDestroy()
451 {
452 MessageParcel data;
453 MessageParcel reply;
454 MessageOption option(MessageOption::TF_ASYNC);
455 if (!data.WriteInterfaceToken(GetDescriptor())) {
456 WLOGFE("WriteInterfaceToken failed");
457 return WSError::WS_ERROR_IPC_FAILED;
458 }
459
460 sptr<IRemoteObject> remote = Remote();
461 if (remote == nullptr) {
462 WLOGFE("remote is null");
463 return WSError::WS_ERROR_IPC_FAILED;
464 }
465
466 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DESTROY),
467 data, reply, option) != ERR_NONE) {
468 WLOGFE("SendRequest failed");
469 return WSError::WS_ERROR_IPC_FAILED;
470 }
471 int32_t ret = reply.ReadInt32();
472 return static_cast<WSError>(ret);
473 }
474
NotifyCloseExistPipWindow()475 WSError SessionStageProxy::NotifyCloseExistPipWindow()
476 {
477 MessageParcel data;
478 MessageParcel reply;
479 MessageOption option(MessageOption::TF_ASYNC);
480 if (!data.WriteInterfaceToken(GetDescriptor())) {
481 WLOGFE("WriteInterfaceToken failed");
482 return WSError::WS_ERROR_IPC_FAILED;
483 }
484
485 sptr<IRemoteObject> remote = Remote();
486 if (remote == nullptr) {
487 WLOGFE("remote is null");
488 return WSError::WS_ERROR_IPC_FAILED;
489 }
490
491 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CLOSE_EXIST_PIP_WINDOW),
492 data, reply, option) != ERR_NONE) {
493 WLOGFE("SendRequest failed");
494 return WSError::WS_ERROR_IPC_FAILED;
495 }
496 int32_t ret = reply.ReadInt32();
497 return static_cast<WSError>(ret);
498 }
499
UpdateFocus(bool focus)500 WSError SessionStageProxy::UpdateFocus(bool focus)
501 {
502 MessageParcel data;
503 MessageParcel reply;
504 MessageOption option(MessageOption::TF_ASYNC);
505 if (!data.WriteInterfaceToken(GetDescriptor())) {
506 WLOGFE("WriteInterfaceToken failed");
507 return WSError::WS_ERROR_IPC_FAILED;
508 }
509
510 if (!data.WriteBool(focus)) {
511 WLOGFE("Write focus failed");
512 return WSError::WS_ERROR_IPC_FAILED;
513 }
514
515 sptr<IRemoteObject> remote = Remote();
516 if (remote == nullptr) {
517 WLOGFE("remote is null");
518 return WSError::WS_ERROR_IPC_FAILED;
519 }
520
521 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOCUS_CHANGE),
522 data, reply, option) != ERR_NONE) {
523 WLOGFW("SendRequest failed");
524 return WSError::WS_ERROR_IPC_FAILED;
525 }
526 int32_t ret = reply.ReadInt32();
527 return static_cast<WSError>(ret);
528 }
529
NotifyTransferComponentData(const AAFwk::WantParams & wantParams)530 WSError SessionStageProxy::NotifyTransferComponentData(const AAFwk::WantParams& wantParams)
531 {
532 MessageParcel data;
533 MessageParcel reply;
534 MessageOption option(MessageOption::TF_ASYNC);
535 if (!data.WriteInterfaceToken(GetDescriptor())) {
536 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
537 return WSError::WS_ERROR_IPC_FAILED;
538 }
539
540 if (!data.WriteParcelable(&wantParams)) {
541 TLOGE(WmsLogTag::WMS_UIEXT, "wantParams write failed.");
542 return WSError::WS_ERROR_IPC_FAILED;
543 }
544
545 sptr<IRemoteObject> remote = Remote();
546 if (remote == nullptr) {
547 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
548 return WSError::WS_ERROR_IPC_FAILED;
549 }
550
551 int sendCode = remote->SendRequest(
552 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA),
553 data, reply, option);
554 if (sendCode != ERR_NONE) {
555 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
556 return WSError::WS_ERROR_IPC_FAILED;
557 }
558 int32_t ret = reply.ReadInt32();
559 return static_cast<WSError>(ret);
560 }
561
NotifyTransferComponentDataSync(const AAFwk::WantParams & wantParams,AAFwk::WantParams & reWantParams)562 WSErrorCode SessionStageProxy::NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams,
563 AAFwk::WantParams& reWantParams)
564 {
565 MessageParcel data;
566 MessageParcel reply;
567 MessageOption option(MessageOption::TF_SYNC);
568 if (!data.WriteInterfaceToken(GetDescriptor())) {
569 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
570 return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
571 }
572
573 if (!data.WriteParcelable(&wantParams)) {
574 TLOGE(WmsLogTag::WMS_UIEXT, "wantParams write failed.");
575 return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
576 }
577
578 sptr<IRemoteObject> remote = Remote();
579 if (remote == nullptr) {
580 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
581 return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
582 }
583
584 int sendCode = remote->SendRequest(
585 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA_SYNC),
586 data, reply, option);
587 if (sendCode != ERR_NONE) {
588 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
589 return static_cast<WSErrorCode>(sendCode);
590 }
591
592 std::shared_ptr<AAFwk::WantParams> readWantParams(reply.ReadParcelable<AAFwk::WantParams>());
593 if (readWantParams == nullptr) {
594 TLOGE(WmsLogTag::WMS_UIEXT, "readWantParams is nullptr");
595 return WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED;
596 }
597
598 reWantParams = *readWantParams;
599 return WSErrorCode::WS_OK;
600 }
601
NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,const std::shared_ptr<RSTransaction> & rsTransaction,const Rect & callingSessionRect,const std::map<AvoidAreaType,AvoidArea> & avoidAreas)602 void SessionStageProxy::NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,
603 const std::shared_ptr<RSTransaction>& rsTransaction, const Rect& callingSessionRect,
604 const std::map<AvoidAreaType, AvoidArea>& avoidAreas)
605 {
606 MessageParcel data;
607 MessageParcel reply;
608 MessageOption option(MessageOption::TF_ASYNC);
609 if (!data.WriteInterfaceToken(GetDescriptor())) {
610 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
611 return;
612 }
613
614 if (!data.WriteParcelable(info.GetRefPtr())) {
615 TLOGE(WmsLogTag::WMS_KEYBOARD, "occupied info write failed.");
616 return;
617 }
618
619 if (!(data.WriteInt32(callingSessionRect.posX_) && data.WriteInt32(callingSessionRect.posY_) &&
620 data.WriteUint32(callingSessionRect.width_) && data.WriteUint32(callingSessionRect.height_))) {
621 WLOGFE("Write callingSessionRect failed");
622 return;
623 }
624 if (!data.WriteUint32(avoidAreas.size())) {
625 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write avoid area size failed");
626 return;
627 }
628 for (const auto& [type, avoidArea] : avoidAreas) {
629 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
630 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write avoid area type failed");
631 return;
632 }
633 if (!data.WriteParcelable(&avoidArea)) {
634 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write avoid area failed");
635 return;
636 }
637 }
638
639 bool hasRSTransaction = rsTransaction != nullptr;
640 if (!data.WriteBool(hasRSTransaction)) {
641 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write has transaction failed");
642 return;
643 }
644 if (hasRSTransaction) {
645 if (!data.WriteParcelable(rsTransaction.get())) {
646 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write transaction sync Id failed");
647 return;
648 }
649 }
650
651 sptr<IRemoteObject> remote = Remote();
652 if (remote == nullptr) {
653 TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
654 return;
655 }
656
657 if (remote->SendRequest(
658 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_OCCUPIED_AREA_CHANGE_INFO),
659 data, reply, option) != ERR_NONE) {
660 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
661 return;
662 }
663 return;
664 }
665
UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)666 WSError SessionStageProxy::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
667 {
668 MessageParcel data;
669 MessageParcel reply;
670 MessageOption option(MessageOption::TF_ASYNC);
671 if (!data.WriteInterfaceToken(GetDescriptor())) {
672 TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
673 return WSError::WS_ERROR_IPC_FAILED;
674 }
675 if (!data.WriteStrongParcelable(avoidArea)) {
676 TLOGE(WmsLogTag::WMS_IMMS, "Write AvoidArea failed");
677 return WSError::WS_ERROR_IPC_FAILED;
678 }
679 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
680 TLOGE(WmsLogTag::WMS_IMMS, "Write AvoidAreaType failed");
681 return WSError::WS_ERROR_IPC_FAILED;
682 }
683 sptr<IRemoteObject> remote = Remote();
684 if (remote == nullptr) {
685 TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
686 return WSError::WS_ERROR_IPC_FAILED;
687 }
688 int sendCode = remote->SendRequest(
689 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_AVOID_AREA), data, reply, option);
690 if (sendCode != ERR_NONE) {
691 TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed, code: %{public}d", sendCode);
692 return WSError::WS_ERROR_IPC_FAILED;
693 }
694 return WSError::WS_OK;
695 }
696
DumpSessionElementInfo(const std::vector<std::string> & params)697 void SessionStageProxy::DumpSessionElementInfo(const std::vector<std::string>& params)
698 {
699 MessageParcel data;
700 MessageParcel reply;
701 MessageOption option(MessageOption::TF_ASYNC);
702 if (!data.WriteInterfaceToken(GetDescriptor())) {
703 WLOGFE("WriteInterfaceToken failed");
704 return;
705 }
706 if (!data.WriteStringVector(params)) {
707 WLOGFE("Write params failed");
708 return;
709 }
710 sptr<IRemoteObject> remote = Remote();
711 if (remote == nullptr) {
712 WLOGFE("remote is null");
713 return;
714 }
715 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_DUMP_SESSSION_ELEMENT_INFO),
716 data, reply, option) != ERR_NONE) {
717 WLOGFE("SendRequest failed");
718 return;
719 }
720 }
721
NotifyScreenshot()722 void SessionStageProxy::NotifyScreenshot()
723 {
724 MessageParcel data;
725 MessageParcel reply;
726 MessageOption option(MessageOption::TF_ASYNC);
727 if (!data.WriteInterfaceToken(GetDescriptor())) {
728 WLOGFE("WriteInterfaceToken failed");
729 return;
730 }
731 sptr<IRemoteObject> remote = Remote();
732 if (remote == nullptr) {
733 WLOGFE("remote is null");
734 return;
735 }
736 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SCREEN_SHOT),
737 data, reply, option) != ERR_NONE) {
738 WLOGFE("SendRequest failed");
739 return;
740 }
741 }
742
NotifyScreenshotAppEvent(ScreenshotEventType type)743 WSError SessionStageProxy::NotifyScreenshotAppEvent(ScreenshotEventType type)
744 {
745 MessageParcel data;
746 MessageParcel reply;
747 MessageOption option(MessageOption::TF_ASYNC);
748 if (!data.WriteInterfaceToken(GetDescriptor())) {
749 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
750 return WSError::WS_ERROR_IPC_FAILED;
751 }
752 if (!data.WriteInt32(static_cast<int32_t>(type))) {
753 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write screenshot event type failed");
754 return WSError::WS_ERROR_IPC_FAILED;
755 }
756 sptr<IRemoteObject> remote = Remote();
757 if (remote == nullptr) {
758 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
759 return WSError::WS_ERROR_IPC_FAILED;
760 }
761 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SCREEN_SHOT_APP_EVENT),
762 data, reply, option) != ERR_NONE) {
763 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
764 return WSError::WS_ERROR_IPC_FAILED;
765 }
766 return WSError::WS_OK;
767 }
768
NotifyTouchOutside()769 WSError SessionStageProxy::NotifyTouchOutside()
770 {
771 MessageParcel data;
772 MessageParcel reply;
773 MessageOption option(MessageOption::TF_ASYNC);
774 if (!data.WriteInterfaceToken(GetDescriptor())) {
775 WLOGFE("WriteInterfaceToken failed");
776 return WSError::WS_ERROR_IPC_FAILED;
777 }
778 sptr<IRemoteObject> remote = Remote();
779 if (remote == nullptr) {
780 WLOGFE("remote is null");
781 return WSError::WS_ERROR_IPC_FAILED;
782 }
783 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TOUCH_OUTSIDE),
784 data, reply, option) != ERR_NONE) {
785 WLOGFE("SendRequest failed");
786 return WSError::WS_ERROR_IPC_FAILED;
787 }
788 return WSError::WS_OK;
789 }
790
NotifyExtensionSecureLimitChange(bool isLimit)791 WSError SessionStageProxy::NotifyExtensionSecureLimitChange(bool isLimit)
792 {
793 MessageParcel data;
794 MessageParcel reply;
795 MessageOption option(MessageOption::TF_ASYNC);
796 if (!data.WriteInterfaceToken(GetDescriptor())) {
797 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
798 return WSError::WS_ERROR_IPC_FAILED;
799 }
800
801 if (!data.WriteBool(isLimit)) {
802 TLOGE(WmsLogTag::WMS_UIEXT, "Write window islimit failed");
803 return WSError::WS_ERROR_IPC_FAILED;
804 }
805
806 sptr<IRemoteObject> remote = Remote();
807 if (remote == nullptr) {
808 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
809 return WSError::WS_ERROR_IPC_FAILED;
810 }
811 int sendCode = remote->SendRequest(
812 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SECURE_LIMIT_CHANGE), data, reply, option);
813 if (sendCode != ERR_NONE) {
814 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code:%{public}d", sendCode);
815 return WSError::WS_ERROR_IPC_FAILED;
816 }
817 return WSError::WS_OK;
818 }
819
NotifyWindowVisibility(bool isVisible)820 WSError SessionStageProxy::NotifyWindowVisibility(bool isVisible)
821 {
822 MessageParcel data;
823 MessageParcel reply;
824 MessageOption option(MessageOption::TF_ASYNC);
825 if (!data.WriteInterfaceToken(GetDescriptor())) {
826 WLOGFE("WriteInterfaceToken failed");
827 return WSError::WS_ERROR_IPC_FAILED;
828 }
829
830 if (!data.WriteBool(isVisible)) {
831 WLOGFE("Write window visible failed");
832 return WSError::WS_ERROR_IPC_FAILED;
833 }
834 uint32_t messageCode = static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_VISIBILITY_CHANGE);
835
836 sptr<IRemoteObject> remote = Remote();
837 if (remote == nullptr) {
838 WLOGFE("remote is null");
839 return WSError::WS_ERROR_IPC_FAILED;
840 }
841 if (remote->SendRequest(messageCode, data, reply, option) != ERR_NONE) {
842 WLOGFE("SendRequest failed");
843 return WSError::WS_ERROR_IPC_FAILED;
844 }
845 int32_t ret = reply.ReadInt32();
846 return static_cast<WSError>(ret);
847 }
848
UpdateWindowMode(WindowMode mode)849 WSError SessionStageProxy::UpdateWindowMode(WindowMode mode)
850 {
851 MessageParcel data;
852 MessageParcel reply;
853 MessageOption option(MessageOption::TF_ASYNC);
854 if (!data.WriteInterfaceToken(GetDescriptor())) {
855 WLOGFE("WriteInterfaceToken failed");
856 return WSError::WS_ERROR_IPC_FAILED;
857 }
858
859 if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
860 WLOGFE("Write mode failed");
861 return WSError::WS_ERROR_IPC_FAILED;
862 }
863
864 sptr<IRemoteObject> remote = Remote();
865 if (remote == nullptr) {
866 WLOGFE("remote is null");
867 return WSError::WS_ERROR_IPC_FAILED;
868 }
869 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_MODE_CHANGE),
870 data, reply, option) != ERR_NONE) {
871 WLOGFE("SendRequest failed");
872 return WSError::WS_ERROR_IPC_FAILED;
873 }
874 int32_t ret = reply.ReadInt32();
875 return static_cast<WSError>(ret);
876 }
877
GetTopNavDestinationName(std::string & topNavDestName)878 WSError SessionStageProxy::GetTopNavDestinationName(std::string& topNavDestName)
879 {
880 MessageParcel data;
881 MessageParcel reply;
882 MessageOption option;
883 if (!data.WriteInterfaceToken(GetDescriptor())) {
884 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write stage interfaceToken failed");
885 return WSError::WS_ERROR_IPC_FAILED;
886 }
887 sptr<IRemoteObject> remote = Remote();
888 if (remote == nullptr) {
889 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "stage remote is null");
890 return WSError::WS_ERROR_IPC_FAILED;
891 }
892 auto reqErrCode = remote->SendRequest(
893 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_TOP_NAV_DEST_NAME), data, reply, option);
894 if (reqErrCode != ERR_NONE) {
895 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "send stage request failed, errCode: %{public}d", reqErrCode);
896 return WSError::WS_ERROR_IPC_FAILED;
897 }
898 const char* namePtr = nullptr;
899 auto size = reply.ReadUint32();
900 if (size != 0) {
901 namePtr = reinterpret_cast<const char*>(reply.ReadRawData(size));
902 }
903 topNavDestName = (namePtr != nullptr) ? std::string(namePtr, size) : "";
904 int32_t errCode = 0;
905 if (!reply.ReadInt32(errCode)) {
906 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read stage errcode failed");
907 return WSError::WS_ERROR_IPC_FAILED;
908 }
909 return static_cast<WSError>(errCode);
910 }
911
NotifyLayoutFinishAfterWindowModeChange(WindowMode mode)912 WSError SessionStageProxy::NotifyLayoutFinishAfterWindowModeChange(WindowMode mode)
913 {
914 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
915 MessageParcel data;
916 MessageParcel reply;
917 MessageOption option(MessageOption::TF_ASYNC);
918 if (!data.WriteInterfaceToken(GetDescriptor())) {
919 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
920 return WSError::WS_ERROR_IPC_FAILED;
921 }
922
923 if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
924 TLOGE(WmsLogTag::WMS_LAYOUT, "Write mode failed");
925 return WSError::WS_ERROR_IPC_FAILED;
926 }
927
928 sptr<IRemoteObject> remote = Remote();
929 if (remote == nullptr) {
930 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
931 return WSError::WS_ERROR_IPC_FAILED;
932 }
933 uint32_t messageCode =
934 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_LAYOUT_FINISH_AFTER_WINDOW_MODE_CHANGE);
935 if (remote->SendRequest(messageCode, data, reply, option) != ERR_NONE) {
936 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
937 return WSError::WS_ERROR_IPC_FAILED;
938 }
939 return WSError::WS_OK;
940 }
941
UpdateWindowModeForUITest(int32_t updateMode)942 WMError SessionStageProxy::UpdateWindowModeForUITest(int32_t updateMode)
943 {
944 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
945 MessageParcel data;
946 MessageParcel reply;
947 MessageOption option(MessageOption::TF_ASYNC);
948 if (!data.WriteInterfaceToken(GetDescriptor())) {
949 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
950 return WMError::WM_ERROR_IPC_FAILED;
951 }
952
953 if (!data.WriteInt32(updateMode)) {
954 TLOGE(WmsLogTag::WMS_LAYOUT, "Write updateMode failed");
955 return WMError::WM_ERROR_IPC_FAILED;
956 }
957
958 sptr<IRemoteObject> remote = Remote();
959 if (remote == nullptr) {
960 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
961 return WMError::WM_ERROR_IPC_FAILED;
962 }
963 uint32_t requestCode =
964 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_WINDOW_MODE_FOR_UI_TEST);
965 if (remote->SendRequest(requestCode, data, reply, option) != ERR_NONE) {
966 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
967 return WMError::WM_ERROR_IPC_FAILED;
968 }
969 return WMError::WM_OK;
970 }
971
NotifyForegroundInteractiveStatus(bool interactive)972 void SessionStageProxy::NotifyForegroundInteractiveStatus(bool interactive)
973 {
974 MessageParcel data;
975 MessageParcel reply;
976 MessageOption option(MessageOption::TF_ASYNC);
977 if (!data.WriteInterfaceToken(GetDescriptor())) {
978 WLOGFE("WriteInterfaceToken failed");
979 return;
980 }
981
982 if (!data.WriteBool(interactive)) {
983 WLOGFE("Write interactive failed");
984 return;
985 }
986
987 sptr<IRemoteObject> remote = Remote();
988 if (remote == nullptr) {
989 WLOGFE("remote is null");
990 return;
991 }
992 if (remote->SendRequest(
993 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS),
994 data, reply, option) != ERR_NONE) {
995 WLOGFE("SendRequest failed");
996 }
997 }
998
NotifyAppUseControlStatus(bool isUseControl)999 void SessionStageProxy::NotifyAppUseControlStatus(bool isUseControl)
1000 {
1001 MessageParcel data;
1002 MessageParcel reply;
1003 MessageOption option(MessageOption::TF_ASYNC);
1004 if (!data.WriteInterfaceToken(GetDescriptor())) {
1005 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
1006 return;
1007 }
1008
1009 if (!data.WriteBool(isUseControl)) {
1010 TLOGE(WmsLogTag::WMS_LIFE, "Write isUseControl failed");
1011 return;
1012 }
1013
1014 sptr<IRemoteObject> remote = Remote();
1015 if (remote == nullptr) {
1016 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
1017 return;
1018 }
1019 int sendResult = remote->SendRequest(
1020 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_USE_CONTROL_STATUS),
1021 data, reply, option);
1022 if (sendResult != ERR_NONE) {
1023 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed, code: %{public}d", sendResult);
1024 }
1025 }
1026
NotifyLifecyclePausedStatus()1027 void SessionStageProxy::NotifyLifecyclePausedStatus()
1028 {
1029 MessageParcel data;
1030 MessageParcel reply;
1031 MessageOption option(MessageOption::TF_ASYNC);
1032 if (!data.WriteInterfaceToken(GetDescriptor())) {
1033 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
1034 return;
1035 }
1036
1037 sptr<IRemoteObject> remote = Remote();
1038 if (remote == nullptr) {
1039 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
1040 return;
1041 }
1042 int sendResult = remote->SendRequest(
1043 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PAUSED_STATUS),
1044 data, reply, option);
1045 if (sendResult != ERR_NONE) {
1046 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed, code: %{public}d", sendResult);
1047 }
1048 }
1049
UpdateMaximizeMode(MaximizeMode mode)1050 WSError SessionStageProxy::UpdateMaximizeMode(MaximizeMode mode)
1051 {
1052 MessageParcel data;
1053 MessageParcel reply;
1054 MessageOption option(MessageOption::TF_ASYNC);
1055 if (!data.WriteInterfaceToken(GetDescriptor())) {
1056 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
1057 return WSError::WS_ERROR_IPC_FAILED;
1058 }
1059
1060 if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
1061 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write mode failed");
1062 return WSError::WS_ERROR_IPC_FAILED;
1063 }
1064
1065 sptr<IRemoteObject> remote = Remote();
1066 if (remote == nullptr) {
1067 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
1068 return WSError::WS_ERROR_IPC_FAILED;
1069 }
1070 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_MAXIMIZE_MODE_CHANGE),
1071 data, reply, option) != ERR_NONE) {
1072 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
1073 return WSError::WS_ERROR_IPC_FAILED;
1074 }
1075 int32_t ret = reply.ReadInt32();
1076 return static_cast<WSError>(ret);
1077 }
1078
NotifySessionForeground(uint32_t reason,bool withAnimation)1079 void SessionStageProxy::NotifySessionForeground(uint32_t reason, bool withAnimation)
1080 {
1081 MessageParcel data;
1082 MessageParcel reply;
1083 MessageOption option(MessageOption::TF_ASYNC);
1084 if (!data.WriteInterfaceToken(GetDescriptor())) {
1085 WLOGFE("WriteInterfaceToken failed");
1086 return;
1087 }
1088
1089 if (!data.WriteUint32(reason)) {
1090 WLOGFE("Write reason failed");
1091 return;
1092 }
1093 if (!data.WriteBool(withAnimation)) {
1094 WLOGFE("Write withAnimation failed");
1095 return;
1096 }
1097 sptr<IRemoteObject> remote = Remote();
1098 if (remote == nullptr) {
1099 WLOGFE("remote is null");
1100 return;
1101 }
1102 if (remote->SendRequest(
1103 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FOREGROUND),
1104 data, reply, option) != ERR_NONE) {
1105 WLOGFE("Send NotifySessionForeground Request failed");
1106 }
1107 }
1108
NotifySessionFullScreen(bool fullScreen)1109 void SessionStageProxy::NotifySessionFullScreen(bool fullScreen)
1110 {
1111 sptr<IRemoteObject> remote = Remote();
1112 if (remote == nullptr) {
1113 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
1114 return;
1115 }
1116 MessageParcel data;
1117 MessageParcel reply;
1118 MessageOption option(MessageOption::TF_ASYNC);
1119 if (!data.WriteInterfaceToken(GetDescriptor())) {
1120 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
1121 return;
1122 }
1123 if (!data.WriteBool(fullScreen)) {
1124 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write fullScreen failed");
1125 return;
1126 }
1127 if (remote->SendRequest(
1128 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN),
1129 data, reply, option) != ERR_NONE) {
1130 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Send Request failed");
1131 }
1132 }
1133
NotifySessionBackground(uint32_t reason,bool withAnimation,bool isFromInnerkits)1134 void SessionStageProxy::NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits)
1135 {
1136 MessageParcel data;
1137 MessageParcel reply;
1138 MessageOption option(MessageOption::TF_ASYNC);
1139 if (!data.WriteInterfaceToken(GetDescriptor())) {
1140 WLOGFE("WriteInterfaceToken failed");
1141 return;
1142 }
1143
1144 if (!data.WriteUint32(reason)) {
1145 WLOGFE("Write reason failed");
1146 return;
1147 }
1148 if (!data.WriteBool(withAnimation)) {
1149 WLOGFE("Write withAnimation failed");
1150 return;
1151 }
1152 if (!data.WriteBool(isFromInnerkits)) {
1153 WLOGFE("Write isFromInnerkits failed");
1154 return;
1155 }
1156 sptr<IRemoteObject> remote = Remote();
1157 if (remote == nullptr) {
1158 WLOGFE("remote is null");
1159 return;
1160 }
1161 if (remote->SendRequest(
1162 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_BACKGROUND),
1163 data, reply, option) != ERR_NONE) {
1164 WLOGFE("Send NotifySessionBackground Request failed");
1165 return;
1166 }
1167 }
1168
UpdateTitleInTargetPos(bool isShow,int32_t height)1169 WSError SessionStageProxy::UpdateTitleInTargetPos(bool isShow, int32_t height)
1170 {
1171 MessageParcel data;
1172 MessageParcel reply;
1173 MessageOption option(MessageOption::TF_ASYNC);
1174 if (!data.WriteInterfaceToken(GetDescriptor())) {
1175 TLOGE(WmsLogTag::WMS_DECOR, "WriteInterfaceToken failed");
1176 return WSError::WS_ERROR_IPC_FAILED;
1177 }
1178
1179 if (!data.WriteBool(isShow)) {
1180 TLOGE(WmsLogTag::WMS_DECOR, "Write isShow failed");
1181 return WSError::WS_ERROR_IPC_FAILED;
1182 }
1183
1184 if (!data.WriteUint32(height)) {
1185 TLOGE(WmsLogTag::WMS_DECOR, "Write height failed");
1186 return WSError::WS_ERROR_IPC_FAILED;
1187 }
1188
1189 sptr<IRemoteObject> remote = Remote();
1190 if (remote == nullptr) {
1191 TLOGE(WmsLogTag::WMS_DECOR, "remote is null");
1192 return WSError::WS_ERROR_IPC_FAILED;
1193 }
1194 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TITLE_POSITION_CHANGE),
1195 data, reply, option) != ERR_NONE) {
1196 TLOGE(WmsLogTag::WMS_DECOR, "SendRequest failed");
1197 return WSError::WS_ERROR_IPC_FAILED;
1198 }
1199 int32_t ret = reply.ReadInt32();
1200 return static_cast<WSError>(ret);
1201 }
1202
NotifyTransformChange(const Transform & transform)1203 void SessionStageProxy::NotifyTransformChange(const Transform& transform)
1204 {
1205 MessageParcel data;
1206 MessageParcel reply;
1207 MessageOption option(MessageOption::TF_ASYNC);
1208 if (!data.WriteInterfaceToken(GetDescriptor())) {
1209 WLOGFE("WriteInterfaceToken failed");
1210 return;
1211 }
1212
1213 if (!transform.Marshalling(data)) {
1214 WLOGFE("Transform marshalling failed");
1215 return;
1216 }
1217
1218 sptr<IRemoteObject> remote = Remote();
1219 if (remote == nullptr) {
1220 WLOGFE("remote is null");
1221 return;
1222 }
1223 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFORM_CHANGE),
1224 data, reply, option) != ERR_NONE) {
1225 WLOGFE("Send NotifyTransformChange Requset failed");
1226 }
1227 }
1228
NotifySingleHandTransformChange(const SingleHandTransform & singleHandTransform)1229 void SessionStageProxy::NotifySingleHandTransformChange(const SingleHandTransform& singleHandTransform)
1230 {
1231 MessageParcel data;
1232 MessageParcel reply;
1233 MessageOption option(MessageOption::TF_ASYNC);
1234 if (!data.WriteInterfaceToken(GetDescriptor())) {
1235 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1236 return;
1237 }
1238
1239 if (!singleHandTransform.Marshalling(data)) {
1240 TLOGE(WmsLogTag::WMS_LAYOUT, "singleHandTransform marshalling failed");
1241 return;
1242 }
1243
1244 sptr<IRemoteObject> remote = Remote();
1245 if (remote == nullptr) {
1246 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1247 return;
1248 }
1249 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SINGLE_HAND_TRANSFORM),
1250 data, reply, option) != ERR_NONE) {
1251 TLOGE(WmsLogTag::WMS_LAYOUT, "Send Requset failed");
1252 }
1253 }
1254
NotifyDensityFollowHost(bool isFollowHost,float densityValue)1255 WSError SessionStageProxy::NotifyDensityFollowHost(bool isFollowHost, float densityValue)
1256 {
1257 MessageParcel data;
1258 MessageParcel reply;
1259 MessageOption option(MessageOption::TF_ASYNC);
1260 if (!data.WriteInterfaceToken(GetDescriptor())) {
1261 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1262 return WSError::WS_ERROR_IPC_FAILED;
1263 }
1264
1265 if (!data.WriteBool(isFollowHost)) {
1266 TLOGE(WmsLogTag::WMS_UIEXT, "Write isFollowHost failed");
1267 return WSError::WS_ERROR_IPC_FAILED;
1268 }
1269
1270 if (!data.WriteFloat(densityValue)) {
1271 TLOGE(WmsLogTag::WMS_UIEXT, "Write densityValue failed");
1272 return WSError::WS_ERROR_IPC_FAILED;
1273 }
1274
1275 sptr<IRemoteObject> remote = Remote();
1276 if (remote == nullptr) {
1277 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1278 return WSError::WS_ERROR_IPC_FAILED;
1279 }
1280 int sendCode = remote->SendRequest(
1281 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST), data, reply, option);
1282 if (sendCode != ERR_NONE) {
1283 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1284 return WSError::WS_ERROR_IPC_FAILED;
1285 }
1286
1287 return WSError::WS_OK;
1288 }
1289
NotifyDialogStateChange(bool isForeground)1290 WSError SessionStageProxy::NotifyDialogStateChange(bool isForeground)
1291 {
1292 MessageParcel data;
1293 MessageParcel reply;
1294 MessageOption option(MessageOption::TF_ASYNC);
1295 if (!data.WriteInterfaceToken(GetDescriptor())) {
1296 WLOGFE("WriteInterfaceToken failed");
1297 return WSError::WS_ERROR_IPC_FAILED;
1298 }
1299
1300 if (!data.WriteBool(isForeground)) {
1301 WLOGFE("Write isForeground failed");
1302 return WSError::WS_ERROR_IPC_FAILED;
1303 }
1304
1305 sptr<IRemoteObject> remote = Remote();
1306 if (remote == nullptr) {
1307 WLOGFE("remote is null");
1308 return WSError::WS_ERROR_IPC_FAILED;
1309 }
1310 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE),
1311 data, reply, option) != ERR_NONE) {
1312 WLOGFE("SendRequest failed");
1313 return WSError::WS_ERROR_IPC_FAILED;
1314 }
1315 return WSError::WS_OK;
1316 }
1317
SetPipActionEvent(const std::string & action,int32_t status)1318 WSError SessionStageProxy::SetPipActionEvent(const std::string& action, int32_t status)
1319 {
1320 MessageParcel data;
1321 MessageParcel reply;
1322 MessageOption option(MessageOption::TF_ASYNC);
1323 if (!data.WriteInterfaceToken(GetDescriptor())) {
1324 WLOGFE("WriteInterfaceToken failed");
1325 return WSError::WS_ERROR_IPC_FAILED;
1326 }
1327
1328 if (!data.WriteString(action)) {
1329 WLOGFE("Write params failed");
1330 return WSError::WS_ERROR_IPC_FAILED;
1331 }
1332
1333 if (!data.WriteInt32(status)) {
1334 WLOGFE("Write status failed");
1335 return WSError::WS_ERROR_IPC_FAILED;
1336 }
1337
1338 sptr<IRemoteObject> remote = Remote();
1339 if (remote == nullptr) {
1340 WLOGFE("remote is null");
1341 return WSError::WS_ERROR_IPC_FAILED;
1342 }
1343 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_ACTION_EVENT),
1344 data, reply, option) != ERR_NONE) {
1345 WLOGFE("SendRequest failed");
1346 return WSError::WS_ERROR_IPC_FAILED;
1347 }
1348 return WSError::WS_OK;
1349 }
1350
SendFbActionEvent(const std::string & action)1351 WSError SessionStageProxy::SendFbActionEvent(const std::string& action)
1352 {
1353 MessageParcel data;
1354 MessageParcel reply;
1355 MessageOption option(MessageOption::TF_ASYNC);
1356 if (!data.WriteInterfaceToken(GetDescriptor())) {
1357 TLOGE(WmsLogTag::WMS_SYSTEM, "WriteInterfaceToken failed");
1358 return WSError::WS_ERROR_IPC_FAILED;
1359 }
1360
1361 if (!data.WriteString(action)) {
1362 TLOGE(WmsLogTag::WMS_SYSTEM, "Write params failed");
1363 return WSError::WS_ERROR_IPC_FAILED;
1364 }
1365
1366 sptr<IRemoteObject> remote = Remote();
1367 if (remote == nullptr) {
1368 TLOGE(WmsLogTag::WMS_SYSTEM, "remote is null");
1369 return WSError::WS_ERROR_IPC_FAILED;
1370 }
1371 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_FB_ACTION_EVENT),
1372 data, reply, option) != ERR_NONE) {
1373 TLOGE(WmsLogTag::WMS_SYSTEM, "SendRequest failed");
1374 return WSError::WS_ERROR_IPC_FAILED;
1375 }
1376 return WSError::WS_OK;
1377 }
1378
NotifyPipWindowSizeChange(double width,double height,double scale)1379 WSError SessionStageProxy::NotifyPipWindowSizeChange(double width, double height, double scale)
1380 {
1381 MessageParcel data;
1382 MessageParcel reply;
1383 MessageOption option(MessageOption::TF_ASYNC);
1384 if (!data.WriteInterfaceToken(GetDescriptor())) {
1385 WLOGFE("WriteInterfaceToken failed");
1386 return WSError::WS_ERROR_IPC_FAILED;
1387 }
1388
1389 if (!data.WriteDouble(width)) {
1390 WLOGFE("Write width failed");
1391 return WSError::WS_ERROR_IPC_FAILED;
1392 }
1393
1394 if (!data.WriteDouble(height)) {
1395 WLOGFE("Write height failed");
1396 return WSError::WS_ERROR_IPC_FAILED;
1397 }
1398
1399 if (!data.WriteDouble(scale)) {
1400 WLOGFE("Write scale failed");
1401 return WSError::WS_ERROR_IPC_FAILED;
1402 }
1403
1404 sptr<IRemoteObject> remote = Remote();
1405 if (remote == nullptr) {
1406 WLOGFE("remote is null");
1407 return WSError::WS_ERROR_IPC_FAILED;
1408 }
1409
1410 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE),
1411 data, reply, option) != ERR_NONE) {
1412 WLOGFE("SendRequest failed");
1413 return WSError::WS_ERROR_IPC_FAILED;
1414 }
1415 return WSError::WS_OK;
1416 }
1417
SetPiPControlEvent(WsPiPControlType controlType,WsPiPControlStatus status)1418 WSError SessionStageProxy::SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status)
1419 {
1420 TLOGI(WmsLogTag::WMS_PIP, "controlType:%{public}u, enabled:%{public}d", controlType, status);
1421 MessageParcel data;
1422 MessageParcel reply;
1423 MessageOption option(MessageOption::TF_ASYNC);
1424 if (!data.WriteInterfaceToken(GetDescriptor())) {
1425 TLOGE(WmsLogTag::WMS_PIP, "WriteInterfaceToken failed");
1426 return WSError::WS_ERROR_IPC_FAILED;
1427 }
1428
1429 if (!data.WriteUint32(static_cast<uint32_t>(controlType))) {
1430 TLOGE(WmsLogTag::WMS_PIP, "Write params failed");
1431 return WSError::WS_ERROR_IPC_FAILED;
1432 }
1433
1434 if (!data.WriteInt32(static_cast<int32_t>(status))) {
1435 TLOGE(WmsLogTag::WMS_PIP, "Write status failed");
1436 return WSError::WS_ERROR_IPC_FAILED;
1437 }
1438
1439 sptr<IRemoteObject> remote = Remote();
1440 if (remote == nullptr) {
1441 TLOGE(WmsLogTag::WMS_PIP, "remote is null");
1442 return WSError::WS_ERROR_IPC_FAILED;
1443 }
1444 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_CONTROL_EVENT),
1445 data, reply, option) != ERR_NONE) {
1446 TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
1447 return WSError::WS_ERROR_IPC_FAILED;
1448 }
1449 return WSError::WS_OK;
1450 }
1451
NotifyDisplayMove(DisplayId from,DisplayId to)1452 void SessionStageProxy::NotifyDisplayMove(DisplayId from, DisplayId to)
1453 {
1454 MessageParcel data;
1455 MessageParcel reply;
1456 MessageOption option(MessageOption::TF_ASYNC);
1457 if (!data.WriteInterfaceToken(GetDescriptor())) {
1458 WLOGFE("WriteInterfaceToken failed");
1459 return;
1460 }
1461
1462 if (!data.WriteUint64(from)) {
1463 WLOGFE("Write from id failed");
1464 return;
1465 }
1466
1467 if (!data.WriteUint64(to)) {
1468 WLOGFE("Write to id failed");
1469 return;
1470 }
1471
1472 sptr<IRemoteObject> remote = Remote();
1473 if (remote == nullptr) {
1474 WLOGFE("remote is null");
1475 return;
1476 }
1477 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE),
1478 data, reply, option) != ERR_NONE) {
1479 WLOGFE("SendRequest notify display move failed");
1480 return;
1481 }
1482 }
1483
NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo & keyboardPanelInfo)1484 void SessionStageProxy::NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo)
1485 {
1486 MessageParcel data;
1487 MessageParcel reply;
1488 MessageOption option(MessageOption::TF_ASYNC);
1489 if (!data.WriteInterfaceToken(GetDescriptor())) {
1490 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
1491 return;
1492 }
1493
1494 if (!data.WriteParcelable(&keyboardPanelInfo)) {
1495 TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardPanelInfo marshalling failed");
1496 return;
1497 }
1498
1499 sptr<IRemoteObject> remote = Remote();
1500 if (remote == nullptr) {
1501 TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
1502 return;
1503 }
1504 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE),
1505 data, reply, option) != ERR_NONE) {
1506 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest notify keyboard panel info change failed");
1507 return;
1508 }
1509 }
1510
PcAppInPadNormalClose()1511 WSError SessionStageProxy::PcAppInPadNormalClose()
1512 {
1513 sptr<IRemoteObject> remote = Remote();
1514 if (remote == nullptr) {
1515 TLOGE(WmsLogTag::WMS_COMPAT, "remote is null");
1516 return WSError::WS_ERROR_IPC_FAILED;
1517 }
1518 MessageParcel data;
1519 MessageParcel reply;
1520 MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER);
1521 if (!data.WriteInterfaceToken(GetDescriptor())) {
1522 TLOGE(WmsLogTag::WMS_COMPAT, "WriteInterfaceToken failed");
1523 return WSError::WS_ERROR_IPC_FAILED;
1524 }
1525
1526 if (remote->SendRequest(
1527 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_PCAPPINPADNORMAL_CLOSE),
1528 data, reply, option) != ERR_NONE) {
1529 TLOGE(WmsLogTag::WMS_COMPAT, "SendRequest failed");
1530 return WSError::WS_ERROR_IPC_FAILED;
1531 }
1532 return WSError::WS_OK;
1533 }
1534
NotifyCompatibleModePropertyChange(const sptr<CompatibleModeProperty> property)1535 WSError SessionStageProxy::NotifyCompatibleModePropertyChange(const sptr<CompatibleModeProperty> property)
1536 {
1537 sptr<IRemoteObject> remote = Remote();
1538 if (remote == nullptr) {
1539 TLOGE(WmsLogTag::WMS_SCB, "remote is null");
1540 return WSError::WS_ERROR_IPC_FAILED;
1541 }
1542 MessageParcel data;
1543 MessageParcel reply;
1544 MessageOption option(MessageOption::TF_ASYNC);
1545 if (!data.WriteInterfaceToken(GetDescriptor())) {
1546 TLOGE(WmsLogTag::WMS_SCB, "WriteInterfaceToken failed");
1547 return WSError::WS_ERROR_IPC_FAILED;
1548 }
1549 if (!data.WriteParcelable(property.GetRefPtr())) {
1550 TLOGE(WmsLogTag::DEFAULT, "Write enable failed");
1551 return WSError::WS_ERROR_IPC_FAILED;
1552 }
1553 if (remote->SendRequest(
1554 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_COMPATIBLE_MODE_PROPERTY_CHANGE),
1555 data, reply, option) != ERR_NONE) {
1556 TLOGE(WmsLogTag::WMS_SCB, "SendRequest failed");
1557 return WSError::WS_ERROR_IPC_FAILED;
1558 }
1559 return WSError::WS_OK;
1560 }
1561
SetUniqueVirtualPixelRatio(bool useUniqueDensity,float virtualPixelRatio)1562 void SessionStageProxy::SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio)
1563 {
1564 sptr<IRemoteObject> remote = Remote();
1565 if (remote == nullptr) {
1566 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is nullptr");
1567 return;
1568 }
1569
1570 MessageParcel data;
1571 MessageParcel reply;
1572 MessageOption option(MessageOption::TF_ASYNC);
1573 if (!data.WriteInterfaceToken(GetDescriptor())) {
1574 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
1575 return;
1576 }
1577 if (!data.WriteBool(useUniqueDensity)) {
1578 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write useUniqueDensity failed");
1579 return;
1580 }
1581 if (!data.WriteFloat(virtualPixelRatio)) {
1582 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write virtualPixelRatio failed");
1583 return;
1584 }
1585
1586 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_UNIQUE),
1587 data, reply, option) != ERR_NONE) {
1588 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
1589 return;
1590 }
1591 }
1592
NotifyDumpInfo(const std::vector<std::string> & params,std::vector<std::string> & info)1593 WSError SessionStageProxy::NotifyDumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
1594 {
1595 sptr<IRemoteObject> remote = Remote();
1596 if (remote == nullptr) {
1597 TLOGE(WmsLogTag::WMS_UIEXT, "remote is nullptr");
1598 return WSError::WS_ERROR_NULLPTR;
1599 }
1600 MessageParcel data;
1601 MessageParcel reply;
1602 MessageOption option(MessageOption::TF_SYNC);
1603 if (!data.WriteInterfaceToken(GetDescriptor())) {
1604 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1605 return WSError::WS_ERROR_IPC_FAILED;
1606 }
1607 if (!data.WriteStringVector(params)) {
1608 TLOGE(WmsLogTag::WMS_UIEXT, "Write params failed");
1609 return WSError::WS_ERROR_IPC_FAILED;
1610 }
1611 int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DUMP_INFO),
1612 data, reply, option);
1613 if (sendCode != ERR_NONE) {
1614 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1615 return WSError::WS_ERROR_IPC_FAILED;
1616 }
1617
1618 bool isLittleSize = false;
1619 if (!reply.ReadBool(isLittleSize)) {
1620 TLOGE(WmsLogTag::WMS_UIEXT, "ReadBool failed");
1621 return WSError::WS_ERROR_IPC_FAILED;
1622 }
1623
1624 bool readResult = isLittleSize ? ReadLittleStringVectorFromParcel(reply, info) :
1625 ReadLargeStringVectorFromParcel(reply, info);
1626 if (!readResult) {
1627 TLOGE(WmsLogTag::WMS_UIEXT, "Read data failed");
1628 return WSError::WS_ERROR_IPC_FAILED;
1629 }
1630
1631 int32_t ret = 0;
1632 if (!reply.ReadInt32(ret)) {
1633 TLOGE(WmsLogTag::WMS_UIEXT, "Read int32 failed");
1634 return WSError::WS_ERROR_IPC_FAILED;
1635 }
1636 return static_cast<WSError>(ret);
1637 }
1638
SendExtensionData(MessageParcel & data,MessageParcel & reply,MessageOption & option)1639 WSError SessionStageProxy::SendExtensionData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
1640 {
1641 sptr<IRemoteObject> remote = Remote();
1642 if (remote == nullptr) {
1643 TLOGE(WmsLogTag::WMS_UIEXT, "remote is nullptr");
1644 return WSError::WS_ERROR_NULLPTR;
1645 }
1646
1647 auto ret = remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_EXTENSION_DATA), data,
1648 reply, option);
1649 if (ret != ERR_NONE) {
1650 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, ret: %{public}d", ret);
1651 return WSError::WS_ERROR_IPC_FAILED;
1652 }
1653 return WSError::WS_OK;
1654 }
1655
LinkKeyFrameCanvasNode(std::shared_ptr<RSCanvasNode> & rsCanvasNode)1656 WSError SessionStageProxy::LinkKeyFrameCanvasNode(std::shared_ptr<RSCanvasNode>& rsCanvasNode)
1657 {
1658 MessageParcel data;
1659 MessageParcel reply;
1660 MessageOption option(MessageOption::TF_ASYNC);
1661 if (!data.WriteInterfaceToken(GetDescriptor())) {
1662 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1663 return WSError::WS_ERROR_IPC_FAILED;
1664 }
1665 if (!rsCanvasNode || !rsCanvasNode->Marshalling(data)) {
1666 TLOGE(WmsLogTag::WMS_LAYOUT, "Write rsCanvasNode failed");
1667 return WSError::WS_ERROR_IPC_FAILED;
1668 }
1669 sptr<IRemoteObject> remote = Remote();
1670 if (remote == nullptr) {
1671 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1672 return WSError::WS_ERROR_IPC_FAILED;
1673 }
1674 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_LINK_KEYFRAME_CANVAS_NODE),
1675 data, reply, option) != ERR_NONE) {
1676 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1677 return WSError::WS_ERROR_IPC_FAILED;
1678 }
1679 return WSError::WS_OK;
1680 }
1681
SetKeyFramePolicy(KeyFramePolicy & keyFramePolicy)1682 WSError SessionStageProxy::SetKeyFramePolicy(KeyFramePolicy& keyFramePolicy)
1683 {
1684 MessageParcel data;
1685 MessageParcel reply;
1686 MessageOption option(MessageOption::TF_ASYNC);
1687 if (!data.WriteInterfaceToken(GetDescriptor())) {
1688 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1689 return WSError::WS_ERROR_IPC_FAILED;
1690 }
1691 if (!data.WriteParcelable(&keyFramePolicy)) {
1692 TLOGE(WmsLogTag::WMS_LAYOUT, "Write keyFramePolicy failed");
1693 return WSError::WS_ERROR_IPC_FAILED;
1694 }
1695 sptr<IRemoteObject> remote = Remote();
1696 if (remote == nullptr) {
1697 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1698 return WSError::WS_ERROR_IPC_FAILED;
1699 }
1700 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_KEYFRAME_POLICY),
1701 data, reply, option) != ERR_NONE) {
1702 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1703 return WSError::WS_ERROR_IPC_FAILED;
1704 }
1705 return WSError::WS_OK;
1706 }
1707
SetDragActivated(bool dragActivated)1708 WSError SessionStageProxy::SetDragActivated(bool dragActivated)
1709 {
1710 MessageParcel data;
1711 MessageParcel reply;
1712 MessageOption option(MessageOption::TF_ASYNC);
1713 if (!data.WriteInterfaceToken(GetDescriptor())) {
1714 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1715 return WSError::WS_ERROR_IPC_FAILED;
1716 }
1717 if (!data.WriteBool(dragActivated)) {
1718 TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1719 return WSError::WS_ERROR_IPC_FAILED;
1720 }
1721 sptr<IRemoteObject> remote = Remote();
1722 if (remote == nullptr) {
1723 TLOGE(WmsLogTag::WMS_LAYOUT, "Remote is null");
1724 return WSError::WS_ERROR_IPC_FAILED;
1725 }
1726 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_DRAG_ACTIVATED),
1727 data, reply, option) != ERR_NONE) {
1728 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1729 return WSError::WS_ERROR_IPC_FAILED;
1730 }
1731 return WSError::WS_OK;
1732 }
1733
SetSplitButtonVisible(bool isVisible)1734 WSError SessionStageProxy::SetSplitButtonVisible(bool isVisible)
1735 {
1736 MessageParcel data;
1737 MessageParcel reply;
1738 MessageOption option(MessageOption::TF_ASYNC);
1739 if (!data.WriteInterfaceToken(GetDescriptor())) {
1740 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1741 return WSError::WS_ERROR_IPC_FAILED;
1742 }
1743 if (!data.WriteBool(isVisible)) {
1744 TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1745 return WSError::WS_ERROR_IPC_FAILED;
1746 }
1747 sptr<IRemoteObject> remote = Remote();
1748 if (remote == nullptr) {
1749 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1750 return WSError::WS_ERROR_IPC_FAILED;
1751 }
1752 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_SPLIT_BUTTON_VISIBLE),
1753 data, reply, option) != ERR_NONE) {
1754 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1755 return WSError::WS_ERROR_IPC_FAILED;
1756 }
1757 return WSError::WS_OK;
1758 }
1759
SetEnableDragBySystem(bool dragEnable)1760 WSError SessionStageProxy::SetEnableDragBySystem(bool dragEnable)
1761 {
1762 MessageParcel data;
1763 MessageParcel reply;
1764 MessageOption option(MessageOption::TF_ASYNC);
1765 if (!data.WriteInterfaceToken(GetDescriptor())) {
1766 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1767 return WSError::WS_ERROR_IPC_FAILED;
1768 }
1769 if (!data.WriteBool(dragEnable)) {
1770 TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1771 return WSError::WS_ERROR_IPC_FAILED;
1772 }
1773 sptr<IRemoteObject> remote = Remote();
1774 if (remote == nullptr) {
1775 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1776 return WSError::WS_ERROR_IPC_FAILED;
1777 }
1778 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM),
1779 data, reply, option) != ERR_NONE) {
1780 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1781 return WSError::WS_ERROR_IPC_FAILED;
1782 }
1783 return WSError::WS_OK;
1784 }
1785
SetFullScreenWaterfallMode(bool isWaterfallMode)1786 WSError SessionStageProxy::SetFullScreenWaterfallMode(bool isWaterfallMode)
1787 {
1788 MessageParcel data;
1789 MessageParcel reply;
1790 MessageOption option(MessageOption::TF_ASYNC);
1791 if (!data.WriteInterfaceToken(GetDescriptor())) {
1792 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1793 return WSError::WS_ERROR_IPC_FAILED;
1794 }
1795 if (!data.WriteBool(isWaterfallMode)) {
1796 TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed");
1797 return WSError::WS_ERROR_IPC_FAILED;
1798 }
1799 sptr<IRemoteObject> remote = Remote();
1800 if (remote == nullptr) {
1801 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1802 return WSError::WS_ERROR_IPC_FAILED;
1803 }
1804 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_FULLSCREEN_WATERFALL_MODE),
1805 data, reply, option) != ERR_NONE) {
1806 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1807 return WSError::WS_ERROR_IPC_FAILED;
1808 }
1809 return WSError::WS_OK;
1810 }
1811
SetSupportEnterWaterfallMode(bool isSupportEnter)1812 WSError SessionStageProxy::SetSupportEnterWaterfallMode(bool isSupportEnter)
1813 {
1814 MessageParcel data;
1815 MessageParcel reply;
1816 MessageOption option(MessageOption::TF_ASYNC);
1817 if (!data.WriteInterfaceToken(GetDescriptor())) {
1818 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
1819 return WSError::WS_ERROR_IPC_FAILED;
1820 }
1821 if (!data.WriteBool(isSupportEnter)) {
1822 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write params failed");
1823 return WSError::WS_ERROR_IPC_FAILED;
1824 }
1825 sptr<IRemoteObject> remote = Remote();
1826 if (remote == nullptr) {
1827 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
1828 return WSError::WS_ERROR_IPC_FAILED;
1829 }
1830 if (remote->SendRequest(static_cast<uint32_t>(
1831 SessionStageInterfaceCode::TRANS_ID_SET_SUPPORT_ENTER_WATERFALL_MODE),
1832 data, reply, option) != ERR_NONE) {
1833 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
1834 return WSError::WS_ERROR_IPC_FAILED;
1835 }
1836 return WSError::WS_OK;
1837 }
1838
SendContainerModalEvent(const std::string & eventName,const std::string & eventValue)1839 WSError SessionStageProxy::SendContainerModalEvent(const std::string& eventName, const std::string& eventValue)
1840 {
1841 MessageParcel data;
1842 MessageParcel reply;
1843 MessageOption option(MessageOption::TF_ASYNC);
1844 if (!data.WriteInterfaceToken(GetDescriptor())) {
1845 TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed");
1846 return WSError::WS_ERROR_IPC_FAILED;
1847 }
1848 if (!data.WriteString(eventName)) {
1849 TLOGE(WmsLogTag::WMS_EVENT, "Write params failed");
1850 return WSError::WS_ERROR_IPC_FAILED;
1851 }
1852 if (!data.WriteString(eventValue)) {
1853 TLOGE(WmsLogTag::WMS_EVENT, "Write params failed");
1854 return WSError::WS_ERROR_IPC_FAILED;
1855 }
1856 sptr<IRemoteObject> remote = Remote();
1857 if (remote == nullptr) {
1858 TLOGE(WmsLogTag::WMS_EVENT, "remote is null");
1859 return WSError::WS_ERROR_IPC_FAILED;
1860 }
1861 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_CONTAINER_MODAL_EVENT),
1862 data, reply, option) != ERR_NONE) {
1863 TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed");
1864 return WSError::WS_ERROR_IPC_FAILED;
1865 }
1866 return WSError::WS_OK;
1867 }
1868
NotifyHighlightChange(bool isHighlight)1869 WSError SessionStageProxy::NotifyHighlightChange(bool isHighlight)
1870 {
1871 MessageParcel data;
1872 MessageParcel reply;
1873 MessageOption option(MessageOption::TF_ASYNC);
1874 if (!data.WriteInterfaceToken(GetDescriptor())) {
1875 TLOGE(WmsLogTag::WMS_FOCUS, "Write interfaceToken failed");
1876 return WSError::WS_ERROR_IPC_FAILED;
1877 }
1878
1879 if (!data.WriteBool(isHighlight)) {
1880 TLOGE(WmsLogTag::WMS_FOCUS, "Write isHighlight failed");
1881 return WSError::WS_ERROR_IPC_FAILED;
1882 }
1883
1884 sptr<IRemoteObject> remote = Remote();
1885 if (remote == nullptr) {
1886 TLOGE(WmsLogTag::WMS_FOCUS, "remote is null");
1887 return WSError::WS_ERROR_IPC_FAILED;
1888 }
1889
1890 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_HIGHLIGHT_CHANGE),
1891 data, reply, option) != ERR_NONE) {
1892 TLOGE(WmsLogTag::WMS_FOCUS, "SendRequest failed");
1893 return WSError::WS_ERROR_IPC_FAILED;
1894 }
1895 return WSError::WS_OK;
1896 }
1897
NotifyWindowCrossAxisChange(CrossAxisState state)1898 void SessionStageProxy::NotifyWindowCrossAxisChange(CrossAxisState state)
1899 {
1900 MessageParcel data;
1901 MessageParcel reply;
1902 MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER);
1903 if (!data.WriteInterfaceToken(GetDescriptor())) {
1904 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
1905 return;
1906 }
1907 if (!data.WriteUint32(static_cast<uint32_t>(state))) {
1908 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write params failed");
1909 return;
1910 }
1911 sptr<IRemoteObject> remote = Remote();
1912 if (remote == nullptr) {
1913 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
1914 return;
1915 }
1916 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CROSS_AXIS),
1917 data, reply, option) != ERR_NONE) {
1918 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
1919 return;
1920 }
1921 }
1922
NotifyWindowAttachStateChange(bool isAttach)1923 WSError SessionStageProxy::NotifyWindowAttachStateChange(bool isAttach)
1924 {
1925 MessageParcel data;
1926 MessageParcel reply;
1927 MessageOption option(MessageOption::TF_ASYNC);
1928 if (!data.WriteInterfaceToken(GetDescriptor())) {
1929 TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
1930 return WSError::WS_ERROR_IPC_FAILED;
1931 }
1932 if (!data.WriteBool(isAttach)) {
1933 TLOGE(WmsLogTag::WMS_SUB, "Write params failed");
1934 return WSError::WS_ERROR_IPC_FAILED;
1935 }
1936 sptr<IRemoteObject> remote = Remote();
1937 if (remote == nullptr) {
1938 TLOGE(WmsLogTag::WMS_SUB, "remote is null");
1939 return WSError::WS_ERROR_IPC_FAILED;
1940 }
1941 if (remote->SendRequest(
1942 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE),
1943 data, reply, option) != ERR_NONE) {
1944 TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
1945 return WSError::WS_ERROR_IPC_FAILED;
1946 }
1947 return WSError::WS_OK;
1948 }
1949
NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo & keyboardPanelInfo)1950 void SessionStageProxy::NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo& keyboardPanelInfo)
1951 {
1952 MessageParcel data;
1953 MessageParcel reply;
1954 MessageOption option(MessageOption::TF_ASYNC);
1955 if (!data.WriteInterfaceToken(GetDescriptor())) {
1956 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
1957 return;
1958 }
1959
1960 if (!data.WriteParcelable(&keyboardPanelInfo)) {
1961 TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardPanelInfo marshalling failed");
1962 return;
1963 }
1964
1965 sptr<IRemoteObject> remote = Remote();
1966 if (remote == nullptr) {
1967 TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
1968 return;
1969 }
1970 if (remote->SendRequest(
1971 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_ANIMATION_COMPLETED),
1972 data, reply, option) != ERR_NONE) {
1973 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
1974 }
1975 }
1976
NotifyTargetRotationInfo(OrientationInfo & info)1977 WSError SessionStageProxy::NotifyTargetRotationInfo(OrientationInfo& info)
1978 {
1979 MessageParcel data;
1980 MessageParcel reply;
1981 MessageOption option(MessageOption::TF_ASYNC);
1982 if (!data.WriteInterfaceToken(GetDescriptor())) {
1983 TLOGE(WmsLogTag::WMS_ROTATION, "WriteInterfaceToken failed");
1984 return WSError::WS_ERROR_IPC_FAILED;
1985 }
1986
1987 if (!data.WriteUint32(info.rotation)) {
1988 TLOGE(WmsLogTag::WMS_ROTATION, "write rotation failed");
1989 return WSError::WS_ERROR_IPC_FAILED;
1990 }
1991
1992 if (!data.WriteInt32(info.rect.posX_) || !data.WriteInt32(info.rect.posY_) ||
1993 !data.WriteUint32(info.rect.width_) || !data.WriteUint32(info.rect.height_)) {
1994 TLOGE(WmsLogTag::WMS_ROTATION, "write rect failed");
1995 return WSError::WS_ERROR_IPC_FAILED;
1996 }
1997
1998 if (!data.WriteUint32(static_cast<uint32_t>(info.avoidAreas.size()))) {
1999 TLOGE(WmsLogTag::WMS_ROTATION, "write avoid area size failed");
2000 return WSError::WS_ERROR_IPC_FAILED;
2001 }
2002
2003 for (const auto& [type, avoidArea] : info.avoidAreas) {
2004 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
2005 TLOGE(WmsLogTag::WMS_ROTATION, "write avoid area type failed");
2006 return WSError::WS_ERROR_IPC_FAILED;
2007 }
2008 if (!data.WriteParcelable(&avoidArea)) {
2009 TLOGE(WmsLogTag::WMS_ROTATION, "write avoid area failed");
2010 return WSError::WS_ERROR_IPC_FAILED;
2011 }
2012 }
2013
2014 sptr<IRemoteObject> remote = Remote();
2015 if (remote == nullptr) {
2016 TLOGE(WmsLogTag::WMS_ROTATION, "remote is null");
2017 return WSError::WS_ERROR_IPC_FAILED;
2018 }
2019 if (remote->SendRequest(
2020 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_ROTATION_PROPERTY),
2021 data, reply, option) != ERR_NONE) {
2022 TLOGE(WmsLogTag::WMS_ROTATION, "SendRequest failed");
2023 return WSError::WS_ERROR_IPC_FAILED;
2024 }
2025 return WSError::WS_OK;
2026 }
2027
NotifyRotationChange(const RotationChangeInfo & rotationChangeInfo)2028 RotationChangeResult SessionStageProxy::NotifyRotationChange(const RotationChangeInfo& rotationChangeInfo)
2029 {
2030 MessageParcel data;
2031 MessageParcel reply;
2032 MessageOption option(MessageOption::TF_SYNC);
2033 RotationChangeResult rotationChangeResult = { RectType::RELATIVE_TO_SCREEN, { 0, 0, 0, 0, } };
2034 if (!data.WriteInterfaceToken(GetDescriptor())) {
2035 TLOGE(WmsLogTag::WMS_ROTATION, "WriteInterfaceToken failed");
2036 return rotationChangeResult;
2037 }
2038 if (!data.WriteUint32(static_cast<uint32_t>(rotationChangeInfo.type_))) {
2039 TLOGE(WmsLogTag::WMS_ROTATION, "Write type failed");
2040 return rotationChangeResult;
2041 }
2042 if (!data.WriteUint32(rotationChangeInfo.orientation_)) {
2043 TLOGE(WmsLogTag::WMS_ROTATION, "Write orientation failed");
2044 return rotationChangeResult;
2045 }
2046 if (!data.WriteUint64(rotationChangeInfo.displayId_)) {
2047 TLOGE(WmsLogTag::WMS_ROTATION, "Write displayId failed");
2048 return rotationChangeResult;
2049 }
2050 if (!data.WriteInt32(rotationChangeInfo.displayRect_.posX_) ||
2051 !data.WriteInt32(rotationChangeInfo.displayRect_.posY_) ||
2052 !data.WriteUint32(rotationChangeInfo.displayRect_.width_) ||
2053 !data.WriteUint32(rotationChangeInfo.displayRect_.height_)) {
2054 TLOGE(WmsLogTag::WMS_ROTATION, "Write display rect failed");
2055 return rotationChangeResult;
2056 }
2057 sptr<IRemoteObject> remote = Remote();
2058 if (remote == nullptr) {
2059 TLOGE(WmsLogTag::WMS_ROTATION, "remote is null");
2060 return rotationChangeResult;
2061 }
2062 if (remote->SendRequest(
2063 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_ROTATION_CHANGE),
2064 data, reply, option) != ERR_NONE) {
2065 TLOGE(WmsLogTag::WMS_ROTATION, "SendRequest failed");
2066 return rotationChangeResult;
2067 }
2068
2069 if (rotationChangeInfo.type_ == RotationChangeType::WINDOW_DID_ROTATE) {
2070 TLOGI(WmsLogTag::WMS_ROTATION, "WINDOW_DID_ROTATE return");
2071 return rotationChangeResult;
2072 }
2073 uint32_t rectType = 0;
2074 if (!reply.ReadUint32(rectType)) {
2075 TLOGE(WmsLogTag::WMS_ROTATION, "read rectType failed");
2076 return rotationChangeResult;
2077 }
2078 rotationChangeResult.rectType_ = static_cast<RectType>(rectType);
2079 if (!reply.ReadInt32(rotationChangeResult.windowRect_.posX_) ||
2080 !reply.ReadInt32(rotationChangeResult.windowRect_.posY_) ||
2081 !reply.ReadUint32(rotationChangeResult.windowRect_.width_) ||
2082 !reply.ReadUint32(rotationChangeResult.windowRect_.height_)) {
2083 TLOGE(WmsLogTag::WMS_ROTATION, "read window rect failed");
2084 return rotationChangeResult;
2085 }
2086 TLOGI(WmsLogTag::WMS_ROTATION, "receive type:%{public}d, rect: [%{public}d, %{public}d, %{public}d, %{public}d]",
2087 rectType, rotationChangeResult.windowRect_.posX_, rotationChangeResult.windowRect_.posY_,
2088 rotationChangeResult.windowRect_.width_, rotationChangeResult.windowRect_.height_);
2089 return rotationChangeResult;
2090 }
2091
NotifyKeyboardAnimationWillBegin(const KeyboardAnimationInfo & keyboardAnimationInfo,const std::shared_ptr<RSTransaction> & rsTransaction)2092 void SessionStageProxy::NotifyKeyboardAnimationWillBegin(const KeyboardAnimationInfo& keyboardAnimationInfo,
2093 const std::shared_ptr<RSTransaction>& rsTransaction)
2094 {
2095 MessageParcel data;
2096 MessageParcel reply;
2097 MessageOption option(MessageOption::TF_ASYNC);
2098 if (!data.WriteInterfaceToken(GetDescriptor())) {
2099 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
2100 return;
2101 }
2102 if (!data.WriteParcelable(&keyboardAnimationInfo)) {
2103 TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardPanelInfo marshalling failed");
2104 return;
2105 }
2106 if (!data.WriteParcelable(rsTransaction.get())) {
2107 TLOGE(WmsLogTag::WMS_KEYBOARD, "RsTransaction marshalling failed");
2108 return;
2109 }
2110 sptr<IRemoteObject> remote = Remote();
2111 if (remote == nullptr) {
2112 TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
2113 return;
2114 }
2115 if (remote->SendRequest(
2116 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_ANIMATION_WILLBEGIN),
2117 data, reply, option) != ERR_NONE) {
2118 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2119 }
2120 }
2121
SetCurrentRotation(int32_t currentRotation)2122 WSError SessionStageProxy::SetCurrentRotation(int32_t currentRotation)
2123 {
2124 MessageParcel data;
2125 MessageParcel reply;
2126 MessageOption option(MessageOption::TF_ASYNC);
2127 if (!data.WriteInterfaceToken(GetDescriptor())) {
2128 TLOGE(WmsLogTag::WMS_ROTATION, "WriteInterfaceToken failed");
2129 return WSError::WS_ERROR_IPC_FAILED;
2130 }
2131
2132 if (!data.WriteInt32(currentRotation)) {
2133 TLOGE(WmsLogTag::WMS_ROTATION, "Write params failed");
2134 return WSError::WS_ERROR_IPC_FAILED;
2135 }
2136
2137 sptr<IRemoteObject> remote = Remote();
2138 if (remote == nullptr) {
2139 TLOGE(WmsLogTag::WMS_ROTATION, "remote is null");
2140 return WSError::WS_ERROR_IPC_FAILED;
2141 }
2142
2143 if (remote->SendRequest(
2144 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_CURRENT_ROTATION),
2145 data, reply, option) != ERR_NONE) {
2146 TLOGE(WmsLogTag::WMS_ROTATION, "SendRequest failed");
2147 return WSError::WS_ERROR_IPC_FAILED;
2148 }
2149 return WSError::WS_OK;
2150 }
2151
NotifyAppForceLandscapeConfigUpdated()2152 WSError SessionStageProxy::NotifyAppForceLandscapeConfigUpdated()
2153 {
2154 MessageParcel data;
2155 MessageParcel reply;
2156 MessageOption option(MessageOption::TF_ASYNC);
2157 if (!data.WriteInterfaceToken(GetDescriptor())) {
2158 WLOGFE("WriteInterfaceToken failed");
2159 return WSError::WS_ERROR_IPC_FAILED;
2160 }
2161
2162 sptr<IRemoteObject> remote = Remote();
2163 if (remote == nullptr) {
2164 WLOGFE("remote is null");
2165 return WSError::WS_ERROR_IPC_FAILED;
2166 }
2167
2168 if (remote->SendRequest(
2169 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_APP_FORCE_LANDSCAPE_CONFIG_UPDATED),
2170 data, reply, option) != ERR_NONE) {
2171 WLOGFE("SendRequest failed");
2172 return WSError::WS_ERROR_IPC_FAILED;
2173 }
2174 return WSError::WS_OK;
2175 }
2176
NotifyAppHookWindowInfoUpdated()2177 WSError SessionStageProxy::NotifyAppHookWindowInfoUpdated()
2178 {
2179 MessageParcel data;
2180 MessageParcel reply;
2181 MessageOption option(MessageOption::TF_ASYNC);
2182 if (!data.WriteInterfaceToken(GetDescriptor())) {
2183 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
2184 return WSError::WS_ERROR_IPC_FAILED;
2185 }
2186
2187 sptr<IRemoteObject> remote = Remote();
2188 if (remote == nullptr) {
2189 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2190 return WSError::WS_ERROR_IPC_FAILED;
2191 }
2192
2193 if (remote->SendRequest(
2194 static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_APP_HOOK_WINDOW_INFO_UPDATED),
2195 data, reply, option) != ERR_NONE) {
2196 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2197 return WSError::WS_ERROR_IPC_FAILED;
2198 }
2199 return WSError::WS_OK;
2200 }
2201
GetRouterStackInfo(std::string & routerStackInfo)2202 WMError SessionStageProxy::GetRouterStackInfo(std::string& routerStackInfo)
2203 {
2204 MessageParcel data;
2205 MessageParcel reply;
2206 MessageOption option;
2207 if (!data.WriteInterfaceToken(GetDescriptor())) {
2208 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
2209 return WMError::WM_ERROR_IPC_FAILED;
2210 }
2211 sptr<IRemoteObject> remote = Remote();
2212 if (remote == nullptr) {
2213 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
2214 return WMError::WM_ERROR_IPC_FAILED;
2215 }
2216 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_ROUTER_STACK_INFO),
2217 data, reply, option) != ERR_NONE) {
2218 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
2219 return WMError::WM_ERROR_IPC_FAILED;
2220 }
2221 ErrCode errCode = ERR_OK;
2222 if (!reply.ReadInt32(errCode)) {
2223 TLOGE(WmsLogTag::WMS_LIFE, "read reply falied");
2224 return WMError::WM_ERROR_IPC_FAILED;
2225 }
2226 routerStackInfo = reply.ReadString();
2227 return static_cast<WMError>(errCode);
2228 }
2229
CloseSpecificScene()2230 WSError SessionStageProxy::CloseSpecificScene()
2231 {
2232 MessageParcel data;
2233 MessageParcel reply;
2234 MessageOption option(MessageOption::TF_ASYNC);
2235 if (!data.WriteInterfaceToken(GetDescriptor())) {
2236 TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed");
2237 return WSError::WS_ERROR_IPC_FAILED;
2238 }
2239 sptr remote = Remote();
2240 if (remote == nullptr) {
2241 TLOGE(WmsLogTag::WMS_EVENT, "remote is null");
2242 return WSError::WS_ERROR_IPC_FAILED;
2243 }
2244 if (remote->SendRequest(static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_CLOSE_SPECIFIC_SCENE),
2245 data, reply, option) != ERR_NONE) {
2246 TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed");
2247 return WSError::WS_ERROR_IPC_FAILED;
2248 }
2249 return WSError::WS_OK;
2250 }
2251 } // namespace OHOS::Rosen
2252