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