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/host/include/zidl/session_proxy.h"
17
18 #include "ability_start_setting.h"
19 #include <ipc_types.h>
20 #include <message_option.h>
21 #include <ui/rs_surface_node.h>
22
23 #include "parcel/accessibility_event_info_parcel.h"
24 #include "process_options.h"
25 #include "start_window_option.h"
26 #include "want.h"
27 #include "key_event.h"
28 #include "pointer_event.h"
29 #include "process_options.h"
30 #include "session/host/include/zidl/session_ipc_interface_code.h"
31 #include "window_manager_hilog.h"
32 namespace OHOS::Rosen {
33 namespace {
34 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionProxy" };
35
WriteAbilitySessionInfoBasic(MessageParcel& data, sptr<AAFwk::SessionInfo> abilitySessionInfo)36 bool WriteAbilitySessionInfoBasic(MessageParcel& data, sptr<AAFwk::SessionInfo> abilitySessionInfo)
37 {
38 if (abilitySessionInfo == nullptr) {
39 WLOGFE("abilitySessionInfo is null");
40 return false;
41 }
42 if (!data.WriteParcelable(&(abilitySessionInfo->want)) ||
43 !data.WriteInt32(abilitySessionInfo->requestCode) ||
44 !data.WriteInt32(abilitySessionInfo->persistentId) ||
45 !data.WriteInt32(static_cast<uint32_t>(abilitySessionInfo->state)) ||
46 !data.WriteInt64(abilitySessionInfo->uiAbilityId) ||
47 !data.WriteInt32(abilitySessionInfo->callingTokenId) ||
48 !data.WriteBool(abilitySessionInfo->reuse) ||
49 !data.WriteParcelable(abilitySessionInfo->processOptions.get())) {
50 return false;
51 }
52 return true;
53 }
54 } // namespace
55
Foreground( sptr<WindowSessionProperty> property, bool isFromClient, const std::string& identityToken)56 WSError SessionProxy::Foreground(
57 sptr<WindowSessionProperty> property, bool isFromClient, const std::string& identityToken)
58 {
59 MessageParcel data;
60 MessageParcel reply;
61 MessageOption option(MessageOption::TF_SYNC);
62 if (!data.WriteInterfaceToken(GetDescriptor())) {
63 WLOGFE("[WMSCom] WriteInterfaceToken failed");
64 return WSError::WS_ERROR_IPC_FAILED;
65 }
66
67 if (property) {
68 if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
69 WLOGFE("[WMSCom] Write property failed");
70 return WSError::WS_ERROR_IPC_FAILED;
71 }
72 } else {
73 if (!data.WriteBool(false)) {
74 WLOGFE("[WMSCom] Write property failed");
75 return WSError::WS_ERROR_IPC_FAILED;
76 }
77 }
78 if (!data.WriteBool(isFromClient)) {
79 TLOGE(WmsLogTag::WMS_LIFE, "Write isFromClient failed");
80 return WSError::WS_ERROR_IPC_FAILED;
81 }
82 if (!data.WriteString(identityToken)) {
83 TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
84 return WSError::WS_ERROR_IPC_FAILED;
85 }
86 sptr<IRemoteObject> remote = Remote();
87 if (remote == nullptr) {
88 WLOGFE("[WMSCom] remote is null");
89 return WSError::WS_ERROR_IPC_FAILED;
90 }
91 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_FOREGROUND),
92 data, reply, option) != ERR_NONE) {
93 WLOGFE("[WMSCom] SendRequest failed");
94 return WSError::WS_ERROR_IPC_FAILED;
95 }
96 int32_t ret = reply.ReadInt32();
97 return static_cast<WSError>(ret);
98 }
99
Background(bool isFromClient, const std::string& identityToken)100 WSError SessionProxy::Background(bool isFromClient, const std::string& identityToken)
101 {
102 MessageParcel data;
103 MessageParcel reply;
104 MessageOption option(MessageOption::TF_ASYNC);
105 if (!data.WriteInterfaceToken(GetDescriptor())) {
106 WLOGFE("[WMSCom] WriteInterfaceToken failed");
107 return WSError::WS_ERROR_IPC_FAILED;
108 }
109 if (!data.WriteBool(isFromClient)) {
110 TLOGE(WmsLogTag::WMS_LIFE, "Write isFromClient failed");
111 return WSError::WS_ERROR_IPC_FAILED;
112 }
113 if (!data.WriteString(identityToken)) {
114 TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
115 return WSError::WS_ERROR_IPC_FAILED;
116 }
117 sptr<IRemoteObject> remote = Remote();
118 if (remote == nullptr) {
119 WLOGFE("[WMSCom] remote is null");
120 return WSError::WS_ERROR_IPC_FAILED;
121 }
122 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKGROUND),
123 data, reply, option) != ERR_NONE) {
124 WLOGFE("[WMSCom] SendRequest failed");
125 return WSError::WS_ERROR_IPC_FAILED;
126 }
127 int32_t ret = reply.ReadInt32();
128 return static_cast<WSError>(ret);
129 }
130
Show(sptr<WindowSessionProperty> property)131 WSError SessionProxy::Show(sptr<WindowSessionProperty> property)
132 {
133 MessageParcel data;
134 MessageParcel reply;
135 MessageOption option(MessageOption::TF_SYNC);
136 if (!data.WriteInterfaceToken(GetDescriptor())) {
137 WLOGFE("WriteInterfaceToken failed");
138 return WSError::WS_ERROR_IPC_FAILED;
139 }
140
141 if (property) {
142 if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
143 WLOGFE("Write property failed");
144 return WSError::WS_ERROR_IPC_FAILED;
145 }
146 } else {
147 if (!data.WriteBool(false)) {
148 WLOGFE("Write property failed");
149 return WSError::WS_ERROR_IPC_FAILED;
150 }
151 }
152
153 sptr<IRemoteObject> remote = Remote();
154 if (remote == nullptr) {
155 WLOGFE("remote is null");
156 return WSError::WS_ERROR_IPC_FAILED;
157 }
158 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SHOW),
159 data, reply, option) != ERR_NONE) {
160 WLOGFE("SendRequest failed");
161 return WSError::WS_ERROR_IPC_FAILED;
162 }
163 int32_t ret = reply.ReadInt32();
164 return static_cast<WSError>(ret);
165 }
166
Hide()167 WSError SessionProxy::Hide()
168 {
169 MessageParcel data;
170 MessageParcel reply;
171 MessageOption option(MessageOption::TF_SYNC);
172 if (!data.WriteInterfaceToken(GetDescriptor())) {
173 WLOGFE("WriteInterfaceToken failed");
174 return WSError::WS_ERROR_IPC_FAILED;
175 }
176
177 sptr<IRemoteObject> remote = Remote();
178 if (remote == nullptr) {
179 WLOGFE("remote is null");
180 return WSError::WS_ERROR_IPC_FAILED;
181 }
182 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_HIDE),
183 data, reply, option) != ERR_NONE) {
184 WLOGFE("SendRequest failed");
185 return WSError::WS_ERROR_IPC_FAILED;
186 }
187 int32_t ret = reply.ReadInt32();
188 return static_cast<WSError>(ret);
189 }
190
Disconnect(bool isFromClient, const std::string& identityToken)191 WSError SessionProxy::Disconnect(bool isFromClient, const std::string& identityToken)
192 {
193 MessageParcel data;
194 MessageParcel reply;
195 MessageOption option(MessageOption::TF_ASYNC);
196 if (!data.WriteInterfaceToken(GetDescriptor())) {
197 WLOGFE("WriteInterfaceToken failed");
198 return WSError::WS_ERROR_IPC_FAILED;
199 }
200
201 if (!data.WriteBool(isFromClient)) {
202 WLOGFE("Write isFromClient failed");
203 return WSError::WS_ERROR_IPC_FAILED;
204 }
205 if (!data.WriteString(identityToken)) {
206 TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
207 return WSError::WS_ERROR_IPC_FAILED;
208 }
209 sptr<IRemoteObject> remote = Remote();
210 if (remote == nullptr) {
211 WLOGFE("remote is null");
212 return WSError::WS_ERROR_IPC_FAILED;
213 }
214 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DISCONNECT),
215 data, reply, option) != ERR_NONE) {
216 WLOGFE("SendRequest failed");
217 return WSError::WS_ERROR_IPC_FAILED;
218 }
219 int32_t ret = reply.ReadInt32();
220 return static_cast<WSError>(ret);
221 }
222
Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token, const std::string& identityToken)223 WSError SessionProxy::Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
224 const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
225 sptr<WindowSessionProperty> property, sptr<IRemoteObject> token,
226 const std::string& identityToken)
227 {
228 MessageParcel data;
229 MessageParcel reply;
230 MessageOption option(MessageOption::TF_SYNC);
231 if (!data.WriteInterfaceToken(GetDescriptor())) {
232 WLOGFE("WriteInterfaceToken failed");
233 return WSError::WS_ERROR_IPC_FAILED;
234 }
235 if (!data.WriteRemoteObject(sessionStage->AsObject())) {
236 WLOGFE("Write ISessionStage failed");
237 return WSError::WS_ERROR_IPC_FAILED;
238 }
239 if (!data.WriteRemoteObject(eventChannel->AsObject())) {
240 WLOGFE("Write IWindowEventChannel failed");
241 return WSError::WS_ERROR_IPC_FAILED;
242 }
243 if (!surfaceNode || !surfaceNode->Marshalling(data)) {
244 WLOGFE("Write surfaceNode failed");
245 return WSError::WS_ERROR_IPC_FAILED;
246 }
247 if (property) {
248 if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
249 WLOGFE("Write property failed");
250 return WSError::WS_ERROR_IPC_FAILED;
251 }
252 } else {
253 if (!data.WriteBool(false)) {
254 WLOGFE("Write property failed");
255 return WSError::WS_ERROR_IPC_FAILED;
256 }
257 }
258 if (token != nullptr) {
259 if (!data.WriteRemoteObject(token)) {
260 WLOGFE("Write abilityToken failed");
261 return WSError::WS_ERROR_IPC_FAILED;
262 }
263 }
264 if (!data.WriteString(identityToken)) {
265 TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
266 return WSError::WS_ERROR_IPC_FAILED;
267 }
268 sptr<IRemoteObject> remote = Remote();
269 if (remote == nullptr) {
270 WLOGFE("remote is null");
271 return WSError::WS_ERROR_IPC_FAILED;
272 }
273 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_CONNECT),
274 data, reply, option) != ERR_NONE) {
275 WLOGFE("SendRequest failed");
276 return WSError::WS_ERROR_IPC_FAILED;
277 }
278 sptr<SystemSessionConfig> config = reply.ReadParcelable<SystemSessionConfig>();
279 if (config) {
280 systemConfig = *config;
281 }
282 if (property) {
283 property->SetPersistentId(reply.ReadInt32());
284 property->SetDisplayId(reply.ReadUint64());
285 bool needUpdate = reply.ReadBool();
286 property->SetIsNeedUpdateWindowMode(needUpdate);
287 if (needUpdate) {
288 property->SetWindowMode(static_cast<WindowMode>(reply.ReadUint32()));
289 }
290 Rect preRect = property->GetWindowRect();
291 Rect rect = { reply.ReadInt32(), reply.ReadInt32(), reply.ReadUint32(), reply.ReadUint32() };
292 TLOGI(WmsLogTag::WMS_LAYOUT, "updateRect when connect."
293 "preRect:[%{public}d,%{public}d,%{public}u,%{public}u]"
294 "rect:[%{public}d,%{public}d,%{public}u,%{public}u]",
295 preRect.posX_, preRect.posY_, preRect.width_, preRect.height_,
296 rect.posX_, rect.posY_, rect.width_, rect.height_);
297 if (preRect.IsUninitializedRect() && !rect.IsUninitializedRect()) {
298 property->SetWindowRect(rect);
299 }
300 property->SetCollaboratorType(reply.ReadInt32());
301 property->SetFullScreenStart(reply.ReadBool());
302 property->SetCompatibleModeInPc(reply.ReadBool());
303 property->SetCompatibleWindowSizeInPc(reply.ReadInt32(), reply.ReadInt32(),
304 reply.ReadInt32(), reply.ReadInt32());
305 property->SetIsAppSupportPhoneInPc(reply.ReadBool());
306 property->SetIsSupportDragInPcCompatibleMode(reply.ReadBool());
307 property->SetIsPcAppInPad(reply.ReadBool());
308 property->SetCompatibleModeEnableInPad(reply.ReadBool());
309 property->SetRequestedOrientation(static_cast<Orientation>(reply.ReadUint32()));
310 property->SetAppInstanceKey(reply.ReadString());
311 }
312 int32_t ret = reply.ReadInt32();
313 return static_cast<WSError>(ret);
314 }
315
DrawingCompleted()316 WSError SessionProxy::DrawingCompleted()
317 {
318 MessageParcel data;
319 MessageParcel reply;
320 MessageOption option;
321 if (!data.WriteInterfaceToken(GetDescriptor())) {
322 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
323 return WSError::WS_ERROR_IPC_FAILED;
324 }
325
326 sptr<IRemoteObject> remote = Remote();
327 if (remote == nullptr) {
328 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
329 return WSError::WS_ERROR_IPC_FAILED;
330 }
331 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DRAWING_COMPLETED),
332 data, reply, option) != ERR_NONE) {
333 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
334 return WSError::WS_ERROR_IPC_FAILED;
335 }
336 return static_cast<WSError>(reply.ReadInt32());
337 }
338
ChangeSessionVisibilityWithStatusBar(sptr<AAFwk::SessionInfo> abilitySessionInfo, bool visible)339 WSError SessionProxy::ChangeSessionVisibilityWithStatusBar(sptr<AAFwk::SessionInfo> abilitySessionInfo, bool visible)
340 {
341 if (abilitySessionInfo == nullptr) {
342 WLOGFE("abilitySessionInfo is null");
343 return WSError::WS_ERROR_INVALID_SESSION;
344 }
345
346 MessageParcel data;
347 MessageParcel reply;
348 MessageOption option(MessageOption::TF_ASYNC);
349 if (!data.WriteInterfaceToken(GetDescriptor())) {
350 WLOGFE("Write interfaceToken failed");
351 return WSError::WS_ERROR_IPC_FAILED;
352 }
353 if (!WriteAbilitySessionInfoBasic(data, abilitySessionInfo)) {
354 WLOGFE("Write abilitySessionInfoBasic failed");
355 return WSError::WS_ERROR_IPC_FAILED;
356 }
357 if (abilitySessionInfo->callerToken) {
358 if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
359 WLOGFE("Write callerToken info failed");
360 return WSError::WS_ERROR_IPC_FAILED;
361 }
362 } else {
363 if (!data.WriteBool(false)) {
364 WLOGFE("Write has not callerToken info failed");
365 return WSError::WS_ERROR_IPC_FAILED;
366 }
367 }
368 if (abilitySessionInfo->startSetting) {
369 if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startSetting.get())) {
370 WLOGFE("Write startSetting failed");
371 return WSError::WS_ERROR_IPC_FAILED;
372 }
373 } else {
374 if (!data.WriteBool(false)) {
375 WLOGFE("Write has not startSetting failed");
376 return WSError::WS_ERROR_IPC_FAILED;
377 }
378 }
379 data.WriteBool(visible);
380 sptr<IRemoteObject> remote = Remote();
381 if (remote == nullptr) {
382 WLOGFE("remote is null");
383 return WSError::WS_ERROR_IPC_FAILED;
384 }
385 if (remote->SendRequest(static_cast<uint32_t>(
386 SessionInterfaceCode::TRANS_ID_CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR),
387 data, reply, option) != ERR_NONE) {
388 WLOGFE("SendRequest failed");
389 return WSError::WS_ERROR_IPC_FAILED;
390 }
391 int32_t ret = reply.ReadInt32();
392 return static_cast<WSError>(ret);
393 }
394
PendingSessionActivation(sptr<AAFwk::SessionInfo> abilitySessionInfo)395 WSError SessionProxy::PendingSessionActivation(sptr<AAFwk::SessionInfo> abilitySessionInfo)
396 {
397 if (abilitySessionInfo == nullptr) {
398 WLOGFE("abilitySessionInfo is null");
399 return WSError::WS_ERROR_INVALID_SESSION;
400 }
401
402 MessageParcel data;
403 MessageParcel reply;
404 MessageOption option(MessageOption::TF_ASYNC);
405 if (!data.WriteInterfaceToken(GetDescriptor())) {
406 WLOGFE("Write interfaceToken failed");
407 return WSError::WS_ERROR_IPC_FAILED;
408 }
409 if (!WriteAbilitySessionInfoBasic(data, abilitySessionInfo)) {
410 WLOGFE("Write abilitySessionInfoBasic failed");
411 return WSError::WS_ERROR_IPC_FAILED;
412 }
413 if (!data.WriteBool(abilitySessionInfo->canStartAbilityFromBackground)) {
414 TLOGE(WmsLogTag::WMS_LIFE, "Write canStartAbilityFromBackground failed");
415 return WSError::WS_ERROR_IPC_FAILED;
416 }
417 if (!data.WriteBool(abilitySessionInfo->isAtomicService) ||
418 !data.WriteBool(abilitySessionInfo->isBackTransition) ||
419 !data.WriteBool(abilitySessionInfo->needClearInNotShowRecent)) {
420 TLOGE(WmsLogTag::WMS_LIFE, "Write isAtomicService or isBackTransition or needClearInNotShowRecent failed");
421 return WSError::WS_ERROR_IPC_FAILED;
422 }
423 if (abilitySessionInfo->callerToken) {
424 if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
425 WLOGFE("Write callerToken info failed");
426 return WSError::WS_ERROR_IPC_FAILED;
427 }
428 } else {
429 if (!data.WriteBool(false)) {
430 WLOGFE("Write has not callerToken info failed");
431 return WSError::WS_ERROR_IPC_FAILED;
432 }
433 }
434 if (abilitySessionInfo->startSetting) {
435 if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startSetting.get())) {
436 WLOGFE("Write startSetting failed");
437 return WSError::WS_ERROR_IPC_FAILED;
438 }
439 } else {
440 if (!data.WriteBool(false)) {
441 WLOGFE("Write has not startSetting failed");
442 return WSError::WS_ERROR_IPC_FAILED;
443 }
444 }
445 if (!data.WriteString(abilitySessionInfo->instanceKey)) {
446 TLOGE(WmsLogTag::WMS_LIFE, "Write instanceKey failed");
447 return WSError::WS_ERROR_IPC_FAILED;
448 }
449 if (!data.WriteBool(abilitySessionInfo->isFromIcon)) {
450 TLOGE(WmsLogTag::WMS_LIFE, "Write isFromIcon failed");
451 return WSError::WS_ERROR_IPC_FAILED;
452 }
453 if (abilitySessionInfo->startWindowOption) {
454 if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startWindowOption.get())) {
455 TLOGE(WmsLogTag::WMS_LIFE, "Write startWindowOption failed");
456 return WSError::WS_ERROR_IPC_FAILED;
457 }
458 } else {
459 if (!data.WriteBool(false)) {
460 TLOGE(WmsLogTag::WMS_LIFE, "Write has not startWindowOption failed");
461 return WSError::WS_ERROR_IPC_FAILED;
462 }
463 }
464 sptr<IRemoteObject> remote = Remote();
465 if (remote == nullptr) {
466 WLOGFE("remote is null");
467 return WSError::WS_ERROR_IPC_FAILED;
468 }
469 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_ACTIVE_PENDING_SESSION),
470 data, reply, option) != ERR_NONE) {
471 WLOGFE("SendRequest failed");
472 return WSError::WS_ERROR_IPC_FAILED;
473 }
474 int32_t ret = reply.ReadInt32();
475 return static_cast<WSError>(ret);
476 }
477
TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)478 WSError SessionProxy::TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)
479 {
480 if (abilitySessionInfo == nullptr) {
481 WLOGFE("abilitySessionInfo is null");
482 return WSError::WS_ERROR_INVALID_SESSION;
483 }
484 MessageParcel data;
485 MessageParcel reply;
486 MessageOption option(MessageOption::TF_ASYNC);
487 if (!data.WriteInterfaceToken(GetDescriptor())) {
488 WLOGFE("WriteInterfaceToken failed");
489 return WSError::WS_ERROR_IPC_FAILED;
490 }
491 if (!data.WriteParcelable(&(abilitySessionInfo->want))) {
492 WLOGFE("Write want info failed");
493 return WSError::WS_ERROR_IPC_FAILED;
494 }
495 if (abilitySessionInfo->callerToken) {
496 if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
497 WLOGFE("Write ability info failed");
498 return WSError::WS_ERROR_IPC_FAILED;
499 }
500 } else {
501 if (!data.WriteBool(false)) {
502 WLOGFE("Write ability info failed");
503 return WSError::WS_ERROR_IPC_FAILED;
504 }
505 }
506 if (!data.WriteInt32(abilitySessionInfo->resultCode)) {
507 WLOGFE("Write resultCode info failed");
508 return WSError::WS_ERROR_IPC_FAILED;
509 }
510 sptr<IRemoteObject> remote = Remote();
511 if (remote == nullptr) {
512 WLOGFE("remote is null");
513 return WSError::WS_ERROR_IPC_FAILED;
514 }
515 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TERMINATE),
516 data, reply, option) != ERR_NONE) {
517 WLOGFE("SendRequest failed");
518 return WSError::WS_ERROR_IPC_FAILED;
519 }
520 int32_t ret = reply.ReadInt32();
521 return static_cast<WSError>(ret);
522 }
523
NotifySessionException(const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needRemoveSession)524 WSError SessionProxy::NotifySessionException(const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needRemoveSession)
525 {
526 if (abilitySessionInfo == nullptr) {
527 TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfo is null");
528 return WSError::WS_ERROR_INVALID_SESSION;
529 }
530 MessageParcel data;
531 MessageParcel reply;
532 MessageOption option(MessageOption::TF_ASYNC);
533 if (!data.WriteInterfaceToken(GetDescriptor())) {
534 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
535 return WSError::WS_ERROR_IPC_FAILED;
536 }
537 if (!data.WriteParcelable(&(abilitySessionInfo->want))) {
538 TLOGE(WmsLogTag::WMS_LIFE, "Write want info failed");
539 return WSError::WS_ERROR_IPC_FAILED;
540 }
541 if (abilitySessionInfo->callerToken) {
542 if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
543 TLOGE(WmsLogTag::WMS_LIFE, "Write ability info failed");
544 return WSError::WS_ERROR_IPC_FAILED;
545 }
546 } else {
547 if (!data.WriteBool(false)) {
548 TLOGE(WmsLogTag::WMS_LIFE, "Write ability info failed");
549 return WSError::WS_ERROR_IPC_FAILED;
550 }
551 }
552 if (!data.WriteInt32(abilitySessionInfo->persistentId)) {
553 TLOGE(WmsLogTag::WMS_LIFE, "Write persistentId info failed");
554 return WSError::WS_ERROR_IPC_FAILED;
555 }
556 if (!data.WriteInt32(abilitySessionInfo->errorCode) ||
557 !data.WriteString(abilitySessionInfo->errorReason)) {
558 TLOGE(WmsLogTag::WMS_LIFE, "Write error info failed");
559 return WSError::WS_ERROR_IPC_FAILED;
560 }
561 if (!data.WriteString(abilitySessionInfo->identityToken)) {
562 TLOGE(WmsLogTag::WMS_LIFE, "Write identity token info failed");
563 return WSError::WS_ERROR_IPC_FAILED;
564 }
565 sptr<IRemoteObject> remote = Remote();
566 if (remote == nullptr) {
567 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
568 return WSError::WS_ERROR_IPC_FAILED;
569 }
570 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_EXCEPTION),
571 data, reply, option) != ERR_NONE) {
572 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
573 return WSError::WS_ERROR_IPC_FAILED;
574 }
575 int32_t ret = reply.ReadInt32();
576 return static_cast<WSError>(ret);
577 }
578
OnSessionEvent(SessionEvent event)579 WSError SessionProxy::OnSessionEvent(SessionEvent event)
580 {
581 MessageParcel data;
582 MessageParcel reply;
583 MessageOption option(MessageOption::TF_ASYNC);
584 if (!data.WriteInterfaceToken(GetDescriptor())) {
585 WLOGFE("WriteInterfaceToken failed");
586 return WSError::WS_ERROR_IPC_FAILED;
587 }
588 if (!(data.WriteUint32(static_cast<uint32_t>(event)))) {
589 WLOGFE("Write event id failed");
590 return WSError::WS_ERROR_IPC_FAILED;
591 }
592 sptr<IRemoteObject> remote = Remote();
593 if (remote == nullptr) {
594 WLOGFE("remote is null");
595 return WSError::WS_ERROR_IPC_FAILED;
596 }
597 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SESSION_EVENT),
598 data, reply, option) != ERR_NONE) {
599 WLOGFE("SendRequest failed");
600 return WSError::WS_ERROR_IPC_FAILED;
601 }
602 int32_t ret = reply.ReadInt32();
603 return static_cast<WSError>(ret);
604 }
605
OnSystemSessionEvent(SessionEvent event)606 WSError SessionProxy::OnSystemSessionEvent(SessionEvent event)
607 {
608 MessageParcel data;
609 MessageParcel reply;
610 MessageOption option(MessageOption::TF_SYNC);
611 if (!data.WriteInterfaceToken(GetDescriptor())) {
612 WLOGFE("WriteInterfaceToken failed");
613 return WSError::WS_ERROR_IPC_FAILED;
614 }
615 if (!(data.WriteInt32(static_cast<int32_t>(event)))) {
616 WLOGFE("Write event id failed");
617 return WSError::WS_ERROR_IPC_FAILED;
618 }
619 if (Remote()->SendRequest(static_cast<int32_t>(SessionInterfaceCode::TRANS_ID_SYSTEM_SESSION_EVENT),
620 data, reply, option) != ERR_NONE) {
621 WLOGFE("SendRequest failed");
622 return WSError::WS_ERROR_IPC_FAILED;
623 }
624 int32_t ret = reply.ReadInt32();
625 return static_cast<WSError>(ret);
626 }
627
OnLayoutFullScreenChange(bool isLayoutFullScreen)628 WSError SessionProxy::OnLayoutFullScreenChange(bool isLayoutFullScreen)
629 {
630 MessageParcel data;
631 MessageParcel reply;
632 MessageOption option(MessageOption::TF_ASYNC);
633 if (!data.WriteInterfaceToken(GetDescriptor())) {
634 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
635 return WSError::WS_ERROR_IPC_FAILED;
636 }
637 if (!data.WriteBool(isLayoutFullScreen)) {
638 TLOGE(WmsLogTag::WMS_LAYOUT, "Write isLayoutFullScreen failed");
639 return WSError::WS_ERROR_IPC_FAILED;
640 }
641 sptr<IRemoteObject> remote = Remote();
642 if (remote == nullptr) {
643 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
644 return WSError::WS_ERROR_IPC_FAILED;
645 }
646 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_LAYOUT_FULL_SCREEN_CHANGE),
647 data, reply, option) != ERR_NONE) {
648 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
649 return WSError::WS_ERROR_IPC_FAILED;
650 }
651 int32_t ret = reply.ReadInt32();
652 return static_cast<WSError>(ret);
653 }
654
OnRestoreMainWindow()655 WSError SessionProxy::OnRestoreMainWindow()
656 {
657 MessageParcel data;
658 MessageParcel reply;
659 MessageOption option(MessageOption::TF_ASYNC);
660 if (!data.WriteInterfaceToken(GetDescriptor())) {
661 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
662 return WSError::WS_ERROR_IPC_FAILED;
663 }
664 sptr<IRemoteObject> remote = Remote();
665 if (remote == nullptr) {
666 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
667 return WSError::WS_ERROR_IPC_FAILED;
668 }
669 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RESTORE_MAIN_WINDOW),
670 data, reply, option) != ERR_NONE) {
671 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
672 return WSError::WS_ERROR_IPC_FAILED;
673 }
674 int32_t ret = reply.ReadInt32();
675 return static_cast<WSError>(ret);
676 }
677
OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown)678 WSError SessionProxy::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown)
679 {
680 MessageParcel data;
681 MessageParcel reply;
682 MessageOption option(MessageOption::TF_ASYNC);
683 if (!data.WriteInterfaceToken(GetDescriptor())) {
684 TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
685 return WSError::WS_ERROR_IPC_FAILED;
686 }
687 if (!data.WriteBool(isTitleHoverShown) || !data.WriteBool(isDockHoverShown)) {
688 TLOGE(WmsLogTag::WMS_IMMS, "Write isTitleAndDockHoverShow failed");
689 return WSError::WS_ERROR_IPC_FAILED;
690 }
691 sptr<IRemoteObject> remote = Remote();
692 if (remote == nullptr) {
693 TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
694 return WSError::WS_ERROR_IPC_FAILED;
695 }
696 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TITLE_AND_DOCK_HOVER_SHOW_CHANGE),
697 data, reply, option) != ERR_NONE) {
698 TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed");
699 return WSError::WS_ERROR_IPC_FAILED;
700 }
701 int32_t ret = reply.ReadInt32();
702 return static_cast<WSError>(ret);
703 }
704
705 /** @note @window.layout */
UpdateSessionRect(const WSRect& rect, const SizeChangeReason reason, bool isGlobal)706 WSError SessionProxy::UpdateSessionRect(const WSRect& rect, const SizeChangeReason reason, bool isGlobal)
707 {
708 TLOGI(WmsLogTag::WMS_LAYOUT, "Rect [%{public}d, %{public}d, %{public}u, %{public}u]",
709 rect.posX_, rect.posY_, rect.width_, rect.height_);
710 MessageParcel data;
711 MessageParcel reply;
712 MessageOption option(MessageOption::TF_ASYNC);
713 if (!data.WriteInterfaceToken(GetDescriptor())) {
714 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
715 return WSError::WS_ERROR_IPC_FAILED;
716 }
717 if (!((data.WriteInt32(static_cast<int32_t>(rect.posX_))) &&
718 (data.WriteInt32(static_cast<int32_t>(rect.posY_))) &&
719 (data.WriteUint32(static_cast<uint32_t>(rect.width_))) &&
720 (data.WriteUint32(static_cast<uint32_t>(rect.height_))))) {
721 TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed");
722 return WSError::WS_ERROR_IPC_FAILED;
723 }
724
725 if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
726 TLOGE(WmsLogTag::WMS_LAYOUT, "Write SessionSizeChangeReason failed");
727 return WSError::WS_ERROR_IPC_FAILED;
728 }
729
730 if (!data.WriteBool(isGlobal)) {
731 TLOGE(WmsLogTag::WMS_LAYOUT, "Write bool failed");
732 return WSError::WS_ERROR_IPC_FAILED;
733 }
734
735 sptr<IRemoteObject> remote = Remote();
736 if (remote == nullptr) {
737 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
738 return WSError::WS_ERROR_IPC_FAILED;
739 }
740 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_RECT),
741 data, reply, option) != ERR_NONE) {
742 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
743 return WSError::WS_ERROR_IPC_FAILED;
744 }
745 int32_t ret = reply.ReadInt32();
746 return static_cast<WSError>(ret);
747 }
748
749 /** @note @window.layout */
UpdateClientRect(const WSRect& rect)750 WSError SessionProxy::UpdateClientRect(const WSRect& rect)
751 {
752 TLOGI(WmsLogTag::WMS_LAYOUT, "rect:[%{public}d, %{public}d, %{public}u, %{public}u]",
753 rect.posX_, rect.posY_, rect.width_, rect.height_);
754 MessageParcel data;
755 MessageParcel reply;
756 MessageOption option;
757 if (!data.WriteInterfaceToken(GetDescriptor())) {
758 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
759 return WSError::WS_ERROR_IPC_FAILED;
760 }
761 if (!((data.WriteInt32(static_cast<int32_t>(rect.posX_))) &&
762 (data.WriteInt32(static_cast<int32_t>(rect.posY_))) &&
763 (data.WriteUint32(static_cast<uint32_t>(rect.width_))) &&
764 (data.WriteUint32(static_cast<uint32_t>(rect.height_))))) {
765 TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed");
766 return WSError::WS_ERROR_IPC_FAILED;
767 }
768
769 sptr<IRemoteObject> remote = Remote();
770 if (remote == nullptr) {
771 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
772 return WSError::WS_ERROR_IPC_FAILED;
773 }
774 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_CLIENT_RECT),
775 data, reply, option) != ERR_NONE) {
776 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
777 return WSError::WS_ERROR_IPC_FAILED;
778 }
779 int32_t ret = reply.ReadInt32();
780 return static_cast<WSError>(ret);
781 }
782
783 /** @note @window.hierarchy */
RaiseToAppTop()784 WSError SessionProxy::RaiseToAppTop()
785 {
786 MessageParcel data;
787 MessageParcel reply;
788 MessageOption option;
789 if (!data.WriteInterfaceToken(GetDescriptor())) {
790 WLOGFE("WriteInterfaceToken failed");
791 return WSError::WS_ERROR_IPC_FAILED;
792 }
793 sptr<IRemoteObject> remote = Remote();
794 if (remote == nullptr) {
795 WLOGFE("remote is null");
796 return WSError::WS_ERROR_IPC_FAILED;
797 }
798 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_TO_APP_TOP),
799 data, reply, option) != ERR_NONE) {
800 WLOGFE("SendRequest failed");
801 return WSError::WS_ERROR_IPC_FAILED;
802 }
803 int32_t ret = reply.ReadInt32();
804 return static_cast<WSError>(ret);
805 }
806
NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect)807 WSError SessionProxy::NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect)
808 {
809 MessageParcel data;
810 MessageParcel reply;
811 MessageOption option(MessageOption::TF_ASYNC);
812 if (!data.WriteInterfaceToken(GetDescriptor())) {
813 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "WriteInterfaceToken failed");
814 return WSError::WS_ERROR_IPC_FAILED;
815 }
816
817 if (!data.WriteBool(notifyListener)) {
818 TLOGE(WmsLogTag::WMS_LAYOUT, "Write notifyListener failed");
819 return WSError::WS_ERROR_IPC_FAILED;
820 }
821
822 if (!data.WriteInt32(rect.posX_) || !data.WriteInt32(rect.posY_) ||
823 !data.WriteInt32(rect.width_) || !data.WriteInt32(rect.height_)) {
824 TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed");
825 return WSError::WS_ERROR_IPC_FAILED;
826 }
827
828 sptr<IRemoteObject> remote = Remote();
829 if (remote == nullptr) {
830 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "remote is null");
831 return WSError::WS_ERROR_IPC_FAILED;
832 }
833
834 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_FRAME_LAYOUT_FINISH),
835 data, reply, option) != ERR_NONE) {
836 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "SendRequest failed");
837 return WSError::WS_ERROR_IPC_FAILED;
838 }
839 return WSError::WS_OK;
840 }
841
842 /** @note @window.hierarchy */
RaiseAboveTarget(int32_t subWindowId)843 WSError SessionProxy::RaiseAboveTarget(int32_t subWindowId)
844 {
845 MessageParcel data;
846 MessageParcel reply;
847 MessageOption option;
848 if (!data.WriteInterfaceToken(GetDescriptor())) {
849 WLOGFE("WriteInterfaceToken failed");
850 return WSError::WS_ERROR_IPC_FAILED;
851 }
852 if (!data.WriteInt32(subWindowId)) {
853 WLOGFE("Write subWindowId failed");
854 }
855 sptr<IRemoteObject> remote = Remote();
856 if (remote == nullptr) {
857 WLOGFE("remote is null");
858 return WSError::WS_ERROR_IPC_FAILED;
859 }
860 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_ABOVE_TARGET),
861 data, reply, option) != ERR_NONE) {
862 WLOGFE("SendRequest failed");
863 return WSError::WS_ERROR_IPC_FAILED;
864 }
865 int32_t ret = reply.ReadInt32();
866 return static_cast<WSError>(ret);
867 }
868
RaiseAppMainWindowToTop()869 WSError SessionProxy::RaiseAppMainWindowToTop()
870 {
871 MessageParcel data;
872 MessageParcel reply;
873 MessageOption option(MessageOption::TF_ASYNC);
874 if (!data.WriteInterfaceToken(GetDescriptor())) {
875 WLOGFE("WriteInterfaceToken failed");
876 return WSError::WS_ERROR_IPC_FAILED;
877 }
878 sptr<IRemoteObject> remote = Remote();
879 if (remote == nullptr) {
880 WLOGFE("remote is null");
881 return WSError::WS_ERROR_IPC_FAILED;
882 }
883 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_APP_MAIN_WINDOW),
884 data, reply, option) != ERR_NONE) {
885 WLOGFE("SendRequest failed");
886 return WSError::WS_ERROR_IPC_FAILED;
887 }
888 int32_t ret = reply.ReadInt32();
889 return static_cast<WSError>(ret);
890 }
891
OnNeedAvoid(bool status)892 WSError SessionProxy::OnNeedAvoid(bool status)
893 {
894 MessageParcel data;
895 MessageParcel reply;
896 MessageOption option(MessageOption::TF_ASYNC);
897 if (!data.WriteInterfaceToken(GetDescriptor())) {
898 WLOGFE("WriteInterfaceToken failed");
899 return WSError::WS_ERROR_IPC_FAILED;
900 }
901 if (!data.WriteBool(status)) {
902 WLOGFE("Write status failed");
903 return WSError::WS_ERROR_IPC_FAILED;
904 }
905 sptr<IRemoteObject> remote = Remote();
906 if (remote == nullptr) {
907 WLOGFE("remote is null");
908 return WSError::WS_ERROR_IPC_FAILED;
909 }
910 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NEED_AVOID),
911 data, reply, option) != ERR_NONE) {
912 WLOGFE("SendRequest failed");
913 return WSError::WS_ERROR_IPC_FAILED;
914 }
915 int32_t ret = reply.ReadInt32();
916 return static_cast<WSError>(ret);
917 }
918
GetAvoidAreaByType(AvoidAreaType type)919 AvoidArea SessionProxy::GetAvoidAreaByType(AvoidAreaType type)
920 {
921 MessageParcel data;
922 MessageParcel reply;
923 MessageOption option(MessageOption::TF_SYNC);
924 AvoidArea avoidArea;
925 if (!data.WriteInterfaceToken(GetDescriptor())) {
926 WLOGFE("WriteInterfaceToken failed");
927 return avoidArea;
928 }
929 if (!(data.WriteUint32(static_cast<uint32_t>(type)))) {
930 WLOGFE("Write type failed");
931 return avoidArea;
932 }
933 sptr<IRemoteObject> remote = Remote();
934 if (remote == nullptr) {
935 WLOGFE("remote is null");
936 return avoidArea;
937 }
938 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_AVOID_AREA),
939 data, reply, option) != ERR_NONE) {
940 WLOGFE("SendRequest failed");
941 return avoidArea;
942 }
943 sptr<AvoidArea> area = reply.ReadParcelable<AvoidArea>();
944 if (area == nullptr) {
945 return avoidArea;
946 }
947 return *area;
948 }
949
GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas)950 WSError SessionProxy::GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas)
951 {
952 MessageParcel data;
953 MessageParcel reply;
954 MessageOption option(MessageOption::TF_SYNC);
955 if (!data.WriteInterfaceToken(GetDescriptor())) {
956 WLOGFE("WriteInterfaceToken failed");
957 return WSError::WS_ERROR_IPC_FAILED;
958 }
959 sptr<IRemoteObject> remote = Remote();
960 if (remote == nullptr) {
961 WLOGFE("remote is null");
962 return WSError::WS_ERROR_IPC_FAILED;
963 }
964 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_ALL_AVOID_AREAS),
965 data, reply, option) != ERR_NONE) {
966 WLOGFE("SendRequest failed");
967 return WSError::WS_ERROR_IPC_FAILED;
968 }
969 uint32_t size = reply.ReadUint32();
970 for (uint32_t i = 0; i < size; i++) {
971 uint32_t type = reply.ReadUint32();
972 if (type < static_cast<uint32_t>(AvoidAreaType::TYPE_SYSTEM) ||
973 type > static_cast<uint32_t>(AvoidAreaType::TYPE_NAVIGATION_INDICATOR)) {
974 WLOGFE("Read type failed");
975 return WSError::WS_ERROR_IPC_FAILED;
976 }
977 sptr<AvoidArea> area = reply.ReadParcelable<AvoidArea>();
978 if (area == nullptr) {
979 return WSError::WS_ERROR_IPC_FAILED;
980 }
981 avoidAreas[static_cast<AvoidAreaType>(type)] = *area;
982 }
983 uint32_t ret = reply.ReadUint32();
984 return static_cast<WSError>(ret);
985 }
986
RequestSessionBack(bool needMoveToBackground)987 WSError SessionProxy::RequestSessionBack(bool needMoveToBackground)
988 {
989 MessageParcel data;
990 MessageParcel reply;
991 MessageOption option(MessageOption::TF_ASYNC);
992 if (!data.WriteInterfaceToken(GetDescriptor())) {
993 WLOGFE("WriteInterfaceToken failed");
994 return WSError::WS_ERROR_IPC_FAILED;
995 }
996 if (!data.WriteBool(needMoveToBackground)) {
997 WLOGFE("Write needMoveToBackground failed");
998 return WSError::WS_ERROR_IPC_FAILED;
999 }
1000 sptr<IRemoteObject> remote = Remote();
1001 if (remote == nullptr) {
1002 WLOGFE("remote is null");
1003 return WSError::WS_ERROR_IPC_FAILED;
1004 }
1005 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKPRESSED),
1006 data, reply, option) != ERR_NONE) {
1007 WLOGFE("SendRequest failed");
1008 return WSError::WS_ERROR_IPC_FAILED;
1009 }
1010 int32_t ret = reply.ReadInt32();
1011 return static_cast<WSError>(ret);
1012 }
1013
MarkProcessed(int32_t eventId)1014 WSError SessionProxy::MarkProcessed(int32_t eventId)
1015 {
1016 MessageParcel data;
1017 MessageParcel reply;
1018 MessageOption option(MessageOption::TF_ASYNC);
1019 if (!data.WriteInterfaceToken(GetDescriptor())) {
1020 WLOGFE("WriteInterfaceToken failed");
1021 return WSError::WS_ERROR_IPC_FAILED;
1022 }
1023 if (!data.WriteInt32(eventId)) {
1024 WLOGFE("WriteInterfaceToken failed");
1025 return WSError::WS_ERROR_IPC_FAILED;
1026 }
1027 sptr<IRemoteObject> remote = Remote();
1028 if (remote == nullptr) {
1029 WLOGFE("remote is null");
1030 return WSError::WS_ERROR_IPC_FAILED;
1031 }
1032 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_MARK_PROCESSED),
1033 data, reply, option) != ERR_NONE) {
1034 WLOGFE("SendRequest failed");
1035 return WSError::WS_ERROR_IPC_FAILED;
1036 }
1037 int32_t ret = reply.ReadInt32();
1038 return static_cast<WSError>(ret);
1039 }
1040
SetGlobalMaximizeMode(MaximizeMode mode)1041 WSError OHOS::Rosen::SessionProxy::SetGlobalMaximizeMode(MaximizeMode mode)
1042 {
1043 MessageParcel data;
1044 MessageParcel reply;
1045 MessageOption option;
1046 if (!data.WriteInterfaceToken(GetDescriptor())) {
1047 WLOGFE("WriteInterfaceToken failed");
1048 return WSError::WS_ERROR_IPC_FAILED;
1049 }
1050 if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
1051 WLOGFE("Write uint32_t failed");
1052 }
1053 sptr<IRemoteObject> remote = Remote();
1054 if (remote == nullptr) {
1055 WLOGFE("remote is null");
1056 return WSError::WS_ERROR_IPC_FAILED;
1057 }
1058 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_MAXIMIZE_MODE),
1059 data, reply, option) != ERR_NONE) {
1060 WLOGFE("SendRequest failed");
1061 return WSError::WS_ERROR_IPC_FAILED;
1062 }
1063 int32_t ret = reply.ReadInt32();
1064 return static_cast<WSError>(ret);
1065 }
1066
GetGlobalMaximizeMode(MaximizeMode& mode)1067 WSError SessionProxy::GetGlobalMaximizeMode(MaximizeMode& mode)
1068 {
1069 MessageParcel data;
1070 MessageParcel reply;
1071 MessageOption option;
1072 if (!data.WriteInterfaceToken(GetDescriptor())) {
1073 WLOGFE("WriteInterfaceToken failed");
1074 return WSError::WS_ERROR_IPC_FAILED;
1075 }
1076 sptr<IRemoteObject> remote = Remote();
1077 if (remote == nullptr) {
1078 WLOGFE("remote is null");
1079 return WSError::WS_ERROR_IPC_FAILED;
1080 }
1081 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_MAXIMIZE_MODE),
1082 data, reply, option) != ERR_NONE) {
1083 WLOGFE("SendRequest failed");
1084 return WSError::WS_ERROR_IPC_FAILED;
1085 }
1086 mode = static_cast<MaximizeMode>(reply.ReadUint32());
1087 int32_t ret = reply.ReadInt32();
1088 return static_cast<WSError>(ret);
1089 }
1090
1091 /** @note @window.layout */
SetAspectRatio(float ratio)1092 WSError SessionProxy::SetAspectRatio(float ratio)
1093 {
1094 MessageParcel data;
1095 MessageParcel reply;
1096 MessageOption option;
1097 if (!data.WriteInterfaceToken(GetDescriptor())) {
1098 WLOGFE("WriteInterfaceToken failed");
1099 return WSError::WS_ERROR_IPC_FAILED;
1100 }
1101 if (!data.WriteFloat(ratio)) {
1102 WLOGFE("Write ratio failed");
1103 return WSError::WS_ERROR_IPC_FAILED;
1104 }
1105 sptr<IRemoteObject> remote = Remote();
1106 if (remote == nullptr) {
1107 WLOGFE("remote is null");
1108 return WSError::WS_ERROR_IPC_FAILED;
1109 }
1110 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_ASPECT_RATIO),
1111 data, reply, option) != ERR_NONE) {
1112 WLOGFE("SendRequest failed");
1113 return WSError::WS_ERROR_IPC_FAILED;
1114 }
1115 int32_t ret = reply.ReadInt32();
1116 return static_cast<WSError>(ret);
1117 }
1118
UpdateWindowSceneAfterCustomAnimation(bool isAdd)1119 WSError SessionProxy::UpdateWindowSceneAfterCustomAnimation(bool isAdd)
1120 {
1121 MessageParcel data;
1122 MessageParcel reply;
1123 MessageOption option(MessageOption::TF_ASYNC);
1124 if (!data.WriteInterfaceToken(GetDescriptor())) {
1125 WLOGFE("WriteInterfaceToken failed");
1126 return WSError::WS_ERROR_IPC_FAILED;
1127 }
1128 if (!data.WriteBool(isAdd)) {
1129 WLOGFE("Write isAdd failed");
1130 return WSError::WS_ERROR_IPC_FAILED;
1131 }
1132 sptr<IRemoteObject> remote = Remote();
1133 if (remote == nullptr) {
1134 WLOGFE("remote is null");
1135 return WSError::WS_ERROR_IPC_FAILED;
1136 }
1137 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_CUSTOM_ANIMATION),
1138 data, reply, option) != ERR_NONE) {
1139 WLOGFE("SendRequest failed");
1140 return WSError::WS_ERROR_IPC_FAILED;
1141 }
1142 int32_t ret = reply.ReadInt32();
1143 return static_cast<WSError>(ret);
1144 }
1145
SetLandscapeMultiWindow(bool isLandscapeMultiWindow)1146 WSError SessionProxy::SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
1147 {
1148 MessageParcel data;
1149 MessageParcel reply;
1150 MessageOption option(MessageOption::TF_ASYNC);
1151 if (!data.WriteInterfaceToken(GetDescriptor())) {
1152 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "WriteInterfaceToken failed");
1153 return WSError::WS_ERROR_IPC_FAILED;
1154 }
1155 if (!data.WriteBool(isLandscapeMultiWindow)) {
1156 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "Write isLandscapeMultiWindow failed");
1157 return WSError::WS_ERROR_IPC_FAILED;
1158 }
1159 sptr<IRemoteObject> remote = Remote();
1160 if (remote == nullptr) {
1161 WLOGFE("remote is null");
1162 return WSError::WS_ERROR_IPC_FAILED;
1163 }
1164 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW),
1165 data, reply, option) != ERR_NONE) {
1166 WLOGFE("SendRequest failed");
1167 return WSError::WS_ERROR_IPC_FAILED;
1168 }
1169 int32_t ret = reply.ReadInt32();
1170 return static_cast<WSError>(ret);
1171 }
1172
TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want)1173 WSError SessionProxy::TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want)
1174 {
1175 MessageParcel data;
1176 MessageParcel reply;
1177 MessageOption option(MessageOption::TF_ASYNC);
1178 if (!data.WriteInterfaceToken(GetDescriptor())) {
1179 WLOGFE("WriteInterfaceToken failed");
1180 return WSError::WS_ERROR_IPC_FAILED;
1181 }
1182 if (!data.WriteUint32(resultCode)) {
1183 WLOGFE("resultCode write failed.");
1184 return WSError::WS_ERROR_IPC_FAILED;
1185 }
1186 if (!data.WriteParcelable(&want)) {
1187 WLOGFE("want write failed.");
1188 return WSError::WS_ERROR_IPC_FAILED;
1189 }
1190 sptr<IRemoteObject> remote = Remote();
1191 if (remote == nullptr) {
1192 WLOGFE("remote is null");
1193 return WSError::WS_ERROR_IPC_FAILED;
1194 }
1195 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_ABILITY_RESULT),
1196 data, reply, option) != ERR_NONE) {
1197 WLOGFE("SendRequest failed");
1198 return WSError::WS_ERROR_IPC_FAILED;
1199 }
1200 int32_t ret = reply.ReadInt32();
1201 return static_cast<WSError>(ret);
1202 }
1203
TransferExtensionData(const AAFwk::WantParams& wantParams)1204 WSError SessionProxy::TransferExtensionData(const AAFwk::WantParams& wantParams)
1205 {
1206 MessageParcel data;
1207 MessageParcel reply;
1208 MessageOption option(MessageOption::TF_ASYNC);
1209 if (!data.WriteInterfaceToken(GetDescriptor())) {
1210 WLOGFE("WriteInterfaceToken failed");
1211 return WSError::WS_ERROR_IPC_FAILED;
1212 }
1213 if (!data.WriteParcelable(&wantParams)) {
1214 WLOGFE("wantParams write failed.");
1215 return WSError::WS_ERROR_IPC_FAILED;
1216 }
1217 sptr<IRemoteObject> remote = Remote();
1218 if (remote == nullptr) {
1219 WLOGFE("remote is null");
1220 return WSError::WS_ERROR_IPC_FAILED;
1221 }
1222 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_EXTENSION_DATA),
1223 data, reply, option) != ERR_NONE) {
1224 WLOGFE("SendRequest failed");
1225 return WSError::WS_ERROR_IPC_FAILED;
1226 }
1227 int32_t ret = reply.ReadInt32();
1228 return static_cast<WSError>(ret);
1229 }
1230
NotifySyncOn()1231 void SessionProxy::NotifySyncOn()
1232 {
1233 MessageParcel data;
1234 MessageParcel reply;
1235 MessageOption option(MessageOption::TF_ASYNC);
1236 if (!data.WriteInterfaceToken(GetDescriptor())) {
1237 WLOGFE("WriteInterfaceToken failed");
1238 return;
1239 }
1240 sptr<IRemoteObject> remote = Remote();
1241 if (remote == nullptr) {
1242 WLOGFE("remote is null");
1243 return;
1244 }
1245 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_SYNC_ON),
1246 data, reply, option) != ERR_NONE) {
1247 WLOGFE("SendRequest failed");
1248 return;
1249 }
1250 }
1251
NotifyAsyncOn()1252 void SessionProxy::NotifyAsyncOn()
1253 {
1254 MessageParcel data;
1255 MessageParcel reply;
1256 MessageOption option(MessageOption::TF_ASYNC);
1257 if (!data.WriteInterfaceToken(GetDescriptor())) {
1258 WLOGFE("WriteInterfaceToken failed");
1259 return;
1260 }
1261 sptr<IRemoteObject> remote = Remote();
1262 if (remote == nullptr) {
1263 WLOGFE("remote is null");
1264 return;
1265 }
1266 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_ASYNC_ON),
1267 data, reply, option) != ERR_NONE) {
1268 WLOGFE("SendRequest failed");
1269 return;
1270 }
1271 }
1272
NotifyExtensionDied()1273 void SessionProxy::NotifyExtensionDied()
1274 {
1275 TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionDied called.");
1276 MessageParcel data;
1277 MessageParcel reply;
1278 MessageOption option(MessageOption::TF_ASYNC);
1279 if (!data.WriteInterfaceToken(GetDescriptor())) {
1280 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1281 return;
1282 }
1283 sptr<IRemoteObject> remote = Remote();
1284 if (remote == nullptr) {
1285 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1286 return;
1287 }
1288 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED),
1289 data, reply, option) != ERR_NONE) {
1290 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
1291 return;
1292 }
1293 }
1294
NotifyExtensionTimeout(int32_t errorCode)1295 void SessionProxy::NotifyExtensionTimeout(int32_t errorCode)
1296 {
1297 TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionTimeout(errorCode:%{public}d) called.", errorCode);
1298 MessageParcel data;
1299 MessageParcel reply;
1300 MessageOption option(MessageOption::TF_ASYNC);
1301 if (!data.WriteInterfaceToken(GetDescriptor())) {
1302 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1303 return;
1304 }
1305 if (!data.WriteInt32(static_cast<int32_t>(errorCode))) {
1306 TLOGE(WmsLogTag::WMS_UIEXT, "errorCode write failed.");
1307 return;
1308 }
1309 sptr<IRemoteObject> remote = Remote();
1310 if (remote == nullptr) {
1311 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1312 return;
1313 }
1314 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT),
1315 data, reply, option) != ERR_NONE) {
1316 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
1317 }
1318 }
1319
TriggerBindModalUIExtension()1320 void SessionProxy::TriggerBindModalUIExtension()
1321 {
1322 MessageParcel data;
1323 MessageParcel reply;
1324 MessageOption option(MessageOption::TF_SYNC);
1325 if (!data.WriteInterfaceToken(GetDescriptor())) {
1326 WLOGFE("WriteInterfaceToken failed");
1327 return;
1328 }
1329 sptr<IRemoteObject> remote = Remote();
1330 if (remote == nullptr) {
1331 WLOGFE("remote is null");
1332 return;
1333 }
1334 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION),
1335 data, reply, option) != ERR_NONE) {
1336 WLOGFE("SendRequest failed");
1337 return;
1338 }
1339 }
1340
UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)1341 WSError SessionProxy::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)
1342 {
1343 MessageParcel data;
1344 MessageParcel reply;
1345 MessageOption option;
1346 if (!data.WriteInterfaceToken(GetDescriptor())) {
1347 WLOGFE("WriteInterfaceToken failed");
1348 return WSError::WS_ERROR_IPC_FAILED;
1349 }
1350 if (!data.WriteBool(needDefaultAnimationFlag)) {
1351 WLOGFE("wantParams write failed.");
1352 return WSError::WS_ERROR_IPC_FAILED;
1353 }
1354 sptr<IRemoteObject> remote = Remote();
1355 if (remote == nullptr) {
1356 WLOGFE("remote is null");
1357 return WSError::WS_ERROR_IPC_FAILED;
1358 }
1359 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG),
1360 data, reply, option) != ERR_NONE) {
1361 WLOGFE("SendRequest failed");
1362 return WSError::WS_ERROR_IPC_FAILED;
1363 }
1364 int32_t ret = reply.ReadInt32();
1365 return static_cast<WSError>(ret);
1366 }
1367
TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel)1368 WSError SessionProxy::TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
1369 int64_t uiExtensionIdLevel)
1370 {
1371 MessageParcel data;
1372 MessageParcel reply;
1373 MessageOption option(MessageOption::TF_ASYNC);
1374 if (!data.WriteInterfaceToken(GetDescriptor())) {
1375 WLOGFE("WriteInterfaceToken failed");
1376 return WSError::WS_ERROR_IPC_FAILED;
1377 }
1378 Accessibility::AccessibilityEventInfoParcel infoParcel(info);
1379 if (!data.WriteParcelable(&infoParcel)) {
1380 WLOGFE("infoParcel write failed.");
1381 return WSError::WS_ERROR_IPC_FAILED;
1382 }
1383 if (!data.WriteInt64(uiExtensionIdLevel)) {
1384 WLOGFE("idVec write failed.");
1385 return WSError::WS_ERROR_IPC_FAILED;
1386 }
1387 sptr<IRemoteObject> remote = Remote();
1388 if (remote == nullptr) {
1389 WLOGFE("remote is null");
1390 return WSError::WS_ERROR_IPC_FAILED;
1391 }
1392 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT),
1393 data, reply, option) != ERR_NONE) {
1394 WLOGFE("SendRequest failed");
1395 return WSError::WS_ERROR_IPC_FAILED;
1396 }
1397 return WSError::WS_OK;
1398 }
1399
NotifyPiPWindowPrepareClose()1400 void SessionProxy::NotifyPiPWindowPrepareClose()
1401 {
1402 MessageParcel data;
1403 MessageParcel reply;
1404 MessageOption option(MessageOption::TF_ASYNC);
1405 if (!data.WriteInterfaceToken(GetDescriptor())) {
1406 WLOGFE("writeInterfaceToken failed");
1407 return;
1408 }
1409 sptr<IRemoteObject> remote = Remote();
1410 if (remote == nullptr) {
1411 WLOGFE("remote is null");
1412 return;
1413 }
1414 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE),
1415 data, reply, option) != ERR_NONE) {
1416 WLOGFE("SendRequest failed");
1417 return;
1418 }
1419 }
1420
UpdatePiPRect(const Rect& rect, SizeChangeReason reason)1421 WSError SessionProxy::UpdatePiPRect(const Rect& rect, SizeChangeReason reason)
1422 {
1423 MessageParcel data;
1424 MessageParcel reply;
1425 MessageOption option;
1426 if (!data.WriteInterfaceToken(GetDescriptor())) {
1427 WLOGFE("writeInterfaceToken failed");
1428 return WSError::WS_ERROR_IPC_FAILED;
1429 }
1430 if (!data.WriteInt32(rect.posX_)) {
1431 WLOGFE("write posX_ failed.");
1432 return WSError::WS_ERROR_IPC_FAILED;
1433 }
1434 if (!data.WriteInt32(rect.posY_)) {
1435 WLOGFE("write posY_ failed.");
1436 return WSError::WS_ERROR_IPC_FAILED;
1437 }
1438 if (!data.WriteUint32(rect.width_)) {
1439 WLOGFE("write width_ failed.");
1440 return WSError::WS_ERROR_IPC_FAILED;
1441 }
1442 if (!data.WriteUint32(rect.height_)) {
1443 WLOGFE("write height_ failed.");
1444 return WSError::WS_ERROR_IPC_FAILED;
1445 }
1446 if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
1447 WLOGFE("reason write failed.");
1448 return WSError::WS_ERROR_IPC_FAILED;
1449 }
1450 sptr<IRemoteObject> remote = Remote();
1451 if (remote == nullptr) {
1452 WLOGFE("remote is null");
1453 return WSError::WS_ERROR_IPC_FAILED;
1454 }
1455 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_RECT),
1456 data, reply, option) != ERR_NONE) {
1457 WLOGFE("SendRequest failed");
1458 return WSError::WS_ERROR_IPC_FAILED;
1459 }
1460 int32_t ret = reply.ReadInt32();
1461 return static_cast<WSError>(ret);
1462 }
1463
UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status)1464 WSError SessionProxy::UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status)
1465 {
1466 TLOGI(WmsLogTag::WMS_PIP, "controlType:%{public}u, status:%{public}d", controlType, status);
1467 MessageParcel data;
1468 MessageParcel reply;
1469 MessageOption option;
1470 if (!data.WriteInterfaceToken(GetDescriptor())) {
1471 TLOGE(WmsLogTag::WMS_PIP, "writeInterfaceToken failed");
1472 return WSError::WS_ERROR_IPC_FAILED;
1473 }
1474 if (!data.WriteUint32(static_cast<uint32_t>(controlType))) {
1475 TLOGE(WmsLogTag::WMS_PIP, "Write controlType failed");
1476 return WSError::WS_ERROR_IPC_FAILED;
1477 }
1478 if (!data.WriteInt32(static_cast<int32_t>(status))) {
1479 TLOGE(WmsLogTag::WMS_PIP, "write status failed.");
1480 return WSError::WS_ERROR_IPC_FAILED;
1481 }
1482 sptr<IRemoteObject> remote = Remote();
1483 if (remote == nullptr) {
1484 TLOGE(WmsLogTag::WMS_PIP, "remote is null");
1485 return WSError::WS_ERROR_IPC_FAILED;
1486 }
1487 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_CONTROL_STATUS),
1488 data, reply, option) != ERR_NONE) {
1489 TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
1490 return WSError::WS_ERROR_IPC_FAILED;
1491 }
1492 int32_t ret = reply.ReadInt32();
1493 return static_cast<WSError>(ret);
1494 }
1495
SetAutoStartPiP(bool isAutoStart)1496 WSError SessionProxy::SetAutoStartPiP(bool isAutoStart)
1497 {
1498 TLOGD(WmsLogTag::WMS_PIP, "isAutoStart:%{public}u", isAutoStart);
1499 MessageParcel data;
1500 MessageParcel reply;
1501 MessageOption option;
1502 if (!data.WriteInterfaceToken(GetDescriptor())) {
1503 TLOGE(WmsLogTag::WMS_PIP, "writeInterfaceToken failed");
1504 return WSError::WS_ERROR_IPC_FAILED;
1505 }
1506 if (!data.WriteBool(isAutoStart)) {
1507 TLOGE(WmsLogTag::WMS_PIP, "write isAutoStart failed");
1508 return WSError::WS_ERROR_IPC_FAILED;
1509 }
1510 sptr<IRemoteObject> remote = Remote();
1511 if (remote == nullptr) {
1512 TLOGE(WmsLogTag::WMS_PIP, "remote is null");
1513 return WSError::WS_ERROR_IPC_FAILED;
1514 }
1515 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_AUTOSTART_PIP),
1516 data, reply, option) != ERR_NONE) {
1517 TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
1518 return WSError::WS_ERROR_IPC_FAILED;
1519 }
1520 int32_t ret = reply.ReadInt32();
1521 return static_cast<WSError>(ret);
1522 }
1523
ProcessPointDownSession(int32_t posX, int32_t posY)1524 WSError SessionProxy::ProcessPointDownSession(int32_t posX, int32_t posY)
1525 {
1526 MessageParcel data;
1527 MessageParcel reply;
1528 MessageOption option;
1529 if (!data.WriteInterfaceToken(GetDescriptor())) {
1530 WLOGFE("writeInterfaceToken failed");
1531 return WSError::WS_ERROR_IPC_FAILED;
1532 }
1533 if (!data.WriteInt32(posX)) {
1534 WLOGFE("width poX failed.");
1535 return WSError::WS_ERROR_IPC_FAILED;
1536 }
1537 if (!data.WriteInt32(posY)) {
1538 WLOGFE("width posY failed.");
1539 return WSError::WS_ERROR_IPC_FAILED;
1540 }
1541 sptr<IRemoteObject> remote = Remote();
1542 if (remote == nullptr) {
1543 WLOGFE("remote is null");
1544 return WSError::WS_ERROR_IPC_FAILED;
1545 }
1546 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_PROCESS_POINT_DOWN_SESSION),
1547 data, reply, option) != ERR_NONE) {
1548 WLOGFE("SendRequest failed");
1549 return WSError::WS_ERROR_IPC_FAILED;
1550 }
1551 return static_cast<WSError>(reply.ReadInt32());
1552 }
1553
SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)1554 WSError SessionProxy::SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
1555 {
1556 MessageParcel data;
1557 MessageParcel reply;
1558 MessageOption option;
1559 if (!data.WriteInterfaceToken(GetDescriptor())) {
1560 WLOGFE("writeInterfaceToken failed");
1561 return WSError::WS_ERROR_IPC_FAILED;
1562 }
1563 if (!pointerEvent->WriteToParcel(data)) {
1564 WLOGFE("width pointerEvent failed.");
1565 return WSError::WS_ERROR_IPC_FAILED;
1566 }
1567 sptr<IRemoteObject> remote = Remote();
1568 if (remote == nullptr) {
1569 WLOGFE("remote is null");
1570 return WSError::WS_ERROR_IPC_FAILED;
1571 }
1572 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SEND_POINTEREVENT_FOR_MOVE_DRAG),
1573 data, reply, option) != ERR_NONE) {
1574 WLOGFE("SendRequest failed");
1575 return WSError::WS_ERROR_IPC_FAILED;
1576 }
1577 return static_cast<WSError>(reply.ReadInt32());
1578 }
1579
SetSystemWindowEnableDrag(bool enableDrag)1580 WMError SessionProxy::SetSystemWindowEnableDrag(bool enableDrag)
1581 {
1582 TLOGI(WmsLogTag::WMS_LAYOUT, "enableDrag: %{public}d", enableDrag);
1583 MessageParcel data;
1584 MessageParcel reply;
1585 MessageOption option(MessageOption::TF_SYNC);
1586 if (!data.WriteInterfaceToken(GetDescriptor())) {
1587 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1588 return WMError::WM_ERROR_IPC_FAILED;
1589 }
1590 if (!data.WriteBool(enableDrag)) {
1591 TLOGE(WmsLogTag::WMS_LAYOUT, "write enableDrag failed");
1592 return WMError::WM_ERROR_IPC_FAILED;
1593 }
1594 sptr<IRemoteObject> remote = Remote();
1595 if (remote == nullptr) {
1596 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1597 return WMError::WM_ERROR_IPC_FAILED;
1598 }
1599 if (remote->SendRequest(
1600 static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_SYSTEM_DRAG_ENABLE),
1601 data, reply, option) != ERR_NONE) {
1602 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1603 return WMError::WM_ERROR_IPC_FAILED;
1604 }
1605 int32_t ret = reply.ReadInt32();
1606 return static_cast<WMError>(ret);
1607 }
1608
GetStartMoveFlag(bool& isMoving)1609 WSError SessionProxy::GetStartMoveFlag(bool& isMoving)
1610 {
1611 MessageParcel data;
1612 MessageParcel reply;
1613 MessageOption option;
1614 if (!data.WriteInterfaceToken(GetDescriptor())) {
1615 TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
1616 return WSError::WS_ERROR_IPC_FAILED;
1617 }
1618 sptr<IRemoteObject> remote = Remote();
1619 if (remote == nullptr) {
1620 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1621 return WSError::WS_ERROR_IPC_FAILED;
1622 }
1623 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_START_MOVE_FLAG),
1624 data, reply, option) != ERR_NONE) {
1625 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
1626 return WSError::WS_ERROR_IPC_FAILED;
1627 }
1628 isMoving = reply.ReadBool();
1629 int32_t ret = reply.ReadInt32();
1630 return static_cast<WSError>(ret);
1631 }
1632
UpdateRectChangeListenerRegistered(bool isRegister)1633 WSError SessionProxy::UpdateRectChangeListenerRegistered(bool isRegister)
1634 {
1635 MessageParcel data;
1636 MessageParcel reply;
1637 MessageOption option(MessageOption::TF_SYNC);
1638 if (!data.WriteInterfaceToken(GetDescriptor())) {
1639 TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1640 return WSError::WS_ERROR_IPC_FAILED;
1641 }
1642 if (!data.WriteBool(isRegister)) {
1643 TLOGE(WmsLogTag::WMS_LAYOUT, "write isRegister failed");
1644 return WSError::WS_ERROR_IPC_FAILED;
1645 }
1646 sptr<IRemoteObject> remote = Remote();
1647 if (remote == nullptr) {
1648 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1649 return WSError::WS_ERROR_IPC_FAILED;
1650 }
1651 if (remote->SendRequest(
1652 static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED),
1653 data, reply, option) != ERR_NONE) {
1654 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1655 return WSError::WS_ERROR_IPC_FAILED;
1656 }
1657 int32_t ret = reply.ReadInt32();
1658 return static_cast<WSError>(ret);
1659 }
1660
SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent)1661 WSError SessionProxy::SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent)
1662 {
1663 MessageParcel data;
1664 MessageParcel reply;
1665 MessageOption option(MessageOption::TF_ASYNC);
1666 if (!data.WriteInterfaceToken(GetDescriptor())) {
1667 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
1668 return WSError::WS_ERROR_IPC_FAILED;
1669 }
1670 if (!data.WriteUint32(static_cast<uint32_t>(gravity))) {
1671 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write gravity failed");
1672 return WSError::WS_ERROR_IPC_FAILED;
1673 }
1674 if (!data.WriteUint32(percent)) {
1675 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write percent failed");
1676 return WSError::WS_ERROR_IPC_FAILED;
1677 }
1678 sptr<IRemoteObject> remote = Remote();
1679 if (remote == nullptr) {
1680 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1681 return WSError::WS_ERROR_IPC_FAILED;
1682 }
1683 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_KEYBOARD_SESSION_GRAVITY),
1684 data, reply, option) != ERR_NONE) {
1685 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
1686 return WSError::WS_ERROR_IPC_FAILED;
1687 }
1688 return static_cast<WSError>(reply.ReadInt32());
1689 }
1690
SetCallingSessionId(const uint32_t callingSessionId)1691 void SessionProxy::SetCallingSessionId(const uint32_t callingSessionId)
1692 {
1693 MessageParcel data;
1694 MessageParcel reply;
1695 MessageOption option;
1696 if (!data.WriteInterfaceToken(GetDescriptor())) {
1697 TLOGE(WmsLogTag::WMS_KEYBOARD, "writeInterfaceToken failed");
1698 return;
1699 }
1700 if (!data.WriteUint32(callingSessionId)) {
1701 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write callingSessionId failed.");
1702 return;
1703 }
1704 sptr<IRemoteObject> remote = Remote();
1705 if (remote == nullptr) {
1706 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1707 return;
1708 }
1709 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CALLING_SESSION_ID),
1710 data, reply, option) != ERR_NONE) {
1711 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
1712 return;
1713 }
1714 }
1715
SetCustomDecorHeight(int32_t height)1716 void SessionProxy::SetCustomDecorHeight(int32_t height)
1717 {
1718 MessageParcel data;
1719 MessageParcel reply;
1720 MessageOption option(MessageOption::TF_ASYNC);
1721 if (!data.WriteInterfaceToken(GetDescriptor())) {
1722 TLOGE(WmsLogTag::WMS_LAYOUT, "writeInterfaceToken failed");
1723 return;
1724 }
1725 if (!data.WriteInt32(height)) {
1726 TLOGE(WmsLogTag::WMS_LAYOUT, "Write height failed.");
1727 return;
1728 }
1729 sptr<IRemoteObject> remote = Remote();
1730 if (remote == nullptr) {
1731 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1732 return;
1733 }
1734 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CUSTOM_DECOR_HEIGHT),
1735 data, reply, option) != ERR_NONE) {
1736 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1737 return;
1738 }
1739 }
1740
AdjustKeyboardLayout(const KeyboardLayoutParams& params)1741 WSError SessionProxy::AdjustKeyboardLayout(const KeyboardLayoutParams& params)
1742 {
1743 MessageParcel data;
1744 MessageParcel reply;
1745 MessageOption option(MessageOption::TF_ASYNC);
1746 if (!data.WriteInterfaceToken(GetDescriptor())) {
1747 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
1748 return WSError::WS_ERROR_IPC_FAILED;
1749 }
1750 if (!data.WriteParcelable(¶ms)) {
1751 TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboard layout params write failed");
1752 return WSError::WS_ERROR_IPC_FAILED;
1753 }
1754 sptr<IRemoteObject> remote = Remote();
1755 if (remote == nullptr) {
1756 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1757 return WSError::WS_ERROR_IPC_FAILED;
1758 }
1759 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_ADJUST_KEYBOARD_LAYOUT),
1760 data, reply, option) != ERR_NONE) {
1761 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
1762 return WSError::WS_ERROR_IPC_FAILED;
1763 }
1764 return static_cast<WSError>(reply.ReadInt32());
1765 }
1766
UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action)1767 WMError SessionProxy::UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
1768 WSPropertyChangeAction action)
1769 {
1770 MessageParcel data;
1771 MessageParcel reply;
1772 MessageOption option(MessageOption::TF_SYNC);
1773 if (action == WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON) {
1774 option.SetFlags(MessageOption::TF_ASYNC);
1775 }
1776 if (!data.WriteInterfaceToken(GetDescriptor())) {
1777 TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
1778 return WMError::WM_ERROR_IPC_FAILED;
1779 }
1780 if (!data.WriteUint32(static_cast<uint32_t>(action))) {
1781 TLOGE(WmsLogTag::DEFAULT, "Write PropertyChangeAction failed");
1782 return WMError::WM_ERROR_IPC_FAILED;
1783 }
1784 if (property) {
1785 if (!data.WriteBool(true) || !property->Write(data, action)) {
1786 TLOGE(WmsLogTag::DEFAULT, "Write property failed");
1787 return WMError::WM_ERROR_IPC_FAILED;
1788 }
1789 } else {
1790 if (!data.WriteBool(false)) {
1791 TLOGE(WmsLogTag::DEFAULT, "Write property failed");
1792 return WMError::WM_ERROR_IPC_FAILED;
1793 }
1794 }
1795
1796 sptr<IRemoteObject> remote = Remote();
1797 if (remote == nullptr) {
1798 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1799 return WMError::WM_ERROR_IPC_FAILED;
1800 }
1801 if (remote->SendRequest(static_cast<uint32_t>(
1802 SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_PROPERTY),
1803 data, reply, option) != ERR_NONE) {
1804 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
1805 return WMError::WM_ERROR_IPC_FAILED;
1806 }
1807 int32_t ret = reply.ReadInt32();
1808 return static_cast<WMError>(ret);
1809 }
1810
GetAppForceLandscapeConfig(AppForceLandscapeConfig& config)1811 WMError SessionProxy::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config)
1812 {
1813 MessageParcel data;
1814 MessageParcel reply;
1815 MessageOption option(MessageOption::TF_SYNC);
1816 if (!data.WriteInterfaceToken(GetDescriptor())) {
1817 TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
1818 return WMError::WM_ERROR_IPC_FAILED;
1819 }
1820 sptr<IRemoteObject> remote = Remote();
1821 if (remote == nullptr) {
1822 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1823 return WMError::WM_ERROR_IPC_FAILED;
1824 }
1825 if (remote->SendRequest(static_cast<uint32_t>(
1826 SessionInterfaceCode::TRANS_ID_GET_FORCE_LANDSCAPE_CONFIG),
1827 data, reply, option) != ERR_NONE) {
1828 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
1829 return WMError::WM_ERROR_IPC_FAILED;
1830 }
1831 sptr<AppForceLandscapeConfig> replyConfig = reply.ReadParcelable<AppForceLandscapeConfig>();
1832 if (replyConfig) {
1833 config = *replyConfig;
1834 }
1835 int32_t ret = reply.ReadInt32();
1836 return static_cast<WMError>(ret);
1837 }
1838
GetStatusBarHeight()1839 int32_t SessionProxy::GetStatusBarHeight()
1840 {
1841 MessageParcel data;
1842 MessageParcel reply;
1843 MessageOption option(MessageOption::TF_SYNC);
1844 int32_t height = 0;
1845 if (!data.WriteInterfaceToken(GetDescriptor())) {
1846 TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
1847 return height;
1848 }
1849 sptr<IRemoteObject> remote = Remote();
1850 if (remote == nullptr) {
1851 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1852 return height;
1853 }
1854 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_STATUSBAR_HEIGHT),
1855 data, reply, option) != ERR_NONE) {
1856 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
1857 return height;
1858 }
1859 height = reply.ReadInt32();
1860 return height;
1861 }
1862
SetDialogSessionBackGestureEnabled(bool isEnabled)1863 WSError SessionProxy::SetDialogSessionBackGestureEnabled(bool isEnabled)
1864 {
1865 MessageParcel data;
1866 MessageParcel reply;
1867 MessageOption option(MessageOption::TF_SYNC);
1868 if (!data.WriteInterfaceToken(GetDescriptor())) {
1869 TLOGE(WmsLogTag::WMS_DIALOG, "WriteInterfaceToken failed");
1870 return WSError::WS_ERROR_IPC_FAILED;
1871 }
1872 if (!data.WriteBool(isEnabled)) {
1873 TLOGE(WmsLogTag::WMS_DIALOG, "Write isEnabled failed");
1874 return WSError::WS_ERROR_IPC_FAILED;
1875 }
1876 sptr<IRemoteObject> remote = Remote();
1877 if (remote == nullptr) {
1878 TLOGE(WmsLogTag::WMS_DIALOG, "remote is null");
1879 return WSError::WS_ERROR_IPC_FAILED;
1880 }
1881 if (remote->SendRequest(
1882 static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_DIALOG_SESSION_BACKGESTURE_ENABLE),
1883 data, reply, option) != ERR_NONE) {
1884 TLOGE(WmsLogTag::WMS_DIALOG, "SendRequest failed");
1885 return WSError::WS_ERROR_IPC_FAILED;
1886 }
1887 int32_t ret = reply.ReadInt32();
1888 return static_cast<WSError>(ret);
1889 }
1890
RequestFocus(bool isFocused)1891 WSError SessionProxy::RequestFocus(bool isFocused)
1892 {
1893 MessageParcel data;
1894 MessageParcel reply;
1895 MessageOption option(MessageOption::TF_SYNC);
1896 if (!data.WriteInterfaceToken(GetDescriptor())) {
1897 TLOGE(WmsLogTag::WMS_FOCUS, "WriteInterfaceToken failed");
1898 return WSError::WS_ERROR_IPC_FAILED;
1899 }
1900 if (!data.WriteBool(isFocused)) {
1901 TLOGE(WmsLogTag::WMS_FOCUS, "Write isFocused failed");
1902 return WSError::WS_ERROR_IPC_FAILED;
1903 }
1904 sptr<IRemoteObject> remote = Remote();
1905 if (remote == nullptr) {
1906 TLOGE(WmsLogTag::WMS_FOCUS, "remote is null");
1907 return WSError::WS_ERROR_IPC_FAILED;
1908 }
1909 if (remote->SendRequest(
1910 static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_REQUEST_FOCUS),
1911 data, reply, option) != ERR_NONE) {
1912 TLOGE(WmsLogTag::WMS_FOCUS, "SendRequest failed");
1913 return WSError::WS_ERROR_IPC_FAILED;
1914 }
1915 int32_t ret = reply.ReadInt32();
1916 return static_cast<WSError>(ret);
1917 }
1918
SetFocusableOnShow(bool isFocusableOnShow)1919 WSError SessionProxy::SetFocusableOnShow(bool isFocusableOnShow)
1920 {
1921 MessageParcel data;
1922 MessageParcel reply;
1923 MessageOption option(MessageOption::TF_SYNC);
1924 if (!data.WriteInterfaceToken(GetDescriptor())) {
1925 TLOGE(WmsLogTag::WMS_FOCUS, "WriteInterfaceToken failed");
1926 return WSError::WS_ERROR_IPC_FAILED;
1927 }
1928 if (!data.WriteBool(isFocusableOnShow)) {
1929 TLOGE(WmsLogTag::WMS_FOCUS, "Write isFocused failed");
1930 return WSError::WS_ERROR_IPC_FAILED;
1931 }
1932 sptr<IRemoteObject> remote = Remote();
1933 if (remote == nullptr) {
1934 TLOGE(WmsLogTag::WMS_FOCUS, "remote is null");
1935 return WSError::WS_ERROR_IPC_FAILED;
1936 }
1937 if (remote->SendRequest(
1938 static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_FOCUSABLE_ON_SHOW),
1939 data, reply, option) != ERR_NONE) {
1940 TLOGE(WmsLogTag::WMS_FOCUS, "SendRequest failed");
1941 return WSError::WS_ERROR_IPC_FAILED;
1942 }
1943 int32_t ret = reply.ReadInt32();
1944 return static_cast<WSError>(ret);
1945 }
1946
NotifyExtensionEventAsync(uint32_t notifyEvent)1947 void SessionProxy::NotifyExtensionEventAsync(uint32_t notifyEvent)
1948 {
1949 MessageParcel data;
1950 MessageParcel reply;
1951 MessageOption option(MessageOption::TF_ASYNC);
1952 if (!data.WriteInterfaceToken(GetDescriptor())) {
1953 TLOGE(WmsLogTag::WMS_DIALOG, "WriteInterfaceToken failed");
1954 return;
1955 }
1956 if (!data.WriteUint32(notifyEvent)) {
1957 TLOGE(WmsLogTag::WMS_DIALOG, "Write notifyEvent failed");
1958 return;
1959 }
1960 sptr<IRemoteObject> remote = Remote();
1961 if (remote == nullptr) {
1962 TLOGE(WmsLogTag::WMS_DIALOG, "remote is null");
1963 return;
1964 }
1965 if (remote->SendRequest(
1966 static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_EVENT_ASYNC),
1967 data, reply, option) != ERR_NONE) {
1968 TLOGE(WmsLogTag::WMS_DIALOG, "SendRequest failed");
1969 return;
1970 }
1971 }
1972
SetGestureBackEnabled(bool isEnabled)1973 WMError SessionProxy::SetGestureBackEnabled(bool isEnabled)
1974 {
1975 MessageParcel data;
1976 MessageParcel reply;
1977 MessageOption option(MessageOption::TF_SYNC);
1978 if (!data.WriteInterfaceToken(GetDescriptor())) {
1979 TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
1980 return WMError::WM_ERROR_IPC_FAILED;
1981 }
1982 if (!data.WriteBool(isEnabled)) {
1983 TLOGE(WmsLogTag::WMS_IMMS, "Write isEnabled failed");
1984 return WMError::WM_ERROR_IPC_FAILED;
1985 }
1986 sptr<IRemoteObject> remote = Remote();
1987 if (remote == nullptr) {
1988 TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
1989 return WMError::WM_ERROR_IPC_FAILED;
1990 }
1991 if (remote->SendRequest(
1992 static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_GESTURE_BACK_ENABLE),
1993 data, reply, option) != ERR_NONE) {
1994 TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed");
1995 return WMError::WM_ERROR_IPC_FAILED;
1996 }
1997 int32_t ret = reply.ReadInt32();
1998 return static_cast<WMError>(ret);
1999 }
2000
OnSessionModalTypeChange(SubWindowModalType subWindowModalType)2001 WSError SessionProxy::OnSessionModalTypeChange(SubWindowModalType subWindowModalType)
2002 {
2003 MessageParcel data;
2004 MessageParcel reply;
2005 MessageOption option(MessageOption::TF_ASYNC);
2006 if (!data.WriteInterfaceToken(GetDescriptor())) {
2007 TLOGE(WmsLogTag::WMS_HIERARCHY, "WriteInterfaceToken failed");
2008 return WSError::WS_ERROR_IPC_FAILED;
2009 }
2010 if (!data.WriteUint32(static_cast<uint32_t>(subWindowModalType))) {
2011 TLOGE(WmsLogTag::WMS_HIERARCHY, "Write subWindowModalType failed");
2012 return WSError::WS_ERROR_IPC_FAILED;
2013 }
2014 sptr<IRemoteObject> remote = Remote();
2015 if (remote == nullptr) {
2016 TLOGE(WmsLogTag::WMS_HIERARCHY, "remote is null");
2017 return WSError::WS_ERROR_IPC_FAILED;
2018 }
2019 if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_MODAL_TYPE_CHANGE),
2020 data, reply, option) != ERR_NONE) {
2021 TLOGE(WmsLogTag::WMS_HIERARCHY, "SendRequest failed");
2022 return WSError::WS_ERROR_IPC_FAILED;
2023 }
2024 int32_t ret = reply.ReadInt32();
2025 return static_cast<WSError>(ret);
2026 }
2027 } // namespace OHOS::Rosen
2028