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