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