• 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 <transaction/rs_transaction.h>
22 #include <ui/rs_surface_node.h>
23 #include <ui/rs_canvas_node.h>
24 
25 #include "parcel/accessibility_event_info_parcel.h"
26 #include "process_options.h"
27 #include "start_window_option.h"
28 #include "want.h"
29 #include "key_event.h"
30 #include "pointer_event.h"
31 #include "process_options.h"
32 #include "session/host/include/zidl/session_ipc_interface_code.h"
33 #include "window_manager_hilog.h"
34 namespace OHOS::Rosen {
35 namespace {
36 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionProxy" };
37 constexpr int32_t MAX_IPC_CAPACITY_FOR_WANT = 216 * 1024;
38 
WriteAbilitySessionInfoBasic(MessageParcel & data,sptr<AAFwk::SessionInfo> abilitySessionInfo)39 bool WriteAbilitySessionInfoBasic(MessageParcel& data, sptr<AAFwk::SessionInfo> abilitySessionInfo)
40 {
41     if (abilitySessionInfo == nullptr) {
42         WLOGFE("abilitySessionInfo is null");
43         return false;
44     }
45     if (data.GetMaxCapacity() < MAX_IPC_CAPACITY_FOR_WANT) {
46         data.SetMaxCapacity(MAX_IPC_CAPACITY_FOR_WANT);
47     }
48     if (!data.WriteParcelable(&(abilitySessionInfo->want)) ||
49         !data.WriteInt32(abilitySessionInfo->requestCode) ||
50         !data.WriteInt32(abilitySessionInfo->persistentId) ||
51         !data.WriteInt32(static_cast<uint32_t>(abilitySessionInfo->state)) ||
52         !data.WriteInt64(abilitySessionInfo->uiAbilityId) ||
53         !data.WriteInt32(abilitySessionInfo->callingTokenId) ||
54         !data.WriteInt32(abilitySessionInfo->requestId) ||
55         !data.WriteBool(abilitySessionInfo->reuse) ||
56         !data.WriteParcelable(abilitySessionInfo->processOptions.get())) {
57         return false;
58     }
59     return true;
60 }
61 } // namespace
62 
Foreground(sptr<WindowSessionProperty> property,bool isFromClient,const std::string & identityToken)63 WSError SessionProxy::Foreground(
64     sptr<WindowSessionProperty> property, bool isFromClient, const std::string& identityToken)
65 {
66     MessageParcel data;
67     MessageParcel reply;
68     MessageOption option(MessageOption::TF_SYNC);
69     if (!data.WriteInterfaceToken(GetDescriptor())) {
70         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
71         return WSError::WS_ERROR_IPC_FAILED;
72     }
73 
74     if (property) {
75         if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
76             TLOGE(WmsLogTag::WMS_LIFE, "Write property failed");
77             return WSError::WS_ERROR_IPC_FAILED;
78         }
79     } else {
80         if (!data.WriteBool(false)) {
81             TLOGE(WmsLogTag::WMS_LIFE, "Write property failed");
82             return WSError::WS_ERROR_IPC_FAILED;
83         }
84     }
85     if (!data.WriteBool(isFromClient)) {
86         TLOGE(WmsLogTag::WMS_LIFE, "Write isFromClient failed");
87         return WSError::WS_ERROR_IPC_FAILED;
88     }
89     if (!data.WriteString(identityToken)) {
90         TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
91         return WSError::WS_ERROR_IPC_FAILED;
92     }
93     sptr<IRemoteObject> remote = Remote();
94     if (remote == nullptr) {
95         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
96         return WSError::WS_ERROR_IPC_FAILED;
97     }
98     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_FOREGROUND),
99         data, reply, option);
100     if (sendCode != ERR_NONE) {
101         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed, code: %{public}d", sendCode);
102         return WSError::WS_ERROR_IPC_FAILED;
103     }
104     int32_t ret = reply.ReadInt32();
105     return static_cast<WSError>(ret);
106 }
107 
Background(bool isFromClient,const std::string & identityToken)108 WSError SessionProxy::Background(bool isFromClient, const std::string& identityToken)
109 {
110     MessageParcel data;
111     MessageParcel reply;
112     MessageOption option(MessageOption::TF_ASYNC);
113     if (!data.WriteInterfaceToken(GetDescriptor())) {
114         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
115         return WSError::WS_ERROR_IPC_FAILED;
116     }
117     if (!data.WriteBool(isFromClient)) {
118         TLOGE(WmsLogTag::WMS_LIFE, "Write isFromClient failed");
119         return WSError::WS_ERROR_IPC_FAILED;
120     }
121     if (!data.WriteString(identityToken)) {
122         TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
123         return WSError::WS_ERROR_IPC_FAILED;
124     }
125     sptr<IRemoteObject> remote = Remote();
126     if (remote == nullptr) {
127         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
128         return WSError::WS_ERROR_IPC_FAILED;
129     }
130     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKGROUND),
131         data, reply, option);
132     if (sendCode != ERR_NONE) {
133         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed, code: %{public}d", sendCode);
134         return WSError::WS_ERROR_IPC_FAILED;
135     }
136     int32_t ret = reply.ReadInt32();
137     return static_cast<WSError>(ret);
138 }
139 
Show(sptr<WindowSessionProperty> property)140 WSError SessionProxy::Show(sptr<WindowSessionProperty> property)
141 {
142     MessageParcel data;
143     MessageParcel reply;
144     MessageOption option(MessageOption::TF_SYNC);
145     if (!data.WriteInterfaceToken(GetDescriptor())) {
146         WLOGFE("WriteInterfaceToken failed");
147         return WSError::WS_ERROR_IPC_FAILED;
148     }
149 
150     if (property) {
151         if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
152             WLOGFE("Write property failed");
153             return WSError::WS_ERROR_IPC_FAILED;
154         }
155     } else {
156         if (!data.WriteBool(false)) {
157             WLOGFE("Write property failed");
158             return WSError::WS_ERROR_IPC_FAILED;
159         }
160     }
161 
162     sptr<IRemoteObject> remote = Remote();
163     if (remote == nullptr) {
164         WLOGFE("remote is null");
165         return WSError::WS_ERROR_IPC_FAILED;
166     }
167     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SHOW),
168         data, reply, option) != ERR_NONE) {
169         WLOGFE("SendRequest failed");
170         return WSError::WS_ERROR_IPC_FAILED;
171     }
172     int32_t ret = reply.ReadInt32();
173     return static_cast<WSError>(ret);
174 }
175 
Hide()176 WSError SessionProxy::Hide()
177 {
178     MessageParcel data;
179     MessageParcel reply;
180     MessageOption option(MessageOption::TF_SYNC);
181     if (!data.WriteInterfaceToken(GetDescriptor())) {
182         WLOGFE("WriteInterfaceToken failed");
183         return WSError::WS_ERROR_IPC_FAILED;
184     }
185 
186     sptr<IRemoteObject> remote = Remote();
187     if (remote == nullptr) {
188         WLOGFE("remote is null");
189         return WSError::WS_ERROR_IPC_FAILED;
190     }
191     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_HIDE),
192         data, reply, option) != ERR_NONE) {
193         WLOGFE("SendRequest failed");
194         return WSError::WS_ERROR_IPC_FAILED;
195     }
196     int32_t ret = reply.ReadInt32();
197     return static_cast<WSError>(ret);
198 }
199 
Disconnect(bool isFromClient,const std::string & identityToken)200 WSError SessionProxy::Disconnect(bool isFromClient, const std::string& identityToken)
201 {
202     MessageParcel data;
203     MessageParcel reply;
204     MessageOption option(MessageOption::TF_ASYNC);
205     if (!data.WriteInterfaceToken(GetDescriptor())) {
206         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
207         return WSError::WS_ERROR_IPC_FAILED;
208     }
209 
210     if (!data.WriteBool(isFromClient)) {
211         TLOGE(WmsLogTag::WMS_LIFE, "Write isFromClient failed");
212         return WSError::WS_ERROR_IPC_FAILED;
213     }
214     if (!data.WriteString(identityToken)) {
215         TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
216         return WSError::WS_ERROR_IPC_FAILED;
217     }
218     sptr<IRemoteObject> remote = Remote();
219     if (remote == nullptr) {
220         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
221         return WSError::WS_ERROR_IPC_FAILED;
222     }
223     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DISCONNECT),
224         data, reply, option);
225     if (sendCode != ERR_NONE) {
226         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed, code: %{public}d", sendCode);
227         return WSError::WS_ERROR_IPC_FAILED;
228     }
229     int32_t ret = reply.ReadInt32();
230     return static_cast<WSError>(ret);
231 }
232 
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)233 WSError SessionProxy::Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
234     const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
235     sptr<WindowSessionProperty> property, sptr<IRemoteObject> token,
236     const std::string& identityToken)
237 {
238     MessageParcel data;
239     MessageParcel reply;
240     MessageOption option(MessageOption::TF_SYNC);
241     if (!data.WriteInterfaceToken(GetDescriptor())) {
242         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
243         return WSError::WS_ERROR_IPC_FAILED;
244     }
245     if (!data.WriteRemoteObject(sessionStage->AsObject())) {
246         TLOGE(WmsLogTag::WMS_LIFE, "Write ISessionStage failed");
247         return WSError::WS_ERROR_IPC_FAILED;
248     }
249     if (!data.WriteRemoteObject(eventChannel->AsObject())) {
250         TLOGE(WmsLogTag::WMS_LIFE, "Write IWindowEventChannel failed");
251         return WSError::WS_ERROR_IPC_FAILED;
252     }
253     if (!surfaceNode || !surfaceNode->Marshalling(data)) {
254         TLOGE(WmsLogTag::WMS_LIFE, "Write surfaceNode failed");
255         return WSError::WS_ERROR_IPC_FAILED;
256     }
257     if (property) {
258         if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
259             TLOGE(WmsLogTag::WMS_LIFE, "Write property failed");
260             return WSError::WS_ERROR_IPC_FAILED;
261         }
262     } else {
263         if (!data.WriteBool(false)) {
264             TLOGE(WmsLogTag::WMS_LIFE, "Write property failed");
265             return WSError::WS_ERROR_IPC_FAILED;
266         }
267     }
268     if (token != nullptr) {
269         if (!data.WriteRemoteObject(token)) {
270             TLOGE(WmsLogTag::WMS_LIFE, "Write abilityToken failed");
271             return WSError::WS_ERROR_IPC_FAILED;
272         }
273     }
274     if (!data.WriteString(identityToken)) {
275         TLOGE(WmsLogTag::WMS_LIFE, "Write identityToken failed");
276         return WSError::WS_ERROR_IPC_FAILED;
277     }
278     sptr<IRemoteObject> remote = Remote();
279     if (remote == nullptr) {
280         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
281         return WSError::WS_ERROR_IPC_FAILED;
282     }
283     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_CONNECT),
284         data, reply, option);
285     if (sendCode != ERR_NONE) {
286         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed, code: %{public}d", sendCode);
287         return WSError::WS_ERROR_IPC_FAILED;
288     }
289     sptr<SystemSessionConfig> config = reply.ReadParcelable<SystemSessionConfig>();
290     if (config) {
291         systemConfig = *config;
292     }
293     if (property) {
294         property->SetPersistentId(reply.ReadInt32());
295         property->SetDisplayId(reply.ReadUint64());
296         bool needUpdate = reply.ReadBool();
297         property->SetIsNeedUpdateWindowMode(needUpdate);
298         if (needUpdate) {
299             property->SetWindowMode(static_cast<WindowMode>(reply.ReadUint32()));
300         }
301         Rect preRect = property->GetWindowRect();
302         Rect rect = { reply.ReadInt32(), reply.ReadInt32(), reply.ReadUint32(), reply.ReadUint32() };
303         TLOGI(WmsLogTag::WMS_LAYOUT, "updateRect when connect."
304             "preRect:[%{public}d,%{public}d,%{public}u,%{public}u]"
305             "rect:[%{public}d,%{public}d,%{public}u,%{public}u]",
306             preRect.posX_, preRect.posY_, preRect.width_, preRect.height_,
307             rect.posX_, rect.posY_, rect.width_, rect.height_);
308         if (preRect.IsUninitializedRect() && !rect.IsUninitializedRect()) {
309             property->SetWindowRect(rect);
310         }
311         property->SetCollaboratorType(reply.ReadInt32());
312         property->SetFullScreenStart(reply.ReadBool());
313         uint32_t size = reply.ReadUint32();
314         if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) {
315             std::vector<AppExecFwk::SupportWindowMode> supportedWindowModes;
316             supportedWindowModes.reserve(size);
317             for (uint32_t i = 0; i < size; i++) {
318                 supportedWindowModes.push_back(
319                     static_cast<AppExecFwk::SupportWindowMode>(reply.ReadInt32()));
320             }
321             property->SetSupportedWindowModes(supportedWindowModes);
322         }
323         WindowSizeLimits windowSizeLimits = { reply.ReadUint32(), reply.ReadUint32(),
324                                               reply.ReadUint32(), reply.ReadUint32() };
325         property->SetWindowSizeLimits(windowSizeLimits);
326         property->SetIsAppSupportPhoneInPc(reply.ReadBool());
327         property->SetIsPcAppInPad(reply.ReadBool());
328         property->SetRequestedOrientation(static_cast<Orientation>(reply.ReadUint32()));
329         property->SetUserRequestedOrientation(static_cast<Orientation>(reply.ReadUint32()));
330         property->SetAppInstanceKey(reply.ReadString());
331         property->SetDragEnabled(reply.ReadBool());
332         property->SetIsAtomicService(reply.ReadBool());
333         property->SetIsAbilityHook(reply.ReadBool());
334         property->SetPcAppInpadCompatibleMode(reply.ReadBool());
335         property->SetPcAppInpadSpecificSystemBarInvisible(reply.ReadBool());
336         property->SetPcAppInpadOrientationLandscape(reply.ReadBool());
337         property->SetCompatibleModeProperty(reply.ReadParcelable<CompatibleModeProperty>());
338         property->SetUseControlState(reply.ReadBool());
339         property->SetAncoRealBundleName(reply.ReadString());
340     }
341     int32_t ret = reply.ReadInt32();
342     return static_cast<WSError>(ret);
343 }
344 
DrawingCompleted()345 WSError SessionProxy::DrawingCompleted()
346 {
347     MessageParcel data;
348     MessageParcel reply;
349     MessageOption option;
350     if (!data.WriteInterfaceToken(GetDescriptor())) {
351         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
352         return WSError::WS_ERROR_IPC_FAILED;
353     }
354 
355     sptr<IRemoteObject> remote = Remote();
356     if (remote == nullptr) {
357         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
358         return WSError::WS_ERROR_IPC_FAILED;
359     }
360     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DRAWING_COMPLETED),
361         data, reply, option) != ERR_NONE) {
362         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
363         return WSError::WS_ERROR_IPC_FAILED;
364     }
365     return static_cast<WSError>(reply.ReadInt32());
366 }
367 
RemoveStartingWindow()368 WSError SessionProxy::RemoveStartingWindow()
369 {
370     MessageParcel data;
371     MessageParcel reply;
372     MessageOption option;
373     if (!data.WriteInterfaceToken(GetDescriptor())) {
374         TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "WriteInterfaceToken failed");
375         return WSError::WS_ERROR_IPC_FAILED;
376     }
377     sptr<IRemoteObject> remote = Remote();
378     if (remote == nullptr) {
379         TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "remote is null");
380         return WSError::WS_ERROR_IPC_FAILED;
381     }
382     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_APP_REMOVE_STARTING_WINDOW),
383         data, reply, option) != ERR_NONE) {
384         TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "SendRequest failed");
385         return WSError::WS_ERROR_IPC_FAILED;
386     }
387     return static_cast<WSError>(reply.ReadInt32());
388 }
389 
ChangeSessionVisibilityWithStatusBar(sptr<AAFwk::SessionInfo> abilitySessionInfo,bool visible)390 WSError SessionProxy::ChangeSessionVisibilityWithStatusBar(sptr<AAFwk::SessionInfo> abilitySessionInfo, bool visible)
391 {
392     if (abilitySessionInfo == nullptr) {
393         WLOGFE("abilitySessionInfo is null");
394         return WSError::WS_ERROR_INVALID_SESSION;
395     }
396 
397     MessageParcel data;
398     MessageParcel reply;
399     MessageOption option(MessageOption::TF_ASYNC);
400     if (!data.WriteInterfaceToken(GetDescriptor())) {
401         WLOGFE("Write interfaceToken failed");
402         return WSError::WS_ERROR_IPC_FAILED;
403     }
404     if (!WriteAbilitySessionInfoBasic(data, abilitySessionInfo)) {
405         WLOGFE("Write abilitySessionInfoBasic failed");
406         return WSError::WS_ERROR_IPC_FAILED;
407     }
408     if (abilitySessionInfo->callerToken) {
409         if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
410             WLOGFE("Write callerToken info failed");
411             return WSError::WS_ERROR_IPC_FAILED;
412         }
413     } else {
414         if (!data.WriteBool(false)) {
415             WLOGFE("Write has not callerToken info failed");
416             return WSError::WS_ERROR_IPC_FAILED;
417         }
418     }
419     if (abilitySessionInfo->startSetting) {
420         if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startSetting.get())) {
421             WLOGFE("Write startSetting failed");
422             return WSError::WS_ERROR_IPC_FAILED;
423         }
424     } else {
425         if (!data.WriteBool(false)) {
426             WLOGFE("Write has not startSetting failed");
427             return WSError::WS_ERROR_IPC_FAILED;
428         }
429     }
430     data.WriteBool(visible);
431     sptr<IRemoteObject> remote = Remote();
432     if (remote == nullptr) {
433         WLOGFE("remote is null");
434         return WSError::WS_ERROR_IPC_FAILED;
435     }
436     if (remote->SendRequest(static_cast<uint32_t>(
437         SessionInterfaceCode::TRANS_ID_CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR),
438         data, reply, option) != ERR_NONE) {
439         WLOGFE("SendRequest failed");
440         return WSError::WS_ERROR_IPC_FAILED;
441     }
442     int32_t ret = reply.ReadInt32();
443     return static_cast<WSError>(ret);
444 }
445 
PendingSessionActivation(sptr<AAFwk::SessionInfo> abilitySessionInfo)446 WSError SessionProxy::PendingSessionActivation(sptr<AAFwk::SessionInfo> abilitySessionInfo)
447 {
448     if (abilitySessionInfo == nullptr) {
449         WLOGFE("abilitySessionInfo is null");
450         return WSError::WS_ERROR_INVALID_SESSION;
451     }
452 
453     MessageParcel data;
454     MessageParcel reply;
455     MessageOption option(MessageOption::TF_ASYNC);
456     if (!data.WriteInterfaceToken(GetDescriptor())) {
457         WLOGFE("Write interfaceToken failed");
458         return WSError::WS_ERROR_IPC_FAILED;
459     }
460     if (!WriteAbilitySessionInfoBasic(data, abilitySessionInfo)) {
461         WLOGFE("Write abilitySessionInfoBasic failed");
462         return WSError::WS_ERROR_IPC_FAILED;
463     }
464     if (!data.WriteBool(abilitySessionInfo->canStartAbilityFromBackground)) {
465         TLOGE(WmsLogTag::WMS_LIFE, "Write canStartAbilityFromBackground failed");
466         return WSError::WS_ERROR_IPC_FAILED;
467     }
468     if (!data.WriteBool(abilitySessionInfo->isAtomicService) ||
469         !data.WriteBool(abilitySessionInfo->isBackTransition) ||
470         !data.WriteBool(abilitySessionInfo->needClearInNotShowRecent)) {
471         TLOGE(WmsLogTag::WMS_LIFE, "Write isAtomicService or isBackTransition or needClearInNotShowRecent failed");
472         return WSError::WS_ERROR_IPC_FAILED;
473     }
474     if (abilitySessionInfo->callerToken) {
475         if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
476             WLOGFE("Write callerToken info failed");
477             return WSError::WS_ERROR_IPC_FAILED;
478         }
479     } else {
480         if (!data.WriteBool(false)) {
481             WLOGFE("Write has not callerToken info failed");
482             return WSError::WS_ERROR_IPC_FAILED;
483         }
484     }
485     if (abilitySessionInfo->startSetting) {
486         if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startSetting.get())) {
487             WLOGFE("Write startSetting failed");
488             return WSError::WS_ERROR_IPC_FAILED;
489         }
490     } else {
491         if (!data.WriteBool(false)) {
492             WLOGFE("Write has not startSetting failed");
493             return WSError::WS_ERROR_IPC_FAILED;
494         }
495     }
496     if (!data.WriteString(abilitySessionInfo->instanceKey)) {
497         TLOGE(WmsLogTag::WMS_LIFE, "Write instanceKey failed");
498         return WSError::WS_ERROR_IPC_FAILED;
499     }
500     if (!data.WriteBool(abilitySessionInfo->isFromIcon)) {
501         TLOGE(WmsLogTag::WMS_LIFE, "Write isFromIcon failed");
502         return WSError::WS_ERROR_IPC_FAILED;
503     }
504     if (abilitySessionInfo->startWindowOption) {
505         if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startWindowOption.get())) {
506             TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "Write startWindowOption failed");
507             return WSError::WS_ERROR_IPC_FAILED;
508         }
509     } else {
510         if (!data.WriteBool(false)) {
511             TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "Write has not startWindowOption failed");
512             return WSError::WS_ERROR_IPC_FAILED;
513         }
514     }
515     auto size = abilitySessionInfo->supportWindowModes.size();
516     if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) {
517         if (!data.WriteUint32(static_cast<uint32_t>(size))) {
518             return WSError::WS_ERROR_IPC_FAILED;
519         }
520         for (decltype(size) i = 0; i < size; i++) {
521             if (!data.WriteInt32(static_cast<int32_t>(abilitySessionInfo->supportWindowModes[i]))) {
522                 return WSError::WS_ERROR_IPC_FAILED;
523             }
524         }
525     } else {
526         if (!data.WriteUint32(0)) {
527             return WSError::WS_ERROR_IPC_FAILED;
528         }
529     }
530     if (!data.WriteString(abilitySessionInfo->specifiedFlag)) {
531         TLOGE(WmsLogTag::WMS_LIFE, "Write specifiedFlag failed");
532         return WSError::WS_ERROR_IPC_FAILED;
533     }
534     if (!data.WriteBool(abilitySessionInfo->reuseDelegatorWindow)) {
535         TLOGE(WmsLogTag::WMS_LIFE, "Write reuseDelegatorWindow failed.");
536         return WSError::WS_ERROR_IPC_FAILED;
537     }
538     if (!data.WriteBool(abilitySessionInfo->hideStartWindow)) {
539         TLOGE(WmsLogTag::WMS_LIFE, "Write hideStartWindow failed.");
540         return WSError::WS_ERROR_IPC_FAILED;
541     }
542     if (!data.WriteInt32(abilitySessionInfo->scenarios)) {
543         TLOGE(WmsLogTag::WMS_LIFE, "Write scenarios failed.");
544         return WSError::WS_ERROR_IPC_FAILED;
545     }
546     if (!data.WriteParcelable(abilitySessionInfo->windowCreateParams.get())) {
547         TLOGE(WmsLogTag::WMS_LIFE, "Write windowCreateParams failed");
548         return WSError::WS_ERROR_IPC_FAILED;
549     }
550     sptr<IRemoteObject> remote = Remote();
551     if (remote == nullptr) {
552         WLOGFE("remote is null");
553         return WSError::WS_ERROR_IPC_FAILED;
554     }
555     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_ACTIVE_PENDING_SESSION),
556         data, reply, option) != ERR_NONE) {
557         WLOGFE("SendRequest failed");
558         return WSError::WS_ERROR_IPC_FAILED;
559     }
560     int32_t ret = reply.ReadInt32();
561     return static_cast<WSError>(ret);
562 }
563 
BatchPendingSessionsActivation(const std::vector<sptr<AAFwk::SessionInfo>> & abilitySessionInfos)564 WSError SessionProxy::BatchPendingSessionsActivation(const std::vector<sptr<AAFwk::SessionInfo>>& abilitySessionInfos)
565 {
566     if (abilitySessionInfos.empty()) {
567         TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfos is empty");
568         return WSError::WS_ERROR_INVALID_PARAM;
569     }
570     MessageParcel data;
571     MessageParcel reply;
572     MessageOption option(MessageOption::TF_ASYNC);
573     if (!data.WriteInterfaceToken(GetDescriptor())) {
574         TLOGE(WmsLogTag::WMS_LIFE, "Write interfaceToken failed");
575         return WSError::WS_ERROR_IPC_FAILED;
576     }
577     if (!data.WriteInt32(static_cast<int32_t>(abilitySessionInfos.size()))) {
578         TLOGE(WmsLogTag::WMS_LIFE, "Write ability session info list size failed");
579         return WSError::WS_ERROR_IPC_FAILED;
580     }
581     for (auto abilitySessionInfo : abilitySessionInfos) {
582         WSError writeRet = WriteOneSessionInfo(data, abilitySessionInfo);
583         if (writeRet != WSError::WS_OK) {
584             return writeRet;
585         }
586     }
587     sptr<IRemoteObject> remote = Remote();
588     if (remote == nullptr) {
589         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
590         return WSError::WS_ERROR_IPC_FAILED;
591     }
592     TLOGI(WmsLogTag::WMS_LIFE, "batch pending session activations size: %{public}zu", abilitySessionInfos.size());
593     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BATCH_ACTIVE_PENDING_SESSION),
594         data, reply, option) != ERR_NONE) {
595         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
596         return WSError::WS_ERROR_IPC_FAILED;
597     }
598     return static_cast<WSError>(reply.ReadInt32());
599 }
600 
WriteOneSessionInfo(MessageParcel & data,const sptr<AAFwk::SessionInfo> & abilitySessionInfo)601 WSError SessionProxy::WriteOneSessionInfo(MessageParcel& data, const sptr<AAFwk::SessionInfo>& abilitySessionInfo)
602 {
603     if (!WriteAbilitySessionInfoBasic(data, abilitySessionInfo)) {
604         TLOGE(WmsLogTag::WMS_LIFE, "Write abilitySessionInfoBasic failed");
605         return WSError::WS_ERROR_IPC_FAILED;
606     }
607     if (!data.WriteBool(abilitySessionInfo->canStartAbilityFromBackground)) {
608         TLOGE(WmsLogTag::WMS_LIFE, "Write canStartAbilityFromBackground failed");
609         return WSError::WS_ERROR_IPC_FAILED;
610     }
611     if (!data.WriteBool(abilitySessionInfo->isAtomicService) ||
612         !data.WriteBool(abilitySessionInfo->isBackTransition) ||
613         !data.WriteBool(abilitySessionInfo->needClearInNotShowRecent)) {
614         TLOGE(WmsLogTag::WMS_LIFE, "Write isAtomicService or isBackTransition or needClearInNotShowRecent failed");
615         return WSError::WS_ERROR_IPC_FAILED;
616     }
617     if (abilitySessionInfo->callerToken) {
618         if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
619             TLOGE(WmsLogTag::WMS_LIFE, "Write callerToken info failed");
620             return WSError::WS_ERROR_IPC_FAILED;
621         }
622     } else {
623         if (!data.WriteBool(false)) {
624             TLOGE(WmsLogTag::WMS_LIFE, "Write has not callerToken info failed");
625             return WSError::WS_ERROR_IPC_FAILED;
626         }
627     }
628     if (abilitySessionInfo->startSetting) {
629         if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startSetting.get())) {
630             TLOGE(WmsLogTag::WMS_LIFE, "Write startSetting failed");
631             return WSError::WS_ERROR_IPC_FAILED;
632         }
633     } else {
634         if (!data.WriteBool(false)) {
635             TLOGE(WmsLogTag::WMS_LIFE, "Write has not startSetting failed");
636             return WSError::WS_ERROR_IPC_FAILED;
637         }
638     }
639     return WriteOneSessionInfoPart(data, abilitySessionInfo);
640 }
641 
WriteOneSessionInfoPart(MessageParcel & data,const sptr<AAFwk::SessionInfo> & abilitySessionInfo)642 WSError SessionProxy::WriteOneSessionInfoPart(MessageParcel& data, const sptr<AAFwk::SessionInfo>& abilitySessionInfo)
643 {
644     if (abilitySessionInfo->startWindowOption) {
645         if (!data.WriteBool(true) || !data.WriteParcelable(abilitySessionInfo->startWindowOption.get())) {
646             TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "Write startWindowOption failed");
647             return WSError::WS_ERROR_IPC_FAILED;
648         }
649     } else {
650         if (!data.WriteBool(false)) {
651             TLOGE(WmsLogTag::WMS_STARTUP_PAGE, "Write has not startWindowOption failed");
652             return WSError::WS_ERROR_IPC_FAILED;
653         }
654     }
655     if (!data.WriteString(abilitySessionInfo->instanceKey)) {
656         TLOGE(WmsLogTag::WMS_LIFE, "Write instanceKey failed");
657         return WSError::WS_ERROR_IPC_FAILED;
658     }
659     if (!data.WriteBool(abilitySessionInfo->isFromIcon)) {
660         TLOGE(WmsLogTag::WMS_LIFE, "Write isFromIcon failed");
661         return WSError::WS_ERROR_IPC_FAILED;
662     }
663     auto size = abilitySessionInfo->supportWindowModes.size();
664     if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) {
665         if (!data.WriteUint32(static_cast<uint32_t>(size))) {
666             return WSError::WS_ERROR_IPC_FAILED;
667         }
668         for (decltype(size) i = 0; i < size; i++) {
669             if (!data.WriteInt32(static_cast<int32_t>(abilitySessionInfo->supportWindowModes[i]))) {
670                 return WSError::WS_ERROR_IPC_FAILED;
671             }
672         }
673     } else {
674         if (!data.WriteUint32(0)) {
675             return WSError::WS_ERROR_IPC_FAILED;
676         }
677     }
678     if (!data.WriteString(abilitySessionInfo->specifiedFlag)) {
679         TLOGE(WmsLogTag::WMS_LIFE, "Write specifiedFlag failed");
680         return WSError::WS_ERROR_IPC_FAILED;
681     }
682     if (!data.WriteBool(abilitySessionInfo->reuseDelegatorWindow)) {
683         TLOGE(WmsLogTag::WMS_LIFE, "Write reuseDelegatorWindow failed.");
684         return WSError::WS_ERROR_IPC_FAILED;
685     }
686     return WSError::WS_OK;
687 }
688 
TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)689 WSError SessionProxy::TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)
690 {
691     if (abilitySessionInfo == nullptr) {
692         WLOGFE("abilitySessionInfo is null");
693         return WSError::WS_ERROR_INVALID_SESSION;
694     }
695     MessageParcel data;
696     MessageParcel reply;
697     MessageOption option(MessageOption::TF_ASYNC);
698     if (!data.WriteInterfaceToken(GetDescriptor())) {
699         WLOGFE("WriteInterfaceToken failed");
700         return WSError::WS_ERROR_IPC_FAILED;
701     }
702     if (!data.WriteParcelable(&(abilitySessionInfo->want))) {
703         WLOGFE("Write want info failed");
704         return WSError::WS_ERROR_IPC_FAILED;
705     }
706     if (abilitySessionInfo->callerToken) {
707         if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
708             WLOGFE("Write ability info failed");
709             return WSError::WS_ERROR_IPC_FAILED;
710         }
711     } else {
712         if (!data.WriteBool(false)) {
713             WLOGFE("Write ability info failed");
714             return WSError::WS_ERROR_IPC_FAILED;
715         }
716     }
717     if (!data.WriteInt32(abilitySessionInfo->resultCode)) {
718         WLOGFE("Write resultCode info failed");
719         return WSError::WS_ERROR_IPC_FAILED;
720     }
721     sptr<IRemoteObject> remote = Remote();
722     if (remote == nullptr) {
723         WLOGFE("remote is null");
724         return WSError::WS_ERROR_IPC_FAILED;
725     }
726     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TERMINATE),
727         data, reply, option) != ERR_NONE) {
728         WLOGFE("SendRequest failed");
729         return WSError::WS_ERROR_IPC_FAILED;
730     }
731     int32_t ret = reply.ReadInt32();
732     return static_cast<WSError>(ret);
733 }
734 
NotifySessionException(const sptr<AAFwk::SessionInfo> abilitySessionInfo,const ExceptionInfo & exceptionInfo)735 WSError SessionProxy::NotifySessionException(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
736     const ExceptionInfo& exceptionInfo)
737 {
738     if (abilitySessionInfo == nullptr) {
739         TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfo is null");
740         return WSError::WS_ERROR_INVALID_SESSION;
741     }
742     MessageParcel data;
743     MessageParcel reply;
744     MessageOption option(MessageOption::TF_ASYNC);
745     if (!data.WriteInterfaceToken(GetDescriptor())) {
746         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
747         return WSError::WS_ERROR_IPC_FAILED;
748     }
749     if (!data.WriteParcelable(&(abilitySessionInfo->want))) {
750         TLOGE(WmsLogTag::WMS_LIFE, "Write want info failed");
751         return WSError::WS_ERROR_IPC_FAILED;
752     }
753     if (abilitySessionInfo->callerToken) {
754         if (!data.WriteBool(true) || !data.WriteRemoteObject(abilitySessionInfo->callerToken)) {
755             TLOGE(WmsLogTag::WMS_LIFE, "Write ability info failed");
756             return WSError::WS_ERROR_IPC_FAILED;
757         }
758     } else {
759         if (!data.WriteBool(false)) {
760             TLOGE(WmsLogTag::WMS_LIFE, "Write ability info failed");
761             return WSError::WS_ERROR_IPC_FAILED;
762         }
763     }
764     if (!data.WriteInt32(abilitySessionInfo->persistentId)) {
765         TLOGE(WmsLogTag::WMS_LIFE, "Write persistentId info failed");
766         return WSError::WS_ERROR_IPC_FAILED;
767     }
768     if (!data.WriteInt32(abilitySessionInfo->errorCode) ||
769         !data.WriteString(abilitySessionInfo->errorReason)) {
770         TLOGE(WmsLogTag::WMS_LIFE, "Write error info failed");
771         return WSError::WS_ERROR_IPC_FAILED;
772     }
773     if (!data.WriteString(abilitySessionInfo->identityToken)) {
774         TLOGE(WmsLogTag::WMS_LIFE, "Write identity token info failed");
775         return WSError::WS_ERROR_IPC_FAILED;
776     }
777     if (!data.WriteBool(exceptionInfo.needRemoveSession)) {
778         TLOGE(WmsLogTag::WMS_LIFE, "Write needRemoveSession info failed");
779         return WSError::WS_ERROR_IPC_FAILED;
780     }
781     if (!data.WriteBool(exceptionInfo.needClearCallerLink)) {
782         TLOGE(WmsLogTag::WMS_LIFE, "Write needClearCallerLink info failed");
783         return WSError::WS_ERROR_IPC_FAILED;
784     }
785     sptr<IRemoteObject> remote = Remote();
786     if (remote == nullptr) {
787         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
788         return WSError::WS_ERROR_IPC_FAILED;
789     }
790     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_EXCEPTION),
791         data, reply, option) != ERR_NONE) {
792         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
793         return WSError::WS_ERROR_IPC_FAILED;
794     }
795     int32_t ret = reply.ReadInt32();
796     return static_cast<WSError>(ret);
797 }
798 
OnSessionEvent(SessionEvent event)799 WSError SessionProxy::OnSessionEvent(SessionEvent event)
800 {
801     MessageParcel data;
802     MessageParcel reply;
803     MessageOption option(MessageOption::TF_ASYNC);
804     if (!data.WriteInterfaceToken(GetDescriptor())) {
805         WLOGFE("WriteInterfaceToken failed");
806         return WSError::WS_ERROR_IPC_FAILED;
807     }
808     if (!(data.WriteUint32(static_cast<uint32_t>(event)))) {
809         WLOGFE("Write event id failed");
810         return WSError::WS_ERROR_IPC_FAILED;
811     }
812     sptr<IRemoteObject> remote = Remote();
813     if (remote == nullptr) {
814         WLOGFE("remote is null");
815         return WSError::WS_ERROR_IPC_FAILED;
816     }
817     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SESSION_EVENT),
818         data, reply, option) != ERR_NONE) {
819         WLOGFE("SendRequest failed");
820         return WSError::WS_ERROR_IPC_FAILED;
821     }
822     int32_t ret = reply.ReadInt32();
823     return static_cast<WSError>(ret);
824 }
825 
SyncSessionEvent(SessionEvent event)826 WSError SessionProxy::SyncSessionEvent(SessionEvent event)
827 {
828     MessageParcel data;
829     MessageParcel reply;
830     MessageOption option(MessageOption::TF_SYNC);
831     if (!data.WriteInterfaceToken(GetDescriptor())) {
832         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
833         return WSError::WS_ERROR_IPC_FAILED;
834     }
835     if (!data.WriteInt32(static_cast<int32_t>(event))) {
836         TLOGE(WmsLogTag::WMS_LAYOUT, "Write event id failed");
837         return WSError::WS_ERROR_IPC_FAILED;
838     }
839     if (Remote()->SendRequest(static_cast<int32_t>(SessionInterfaceCode::TRANS_ID_SYNC_SESSION_EVENT),
840         data, reply, option) != ERR_NONE) {
841         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
842         return WSError::WS_ERROR_IPC_FAILED;
843     }
844     int32_t ret = reply.ReadInt32();
845     return static_cast<WSError>(ret);
846 }
847 
OnLayoutFullScreenChange(bool isLayoutFullScreen)848 WSError SessionProxy::OnLayoutFullScreenChange(bool isLayoutFullScreen)
849 {
850     MessageParcel data;
851     MessageParcel reply;
852     MessageOption option(MessageOption::TF_ASYNC);
853     if (!data.WriteInterfaceToken(GetDescriptor())) {
854         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
855         return WSError::WS_ERROR_IPC_FAILED;
856     }
857     if (!data.WriteBool(isLayoutFullScreen)) {
858         TLOGE(WmsLogTag::WMS_LAYOUT, "Write isLayoutFullScreen failed");
859         return WSError::WS_ERROR_IPC_FAILED;
860     }
861     sptr<IRemoteObject> remote = Remote();
862     if (remote == nullptr) {
863         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
864         return WSError::WS_ERROR_IPC_FAILED;
865     }
866     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_LAYOUT_FULL_SCREEN_CHANGE),
867         data, reply, option) != ERR_NONE) {
868         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
869         return WSError::WS_ERROR_IPC_FAILED;
870     }
871     int32_t ret = reply.ReadInt32();
872     return static_cast<WSError>(ret);
873 }
874 
OnDefaultDensityEnabled(bool isDefaultDensityEnabled)875 WSError SessionProxy::OnDefaultDensityEnabled(bool isDefaultDensityEnabled)
876 {
877     MessageParcel data;
878     MessageParcel reply;
879     MessageOption option(MessageOption::TF_ASYNC);
880     if (!data.WriteInterfaceToken(GetDescriptor())) {
881         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
882         return WSError::WS_ERROR_IPC_FAILED;
883     }
884     if (!data.WriteBool(isDefaultDensityEnabled)) {
885         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write isDefaultDensityEnabled failed");
886         return WSError::WS_ERROR_IPC_FAILED;
887     }
888     sptr<IRemoteObject> remote = Remote();
889     if (remote == nullptr) {
890         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
891         return WSError::WS_ERROR_IPC_FAILED;
892     }
893     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DEFAULT_DENSITY_ENABLED),
894         data, reply, option) != ERR_NONE) {
895         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
896         return WSError::WS_ERROR_IPC_FAILED;
897     }
898     int32_t ret = reply.ReadInt32();
899     return static_cast<WSError>(ret);
900 }
901 
OnTitleAndDockHoverShowChange(bool isTitleHoverShown,bool isDockHoverShown)902 WSError SessionProxy::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown)
903 {
904     MessageParcel data;
905     MessageParcel reply;
906     MessageOption option(MessageOption::TF_ASYNC);
907     if (!data.WriteInterfaceToken(GetDescriptor())) {
908         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
909         return WSError::WS_ERROR_IPC_FAILED;
910     }
911     if (!data.WriteBool(isTitleHoverShown) || !data.WriteBool(isDockHoverShown)) {
912         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write isTitleHoverShown or isDockHoverShown failed");
913         return WSError::WS_ERROR_IPC_FAILED;
914     }
915     sptr<IRemoteObject> remote = Remote();
916     if (remote == nullptr) {
917         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
918         return WSError::WS_ERROR_IPC_FAILED;
919     }
920     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TITLE_AND_DOCK_HOVER_SHOW_CHANGE),
921         data, reply, option) != ERR_NONE) {
922         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
923         return WSError::WS_ERROR_IPC_FAILED;
924     }
925     uint32_t ret = reply.ReadUint32();
926     return static_cast<WSError>(ret);
927 }
928 
OnRestoreMainWindow()929 WSError SessionProxy::OnRestoreMainWindow()
930 {
931     MessageParcel data;
932     MessageParcel reply;
933     MessageOption option(MessageOption::TF_ASYNC);
934     if (!data.WriteInterfaceToken(GetDescriptor())) {
935         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
936         return WSError::WS_ERROR_IPC_FAILED;
937     }
938     sptr<IRemoteObject> remote = Remote();
939     if (remote == nullptr) {
940         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
941         return WSError::WS_ERROR_IPC_FAILED;
942     }
943     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RESTORE_MAIN_WINDOW),
944         data, reply, option) != ERR_NONE) {
945         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
946         return WSError::WS_ERROR_IPC_FAILED;
947     }
948     return WSError::WS_OK;
949 }
950 
951 /** @note @window.layout */
UpdateSessionRect(const WSRect & rect,SizeChangeReason reason,bool isGlobal,bool isFromMoveToGlobal,const MoveConfiguration & moveConfiguration,const RectAnimationConfig & rectAnimationConfig)952 WSError SessionProxy::UpdateSessionRect(const WSRect& rect, SizeChangeReason reason,
953     bool isGlobal, bool isFromMoveToGlobal, const MoveConfiguration& moveConfiguration,
954     const RectAnimationConfig& rectAnimationConfig)
955 {
956     TLOGI(WmsLogTag::WMS_LAYOUT, "Rect [%{public}d, %{public}d, %{public}u, %{public}u] isGlobal %{public}d "
957         "isFromMoveToGlobal %{public}d moveConfiguration %{public}s", rect.posX_, rect.posY_,
958         rect.width_, rect.height_, isGlobal, isFromMoveToGlobal, moveConfiguration.ToString().c_str());
959     MessageParcel data;
960     MessageParcel reply;
961     MessageOption option(MessageOption::TF_ASYNC);
962     if (!data.WriteInterfaceToken(GetDescriptor())) {
963         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
964         return WSError::WS_ERROR_IPC_FAILED;
965     }
966     if (!((data.WriteInt32(static_cast<int32_t>(rect.posX_))) &&
967         (data.WriteInt32(static_cast<int32_t>(rect.posY_))) &&
968         (data.WriteUint32(static_cast<uint32_t>(rect.width_))) &&
969         (data.WriteUint32(static_cast<uint32_t>(rect.height_))))) {
970         TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed");
971         return WSError::WS_ERROR_IPC_FAILED;
972     }
973 
974     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
975         TLOGE(WmsLogTag::WMS_LAYOUT, "Write SessionSizeChangeReason failed");
976         return WSError::WS_ERROR_IPC_FAILED;
977     }
978 
979     if (!data.WriteBool(isGlobal)) {
980         TLOGE(WmsLogTag::WMS_LAYOUT, "Write bool failed");
981         return WSError::WS_ERROR_IPC_FAILED;
982     }
983 
984     if (!data.WriteBool(isFromMoveToGlobal)) {
985         TLOGE(WmsLogTag::WMS_LAYOUT, "Write bool failed");
986         return WSError::WS_ERROR_IPC_FAILED;
987     }
988 
989     if (!data.WriteUint64(static_cast<uint64_t>(moveConfiguration.displayId))) {
990         TLOGE(WmsLogTag::WMS_LAYOUT, "Write session displayId failed");
991         return WSError::WS_ERROR_IPC_FAILED;
992     }
993 
994     if (reason == SizeChangeReason::MOVE_WITH_ANIMATION || reason == SizeChangeReason::RESIZE_WITH_ANIMATION) {
995         if (!data.WriteUint32(rectAnimationConfig.duration) || !data.WriteFloat(rectAnimationConfig.x1) ||
996             !data.WriteFloat(rectAnimationConfig.y1) || !data.WriteFloat(rectAnimationConfig.x2) ||
997             !data.WriteFloat(rectAnimationConfig.y2)) {
998             TLOGE(WmsLogTag::WMS_LAYOUT, "Write rectAnimationConfig failed");
999             return WSError::WS_ERROR_IPC_FAILED;
1000         }
1001     }
1002 
1003     sptr<IRemoteObject> remote = Remote();
1004     if (remote == nullptr) {
1005         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1006         return WSError::WS_ERROR_IPC_FAILED;
1007     }
1008     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_RECT),
1009         data, reply, option) != ERR_NONE) {
1010         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1011         return WSError::WS_ERROR_IPC_FAILED;
1012     }
1013     int32_t ret = reply.ReadInt32();
1014     return static_cast<WSError>(ret);
1015 }
1016 
1017 /** @note @window.layout */
UpdateGlobalDisplayRectFromClient(const WSRect & rect,SizeChangeReason reason)1018 WSError SessionProxy::UpdateGlobalDisplayRectFromClient(const WSRect& rect, SizeChangeReason reason)
1019 {
1020     MessageParcel data;
1021     if (!data.WriteInterfaceToken(GetDescriptor())) {
1022         TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to write interface token");
1023         return WSError::WS_ERROR_IPC_FAILED;
1024     }
1025     if (!data.WriteInt32(rect.posX_) || !data.WriteInt32(rect.posY_) ||
1026         !data.WriteInt32(rect.width_) || !data.WriteInt32(rect.height_)) {
1027         TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to write rect");
1028         return WSError::WS_ERROR_IPC_FAILED;
1029     }
1030     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
1031         TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to write reason");
1032         return WSError::WS_ERROR_IPC_FAILED;
1033     }
1034     sptr<IRemoteObject> remote = Remote();
1035     if (remote == nullptr) {
1036         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is nullptr");
1037         return WSError::WS_ERROR_IPC_FAILED;
1038     }
1039     MessageParcel reply;
1040     MessageOption option(MessageOption::TF_ASYNC);
1041     int sendRet = remote->SendRequest(
1042         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_GLOBAL_DISPLAY_RECT), data, reply, option);
1043     if (sendRet != ERR_NONE) {
1044         TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to send request, error = %{public}d", sendRet);
1045         return WSError::WS_ERROR_IPC_FAILED;
1046     }
1047     return WSError::WS_OK;
1048 }
1049 
1050 /** @note @window.layout */
GetGlobalScaledRect(Rect & globalScaledRect)1051 WMError SessionProxy::GetGlobalScaledRect(Rect& globalScaledRect)
1052 {
1053     MessageParcel data;
1054     MessageParcel reply;
1055     MessageOption option;
1056     if (!data.WriteInterfaceToken(GetDescriptor())) {
1057         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1058         return WMError::WM_ERROR_IPC_FAILED;
1059     }
1060     sptr<IRemoteObject> remote = Remote();
1061     if (remote == nullptr) {
1062         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1063         return WMError::WM_ERROR_IPC_FAILED;
1064     }
1065     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_GLOBAL_SCALED_RECT),
1066         data, reply, option) != ERR_NONE) {
1067         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1068         return WMError::WM_ERROR_IPC_FAILED;
1069     }
1070     int32_t posX = 0;
1071     int32_t posY = 0;
1072     uint32_t width = 0;
1073     uint32_t height = 0;
1074     int32_t ret = 0;
1075     if (!reply.ReadInt32(posX) || !reply.ReadInt32(posY) ||
1076         !reply.ReadUint32(width) || !reply.ReadUint32(height) || !reply.ReadInt32(ret)) {
1077         TLOGE(WmsLogTag::WMS_LAYOUT, "read failed");
1078         return WMError::WM_ERROR_IPC_FAILED;
1079     }
1080     globalScaledRect = { posX, posY, width, height };
1081     return static_cast<WMError>(ret);
1082 }
1083 
1084 /** @note @window.layout */
UpdateClientRect(const WSRect & rect)1085 WSError SessionProxy::UpdateClientRect(const WSRect& rect)
1086 {
1087     TLOGD(WmsLogTag::WMS_LAYOUT, "rect:[%{public}d, %{public}d, %{public}d, %{public}d]",
1088         rect.posX_, rect.posY_, rect.width_, rect.height_);
1089     MessageParcel data;
1090     MessageParcel reply;
1091     MessageOption option;
1092     if (!data.WriteInterfaceToken(GetDescriptor())) {
1093         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
1094         return WSError::WS_ERROR_IPC_FAILED;
1095     }
1096     if (!data.WriteInt32(rect.posX_) ||
1097         !data.WriteInt32(rect.posY_) ||
1098         !data.WriteInt32(rect.width_) ||
1099         !data.WriteInt32(rect.height_)) {
1100         TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed");
1101         return WSError::WS_ERROR_IPC_FAILED;
1102     }
1103 
1104     sptr<IRemoteObject> remote = Remote();
1105     if (remote == nullptr) {
1106         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
1107         return WSError::WS_ERROR_IPC_FAILED;
1108     }
1109     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_CLIENT_RECT),
1110         data, reply, option) != ERR_NONE) {
1111         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
1112         return WSError::WS_ERROR_IPC_FAILED;
1113     }
1114     int32_t ret = reply.ReadInt32();
1115     return static_cast<WSError>(ret);
1116 }
1117 
1118 /** @note @window.hierarchy */
RaiseToAppTop()1119 WSError SessionProxy::RaiseToAppTop()
1120 {
1121     MessageParcel data;
1122     MessageParcel reply;
1123     MessageOption option;
1124     if (!data.WriteInterfaceToken(GetDescriptor())) {
1125         WLOGFE("WriteInterfaceToken failed");
1126         return WSError::WS_ERROR_IPC_FAILED;
1127     }
1128     sptr<IRemoteObject> remote = Remote();
1129     if (remote == nullptr) {
1130         WLOGFE("remote is null");
1131         return WSError::WS_ERROR_IPC_FAILED;
1132     }
1133     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_TO_APP_TOP),
1134         data, reply, option) != ERR_NONE) {
1135         WLOGFE("SendRequest failed");
1136         return WSError::WS_ERROR_IPC_FAILED;
1137     }
1138     int32_t ret = reply.ReadInt32();
1139     return static_cast<WSError>(ret);
1140 }
1141 
NotifyFrameLayoutFinishFromApp(bool notifyListener,const WSRect & rect)1142 WSError SessionProxy::NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect)
1143 {
1144     MessageParcel data;
1145     MessageParcel reply;
1146     MessageOption option(MessageOption::TF_ASYNC);
1147     if (!data.WriteInterfaceToken(GetDescriptor())) {
1148         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "WriteInterfaceToken failed");
1149         return WSError::WS_ERROR_IPC_FAILED;
1150     }
1151 
1152     if (!data.WriteBool(notifyListener)) {
1153         TLOGE(WmsLogTag::WMS_LAYOUT, "Write notifyListener failed");
1154         return WSError::WS_ERROR_IPC_FAILED;
1155     }
1156 
1157     if (!data.WriteInt32(rect.posX_) || !data.WriteInt32(rect.posY_) ||
1158         !data.WriteInt32(rect.width_) || !data.WriteInt32(rect.height_)) {
1159         TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed");
1160         return WSError::WS_ERROR_IPC_FAILED;
1161     }
1162 
1163     sptr<IRemoteObject> remote = Remote();
1164     if (remote == nullptr) {
1165         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "remote is null");
1166         return WSError::WS_ERROR_IPC_FAILED;
1167     }
1168 
1169     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_FRAME_LAYOUT_FINISH),
1170         data, reply, option) != ERR_NONE) {
1171         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "SendRequest failed");
1172         return WSError::WS_ERROR_IPC_FAILED;
1173     }
1174     return WSError::WS_OK;
1175 }
1176 
NotifySnapshotUpdate()1177 WMError SessionProxy::NotifySnapshotUpdate()
1178 {
1179     TLOGI(WmsLogTag::WMS_PATTERN, "in");
1180     MessageParcel data;
1181     MessageParcel reply;
1182     MessageOption option(MessageOption::TF_ASYNC);
1183     if (!data.WriteInterfaceToken(GetDescriptor())) {
1184         TLOGE(WmsLogTag::WMS_PATTERN, "WriteInterfaceToken failed");
1185         return WMError::WM_ERROR_IPC_FAILED;
1186     }
1187     sptr<IRemoteObject> remote = Remote();
1188     if (remote == nullptr) {
1189         TLOGE(WmsLogTag::WMS_PATTERN, "remote is null");
1190         return WMError::WM_ERROR_IPC_FAILED;
1191     }
1192     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_SNAPSHOT_UPDATE),
1193         data, reply, option) != ERR_NONE) {
1194         TLOGE(WmsLogTag::WMS_PATTERN, "SendRequest failed");
1195         return WMError::WM_ERROR_IPC_FAILED;
1196     }
1197     return WMError::WM_OK;
1198 }
1199 
1200 /** @note @window.hierarchy */
RaiseAboveTarget(int32_t subWindowId)1201 WSError SessionProxy::RaiseAboveTarget(int32_t subWindowId)
1202 {
1203     MessageParcel data;
1204     MessageParcel reply;
1205     MessageOption option;
1206     if (!data.WriteInterfaceToken(GetDescriptor())) {
1207         WLOGFE("WriteInterfaceToken failed");
1208         return WSError::WS_ERROR_IPC_FAILED;
1209     }
1210     if (!data.WriteInt32(subWindowId)) {
1211         WLOGFE("Write subWindowId failed");
1212     }
1213     sptr<IRemoteObject> remote = Remote();
1214     if (remote == nullptr) {
1215         WLOGFE("remote is null");
1216         return WSError::WS_ERROR_IPC_FAILED;
1217     }
1218     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_ABOVE_TARGET),
1219         data, reply, option) != ERR_NONE) {
1220         WLOGFE("SendRequest failed");
1221         return WSError::WS_ERROR_IPC_FAILED;
1222     }
1223     int32_t ret = reply.ReadInt32();
1224     return static_cast<WSError>(ret);
1225 }
1226 
1227 /** @note @window.hierarchy */
RaiseMainWindowAboveTarget(int32_t targetId)1228 WSError SessionProxy::RaiseMainWindowAboveTarget(int32_t targetId)
1229 {
1230     MessageParcel data;
1231     MessageParcel reply;
1232     MessageOption option(MessageOption::TF_SYNC);
1233     if (!data.WriteInterfaceToken(GetDescriptor())) {
1234         WLOGFE("WriteInterfaceToken failed");
1235         return WSError::WS_ERROR_IPC_FAILED;
1236     }
1237     if (!data.WriteInt32(targetId)) {
1238         WLOGFE("Write targetId failed");
1239         return WSError::WS_ERROR_IPC_FAILED;
1240     }
1241     sptr<IRemoteObject> remote = Remote();
1242     if (remote == nullptr) {
1243         WLOGFE("remote is null");
1244         return WSError::WS_ERROR_IPC_FAILED;
1245     }
1246     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_MAIN_WINDOW_ABOVE_TARGET),
1247         data, reply, option) != ERR_NONE) {
1248         WLOGFE("SendRequest failed");
1249         return WSError::WS_ERROR_IPC_FAILED;
1250     }
1251     int32_t ret = reply.ReadInt32();
1252     return static_cast<WSError>(ret);
1253 }
1254 
RaiseAppMainWindowToTop()1255 WSError SessionProxy::RaiseAppMainWindowToTop()
1256 {
1257     MessageParcel data;
1258     MessageParcel reply;
1259     MessageOption option(MessageOption::TF_ASYNC);
1260     if (!data.WriteInterfaceToken(GetDescriptor())) {
1261         WLOGFE("WriteInterfaceToken failed");
1262         return WSError::WS_ERROR_IPC_FAILED;
1263     }
1264     sptr<IRemoteObject> remote = Remote();
1265     if (remote == nullptr) {
1266         WLOGFE("remote is null");
1267         return WSError::WS_ERROR_IPC_FAILED;
1268     }
1269     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_APP_MAIN_WINDOW),
1270         data, reply, option) != ERR_NONE) {
1271         WLOGFE("SendRequest failed");
1272         return WSError::WS_ERROR_IPC_FAILED;
1273     }
1274     int32_t ret = reply.ReadInt32();
1275     return static_cast<WSError>(ret);
1276 }
1277 
OnNeedAvoid(bool status)1278 WSError SessionProxy::OnNeedAvoid(bool status)
1279 {
1280     MessageParcel data;
1281     MessageParcel reply;
1282     MessageOption option(MessageOption::TF_ASYNC);
1283     if (!data.WriteInterfaceToken(GetDescriptor())) {
1284         WLOGFE("WriteInterfaceToken failed");
1285         return WSError::WS_ERROR_IPC_FAILED;
1286     }
1287     if (!data.WriteBool(status)) {
1288         WLOGFE("Write status failed");
1289         return WSError::WS_ERROR_IPC_FAILED;
1290     }
1291     sptr<IRemoteObject> remote = Remote();
1292     if (remote == nullptr) {
1293         WLOGFE("remote is null");
1294         return WSError::WS_ERROR_IPC_FAILED;
1295     }
1296     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NEED_AVOID),
1297         data, reply, option) != ERR_NONE) {
1298         WLOGFE("SendRequest failed");
1299         return WSError::WS_ERROR_IPC_FAILED;
1300     }
1301     int32_t ret = reply.ReadInt32();
1302     return static_cast<WSError>(ret);
1303 }
1304 
GetAvoidAreaByType(AvoidAreaType type,const WSRect & rect,int32_t apiVersion)1305 AvoidArea SessionProxy::GetAvoidAreaByType(AvoidAreaType type, const WSRect& rect, int32_t apiVersion)
1306 {
1307     MessageParcel data;
1308     MessageParcel reply;
1309     MessageOption option(MessageOption::TF_SYNC);
1310     AvoidArea avoidArea;
1311     if (!data.WriteInterfaceToken(GetDescriptor())) {
1312         TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
1313         return avoidArea;
1314     }
1315     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
1316         TLOGE(WmsLogTag::WMS_IMMS, "write type error");
1317         return avoidArea;
1318     }
1319     if (!data.WriteInt32(rect.posX_) || !data.WriteInt32(rect.posY_) ||
1320         !data.WriteInt32(rect.width_) || !data.WriteInt32(rect.height_)) {
1321         TLOGE(WmsLogTag::WMS_IMMS, "write rect error");
1322         return avoidArea;
1323     }
1324     if (!data.WriteInt32(apiVersion)) {
1325         TLOGE(WmsLogTag::WMS_IMMS, "write api version error");
1326         return avoidArea;
1327     }
1328 
1329     sptr<IRemoteObject> remote = Remote();
1330     if (remote == nullptr) {
1331         TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
1332         return avoidArea;
1333     }
1334     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_AVOID_AREA),
1335         data, reply, option);
1336     if (sendCode != ERR_NONE) {
1337         TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed, code: %{public}d", sendCode);
1338         return avoidArea;
1339     }
1340     sptr<AvoidArea> area = reply.ReadParcelable<AvoidArea>();
1341     if (area == nullptr) {
1342         return avoidArea;
1343     }
1344     return *area;
1345 }
1346 
GetAllAvoidAreas(std::map<AvoidAreaType,AvoidArea> & avoidAreas)1347 WSError SessionProxy::GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas)
1348 {
1349     MessageParcel data;
1350     MessageParcel reply;
1351     MessageOption option(MessageOption::TF_SYNC);
1352     if (!data.WriteInterfaceToken(GetDescriptor())) {
1353         WLOGFE("WriteInterfaceToken failed");
1354         return WSError::WS_ERROR_IPC_FAILED;
1355     }
1356     sptr<IRemoteObject> remote = Remote();
1357     if (remote == nullptr) {
1358         WLOGFE("remote is null");
1359         return WSError::WS_ERROR_IPC_FAILED;
1360     }
1361     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_ALL_AVOID_AREAS),
1362         data, reply, option) != ERR_NONE) {
1363         WLOGFE("SendRequest failed");
1364         return WSError::WS_ERROR_IPC_FAILED;
1365     }
1366     uint32_t size = reply.ReadUint32();
1367     constexpr uint32_t AVOID_AREA_TYPE_MAX_SIZE = 100;
1368     if (size > AVOID_AREA_TYPE_MAX_SIZE) {
1369         TLOGE(WmsLogTag::WMS_IMMS, "size is invalid");
1370         return WSError::WS_ERROR_IPC_FAILED;
1371     }
1372     for (uint32_t i = 0; i < size; i++) {
1373         uint32_t type = reply.ReadUint32();
1374         if (type < static_cast<uint32_t>(AvoidAreaType::TYPE_SYSTEM) ||
1375             type > static_cast<uint32_t>(AvoidAreaType::TYPE_NAVIGATION_INDICATOR)) {
1376             WLOGFE("Read type failed");
1377             return WSError::WS_ERROR_IPC_FAILED;
1378         }
1379         sptr<AvoidArea> area = reply.ReadParcelable<AvoidArea>();
1380         if (area == nullptr) {
1381             return WSError::WS_ERROR_IPC_FAILED;
1382         }
1383         avoidAreas[static_cast<AvoidAreaType>(type)] = *area;
1384     }
1385     uint32_t ret = reply.ReadUint32();
1386     return static_cast<WSError>(ret);
1387 }
1388 
1389 
GetTargetOrientationConfigInfo(Orientation targetOrientation,const std::map<Rosen::WindowType,Rosen::SystemBarProperty> & properties)1390 WSError SessionProxy::GetTargetOrientationConfigInfo(Orientation targetOrientation,
1391     const std::map<Rosen::WindowType, Rosen::SystemBarProperty>& properties)
1392 {
1393     MessageParcel data;
1394     MessageParcel reply;
1395     MessageOption option(MessageOption::TF_ASYNC);
1396     if (!data.WriteInterfaceToken(GetDescriptor())) {
1397         TLOGE(WmsLogTag::WMS_ROTATION, "WriteInterfaceToken failed");
1398         return WSError::WS_ERROR_IPC_FAILED;
1399     }
1400     if (!data.WriteUint32(static_cast<uint32_t>(targetOrientation))) {
1401         TLOGE(WmsLogTag::WMS_ROTATION, "write orientation error");
1402         return WSError::WS_ERROR_IPC_FAILED;
1403     }
1404     if (!data.WriteUint32(static_cast<uint32_t>(properties.size()))) {
1405         TLOGE(WmsLogTag::WMS_ROTATION, "write size error");
1406         return WSError::WS_ERROR_IPC_FAILED;
1407     }
1408     for (const auto& [type, systemBarProperty] : properties) {
1409         if (!data.WriteUint32(static_cast<uint32_t>(type))) {
1410             return WSError::WS_ERROR_IPC_FAILED;
1411         }
1412         if (!data.WriteBool(systemBarProperty.enable_)) {
1413             return WSError::WS_ERROR_IPC_FAILED;
1414         }
1415         if (!data.WriteUint32(systemBarProperty.backgroundColor_)) {
1416             return WSError::WS_ERROR_IPC_FAILED;
1417         }
1418         if (!data.WriteUint32(systemBarProperty.contentColor_)) {
1419             return WSError::WS_ERROR_IPC_FAILED;
1420         }
1421         if (!data.WriteBool(systemBarProperty.enableAnimation_)) {
1422             return WSError::WS_ERROR_IPC_FAILED;
1423         }
1424         if (!data.WriteUint32(static_cast<uint32_t>(systemBarProperty.settingFlag_))) {
1425             return WSError::WS_ERROR_IPC_FAILED;
1426         }
1427     }
1428     sptr<IRemoteObject> remote = Remote();
1429     if (remote == nullptr) {
1430         TLOGE(WmsLogTag::WMS_ROTATION, "remote is null");
1431         return WSError::WS_ERROR_IPC_FAILED;
1432     }
1433     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_TARGET_ORIENTATION_CONFIG_INFO),
1434         data, reply, option) != ERR_NONE) {
1435         TLOGE(WmsLogTag::WMS_ROTATION, "SendRequest failed");
1436         return WSError::WS_ERROR_IPC_FAILED;
1437     }
1438     uint32_t ret = reply.ReadUint32();
1439     return static_cast<WSError>(ret);
1440 }
1441 
RequestSessionBack(bool needMoveToBackground)1442 WSError SessionProxy::RequestSessionBack(bool needMoveToBackground)
1443 {
1444     MessageParcel data;
1445     MessageParcel reply;
1446     MessageOption option(MessageOption::TF_ASYNC);
1447     if (!data.WriteInterfaceToken(GetDescriptor())) {
1448         WLOGFE("WriteInterfaceToken failed");
1449         return WSError::WS_ERROR_IPC_FAILED;
1450     }
1451     if (!data.WriteBool(needMoveToBackground)) {
1452         WLOGFE("Write needMoveToBackground failed");
1453         return WSError::WS_ERROR_IPC_FAILED;
1454     }
1455     sptr<IRemoteObject> remote = Remote();
1456     if (remote == nullptr) {
1457         WLOGFE("remote is null");
1458         return WSError::WS_ERROR_IPC_FAILED;
1459     }
1460     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKPRESSED),
1461         data, reply, option) != ERR_NONE) {
1462         WLOGFE("SendRequest failed");
1463         return WSError::WS_ERROR_IPC_FAILED;
1464     }
1465     int32_t ret = reply.ReadInt32();
1466     return static_cast<WSError>(ret);
1467 }
1468 
MarkProcessed(int32_t eventId)1469 WSError SessionProxy::MarkProcessed(int32_t eventId)
1470 {
1471     MessageParcel data;
1472     MessageParcel reply;
1473     MessageOption option(MessageOption::TF_ASYNC);
1474     if (!data.WriteInterfaceToken(GetDescriptor())) {
1475         WLOGFE("WriteInterfaceToken failed");
1476         return WSError::WS_ERROR_IPC_FAILED;
1477     }
1478     if (!data.WriteInt32(eventId)) {
1479         WLOGFE("WriteInterfaceToken failed");
1480         return WSError::WS_ERROR_IPC_FAILED;
1481     }
1482     sptr<IRemoteObject> remote = Remote();
1483     if (remote == nullptr) {
1484         WLOGFE("remote is null");
1485         return WSError::WS_ERROR_IPC_FAILED;
1486     }
1487     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_MARK_PROCESSED),
1488         data, reply, option) != ERR_NONE) {
1489         WLOGFE("SendRequest failed");
1490         return WSError::WS_ERROR_IPC_FAILED;
1491     }
1492     int32_t ret = reply.ReadInt32();
1493     return static_cast<WSError>(ret);
1494 }
1495 
SetGlobalMaximizeMode(MaximizeMode mode)1496 WSError OHOS::Rosen::SessionProxy::SetGlobalMaximizeMode(MaximizeMode mode)
1497 {
1498     MessageParcel data;
1499     MessageParcel reply;
1500     MessageOption option;
1501     if (!data.WriteInterfaceToken(GetDescriptor())) {
1502         WLOGFE("WriteInterfaceToken failed");
1503         return WSError::WS_ERROR_IPC_FAILED;
1504     }
1505     if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
1506         WLOGFE("Write uint32_t failed");
1507     }
1508     sptr<IRemoteObject> remote = Remote();
1509     if (remote == nullptr) {
1510         WLOGFE("remote is null");
1511         return WSError::WS_ERROR_IPC_FAILED;
1512     }
1513     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_MAXIMIZE_MODE),
1514         data, reply, option) != ERR_NONE) {
1515         WLOGFE("SendRequest failed");
1516         return WSError::WS_ERROR_IPC_FAILED;
1517     }
1518     int32_t ret = reply.ReadInt32();
1519     return static_cast<WSError>(ret);
1520 }
1521 
GetGlobalMaximizeMode(MaximizeMode & mode)1522 WSError SessionProxy::GetGlobalMaximizeMode(MaximizeMode& mode)
1523 {
1524     MessageParcel data;
1525     MessageParcel reply;
1526     MessageOption option;
1527     if (!data.WriteInterfaceToken(GetDescriptor())) {
1528         WLOGFE("WriteInterfaceToken failed");
1529         return WSError::WS_ERROR_IPC_FAILED;
1530     }
1531     sptr<IRemoteObject> remote = Remote();
1532     if (remote == nullptr) {
1533         WLOGFE("remote is null");
1534         return WSError::WS_ERROR_IPC_FAILED;
1535     }
1536     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_MAXIMIZE_MODE),
1537         data, reply, option) != ERR_NONE) {
1538         WLOGFE("SendRequest failed");
1539         return WSError::WS_ERROR_IPC_FAILED;
1540     }
1541     mode = static_cast<MaximizeMode>(reply.ReadUint32());
1542     int32_t ret = reply.ReadInt32();
1543     return static_cast<WSError>(ret);
1544 }
1545 
1546 /** @note @window.layout */
SetAspectRatio(float ratio)1547 WSError SessionProxy::SetAspectRatio(float ratio)
1548 {
1549     MessageParcel data;
1550     MessageParcel reply;
1551     MessageOption option;
1552     if (!data.WriteInterfaceToken(GetDescriptor())) {
1553         WLOGFE("WriteInterfaceToken failed");
1554         return WSError::WS_ERROR_IPC_FAILED;
1555     }
1556     if (!data.WriteFloat(ratio)) {
1557         WLOGFE("Write ratio failed");
1558         return WSError::WS_ERROR_IPC_FAILED;
1559     }
1560     sptr<IRemoteObject> remote = Remote();
1561     if (remote == nullptr) {
1562         WLOGFE("remote is null");
1563         return WSError::WS_ERROR_IPC_FAILED;
1564     }
1565     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_ASPECT_RATIO),
1566                             data, reply, option) != ERR_NONE) {
1567         WLOGFE("SendRequest failed");
1568         return WSError::WS_ERROR_IPC_FAILED;
1569     }
1570     int32_t ret = reply.ReadInt32();
1571     return static_cast<WSError>(ret);
1572 }
1573 
UpdateWindowSceneAfterCustomAnimation(bool isAdd)1574 WSError SessionProxy::UpdateWindowSceneAfterCustomAnimation(bool isAdd)
1575 {
1576     MessageParcel data;
1577     MessageParcel reply;
1578     MessageOption option(MessageOption::TF_ASYNC);
1579     if (!data.WriteInterfaceToken(GetDescriptor())) {
1580         WLOGFE("WriteInterfaceToken failed");
1581         return WSError::WS_ERROR_IPC_FAILED;
1582     }
1583     if (!data.WriteBool(isAdd)) {
1584         WLOGFE("Write isAdd failed");
1585         return WSError::WS_ERROR_IPC_FAILED;
1586     }
1587     sptr<IRemoteObject> remote = Remote();
1588     if (remote == nullptr) {
1589         WLOGFE("remote is null");
1590         return WSError::WS_ERROR_IPC_FAILED;
1591     }
1592     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_CUSTOM_ANIMATION),
1593                             data, reply, option) != ERR_NONE) {
1594         WLOGFE("SendRequest failed");
1595         return WSError::WS_ERROR_IPC_FAILED;
1596     }
1597     int32_t ret = reply.ReadInt32();
1598     return static_cast<WSError>(ret);
1599 }
1600 
SetLandscapeMultiWindow(bool isLandscapeMultiWindow)1601 WSError SessionProxy::SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
1602 {
1603     MessageParcel data;
1604     MessageParcel reply;
1605     MessageOption option(MessageOption::TF_ASYNC);
1606     if (!data.WriteInterfaceToken(GetDescriptor())) {
1607         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "WriteInterfaceToken failed");
1608         return WSError::WS_ERROR_IPC_FAILED;
1609     }
1610     if (!data.WriteBool(isLandscapeMultiWindow)) {
1611         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "Write isLandscapeMultiWindow failed");
1612         return WSError::WS_ERROR_IPC_FAILED;
1613     }
1614     sptr<IRemoteObject> remote = Remote();
1615     if (remote == nullptr) {
1616         WLOGFE("remote is null");
1617         return WSError::WS_ERROR_IPC_FAILED;
1618     }
1619     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW),
1620                             data, reply, option) != ERR_NONE) {
1621         WLOGFE("SendRequest failed");
1622         return WSError::WS_ERROR_IPC_FAILED;
1623     }
1624     int32_t ret = reply.ReadInt32();
1625     return static_cast<WSError>(ret);
1626 }
1627 
GetIsMidScene(bool & isMidScene)1628 WSError SessionProxy::GetIsMidScene(bool& isMidScene)
1629 {
1630     MessageParcel data;
1631     MessageParcel reply;
1632     MessageOption option;
1633     if (!data.WriteInterfaceToken(GetDescriptor())) {
1634         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "WriteInterfaceToken failed");
1635         return WSError::WS_ERROR_IPC_FAILED;
1636     }
1637     sptr<IRemoteObject> remote = Remote();
1638     if (remote == nullptr) {
1639         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "remote is null");
1640         return WSError::WS_ERROR_IPC_FAILED;
1641     }
1642     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_IS_MID_SCENE),
1643         data, reply, option) != ERR_NONE) {
1644         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "SendRequest failed");
1645         return WSError::WS_ERROR_IPC_FAILED;
1646     }
1647     if (!reply.ReadBool(isMidScene)) {
1648         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "Read isMidScene failed");
1649         return WSError::WS_ERROR_IPC_FAILED;
1650     }
1651     int32_t ret = reply.ReadInt32();
1652     return static_cast<WSError>(ret);
1653 }
1654 
TransferAbilityResult(uint32_t resultCode,const AAFwk::Want & want)1655 WSError SessionProxy::TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want)
1656 {
1657     MessageParcel data;
1658     MessageParcel reply;
1659     MessageOption option(MessageOption::TF_ASYNC);
1660     if (!data.WriteInterfaceToken(GetDescriptor())) {
1661         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1662         return WSError::WS_ERROR_IPC_FAILED;
1663     }
1664     if (!data.WriteUint32(resultCode)) {
1665         TLOGE(WmsLogTag::WMS_UIEXT, "resultCode write failed.");
1666         return WSError::WS_ERROR_IPC_FAILED;
1667     }
1668     if (!data.WriteParcelable(&want)) {
1669         TLOGE(WmsLogTag::WMS_UIEXT, "want write failed.");
1670         return WSError::WS_ERROR_IPC_FAILED;
1671     }
1672     sptr<IRemoteObject> remote = Remote();
1673     if (remote == nullptr) {
1674         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1675         return WSError::WS_ERROR_IPC_FAILED;
1676     }
1677     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_ABILITY_RESULT),
1678         data, reply, option);
1679     if (sendCode != ERR_NONE) {
1680         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1681         return WSError::WS_ERROR_IPC_FAILED;
1682     }
1683     int32_t ret = reply.ReadInt32();
1684     return static_cast<WSError>(ret);
1685 }
1686 
TransferExtensionData(const AAFwk::WantParams & wantParams)1687 int32_t SessionProxy::TransferExtensionData(const AAFwk::WantParams& wantParams)
1688 {
1689     MessageParcel data;
1690     MessageParcel reply;
1691     MessageOption option(MessageOption::TF_ASYNC);
1692     if (!data.WriteInterfaceToken(GetDescriptor())) {
1693         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1694         return IPC_PROXY_ERR;
1695     }
1696     if (!data.WriteParcelable(&wantParams)) {
1697         TLOGE(WmsLogTag::WMS_UIEXT, "wantParams write failed.");
1698         return IPC_PROXY_ERR;
1699     }
1700     sptr<IRemoteObject> remote = Remote();
1701     if (remote == nullptr) {
1702         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1703         return IPC_PROXY_ERR;
1704     }
1705     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_EXTENSION_DATA),
1706         data, reply, option);
1707     if (sendCode != ERR_NONE) {
1708         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1709     }
1710     int32_t ret = reply.ReadInt32();
1711     if (ret != ERR_NONE) {
1712         TLOGE(WmsLogTag::WMS_UIEXT, "Ret value read by ReadInt32 is abnormal, ret: %{public}d", ret);
1713     }
1714     return sendCode;
1715 }
1716 
NotifySyncOn()1717 void SessionProxy::NotifySyncOn()
1718 {
1719     MessageParcel data;
1720     MessageParcel reply;
1721     MessageOption option(MessageOption::TF_ASYNC);
1722     if (!data.WriteInterfaceToken(GetDescriptor())) {
1723         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1724         return;
1725     }
1726     sptr<IRemoteObject> remote = Remote();
1727     if (remote == nullptr) {
1728         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1729         return;
1730     }
1731     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_SYNC_ON),
1732         data, reply, option);
1733     if (sendCode != ERR_NONE) {
1734         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1735     }
1736 }
1737 
NotifyAsyncOn()1738 void SessionProxy::NotifyAsyncOn()
1739 {
1740     MessageParcel data;
1741     MessageParcel reply;
1742     MessageOption option(MessageOption::TF_ASYNC);
1743     if (!data.WriteInterfaceToken(GetDescriptor())) {
1744         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1745         return;
1746     }
1747     sptr<IRemoteObject> remote = Remote();
1748     if (remote == nullptr) {
1749         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1750         return;
1751     }
1752     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_ASYNC_ON),
1753         data, reply, option);
1754     if (sendCode != ERR_NONE) {
1755         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1756     }
1757 }
1758 
NotifyExtensionDied()1759 void SessionProxy::NotifyExtensionDied()
1760 {
1761     TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionDied called.");
1762     MessageParcel data;
1763     MessageParcel reply;
1764     MessageOption option(MessageOption::TF_ASYNC);
1765     if (!data.WriteInterfaceToken(GetDescriptor())) {
1766         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1767         return;
1768     }
1769     sptr<IRemoteObject> remote = Remote();
1770     if (remote == nullptr) {
1771         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1772         return;
1773     }
1774     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED),
1775         data, reply, option);
1776     if (sendCode != ERR_NONE) {
1777         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1778     }
1779 }
1780 
NotifyExtensionTimeout(int32_t errorCode)1781 void SessionProxy::NotifyExtensionTimeout(int32_t errorCode)
1782 {
1783     TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionTimeout(errorCode:%{public}d) called.", errorCode);
1784     MessageParcel data;
1785     MessageParcel reply;
1786     MessageOption option(MessageOption::TF_ASYNC);
1787     if (!data.WriteInterfaceToken(GetDescriptor())) {
1788         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1789         return;
1790     }
1791     if (!data.WriteInt32(static_cast<int32_t>(errorCode))) {
1792         TLOGE(WmsLogTag::WMS_UIEXT, "errorCode write failed.");
1793         return;
1794     }
1795     sptr<IRemoteObject> remote = Remote();
1796     if (remote == nullptr) {
1797         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1798         return;
1799     }
1800     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT),
1801         data, reply, option);
1802     if (sendCode != ERR_NONE) {
1803         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1804     }
1805 }
1806 
TriggerBindModalUIExtension()1807 void SessionProxy::TriggerBindModalUIExtension()
1808 {
1809     MessageParcel data;
1810     MessageParcel reply;
1811     MessageOption option(MessageOption::TF_SYNC);
1812     if (!data.WriteInterfaceToken(GetDescriptor())) {
1813         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1814         return;
1815     }
1816     sptr<IRemoteObject> remote = Remote();
1817     if (remote == nullptr) {
1818         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1819         return;
1820     }
1821     int sendCode = remote->SendRequest(
1822         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION), data, reply, option);
1823     if (sendCode != ERR_NONE) {
1824         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1825     }
1826 }
1827 
UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)1828 WSError SessionProxy::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)
1829 {
1830     MessageParcel data;
1831     MessageParcel reply;
1832     MessageOption option;
1833     if (!data.WriteInterfaceToken(GetDescriptor())) {
1834         WLOGFE("WriteInterfaceToken failed");
1835         return WSError::WS_ERROR_IPC_FAILED;
1836     }
1837     if (!data.WriteBool(needDefaultAnimationFlag)) {
1838         WLOGFE("wantParams write failed.");
1839         return WSError::WS_ERROR_IPC_FAILED;
1840     }
1841     sptr<IRemoteObject> remote = Remote();
1842     if (remote == nullptr) {
1843         WLOGFE("remote is null");
1844         return WSError::WS_ERROR_IPC_FAILED;
1845     }
1846     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG),
1847         data, reply, option) != ERR_NONE) {
1848         WLOGFE("SendRequest failed");
1849         return WSError::WS_ERROR_IPC_FAILED;
1850     }
1851     int32_t ret = reply.ReadInt32();
1852     return static_cast<WSError>(ret);
1853 }
1854 
TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)1855 WSError SessionProxy::TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
1856     int64_t uiExtensionIdLevel)
1857 {
1858     MessageParcel data;
1859     MessageParcel reply;
1860     MessageOption option(MessageOption::TF_ASYNC);
1861     if (!data.WriteInterfaceToken(GetDescriptor())) {
1862         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1863         return WSError::WS_ERROR_IPC_FAILED;
1864     }
1865     Accessibility::AccessibilityEventInfoParcel infoParcel(info);
1866     if (!data.WriteParcelable(&infoParcel)) {
1867         TLOGE(WmsLogTag::WMS_UIEXT, "infoParcel write failed.");
1868         return WSError::WS_ERROR_IPC_FAILED;
1869     }
1870     if (!data.WriteInt64(uiExtensionIdLevel)) {
1871         TLOGE(WmsLogTag::WMS_UIEXT, "idVec write failed.");
1872         return WSError::WS_ERROR_IPC_FAILED;
1873     }
1874     sptr<IRemoteObject> remote = Remote();
1875     if (remote == nullptr) {
1876         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1877         return WSError::WS_ERROR_IPC_FAILED;
1878     }
1879     int sendCode = remote->SendRequest(
1880         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT), data, reply, option);
1881     if (sendCode != ERR_NONE) {
1882         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
1883         return WSError::WS_ERROR_IPC_FAILED;
1884     }
1885     return WSError::WS_OK;
1886 }
1887 
NotifyPiPWindowPrepareClose()1888 void SessionProxy::NotifyPiPWindowPrepareClose()
1889 {
1890     MessageParcel data;
1891     MessageParcel reply;
1892     MessageOption option(MessageOption::TF_ASYNC);
1893     if (!data.WriteInterfaceToken(GetDescriptor())) {
1894         WLOGFE("writeInterfaceToken failed");
1895         return;
1896     }
1897     sptr<IRemoteObject> remote = Remote();
1898     if (remote == nullptr) {
1899         WLOGFE("remote is null");
1900         return;
1901     }
1902     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE),
1903         data, reply, option) != ERR_NONE) {
1904         WLOGFE("SendRequest failed");
1905         return;
1906     }
1907 }
1908 
UpdatePiPRect(const Rect & rect,SizeChangeReason reason)1909 WSError SessionProxy::UpdatePiPRect(const Rect& rect, SizeChangeReason reason)
1910 {
1911     MessageParcel data;
1912     MessageParcel reply;
1913     MessageOption option;
1914     if (!data.WriteInterfaceToken(GetDescriptor())) {
1915         WLOGFE("writeInterfaceToken failed");
1916         return WSError::WS_ERROR_IPC_FAILED;
1917     }
1918     if (!data.WriteInt32(rect.posX_)) {
1919         WLOGFE("write posX_ failed.");
1920         return WSError::WS_ERROR_IPC_FAILED;
1921     }
1922     if (!data.WriteInt32(rect.posY_)) {
1923         WLOGFE("write posY_ failed.");
1924         return WSError::WS_ERROR_IPC_FAILED;
1925     }
1926     if (!data.WriteUint32(rect.width_)) {
1927         WLOGFE("write width_ failed.");
1928         return WSError::WS_ERROR_IPC_FAILED;
1929     }
1930     if (!data.WriteUint32(rect.height_)) {
1931         WLOGFE("write height_ failed.");
1932         return WSError::WS_ERROR_IPC_FAILED;
1933     }
1934     if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
1935         WLOGFE("reason write failed.");
1936         return WSError::WS_ERROR_IPC_FAILED;
1937     }
1938     sptr<IRemoteObject> remote = Remote();
1939     if (remote == nullptr) {
1940         WLOGFE("remote is null");
1941         return WSError::WS_ERROR_IPC_FAILED;
1942     }
1943     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_RECT),
1944         data, reply, option) != ERR_NONE) {
1945         WLOGFE("SendRequest failed");
1946         return WSError::WS_ERROR_IPC_FAILED;
1947     }
1948     int32_t ret = reply.ReadInt32();
1949     return static_cast<WSError>(ret);
1950 }
1951 
UpdatePiPControlStatus(WsPiPControlType controlType,WsPiPControlStatus status)1952 WSError SessionProxy::UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status)
1953 {
1954     TLOGI(WmsLogTag::WMS_PIP, "controlType:%{public}u, status:%{public}d", controlType, status);
1955     MessageParcel data;
1956     MessageParcel reply;
1957     MessageOption option;
1958     if (!data.WriteInterfaceToken(GetDescriptor())) {
1959         TLOGE(WmsLogTag::WMS_PIP, "writeInterfaceToken failed");
1960         return WSError::WS_ERROR_IPC_FAILED;
1961     }
1962     if (!data.WriteUint32(static_cast<uint32_t>(controlType))) {
1963         TLOGE(WmsLogTag::WMS_PIP, "Write controlType failed");
1964         return WSError::WS_ERROR_IPC_FAILED;
1965     }
1966     if (!data.WriteInt32(static_cast<int32_t>(status))) {
1967         TLOGE(WmsLogTag::WMS_PIP, "write status failed.");
1968         return WSError::WS_ERROR_IPC_FAILED;
1969     }
1970     sptr<IRemoteObject> remote = Remote();
1971     if (remote == nullptr) {
1972         TLOGE(WmsLogTag::WMS_PIP, "remote is null");
1973         return WSError::WS_ERROR_IPC_FAILED;
1974     }
1975     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_CONTROL_STATUS),
1976         data, reply, option) != ERR_NONE) {
1977         TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
1978         return WSError::WS_ERROR_IPC_FAILED;
1979     }
1980     int32_t ret = reply.ReadInt32();
1981     return static_cast<WSError>(ret);
1982 }
1983 
SetAutoStartPiP(bool isAutoStart,uint32_t priority,uint32_t width,uint32_t height)1984 WSError SessionProxy::SetAutoStartPiP(bool isAutoStart, uint32_t priority, uint32_t width, uint32_t height)
1985 {
1986     TLOGD(WmsLogTag::WMS_PIP, "isAutoStart:%{public}u priority:%{public}u width:%{public}u height:%{public}u",
1987         isAutoStart, priority, width, height);
1988     MessageParcel data;
1989     MessageParcel reply;
1990     MessageOption option;
1991     if (!data.WriteInterfaceToken(GetDescriptor())) {
1992         TLOGE(WmsLogTag::WMS_PIP, "writeInterfaceToken failed");
1993         return WSError::WS_ERROR_IPC_FAILED;
1994     }
1995     if (!data.WriteBool(isAutoStart)) {
1996         TLOGE(WmsLogTag::WMS_PIP, "write isAutoStart failed");
1997         return WSError::WS_ERROR_IPC_FAILED;
1998     }
1999     if (!data.WriteUint32(priority)) {
2000         TLOGE(WmsLogTag::WMS_PIP, "write priority failed");
2001         return WSError::WS_ERROR_IPC_FAILED;
2002     }
2003     if (!data.WriteUint32(width)) {
2004         TLOGE(WmsLogTag::WMS_PIP, "write width failed");
2005         return WSError::WS_ERROR_IPC_FAILED;
2006     }
2007     if (!data.WriteUint32(height)) {
2008         TLOGE(WmsLogTag::WMS_PIP, "write height failed");
2009         return WSError::WS_ERROR_IPC_FAILED;
2010     }
2011     sptr<IRemoteObject> remote = Remote();
2012     if (remote == nullptr) {
2013         TLOGE(WmsLogTag::WMS_PIP, "remote is null");
2014         return WSError::WS_ERROR_IPC_FAILED;
2015     }
2016     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_AUTOSTART_PIP),
2017         data, reply, option) != ERR_NONE) {
2018         TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
2019         return WSError::WS_ERROR_IPC_FAILED;
2020     }
2021     int32_t ret = reply.ReadInt32();
2022     return static_cast<WSError>(ret);
2023 }
2024 
UpdateFloatingBall(const FloatingBallTemplateInfo & fbTemplateInfo)2025 WMError SessionProxy::UpdateFloatingBall(const FloatingBallTemplateInfo& fbTemplateInfo)
2026 {
2027     MessageParcel data;
2028     MessageParcel reply;
2029     MessageOption option;
2030     if (!data.WriteInterfaceToken(GetDescriptor())) {
2031         TLOGE(WmsLogTag::WMS_SYSTEM, "writeInterfaceToken failed");
2032         return WMError::WM_ERROR_IPC_FAILED;
2033     }
2034     if (!data.WriteParcelable(&fbTemplateInfo)) {
2035         TLOGE(WmsLogTag::WMS_SYSTEM, "write fbTemplateInfo failed");
2036         return WMError::WM_ERROR_IPC_FAILED;
2037     }
2038     sptr<IRemoteObject> remote = Remote();
2039     if (remote == nullptr) {
2040         TLOGE(WmsLogTag::WMS_SYSTEM, "remote is null");
2041         return WMError::WM_ERROR_IPC_FAILED;
2042     }
2043     auto errCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_FLOATING_BALL),
2044                                        data, reply, option);
2045     if (errCode != ERR_NONE) {
2046         TLOGE(WmsLogTag::WMS_SYSTEM, "SendRequest failed code: %{public}d", errCode);
2047         return WMError::WM_ERROR_IPC_FAILED;
2048     }
2049     int32_t ret = 0;
2050     if (!reply.ReadInt32(ret)) {
2051         TLOGE(WmsLogTag::WMS_SYSTEM, "Read reply failed");
2052         return WMError::WM_ERROR_IPC_FAILED;
2053     }
2054     return static_cast<WMError>(ret);
2055 }
2056 
RestoreFbMainWindow(const std::shared_ptr<AAFwk::Want> & want)2057 WMError SessionProxy::RestoreFbMainWindow(const std::shared_ptr<AAFwk::Want>& want)
2058 {
2059     MessageParcel data;
2060     MessageParcel reply;
2061     MessageOption option;
2062     if (want == nullptr) {
2063         TLOGE(WmsLogTag::WMS_SYSTEM, "want is nullptr");
2064         return WMError::WM_ERROR_IPC_FAILED;
2065     }
2066 
2067     if (!data.WriteInterfaceToken(GetDescriptor())) {
2068         TLOGE(WmsLogTag::WMS_SYSTEM, "writeInterfaceToken failed");
2069         return WMError::WM_ERROR_IPC_FAILED;
2070     }
2071     if (!data.WriteParcelable(want.get())) {
2072         TLOGE(WmsLogTag::WMS_SYSTEM, "write icon failed");
2073         return WMError::WM_ERROR_IPC_FAILED;
2074     }
2075     sptr<IRemoteObject> remote = Remote();
2076     if (remote == nullptr) {
2077         TLOGE(WmsLogTag::WMS_SYSTEM, "remote is null");
2078         return WMError::WM_ERROR_IPC_FAILED;
2079     }
2080     auto errCode = remote->SendRequest(
2081         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_START_FLOATING_BALL_MAIN_WINDOW), data, reply, option);
2082     if (errCode != ERR_NONE) {
2083         TLOGE(WmsLogTag::WMS_SYSTEM, "SendRequest failed code: %{public}d", errCode);
2084         return WMError::WM_ERROR_IPC_FAILED;
2085     }
2086     int32_t ret = 0;
2087     if (!reply.ReadInt32(ret)) {
2088         TLOGE(WmsLogTag::WMS_SYSTEM, "Read reply failed");
2089         return WMError::WM_ERROR_IPC_FAILED;
2090     }
2091     return static_cast<WMError>(ret);
2092 }
2093 
GetFloatingBallWindowId(uint32_t & windowId)2094 WMError SessionProxy::GetFloatingBallWindowId(uint32_t& windowId)
2095 {
2096     TLOGI(WmsLogTag::WMS_SYSTEM, "GetFloatingBallWindowId start");
2097     MessageParcel data;
2098     MessageParcel reply;
2099     MessageOption option;
2100     if (!data.WriteInterfaceToken(GetDescriptor())) {
2101         TLOGE(WmsLogTag::WMS_SYSTEM, "writeInterfaceToken failed");
2102         return WMError::WM_ERROR_IPC_FAILED;
2103     }
2104     sptr<IRemoteObject> remote = Remote();
2105     if (remote == nullptr) {
2106         TLOGE(WmsLogTag::WMS_SYSTEM, "remote is null");
2107         return WMError::WM_ERROR_IPC_FAILED;
2108     }
2109     auto errCode = remote->SendRequest(
2110         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_FLOATING_BALL_WINDOW_ID), data, reply, option);
2111     if (errCode != ERR_NONE) {
2112         TLOGE(WmsLogTag::WMS_SYSTEM, "SendRequest failed code: %{public}d", errCode);
2113         return WMError::WM_ERROR_IPC_FAILED;
2114     }
2115 
2116     int32_t ret = 0;
2117     if (!reply.ReadInt32(ret)) {
2118         TLOGE(WmsLogTag::WMS_SYSTEM, "Read reply failed");
2119         return WMError::WM_ERROR_IPC_FAILED;
2120     }
2121     if (!reply.ReadUint32(windowId)) {
2122         TLOGE(WmsLogTag::WMS_SYSTEM, "Read windowId failed");
2123         return WMError::WM_ERROR_IPC_FAILED;
2124     }
2125 
2126     TLOGI(WmsLogTag::WMS_SYSTEM, "GetFloatingBallWindowId send success, %{public}d, %{public}d", ret, windowId);
2127     return static_cast<WMError>(ret);
2128 }
2129 
ProcessPointDownSession(int32_t posX,int32_t posY)2130 WSError SessionProxy::ProcessPointDownSession(int32_t posX, int32_t posY)
2131 {
2132     MessageParcel data;
2133     MessageParcel reply;
2134     MessageOption option;
2135     if (!data.WriteInterfaceToken(GetDescriptor())) {
2136         WLOGFE("writeInterfaceToken failed");
2137         return WSError::WS_ERROR_IPC_FAILED;
2138     }
2139     if (!data.WriteInt32(posX)) {
2140         WLOGFE("width poX failed.");
2141         return WSError::WS_ERROR_IPC_FAILED;
2142     }
2143     if (!data.WriteInt32(posY)) {
2144         WLOGFE("width posY failed.");
2145         return WSError::WS_ERROR_IPC_FAILED;
2146     }
2147     sptr<IRemoteObject> remote = Remote();
2148     if (remote == nullptr) {
2149         WLOGFE("remote is null");
2150         return WSError::WS_ERROR_IPC_FAILED;
2151     }
2152     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_PROCESS_POINT_DOWN_SESSION),
2153         data, reply, option) != ERR_NONE) {
2154         WLOGFE("SendRequest failed");
2155         return WSError::WS_ERROR_IPC_FAILED;
2156     }
2157     return static_cast<WSError>(reply.ReadInt32());
2158 }
2159 
SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent> & pointerEvent,bool isExecuteDelayRaise)2160 WSError SessionProxy::SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
2161     bool isExecuteDelayRaise)
2162 {
2163     MessageParcel data;
2164     MessageParcel reply;
2165     MessageOption option;
2166     if (!data.WriteInterfaceToken(GetDescriptor())) {
2167         WLOGFE("writeInterfaceToken failed");
2168         return WSError::WS_ERROR_IPC_FAILED;
2169     }
2170     if (!pointerEvent->WriteToParcel(data)) {
2171         WLOGFE("width pointerEvent failed.");
2172         return WSError::WS_ERROR_IPC_FAILED;
2173     }
2174     if (!data.WriteBool(isExecuteDelayRaise)) {
2175         TLOGE(WmsLogTag::WMS_FOCUS, "write isExecuteDelayRaise failed");
2176         return WSError::WS_ERROR_IPC_FAILED;
2177     }
2178     sptr<IRemoteObject> remote = Remote();
2179     if (remote == nullptr) {
2180         WLOGFE("remote is null");
2181         return WSError::WS_ERROR_IPC_FAILED;
2182     }
2183     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SEND_POINTEREVENT_FOR_MOVE_DRAG),
2184         data, reply, option) != ERR_NONE) {
2185         WLOGFE("SendRequest failed");
2186         return WSError::WS_ERROR_IPC_FAILED;
2187     }
2188     return static_cast<WSError>(reply.ReadInt32());
2189 }
2190 
IsStartMoving()2191 bool SessionProxy::IsStartMoving()
2192 {
2193     MessageParcel data;
2194     MessageParcel reply;
2195     MessageOption option;
2196     if (!data.WriteInterfaceToken(GetDescriptor())) {
2197         TLOGE(WmsLogTag::WMS_LAYOUT, "writeInterfaceToken failed");
2198         return false;
2199     }
2200     sptr<IRemoteObject> remote = Remote();
2201     if (remote == nullptr) {
2202         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2203         return false;
2204     }
2205     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_IS_START_MOVING),
2206         data, reply, option) != ERR_NONE) {
2207         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2208         return false;
2209     }
2210     bool isMoving = false;
2211     if (!reply.ReadBool(isMoving)) {
2212         TLOGE(WmsLogTag::WMS_LAYOUT, "Read isMoving failed");
2213         return false;
2214     }
2215     return isMoving;
2216 }
2217 
SetSystemWindowEnableDrag(bool enableDrag)2218 WMError SessionProxy::SetSystemWindowEnableDrag(bool enableDrag)
2219 {
2220     TLOGD(WmsLogTag::WMS_LAYOUT, "enableDrag: %{public}d", enableDrag);
2221     MessageParcel data;
2222     MessageParcel reply;
2223     MessageOption option(MessageOption::TF_SYNC);
2224     if (!data.WriteInterfaceToken(GetDescriptor())) {
2225         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
2226         return WMError::WM_ERROR_IPC_FAILED;
2227     }
2228     if (!data.WriteBool(enableDrag)) {
2229         TLOGE(WmsLogTag::WMS_LAYOUT, "write enableDrag failed");
2230         return WMError::WM_ERROR_IPC_FAILED;
2231     }
2232     sptr<IRemoteObject> remote = Remote();
2233     if (remote == nullptr) {
2234         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2235         return WMError::WM_ERROR_IPC_FAILED;
2236     }
2237     if (remote->SendRequest(
2238         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_SYSTEM_DRAG_ENABLE),
2239         data, reply, option) != ERR_NONE) {
2240         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2241         return WMError::WM_ERROR_IPC_FAILED;
2242     }
2243     int32_t ret = reply.ReadInt32();
2244     return static_cast<WMError>(ret);
2245 }
2246 
UpdateRectChangeListenerRegistered(bool isRegister)2247 WSError SessionProxy::UpdateRectChangeListenerRegistered(bool isRegister)
2248 {
2249     MessageParcel data;
2250     MessageParcel reply;
2251     MessageOption option(MessageOption::TF_SYNC);
2252     if (!data.WriteInterfaceToken(GetDescriptor())) {
2253         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
2254         return WSError::WS_ERROR_IPC_FAILED;
2255     }
2256     if (!data.WriteBool(isRegister)) {
2257         TLOGE(WmsLogTag::WMS_LAYOUT, "write isRegister failed");
2258         return WSError::WS_ERROR_IPC_FAILED;
2259     }
2260     sptr<IRemoteObject> remote = Remote();
2261     if (remote == nullptr) {
2262         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2263         return WSError::WS_ERROR_IPC_FAILED;
2264     }
2265     if (remote->SendRequest(
2266         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED),
2267         data, reply, option) != ERR_NONE) {
2268         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2269         return WSError::WS_ERROR_IPC_FAILED;
2270     }
2271     int32_t ret = reply.ReadInt32();
2272     return static_cast<WSError>(ret);
2273 }
2274 
SetCallingSessionId(const uint32_t callingSessionId)2275 void SessionProxy::SetCallingSessionId(const uint32_t callingSessionId)
2276 {
2277     MessageParcel data;
2278     MessageParcel reply;
2279     MessageOption option;
2280     if (!data.WriteInterfaceToken(GetDescriptor())) {
2281         TLOGE(WmsLogTag::WMS_KEYBOARD, "writeInterfaceToken failed");
2282         return;
2283     }
2284     if (!data.WriteUint32(callingSessionId)) {
2285         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write callingSessionId failed.");
2286         return;
2287     }
2288     sptr<IRemoteObject> remote = Remote();
2289     if (remote == nullptr) {
2290         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2291         return;
2292     }
2293     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CALLING_SESSION_ID),
2294         data, reply, option) != ERR_NONE) {
2295         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2296         return;
2297     }
2298 }
2299 
SetCustomDecorHeight(int32_t height)2300 void SessionProxy::SetCustomDecorHeight(int32_t height)
2301 {
2302     MessageParcel data;
2303     MessageParcel reply;
2304     MessageOption option(MessageOption::TF_ASYNC);
2305     if (!data.WriteInterfaceToken(GetDescriptor())) {
2306         TLOGE(WmsLogTag::WMS_DECOR, "writeInterfaceToken failed");
2307         return;
2308     }
2309     if (!data.WriteInt32(height)) {
2310         TLOGE(WmsLogTag::WMS_DECOR, "Write height failed.");
2311         return;
2312     }
2313     sptr<IRemoteObject> remote = Remote();
2314     if (remote == nullptr) {
2315         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2316         return;
2317     }
2318     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CUSTOM_DECOR_HEIGHT),
2319         data, reply, option) != ERR_NONE) {
2320         TLOGE(WmsLogTag::WMS_DECOR, "SendRequest failed");
2321         return;
2322     }
2323 }
2324 
AdjustKeyboardLayout(const KeyboardLayoutParams & params)2325 WSError SessionProxy::AdjustKeyboardLayout(const KeyboardLayoutParams& params)
2326 {
2327     MessageParcel data;
2328     MessageParcel reply;
2329     MessageOption option(MessageOption::TF_ASYNC);
2330     if (!data.WriteInterfaceToken(GetDescriptor())) {
2331         TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
2332         return WSError::WS_ERROR_IPC_FAILED;
2333     }
2334     if (!data.WriteParcelable(&params)) {
2335         TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboard layout params write failed");
2336         return WSError::WS_ERROR_IPC_FAILED;
2337     }
2338     sptr<IRemoteObject> remote = Remote();
2339     if (remote == nullptr) {
2340         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2341         return WSError::WS_ERROR_IPC_FAILED;
2342     }
2343     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_ADJUST_KEYBOARD_LAYOUT),
2344         data, reply, option) != ERR_NONE) {
2345         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2346         return WSError::WS_ERROR_IPC_FAILED;
2347     }
2348     return static_cast<WSError>(reply.ReadInt32());
2349 }
2350 
ChangeKeyboardEffectOption(const KeyboardEffectOption & effectOption)2351 WSError SessionProxy::ChangeKeyboardEffectOption(const KeyboardEffectOption& effectOption)
2352 {
2353     MessageParcel data;
2354     MessageParcel reply;
2355     MessageOption option(MessageOption::TF_ASYNC);
2356     if (!data.WriteInterfaceToken(GetDescriptor())) {
2357         TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
2358         return WSError::WS_ERROR_IPC_FAILED;
2359     }
2360     if (!data.WriteParcelable(&effectOption)) {
2361         TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboard layout params write failed");
2362         return WSError::WS_ERROR_IPC_FAILED;
2363     }
2364     sptr<IRemoteObject> remote = Remote();
2365     if (remote == nullptr) {
2366         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2367         return WSError::WS_ERROR_IPC_FAILED;
2368     }
2369     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_CHANGE_KEYBOARD_VIEW_MODE),
2370         data, reply, option) != ERR_NONE) {
2371         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2372         return WSError::WS_ERROR_IPC_FAILED;
2373     }
2374     return WSError::WS_OK;
2375 }
2376 
UpdateSessionPropertyByAction(const sptr<WindowSessionProperty> & property,WSPropertyChangeAction action)2377 WMError SessionProxy::UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
2378     WSPropertyChangeAction action)
2379 {
2380     MessageParcel data;
2381     MessageParcel reply;
2382     MessageOption option(MessageOption::TF_SYNC);
2383     if (action == WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON ||
2384         action == WSPropertyChangeAction::ACTION_UPDATE_VIEW_KEEP_SCREEN_ON) {
2385         option.SetFlags(MessageOption::TF_ASYNC);
2386     }
2387     if (!data.WriteInterfaceToken(GetDescriptor())) {
2388         TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
2389         return WMError::WM_ERROR_IPC_FAILED;
2390     }
2391     if (!data.WriteUint64(static_cast<uint64_t>(action))) {
2392         TLOGE(WmsLogTag::DEFAULT, "Write PropertyChangeAction failed");
2393         return WMError::WM_ERROR_IPC_FAILED;
2394     }
2395     if (property) {
2396         if (!data.WriteBool(true) || !property->Write(data, action)) {
2397             TLOGE(WmsLogTag::DEFAULT, "Write property failed");
2398             return WMError::WM_ERROR_IPC_FAILED;
2399         }
2400     } else {
2401         if (!data.WriteBool(false)) {
2402             TLOGE(WmsLogTag::DEFAULT, "Write property failed");
2403             return WMError::WM_ERROR_IPC_FAILED;
2404         }
2405     }
2406 
2407     sptr<IRemoteObject> remote = Remote();
2408     if (remote == nullptr) {
2409         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2410         return WMError::WM_ERROR_IPC_FAILED;
2411     }
2412     if (remote->SendRequest(static_cast<uint32_t>(
2413         SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_PROPERTY),
2414         data, reply, option) != ERR_NONE) {
2415         TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2416         return WMError::WM_ERROR_IPC_FAILED;
2417     }
2418     int32_t ret = reply.ReadInt32();
2419     return static_cast<WMError>(ret);
2420 }
2421 
GetAppForceLandscapeConfig(AppForceLandscapeConfig & config)2422 WMError SessionProxy::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config)
2423 {
2424     MessageParcel data;
2425     MessageParcel reply;
2426     MessageOption option(MessageOption::TF_SYNC);
2427     if (!data.WriteInterfaceToken(GetDescriptor())) {
2428         TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
2429         return WMError::WM_ERROR_IPC_FAILED;
2430     }
2431     sptr<IRemoteObject> remote = Remote();
2432     if (remote == nullptr) {
2433         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2434         return WMError::WM_ERROR_IPC_FAILED;
2435     }
2436     if (remote->SendRequest(static_cast<uint32_t>(
2437         SessionInterfaceCode::TRANS_ID_GET_FORCE_LANDSCAPE_CONFIG),
2438         data, reply, option) != ERR_NONE) {
2439         TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2440         return WMError::WM_ERROR_IPC_FAILED;
2441     }
2442     sptr<AppForceLandscapeConfig> replyConfig = reply.ReadParcelable<AppForceLandscapeConfig>();
2443     if (replyConfig) {
2444         config = *replyConfig;
2445     }
2446     int32_t ret = reply.ReadInt32();
2447     return static_cast<WMError>(ret);
2448 }
2449 
GetAppHookWindowInfoFromServer(HookWindowInfo & hookWindowInfo)2450 WMError SessionProxy::GetAppHookWindowInfoFromServer(HookWindowInfo& hookWindowInfo)
2451 {
2452     MessageParcel data;
2453     MessageParcel reply;
2454     MessageOption option(MessageOption::TF_SYNC);
2455     if (!data.WriteInterfaceToken(GetDescriptor())) {
2456         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
2457         return WMError::WM_ERROR_IPC_FAILED;
2458     }
2459     sptr<IRemoteObject> remote = Remote();
2460     if (!remote) {
2461         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2462         return WMError::WM_ERROR_IPC_FAILED;
2463     }
2464     uint32_t requestCode = static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_HOOK_WINDOW_INFO);
2465     if (remote->SendRequest(requestCode, data, reply, option) != ERR_NONE) {
2466         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2467         return WMError::WM_ERROR_IPC_FAILED;
2468     }
2469     sptr<HookWindowInfo> replyInfo = reply.ReadParcelable<HookWindowInfo>();
2470     if (replyInfo) {
2471         hookWindowInfo = *replyInfo;
2472     }
2473     int32_t ret = 0;
2474     if (!reply.ReadInt32(ret)) {
2475         TLOGE(WmsLogTag::WMS_LAYOUT, "read ret failed");
2476         return WMError::WM_ERROR_IPC_FAILED;
2477     }
2478     return static_cast<WMError>(ret);
2479 }
2480 
SetDialogSessionBackGestureEnabled(bool isEnabled)2481 WSError SessionProxy::SetDialogSessionBackGestureEnabled(bool isEnabled)
2482 {
2483     MessageParcel data;
2484     MessageParcel reply;
2485     MessageOption option(MessageOption::TF_SYNC);
2486     if (!data.WriteInterfaceToken(GetDescriptor())) {
2487         TLOGE(WmsLogTag::WMS_DIALOG, "WriteInterfaceToken failed");
2488         return WSError::WS_ERROR_IPC_FAILED;
2489     }
2490     if (!data.WriteBool(isEnabled)) {
2491         TLOGE(WmsLogTag::WMS_DIALOG, "Write isEnabled failed");
2492         return WSError::WS_ERROR_IPC_FAILED;
2493     }
2494     sptr<IRemoteObject> remote = Remote();
2495     if (remote == nullptr) {
2496         TLOGE(WmsLogTag::WMS_DIALOG, "remote is null");
2497         return WSError::WS_ERROR_IPC_FAILED;
2498     }
2499     if (remote->SendRequest(
2500         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_DIALOG_SESSION_BACKGESTURE_ENABLE),
2501         data, reply, option) != ERR_NONE) {
2502         TLOGE(WmsLogTag::WMS_DIALOG, "SendRequest failed");
2503         return WSError::WS_ERROR_IPC_FAILED;
2504     }
2505     int32_t ret = reply.ReadInt32();
2506     return static_cast<WSError>(ret);
2507 }
2508 
GetStatusBarHeight()2509 int32_t SessionProxy::GetStatusBarHeight()
2510 {
2511     MessageParcel data;
2512     MessageParcel reply;
2513     MessageOption option(MessageOption::TF_SYNC);
2514     int32_t height = 0;
2515     if (!data.WriteInterfaceToken(GetDescriptor())) {
2516         TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
2517         return height;
2518     }
2519     sptr<IRemoteObject> remote = Remote();
2520     if (remote == nullptr) {
2521         TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
2522         return height;
2523     }
2524     int sendCode = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_STATUSBAR_HEIGHT),
2525         data, reply, option);
2526     if (sendCode != ERR_NONE) {
2527         TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed, code: %{public}d", sendCode);
2528         return height;
2529     }
2530     height = reply.ReadInt32();
2531     return height;
2532 }
2533 
NotifyExtensionEventAsync(uint32_t notifyEvent)2534 void SessionProxy::NotifyExtensionEventAsync(uint32_t notifyEvent)
2535 {
2536     MessageParcel data;
2537     MessageParcel reply;
2538     MessageOption option(MessageOption::TF_ASYNC);
2539     if (!data.WriteInterfaceToken(GetDescriptor())) {
2540         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
2541         return;
2542     }
2543     if (!data.WriteUint32(notifyEvent)) {
2544         TLOGE(WmsLogTag::WMS_UIEXT, "Write notifyEvent failed");
2545         return;
2546     }
2547     sptr<IRemoteObject> remote = Remote();
2548     if (remote == nullptr) {
2549         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2550         return;
2551     }
2552     int sendCode = remote->SendRequest(
2553         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_EVENT_ASYNC), data, reply, option);
2554     if (sendCode != ERR_NONE) {
2555         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, code: %{public}d", sendCode);
2556     }
2557 }
2558 
SendExtensionData(MessageParcel & data,MessageParcel & reply,MessageOption & option)2559 WSError SessionProxy::SendExtensionData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
2560 {
2561     sptr<IRemoteObject> remote = Remote();
2562     if (remote == nullptr) {
2563         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2564         return WSError::WS_ERROR_IPC_FAILED;
2565     }
2566 
2567     auto ret = remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SEND_EXTENSION_DATA), data,
2568                                    reply, option);
2569     if (ret != ERR_NONE) {
2570         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed, ret code: %{public}u", ret);
2571         return WSError::WS_ERROR_IPC_FAILED;
2572     }
2573 
2574     return WSError::WS_OK;
2575 }
2576 
2577 
NotifyExtensionDetachToDisplay()2578 void SessionProxy::NotifyExtensionDetachToDisplay()
2579 {
2580     TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: UIExtcalled");
2581     MessageParcel data;
2582     MessageParcel reply;
2583     MessageOption option(MessageOption::TF_SYNC);
2584 
2585     if (!data.WriteInterfaceToken(GetDescriptor())) {
2586         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: WriteInterfaceToken failed");
2587         return;
2588     }
2589 
2590     sptr<IRemoteObject> remote = Remote();
2591     if (!remote) {
2592         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: remote is null");
2593         return;
2594     }
2595 
2596     auto ret = remote->SendRequest(
2597         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY), data, reply, option);
2598     if (ret != ERR_NONE) {
2599         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: SendRequest failed, ret code: %{public}u", ret);
2600     }
2601 }
2602 
SetGestureBackEnabled(bool isEnabled)2603 WMError SessionProxy::SetGestureBackEnabled(bool isEnabled)
2604 {
2605     MessageParcel data;
2606     MessageParcel reply;
2607     MessageOption option(MessageOption::TF_SYNC);
2608     if (!data.WriteInterfaceToken(GetDescriptor())) {
2609         TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
2610         return WMError::WM_ERROR_IPC_FAILED;
2611     }
2612     if (!data.WriteBool(isEnabled)) {
2613         TLOGE(WmsLogTag::WMS_IMMS, "Write isEnabled failed");
2614         return WMError::WM_ERROR_IPC_FAILED;
2615     }
2616     sptr<IRemoteObject> remote = Remote();
2617     if (remote == nullptr) {
2618         TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
2619         return WMError::WM_ERROR_IPC_FAILED;
2620     }
2621     if (remote->SendRequest(
2622         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_GESTURE_BACK_ENABLE),
2623         data, reply, option) != ERR_NONE) {
2624         TLOGE(WmsLogTag::WMS_IMMS, "SendRequest failed");
2625         return WMError::WM_ERROR_IPC_FAILED;
2626     }
2627     int32_t ret = reply.ReadInt32();
2628     return static_cast<WMError>(ret);
2629 }
2630 
NotifySubModalTypeChange(SubWindowModalType subWindowModalType)2631 WSError SessionProxy::NotifySubModalTypeChange(SubWindowModalType subWindowModalType)
2632 {
2633     MessageParcel data;
2634     MessageParcel reply;
2635     MessageOption option(MessageOption::TF_ASYNC);
2636     if (!data.WriteInterfaceToken(GetDescriptor())) {
2637         TLOGE(WmsLogTag::WMS_HIERARCHY, "WriteInterfaceToken failed");
2638         return WSError::WS_ERROR_IPC_FAILED;
2639     }
2640     if (!data.WriteUint32(static_cast<uint32_t>(subWindowModalType))) {
2641         TLOGE(WmsLogTag::WMS_HIERARCHY, "Write subWindowModalType failed");
2642         return WSError::WS_ERROR_IPC_FAILED;
2643     }
2644     sptr<IRemoteObject> remote = Remote();
2645     if (remote == nullptr) {
2646         TLOGE(WmsLogTag::WMS_HIERARCHY, "remote is null");
2647         return WSError::WS_ERROR_IPC_FAILED;
2648     }
2649     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SUB_MODAL_TYPE_CHANGE),
2650         data, reply, option) != ERR_NONE) {
2651         TLOGE(WmsLogTag::WMS_HIERARCHY, "SendRequest failed");
2652         return WSError::WS_ERROR_IPC_FAILED;
2653     }
2654     return WSError::WS_OK;
2655 }
2656 
NotifyMainModalTypeChange(bool isModal)2657 WSError SessionProxy::NotifyMainModalTypeChange(bool isModal)
2658 {
2659     MessageParcel data;
2660     MessageParcel reply;
2661     MessageOption option(MessageOption::TF_ASYNC);
2662     if (!data.WriteInterfaceToken(GetDescriptor())) {
2663         TLOGE(WmsLogTag::WMS_HIERARCHY, "WriteInterfaceToken failed");
2664         return WSError::WS_ERROR_IPC_FAILED;
2665     }
2666     if (!data.WriteBool(isModal)) {
2667         TLOGE(WmsLogTag::WMS_HIERARCHY, "Write isModal failed");
2668         return WSError::WS_ERROR_IPC_FAILED;
2669     }
2670     sptr<IRemoteObject> remote = Remote();
2671     if (remote == nullptr) {
2672         TLOGE(WmsLogTag::WMS_HIERARCHY, "remote is null");
2673         return WSError::WS_ERROR_IPC_FAILED;
2674     }
2675     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_MAIN_MODAL_TYPE_CHANGE),
2676         data, reply, option) != ERR_NONE) {
2677         TLOGE(WmsLogTag::WMS_HIERARCHY, "SendRequest failed");
2678         return WSError::WS_ERROR_IPC_FAILED;
2679     }
2680     return WSError::WS_OK;
2681 }
2682 
OnSetWindowRectAutoSave(bool enabled,bool isSaveBySpecifiedFlag)2683 WSError SessionProxy::OnSetWindowRectAutoSave(bool enabled, bool isSaveBySpecifiedFlag)
2684 {
2685     MessageParcel data;
2686     MessageParcel reply;
2687     MessageOption option(MessageOption::TF_ASYNC);
2688     if (!data.WriteInterfaceToken(GetDescriptor())) {
2689         TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed");
2690         return WSError::WS_ERROR_IPC_FAILED;
2691     }
2692     if (!data.WriteBool(enabled)) {
2693         TLOGE(WmsLogTag::WMS_MAIN, "Write enable failed");
2694         return WSError::WS_ERROR_IPC_FAILED;
2695     }
2696     if (!data.WriteBool(isSaveBySpecifiedFlag)) {
2697         TLOGE(WmsLogTag::WMS_MAIN, "Write isSaveBySpecifiedFlag failed");
2698         return WSError::WS_ERROR_IPC_FAILED;
2699     }
2700     TLOGD(WmsLogTag::WMS_MAIN, "enable: %{public}d, isSaveBySpecifiedFlag: %{public}d",
2701         enabled, isSaveBySpecifiedFlag);
2702     sptr<IRemoteObject> remote = Remote();
2703     if (remote == nullptr) {
2704         TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
2705         return WSError::WS_ERROR_IPC_FAILED;
2706     }
2707     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_WINDOW_RECT_AUTO_SAVE),
2708         data, reply, option) != ERR_NONE) {
2709         TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
2710         return WSError::WS_ERROR_IPC_FAILED;
2711     }
2712     return WSError::WS_OK;
2713 }
2714 
NotifySupportWindowModesChange(const std::vector<AppExecFwk::SupportWindowMode> & supportedWindowModes)2715 WSError SessionProxy::NotifySupportWindowModesChange(
2716     const std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes)
2717 {
2718     MessageParcel data;
2719     MessageParcel reply;
2720     MessageOption option(MessageOption::TF_ASYNC);
2721     if (!data.WriteInterfaceToken(GetDescriptor())) {
2722         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
2723         return WSError::WS_ERROR_IPC_FAILED;
2724     }
2725     auto size = supportedWindowModes.size();
2726     if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) {
2727         if (!data.WriteUint32(static_cast<uint32_t>(size))) {
2728             return WSError::WS_ERROR_IPC_FAILED;
2729         }
2730         for (decltype(size) i = 0; i < size; i++) {
2731             if (!data.WriteInt32(static_cast<int32_t>(supportedWindowModes[i]))) {
2732                 return WSError::WS_ERROR_IPC_FAILED;
2733             }
2734         }
2735     } else {
2736         if (!data.WriteUint32(0)) {
2737             return WSError::WS_ERROR_IPC_FAILED;
2738         }
2739     }
2740     sptr<IRemoteObject> remote = Remote();
2741     if (remote == nullptr) {
2742         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
2743         return WSError::WS_ERROR_IPC_FAILED;
2744     }
2745     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_SUPPORT_WINDOW_MODES),
2746         data, reply, option) != ERR_NONE) {
2747         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
2748         return WSError::WS_ERROR_IPC_FAILED;
2749     }
2750     return WSError::WS_OK;
2751 }
2752 
SetSessionLabelAndIcon(const std::string & label,const std::shared_ptr<Media::PixelMap> & icon)2753 WSError SessionProxy::SetSessionLabelAndIcon(const std::string& label, const std::shared_ptr<Media::PixelMap>& icon)
2754 {
2755     MessageParcel data;
2756     MessageParcel reply;
2757     MessageOption option;
2758     if (!data.WriteInterfaceToken(GetDescriptor())) {
2759         TLOGE(WmsLogTag::WMS_MAIN, "writeInterfaceToken failed");
2760         return WSError::WS_ERROR_IPC_FAILED;
2761     }
2762     if (!data.WriteString(label)) {
2763         TLOGE(WmsLogTag::WMS_MAIN, "write label failed");
2764         return WSError::WS_ERROR_IPC_FAILED;
2765     }
2766     if (!data.WriteParcelable(icon.get())) {
2767         TLOGE(WmsLogTag::WMS_MAIN, "write icon failed");
2768         return WSError::WS_ERROR_IPC_FAILED;
2769     }
2770 
2771     sptr<IRemoteObject> remote = Remote();
2772     if (remote == nullptr) {
2773         TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
2774         return WSError::WS_ERROR_IPC_FAILED;
2775     }
2776     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_SESSION_LABEL_AND_ICON),
2777         data, reply, option) != ERR_NONE) {
2778         TLOGE(WmsLogTag::WMS_MAIN, "sendRequest failed");
2779         return WSError::WS_ERROR_IPC_FAILED;
2780     }
2781     int32_t ret = 0;
2782     if (!reply.ReadInt32(ret)) {
2783         TLOGE(WmsLogTag::WMS_MAIN, "read ret failed");
2784         return WSError::WS_ERROR_IPC_FAILED;
2785     }
2786     return static_cast<WSError>(ret);
2787 }
2788 
SetWindowCornerRadius(float cornerRadius)2789 WSError SessionProxy::SetWindowCornerRadius(float cornerRadius)
2790 {
2791     TLOGD(WmsLogTag::WMS_ATTRIBUTE, "cornerRadius: %{public}f", cornerRadius);
2792     MessageParcel data;
2793     MessageParcel reply;
2794     MessageOption option(MessageOption::TF_ASYNC);
2795     if (!data.WriteInterfaceToken(GetDescriptor())) {
2796         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
2797         return WSError::WS_ERROR_IPC_FAILED;
2798     }
2799     if (!data.WriteFloat(cornerRadius)) {
2800         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write enable failed");
2801         return WSError::WS_ERROR_IPC_FAILED;
2802     }
2803     sptr<IRemoteObject> remote = Remote();
2804     if (remote == nullptr) {
2805         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
2806         return WSError::WS_ERROR_IPC_FAILED;
2807     }
2808     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_WINDOW_CORNER_RADIUS),
2809         data, reply, option) != ERR_NONE) {
2810         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
2811         return WSError::WS_ERROR_IPC_FAILED;
2812     }
2813     return WSError::WS_OK;
2814 }
2815 
SetWindowShadows(const ShadowsInfo & shadowsInfo)2816 WSError SessionProxy::SetWindowShadows(const ShadowsInfo& shadowsInfo)
2817 {
2818     TLOGD(WmsLogTag::WMS_ANIMATION, "shadow radius: %{public}f, color: %{public}s, offsetX: %{public}f, "
2819         "offsetY: %{public}f", shadowsInfo.radius_, shadowsInfo.color_.c_str(), shadowsInfo.offsetX_,
2820         shadowsInfo.offsetY_);
2821     MessageParcel data;
2822     MessageParcel reply;
2823     MessageOption option(MessageOption::TF_ASYNC);
2824     if (!data.WriteInterfaceToken(GetDescriptor())) {
2825         TLOGE(WmsLogTag::WMS_ANIMATION, "WriteInterfaceToken failed");
2826         return WSError::WS_ERROR_IPC_FAILED;
2827     }
2828     if (!data.WriteParcelable(&shadowsInfo)) {
2829         TLOGE(WmsLogTag::WMS_ANIMATION, "Write shadowsInfo failed");
2830         return WSError::WS_ERROR_IPC_FAILED;
2831     }
2832     sptr<IRemoteObject> remote = Remote();
2833     if (remote == nullptr) {
2834         TLOGE(WmsLogTag::WMS_ANIMATION, "remote is null");
2835         return WSError::WS_ERROR_IPC_FAILED;
2836     }
2837     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_WINDOW_SHADOWS),
2838         data, reply, option) != ERR_NONE) {
2839         TLOGE(WmsLogTag::WMS_ANIMATION, "SendRequest failed");
2840         return WSError::WS_ERROR_IPC_FAILED;
2841     }
2842     return WSError::WS_OK;
2843 }
2844 
SetFollowParentWindowLayoutEnabled(bool isFollow)2845 WSError SessionProxy::SetFollowParentWindowLayoutEnabled(bool isFollow)
2846 {
2847     TLOGD(WmsLogTag::WMS_SUB, "isFollow: %{public}d", isFollow);
2848     MessageParcel data;
2849     MessageParcel reply;
2850     MessageOption option(MessageOption::TF_SYNC);
2851     if (!data.WriteInterfaceToken(GetDescriptor())) {
2852         TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
2853         return WSError::WS_ERROR_IPC_FAILED;
2854     }
2855     if (!data.WriteBool(isFollow)) {
2856         TLOGE(WmsLogTag::WMS_SUB, "Write enable failed");
2857         return WSError::WS_ERROR_IPC_FAILED;
2858     }
2859     sptr<IRemoteObject> remote = Remote();
2860     if (remote == nullptr) {
2861         TLOGE(WmsLogTag::WMS_SUB, "remote is null");
2862         return WSError::WS_ERROR_IPC_FAILED;
2863     }
2864     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_FOLLOW_PARENT_LAYOUT_ENABLED),
2865         data, reply, option) != ERR_NONE) {
2866         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
2867         return WSError::WS_ERROR_IPC_FAILED;
2868     }
2869     int32_t ret = 0;
2870     if (!reply.ReadInt32(ret)) {
2871         TLOGE(WmsLogTag::WMS_SUB, "read ret failed");
2872         return WSError::WS_ERROR_IPC_FAILED;
2873     }
2874     return static_cast<WSError>(ret);
2875 }
2876 
SetWindowAnchorInfo(const WindowAnchorInfo & windowAnchorInfo)2877 WSError SessionProxy::SetWindowAnchorInfo(const WindowAnchorInfo& windowAnchorInfo)
2878 {
2879     MessageParcel data;
2880     MessageParcel reply;
2881     MessageOption option(MessageOption::TF_SYNC);
2882     if (!data.WriteInterfaceToken(GetDescriptor())) {
2883         TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
2884         return WSError::WS_ERROR_IPC_FAILED;
2885     }
2886     if (!data.WriteParcelable(&windowAnchorInfo)) {
2887         TLOGE(WmsLogTag::WMS_SUB, "Write windowAnchorInfo failed");
2888         return WSError::WS_ERROR_IPC_FAILED;
2889     }
2890     sptr remote = Remote();
2891     if (remote == nullptr) {
2892         TLOGE(WmsLogTag::WMS_SUB, "remote is null");
2893         return WSError::WS_ERROR_IPC_FAILED;
2894     }
2895     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_WINDOW_ANCHOR_INFO),
2896         data, reply, option) != ERR_NONE) {
2897         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
2898         return WSError::WS_ERROR_IPC_FAILED;
2899     }
2900     int32_t ret = 0;
2901     if (!reply.ReadInt32(ret)) {
2902         TLOGE(WmsLogTag::WMS_SUB, "read ret failed");
2903         return WSError::WS_ERROR_IPC_FAILED;
2904     }
2905     return static_cast<WSError>(ret);
2906 }
2907 
2908 
KeyFrameAnimateEnd()2909 WSError SessionProxy::KeyFrameAnimateEnd()
2910 {
2911     MessageParcel data;
2912     MessageParcel reply;
2913     MessageOption option;
2914     if (!data.WriteInterfaceToken(GetDescriptor())) {
2915         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
2916         return WSError::WS_ERROR_IPC_FAILED;
2917     }
2918     sptr<IRemoteObject> remote = Remote();
2919     if (remote == nullptr) {
2920         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2921         return WSError::WS_ERROR_IPC_FAILED;
2922     }
2923     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_KEY_FRAME_ANIMATE_END),
2924         data, reply, option) != ERR_NONE) {
2925         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2926         return WSError::WS_ERROR_IPC_FAILED;
2927     }
2928     int32_t ret = 0;
2929     if (!reply.ReadInt32(ret)) {
2930         TLOGE(WmsLogTag::WMS_LAYOUT, "read ret failed");
2931         return WSError::WS_ERROR_IPC_FAILED;
2932     }
2933     return static_cast<WSError>(ret);
2934 }
2935 
SetWindowTransitionAnimation(WindowTransitionType transitionType,const TransitionAnimation & animation)2936 WSError SessionProxy::SetWindowTransitionAnimation(WindowTransitionType transitionType,
2937     const TransitionAnimation& animation)
2938 {
2939     MessageParcel data;
2940     MessageParcel reply;
2941     MessageOption option;
2942     if (!data.WriteInterfaceToken(GetDescriptor())) {
2943         TLOGE(WmsLogTag::WMS_ANIMATION, "WriteInterfaceToken failed");
2944         return WSError::WS_ERROR_IPC_FAILED;
2945     }
2946     if (!data.WriteUint32(static_cast<uint32_t>(transitionType))) {
2947         TLOGE(WmsLogTag::WMS_ANIMATION, "Write type failed");
2948         return WSError::WS_ERROR_IPC_FAILED;
2949     }
2950     if (!data.WriteParcelable(&animation)) {
2951         TLOGE(WmsLogTag::WMS_ANIMATION, "Write animation failed");
2952         return WSError::WS_ERROR_IPC_FAILED;
2953     }
2954     sptr<IRemoteObject> remote = Remote();
2955     if (remote == nullptr) {
2956         TLOGE(WmsLogTag::WMS_ANIMATION, "Remote is null");
2957         return WSError::WS_ERROR_IPC_FAILED;
2958     }
2959     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_WINDOW_TRANSITION_ANIMATION),
2960         data, reply, option) != ERR_NONE) {
2961         TLOGE(WmsLogTag::WMS_ANIMATION, "SendRequest failed");
2962         return WSError::WS_ERROR_IPC_FAILED;
2963     }
2964     int32_t ret = 0;
2965     if (!reply.ReadInt32(ret)) {
2966         TLOGE(WmsLogTag::WMS_ANIMATION, "Read ret failed");
2967         return WSError::WS_ERROR_IPC_FAILED;
2968     }
2969     return static_cast<WSError>(ret);
2970 }
2971 
UpdateKeyFrameCloneNode(std::shared_ptr<RSCanvasNode> & rsCanvasNode,std::shared_ptr<RSTransaction> & rsTransaction)2972 WSError SessionProxy::UpdateKeyFrameCloneNode(std::shared_ptr<RSCanvasNode>& rsCanvasNode,
2973     std::shared_ptr<RSTransaction>& rsTransaction)
2974 {
2975     MessageParcel data;
2976     MessageParcel reply;
2977     MessageOption option;
2978     if (!data.WriteInterfaceToken(GetDescriptor())) {
2979         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
2980         return WSError::WS_ERROR_IPC_FAILED;
2981     }
2982     sptr<IRemoteObject> remote = Remote();
2983     if (remote == nullptr) {
2984         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2985         return WSError::WS_ERROR_IPC_FAILED;
2986     }
2987     if (!rsCanvasNode || !rsCanvasNode->Marshalling(data)) {
2988         TLOGE(WmsLogTag::WMS_LAYOUT, "write rsCanvasNode failed");
2989         return WSError::WS_ERROR_IPC_FAILED;
2990     }
2991     if (!rsTransaction || !data.WriteParcelable(rsTransaction.get())) {
2992         TLOGE(WmsLogTag::WMS_LAYOUT, "write rsTransaction failed");
2993         return WSError::WS_ERROR_IPC_FAILED;
2994     }
2995     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_KEY_FRAME_CLONE_NODE),
2996         data, reply, option) != ERR_NONE) {
2997         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2998         return WSError::WS_ERROR_IPC_FAILED;
2999     }
3000     int32_t ret = 0;
3001     if (!reply.ReadInt32(ret)) {
3002         TLOGE(WmsLogTag::WMS_LAYOUT, "read ret failed");
3003         return WSError::WS_ERROR_IPC_FAILED;
3004     }
3005     return static_cast<WSError>(ret);
3006 }
3007 
SetDragKeyFramePolicy(const KeyFramePolicy & keyFramePolicy)3008 WSError SessionProxy::SetDragKeyFramePolicy(const KeyFramePolicy& keyFramePolicy)
3009 {
3010     MessageParcel data;
3011     MessageParcel reply;
3012     MessageOption option;
3013     if (!data.WriteInterfaceToken(GetDescriptor())) {
3014         TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed");
3015         return WSError::WS_ERROR_IPC_FAILED;
3016     }
3017     if (!data.WriteParcelable(&keyFramePolicy)) {
3018         TLOGE(WmsLogTag::WMS_LAYOUT, "Write keyFramePolicy failed");
3019         return WSError::WS_ERROR_IPC_FAILED;
3020     }
3021     sptr<IRemoteObject> remote = Remote();
3022     if (remote == nullptr) {
3023         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
3024         return WSError::WS_ERROR_IPC_FAILED;
3025     }
3026     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_DRAG_KEY_FRAME_POLICY),
3027         data, reply, option) != ERR_NONE) {
3028         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
3029         return WSError::WS_ERROR_IPC_FAILED;
3030     }
3031     int32_t ret = 0;
3032     if (!reply.ReadInt32(ret)) {
3033         TLOGE(WmsLogTag::WMS_LAYOUT, "read ret failed");
3034         return WSError::WS_ERROR_IPC_FAILED;
3035     }
3036     return static_cast<WSError>(ret);
3037 }
3038 
StartMovingWithCoordinate(int32_t offsetX,int32_t offsetY,int32_t pointerPosX,int32_t pointerPosY,DisplayId displayId)3039 WSError SessionProxy::StartMovingWithCoordinate(int32_t offsetX, int32_t offsetY,
3040     int32_t pointerPosX, int32_t pointerPosY, DisplayId displayId)
3041 {
3042     MessageParcel data;
3043     MessageParcel reply;
3044     MessageOption option(MessageOption::TF_SYNC);
3045     if (!data.WriteInterfaceToken(GetDescriptor())) {
3046         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "WriteInterfaceToken failed");
3047         return WSError::WS_ERROR_IPC_FAILED;
3048     }
3049     if (!data.WriteInt32(offsetX)) {
3050         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write offsetX failed");
3051         return WSError::WS_ERROR_IPC_FAILED;
3052     }
3053     if (!data.WriteInt32(offsetY)) {
3054         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write offsetY failed");
3055         return WSError::WS_ERROR_IPC_FAILED;
3056     }
3057     if (!data.WriteInt32(pointerPosX)) {
3058         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write pointerPosX failed");
3059         return WSError::WS_ERROR_IPC_FAILED;
3060     }
3061     if (!data.WriteInt32(pointerPosY)) {
3062         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write pointerPosY failed");
3063         return WSError::WS_ERROR_IPC_FAILED;
3064     }
3065     if (!data.WriteUint64(displayId)) {
3066         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Write displayId failed");
3067         return WSError::WS_ERROR_IPC_FAILED;
3068     }
3069     sptr<IRemoteObject> remote = Remote();
3070     if (remote == nullptr) {
3071         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
3072         return WSError::WS_ERROR_IPC_FAILED;
3073     }
3074     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_START_MOVING_WITH_COORDINATE),
3075         data, reply, option) != ERR_NONE) {
3076         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "SendRequest failed");
3077         return WSError::WS_ERROR_IPC_FAILED;
3078     }
3079     int32_t ret = reply.ReadInt32();
3080     return static_cast<WSError>(ret);
3081 }
GetCrossAxisState(CrossAxisState & state)3082 WSError SessionProxy::GetCrossAxisState(CrossAxisState& state)
3083 {
3084     MessageParcel data;
3085     MessageParcel reply;
3086     MessageOption option;
3087     if (!data.WriteInterfaceToken(GetDescriptor())) {
3088         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "writeInterfaceToken failed");
3089         return WSError::WS_ERROR_IPC_FAILED;
3090     }
3091     sptr<IRemoteObject> remote = Remote();
3092     if (remote == nullptr) {
3093         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "remote is null");
3094         return WSError::WS_ERROR_IPC_FAILED;
3095     }
3096     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_CROSS_AXIS_STATE),
3097         data, reply, option) != ERR_NONE) {
3098         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "sendRequest failed");
3099         return WSError::WS_ERROR_IPC_FAILED;
3100     }
3101     uint32_t ret = 0;
3102     if (!reply.ReadUint32(ret)) {
3103         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "read ret failed");
3104         return WSError::WS_ERROR_IPC_FAILED;
3105     }
3106     state = static_cast<CrossAxisState>(ret);
3107     return WSError::WS_OK;
3108 }
3109 
GetWaterfallMode(bool & isWaterfallMode)3110 WSError SessionProxy::GetWaterfallMode(bool& isWaterfallMode)
3111 {
3112     MessageParcel data;
3113     MessageParcel reply;
3114     MessageOption option;
3115     if (!data.WriteInterfaceToken(GetDescriptor())) {
3116         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "writeInterfaceToken failed");
3117         return WSError::WS_ERROR_IPC_FAILED;
3118     }
3119     sptr<IRemoteObject> remote = Remote();
3120     if (remote == nullptr) {
3121         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
3122         return WSError::WS_ERROR_IPC_FAILED;
3123     }
3124     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_WATERFALL_MODE),
3125         data, reply, option) != ERR_NONE) {
3126         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "sendRequest failed");
3127         return WSError::WS_ERROR_IPC_FAILED;
3128     }
3129     isWaterfallMode = reply.ReadBool();
3130     return WSError::WS_OK;
3131 }
3132 
IsMainWindowFullScreenAcrossDisplays(bool & isAcrossDisplays)3133 WMError SessionProxy::IsMainWindowFullScreenAcrossDisplays(bool& isAcrossDisplays)
3134 {
3135     MessageParcel data;
3136     MessageParcel reply;
3137     MessageOption option(MessageOption::TF_SYNC);
3138     if (!data.WriteInterfaceToken(GetDescriptor())) {
3139         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "writeInterfaceToken failed");
3140         return WMError::WM_ERROR_IPC_FAILED;
3141     }
3142     sptr<IRemoteObject> remote = Remote();
3143     if (remote == nullptr) {
3144         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
3145         return WMError::WM_ERROR_IPC_FAILED;
3146     }
3147     uint32_t code = static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_MAIN_WINDOW_FULL_SCREEN_ACROSS_DISPLAYS);
3148     if (remote->SendRequest(code, data, reply, option) != ERR_NONE) {
3149         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "sendRequest failed");
3150         return WMError::WM_ERROR_IPC_FAILED;
3151     }
3152     int32_t ret = 0;
3153     if (!reply.ReadInt32(ret)) {
3154         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read ret failed");
3155         return WMError::WM_ERROR_IPC_FAILED;
3156     }
3157     if (!reply.ReadBool(isAcrossDisplays)) {
3158         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read isAcrossDisplays failed");
3159         return WMError::WM_ERROR_IPC_FAILED;
3160     }
3161     return static_cast<WMError>(ret);
3162 }
3163 
OnContainerModalEvent(const std::string & eventName,const std::string & eventValue)3164 WSError SessionProxy::OnContainerModalEvent(const std::string& eventName, const std::string& eventValue)
3165 {
3166     MessageParcel data;
3167     MessageParcel reply;
3168     MessageOption option(MessageOption::TF_ASYNC);
3169     if (!data.WriteInterfaceToken(GetDescriptor())) {
3170         TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed");
3171         return WSError::WS_ERROR_IPC_FAILED;
3172     }
3173     if (!data.WriteString(eventName)) {
3174         TLOGE(WmsLogTag::WMS_EVENT, "Write eventName failed");
3175         return WSError::WS_ERROR_IPC_FAILED;
3176     }
3177     if (!data.WriteString(eventValue)) {
3178         TLOGE(WmsLogTag::WMS_EVENT, "Write eventValue failed");
3179         return WSError::WS_ERROR_IPC_FAILED;
3180     }
3181     sptr<IRemoteObject> remote = Remote();
3182     if (remote == nullptr) {
3183         TLOGE(WmsLogTag::WMS_EVENT, "remote is null");
3184         return WSError::WS_ERROR_IPC_FAILED;
3185     }
3186     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_CONTAINER_MODAL_EVENT),
3187         data, reply, option) != ERR_NONE) {
3188         TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed");
3189         return WSError::WS_ERROR_IPC_FAILED;
3190     }
3191     return WSError::WS_OK;
3192 }
3193 
NotifyFollowParentMultiScreenPolicy(bool enabled)3194 WSError SessionProxy::NotifyFollowParentMultiScreenPolicy(bool enabled)
3195 {
3196     MessageParcel data;
3197     MessageParcel reply;
3198     MessageOption option(MessageOption::TF_ASYNC);
3199     if (!data.WriteInterfaceToken(GetDescriptor())) {
3200         TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
3201         return WSError::WS_ERROR_IPC_FAILED;
3202     }
3203     if (!data.WriteBool(enabled)) {
3204         TLOGE(WmsLogTag::WMS_SUB, "Write enabled failed");
3205         return WSError::WS_ERROR_IPC_FAILED;
3206     }
3207     sptr<IRemoteObject> remote = Remote();
3208     if (remote == nullptr) {
3209         TLOGE(WmsLogTag::WMS_SUB, "remote is null");
3210         return WSError::WS_ERROR_IPC_FAILED;
3211     }
3212     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_FOLLOW_PARENT_MULTI_SCREEN_POLICY),
3213         data, reply, option) != ERR_NONE) {
3214         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
3215         return WSError::WS_ERROR_IPC_FAILED;
3216     }
3217     return WSError::WS_OK;
3218 }
3219 
NotifyWindowAttachStateListenerRegistered(bool registered)3220 void SessionProxy::NotifyWindowAttachStateListenerRegistered(bool registered)
3221 {
3222     MessageParcel data;
3223     MessageParcel reply;
3224     MessageOption option(MessageOption::TF_ASYNC);
3225     if (!data.WriteInterfaceToken(GetDescriptor())) {
3226         TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed");
3227         return;
3228     }
3229     if (!data.WriteBool(registered)) {
3230         TLOGE(WmsLogTag::WMS_MAIN, "Write enable failed");
3231         return;
3232     }
3233     sptr<IRemoteObject> remote = Remote();
3234     if (remote == nullptr) {
3235         TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
3236         return;
3237     }
3238     if (remote->SendRequest(
3239         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_LISTENER_REGISTERED),
3240         data, reply, option) != ERR_NONE) {
3241         TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
3242     }
3243 }
3244 
NotifyKeyboardWillShowRegistered(bool registered)3245 void SessionProxy::NotifyKeyboardWillShowRegistered(bool registered)
3246 {
3247     MessageParcel data;
3248     MessageParcel reply;
3249     MessageOption option;
3250     if (!data.WriteInterfaceToken(GetDescriptor())) {
3251         TLOGE(WmsLogTag::WMS_KEYBOARD, "writeInterfaceToken failed");
3252         return;
3253     }
3254     if (!data.WriteBool(registered)) {
3255         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write registered failed.");
3256         return;
3257     }
3258     sptr<IRemoteObject> remote = Remote();
3259     if (remote == nullptr) {
3260         TLOGE(WmsLogTag::WMS_KEYBOARD, "Remote is null");
3261         return;
3262     }
3263     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_KEYBOARD_WILL_SHOW_REGISTERED),
3264         data, reply, option) != ERR_NONE) {
3265         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
3266     }
3267 }
3268 
NotifyKeyboardWillHideRegistered(bool registered)3269 void SessionProxy::NotifyKeyboardWillHideRegistered(bool registered)
3270 {
3271     MessageParcel data;
3272     MessageParcel reply;
3273     MessageOption option;
3274     if (!data.WriteInterfaceToken(GetDescriptor())) {
3275         TLOGE(WmsLogTag::WMS_KEYBOARD, "writeInterfaceToken failed");
3276         return;
3277     }
3278     if (!data.WriteBool(registered)) {
3279         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write registered failed.");
3280         return;
3281     }
3282     sptr<IRemoteObject> remote = Remote();
3283     if (remote == nullptr) {
3284         TLOGE(WmsLogTag::WMS_KEYBOARD, "Remote is null");
3285         return;
3286     }
3287     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_KEYBOARD_WILL_HIDE_REGISTERED),
3288         data, reply, option) != ERR_NONE) {
3289         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
3290     }
3291 }
3292 
NotifyKeyboardDidShowRegistered(bool registered)3293 void SessionProxy::NotifyKeyboardDidShowRegistered(bool registered)
3294 {
3295     MessageParcel data;
3296     MessageParcel reply;
3297     MessageOption option;
3298     if (!data.WriteInterfaceToken(GetDescriptor())) {
3299         TLOGE(WmsLogTag::WMS_KEYBOARD, "writeInterfaceToken failed");
3300         return;
3301     }
3302     if (!data.WriteBool(registered)) {
3303         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write registered failed.");
3304         return;
3305     }
3306     sptr<IRemoteObject> remote = Remote();
3307     if (remote == nullptr) {
3308         TLOGE(WmsLogTag::WMS_KEYBOARD, "Remote is null");
3309         return;
3310     }
3311     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_KEYBOARD_DID_SHOW_REGISTERED),
3312         data, reply, option) != ERR_NONE) {
3313         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
3314     }
3315 }
3316 
NotifyKeyboardDidHideRegistered(bool registered)3317 void SessionProxy::NotifyKeyboardDidHideRegistered(bool registered)
3318 {
3319     MessageParcel data;
3320     MessageParcel reply;
3321     MessageOption option;
3322     if (!data.WriteInterfaceToken(GetDescriptor())) {
3323         TLOGE(WmsLogTag::WMS_KEYBOARD, "writeInterfaceToken failed");
3324         return;
3325     }
3326     if (!data.WriteBool(registered)) {
3327         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write registered failed.");
3328         return;
3329     }
3330     sptr<IRemoteObject> remote = Remote();
3331     if (remote == nullptr) {
3332         TLOGE(WmsLogTag::WMS_KEYBOARD, "Remote is null");
3333         return;
3334     }
3335     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_KEYBOARD_DID_HIDE_REGISTERED),
3336         data, reply, option) != ERR_NONE) {
3337         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
3338     }
3339 }
3340 
UpdateFlag(const std::string & flag)3341 WSError SessionProxy::UpdateFlag(const std::string& flag)
3342 {
3343     MessageParcel data;
3344     MessageParcel reply;
3345     MessageOption option(MessageOption::TF_ASYNC);
3346     if (!data.WriteInterfaceToken(GetDescriptor())) {
3347         TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed");
3348         return WSError::WS_ERROR_IPC_FAILED;
3349     }
3350     if (!data.WriteString(flag)) {
3351         TLOGE(WmsLogTag::WMS_MAIN, "Write flag failed");
3352         return WSError::WS_ERROR_IPC_FAILED;
3353     }
3354     TLOGD(WmsLogTag::WMS_MAIN, "specifiedFlag: %{public}s", flag.c_str());
3355     sptr<IRemoteObject> remote = Remote();
3356     if (remote == nullptr) {
3357         TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
3358         return WSError::WS_ERROR_IPC_FAILED;
3359     }
3360     if (remote->SendRequest(
3361         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_FLAG),
3362         data, reply, option) != ERR_NONE) {
3363         TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
3364         return WSError::WS_ERROR_IPC_FAILED;
3365     }
3366     return WSError::WS_OK;
3367 }
3368 
UpdatePiPTemplateInfo(PiPTemplateInfo & pipTemplateInfo)3369 WSError SessionProxy::UpdatePiPTemplateInfo(PiPTemplateInfo& pipTemplateInfo)
3370 {
3371     TLOGD(WmsLogTag::WMS_PIP, "UpdatePiPTemplateInfo, pipTemplateType: %{public}u, priority: %{public}d, "
3372         "defaultWindowSizeType: %{public}d", pipTemplateInfo.pipTemplateType, pipTemplateInfo.priority,
3373         pipTemplateInfo.defaultWindowSizeType);
3374     MessageParcel data;
3375     MessageParcel reply;
3376     MessageOption option;
3377     if (!data.WriteInterfaceToken(GetDescriptor())) {
3378         TLOGE(WmsLogTag::WMS_PIP, "writeInterfaceToken failed");
3379         return WSError::WS_ERROR_IPC_FAILED;
3380     }
3381     if (!data.WriteParcelable(&pipTemplateInfo)) {
3382         TLOGE(WmsLogTag::WMS_PIP, "write pipTemplateInfo failed");
3383         return WSError::WS_ERROR_IPC_FAILED;
3384     }
3385     sptr<IRemoteObject> remote = Remote();
3386     if (remote == nullptr) {
3387         TLOGE(WmsLogTag::WMS_PIP, "remote is null");
3388         return WSError::WS_ERROR_IPC_FAILED;
3389     }
3390     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_TEMPLATE_INFO),
3391         data, reply, option) != ERR_NONE) {
3392         TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
3393         return WSError::WS_ERROR_IPC_FAILED;
3394     }
3395     int32_t ret = 0;
3396     if (!reply.ReadInt32(ret)) {
3397         TLOGE(WmsLogTag::WMS_PIP, "read ret failed");
3398         return WSError::WS_ERROR_IPC_FAILED;
3399     }
3400     return static_cast<WSError>(ret);
3401 }
3402 
UpdateRotationChangeRegistered(int32_t persistentId,bool isRegister)3403 WSError SessionProxy::UpdateRotationChangeRegistered(int32_t persistentId, bool isRegister)
3404 {
3405     MessageParcel data;
3406     MessageParcel reply;
3407     MessageOption option(MessageOption::TF_ASYNC);
3408     if (!data.WriteInterfaceToken(GetDescriptor())) {
3409         TLOGE(WmsLogTag::WMS_ROTATION, "WriteInterfaceToken failed");
3410         return WSError::WS_ERROR_IPC_FAILED;
3411     }
3412     if (!data.WriteInt32(persistentId)) {
3413         TLOGE(WmsLogTag::WMS_ROTATION, "Write persistentId failed");
3414         return WSError::WS_ERROR_IPC_FAILED;
3415     }
3416     if (!data.WriteBool(isRegister)) {
3417         TLOGE(WmsLogTag::WMS_ROTATION, "Write isRegister failed");
3418         return WSError::WS_ERROR_IPC_FAILED;
3419     }
3420     sptr<IRemoteObject> remote = Remote();
3421     if (remote == nullptr) {
3422         TLOGE(WmsLogTag::WMS_ROTATION, "remote is null");
3423         return WSError::WS_ERROR_IPC_FAILED;
3424     }
3425     if (remote->SendRequest(
3426         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_ROTATION_CHANGE),
3427         data, reply, option) != ERR_NONE) {
3428         TLOGE(WmsLogTag::WMS_ROTATION, "SendRequest failed");
3429         return WSError::WS_ERROR_IPC_FAILED;
3430     }
3431     return WSError::WS_OK;
3432 }
3433 
UpdateScreenshotAppEventRegistered(int32_t persistentId,bool isRegister)3434 WMError SessionProxy::UpdateScreenshotAppEventRegistered(int32_t persistentId, bool isRegister)
3435 {
3436     MessageParcel data;
3437     MessageParcel reply;
3438     MessageOption option(MessageOption::TF_SYNC);
3439     if (!data.WriteInterfaceToken(GetDescriptor())) {
3440         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
3441         return WMError::WM_ERROR_IPC_FAILED;
3442     }
3443     if (!data.WriteInt32(persistentId)) {
3444         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write persistentId failed");
3445         return WMError::WM_ERROR_IPC_FAILED;
3446     }
3447     if (!data.WriteBool(isRegister)) {
3448         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write isRegister failed");
3449         return WMError::WM_ERROR_IPC_FAILED;
3450     }
3451     sptr<IRemoteObject> remote = Remote();
3452     if (remote == nullptr) {
3453         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
3454         return WMError::WM_ERROR_IPC_FAILED;
3455     }
3456     if (remote->SendRequest(
3457         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_SCREEN_SHOT_APP_EVENT_REGISTERED),
3458         data, reply, option) != ERR_NONE) {
3459         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
3460         return WMError::WM_ERROR_IPC_FAILED;
3461     }
3462     int32_t ret = 0;
3463     if (!reply.ReadInt32(ret)) {
3464         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read ret failed.");
3465         return WMError::WM_ERROR_IPC_FAILED;
3466     }
3467     return static_cast<WMError>(ret);
3468 }
3469 
UpdateAcrossDisplaysChangeRegistered(bool isRegister)3470 WMError SessionProxy::UpdateAcrossDisplaysChangeRegistered(bool isRegister)
3471 {
3472     MessageParcel data;
3473     MessageParcel reply;
3474     MessageOption option(MessageOption::TF_SYNC);
3475     if (!data.WriteInterfaceToken(GetDescriptor())) {
3476         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
3477         return WMError::WM_ERROR_IPC_FAILED;
3478     }
3479     if (!data.WriteBool(isRegister)) {
3480         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write isRegister failed");
3481         return WMError::WM_ERROR_IPC_FAILED;
3482     }
3483     sptr<IRemoteObject> remote = Remote();
3484     if (remote == nullptr) {
3485         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
3486         return WMError::WM_ERROR_IPC_FAILED;
3487     }
3488     uint32_t code = static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_ACROSS_DISPLAYS_REGISTERED);
3489     if (remote->SendRequest(code, data, reply, option) != ERR_NONE) {
3490         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
3491         return WMError::WM_ERROR_IPC_FAILED;
3492     }
3493     int32_t ret = 0;
3494     if (!reply.ReadInt32(ret)) {
3495         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read ret failed.");
3496         return WMError::WM_ERROR_IPC_FAILED;
3497     }
3498     return static_cast<WMError>(ret);
3499 }
3500 
RequestFocus(bool isFocused)3501 WSError SessionProxy::RequestFocus(bool isFocused)
3502 {
3503     MessageParcel data;
3504     MessageParcel reply;
3505     MessageOption option(MessageOption::TF_SYNC);
3506     if (!data.WriteInterfaceToken(GetDescriptor())) {
3507         TLOGE(WmsLogTag::WMS_FOCUS, "WriteInterfaceToken failed");
3508         return WSError::WS_ERROR_IPC_FAILED;
3509     }
3510     if (!data.WriteBool(isFocused)) {
3511         TLOGE(WmsLogTag::WMS_FOCUS, "Write isFocused failed");
3512         return WSError::WS_ERROR_IPC_FAILED;
3513     }
3514     sptr<IRemoteObject> remote = Remote();
3515     if (remote == nullptr) {
3516         TLOGE(WmsLogTag::WMS_FOCUS, "remote is null");
3517         return WSError::WS_ERROR_IPC_FAILED;
3518     }
3519     if (remote->SendRequest(
3520         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_REQUEST_FOCUS),
3521         data, reply, option) != ERR_NONE) {
3522         TLOGE(WmsLogTag::WMS_FOCUS, "SendRequest failed");
3523         return WSError::WS_ERROR_IPC_FAILED;
3524     }
3525     int32_t ret = reply.ReadInt32();
3526     return static_cast<WSError>(ret);
3527 }
3528 
GetIsHighlighted(bool & isHighlighted)3529 WSError SessionProxy::GetIsHighlighted(bool& isHighlighted)
3530 {
3531     MessageParcel data;
3532     MessageParcel reply;
3533     MessageOption option(MessageOption::TF_SYNC);
3534     if (!data.WriteInterfaceToken(GetDescriptor())) {
3535         TLOGE(WmsLogTag::WMS_FOCUS, "WriteInterfaceToken failed");
3536         return WSError::WS_ERROR_IPC_FAILED;
3537     }
3538     sptr<IRemoteObject> remote = Remote();
3539     if (remote == nullptr) {
3540         TLOGE(WmsLogTag::WMS_FOCUS, "remote is null");
3541         return WSError::WS_ERROR_IPC_FAILED;
3542     }
3543     if (remote->SendRequest(
3544         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_IS_HIGHLIGHTED),
3545         data, reply, option) != ERR_NONE) {
3546         TLOGE(WmsLogTag::WMS_FOCUS, "SendRequest failed");
3547         return WSError::WS_ERROR_IPC_FAILED;
3548     }
3549     if (!reply.ReadBool(isHighlighted)) {
3550         TLOGE(WmsLogTag::WMS_FOCUS, "Read isHighlighted failed");
3551         return WSError::WS_ERROR_IPC_FAILED;
3552     }
3553     return WSError::WS_OK;
3554 }
3555 
NotifyDisableDelegatorChange()3556 WMError SessionProxy::NotifyDisableDelegatorChange()
3557 {
3558     TLOGD(WmsLogTag::WMS_LIFE, "in");
3559     MessageParcel data;
3560     MessageParcel reply;
3561     MessageOption option;
3562     if (!data.WriteInterfaceToken(GetDescriptor())) {
3563         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
3564         return WMError::WM_ERROR_IPC_FAILED;
3565     }
3566     sptr<IRemoteObject> remote = Remote();
3567     if (remote == nullptr) {
3568         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
3569         return WMError::WM_ERROR_IPC_FAILED;
3570     }
3571     if (remote->SendRequest(
3572         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_DISABLE_DELEGATOR_CHANGE),
3573         data, reply, option) != ERR_NONE) {
3574         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
3575         return WMError::WM_ERROR_IPC_FAILED;
3576     }
3577     int32_t ret = 0;
3578     if (!reply.ReadInt32(ret)) {
3579         TLOGE(WmsLogTag::WMS_LIFE, "Read ret failed.");
3580         return WMError::WM_ERROR_IPC_FAILED;
3581     }
3582     return static_cast<WMError>(ret);
3583 }
3584 
UseImplicitAnimation(bool useImplicit)3585 WSError OHOS::Rosen::SessionProxy::UseImplicitAnimation(bool useImplicit)
3586 {
3587     TLOGD(WmsLogTag::WMS_PC, "in");
3588     MessageParcel data;
3589     MessageParcel reply;
3590     MessageOption option;
3591     if (!data.WriteInterfaceToken(GetDescriptor())) {
3592         TLOGE(WmsLogTag::WMS_PC, "WriteInterfaceToken failed");
3593         return WSError::WS_ERROR_IPC_FAILED;
3594     }
3595     if (!data.WriteBool(useImplicit)) {
3596         TLOGE(WmsLogTag::WMS_PC, "write useImplicit failed");
3597         return WSError::WS_ERROR_IPC_FAILED;
3598     }
3599     sptr<IRemoteObject> remote = Remote();
3600     if (remote == nullptr) {
3601         TLOGE(WmsLogTag::WMS_PC, "remote is null");
3602         return WSError::WS_ERROR_IPC_FAILED;
3603     }
3604     if (remote->SendRequest(
3605         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_USE_IMPLICT_ANIMATION),
3606         data, reply, option) != ERR_NONE) {
3607         TLOGE(WmsLogTag::WMS_PC, "SendRequest failed");
3608         return WSError::WS_ERROR_IPC_FAILED;
3609     }
3610     int32_t ret = 0;
3611     if (!reply.ReadInt32(ret)) {
3612         TLOGE(WmsLogTag::WMS_LIFE, "Read ret failed.");
3613         return WSError::WS_ERROR_IPC_FAILED;
3614     }
3615     return static_cast<WSError>(ret);
3616 }
3617 
SetSubWindowSource(SubWindowSource source)3618 WSError SessionProxy::SetSubWindowSource(SubWindowSource source)
3619 {
3620     TLOGD(WmsLogTag::WMS_SUB, "source: %{public}d", source);
3621     MessageParcel data;
3622     MessageParcel reply;
3623     MessageOption option(MessageOption::TF_SYNC);
3624     if (!data.WriteInterfaceToken(GetDescriptor())) {
3625         TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
3626         return WSError::WS_ERROR_IPC_FAILED;
3627     }
3628     if (!data.WriteUint32(static_cast<uint32_t>(source))) {
3629         TLOGE(WmsLogTag::WMS_SUB, "Write source failed");
3630         return WSError::WS_ERROR_IPC_FAILED;
3631     }
3632     sptr remote = Remote();
3633     if (remote == nullptr) {
3634         TLOGE(WmsLogTag::WMS_SUB, "remote is null");
3635         return WSError::WS_ERROR_IPC_FAILED;
3636     }
3637     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_SUBWINDOW_SOURCE),
3638         data, reply, option) != ERR_NONE) {
3639         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
3640         return WSError::WS_ERROR_IPC_FAILED;
3641     }
3642     int32_t ret = 0;
3643     if (!reply.ReadInt32(ret)) {
3644         TLOGE(WmsLogTag::WMS_SUB, "read ret failed");
3645         return WSError::WS_ERROR_IPC_FAILED;
3646     }
3647     return static_cast<WSError>(ret);
3648 }
3649 
SetFrameRectForPartialZoomIn(const Rect & frameRect)3650 WSError SessionProxy::SetFrameRectForPartialZoomIn(const Rect& frameRect)
3651 {
3652     TLOGD(WmsLogTag::WMS_ANIMATION, "in");
3653     MessageParcel data;
3654     MessageParcel reply;
3655     MessageOption option(MessageOption::TF_SYNC);
3656     if (!data.WriteInterfaceToken(GetDescriptor())) {
3657         TLOGE(WmsLogTag::WMS_ANIMATION, "WriteInterfaceToken failed");
3658         return WSError::WS_ERROR_IPC_FAILED;
3659     }
3660     if (!(data.WriteInt32(frameRect.posX_) && data.WriteInt32(frameRect.posY_) &&
3661           data.WriteUint32(frameRect.width_) && data.WriteUint32(frameRect.height_))) {
3662         TLOGE(WmsLogTag::WMS_ANIMATION, "Write frame rect failed");
3663         return WSError::WS_ERROR_IPC_FAILED;
3664     }
3665 
3666     auto remote = Remote();
3667     if (remote == nullptr) {
3668         TLOGE(WmsLogTag::WMS_ANIMATION, "remote is null");
3669         return WSError::WS_ERROR_IPC_FAILED;
3670     }
3671     if (remote->SendRequest(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_FRAMERECT_FOR_PARTIAL_ZOOMIN),
3672         data, reply, option) != ERR_NONE) {
3673         TLOGE(WmsLogTag::WMS_ANIMATION, "SendRequest failed");
3674         return WSError::WS_ERROR_IPC_FAILED;
3675     }
3676     int32_t ret = 0;
3677     if (!reply.ReadInt32(ret)) {
3678         TLOGE(WmsLogTag::WMS_ANIMATION, "read ret failed");
3679         return WSError::WS_ERROR_IPC_FAILED;
3680     }
3681     return static_cast<WSError>(ret);
3682 }
3683 
NotifyFloatingBallPrepareClose()3684 void SessionProxy::NotifyFloatingBallPrepareClose()
3685 {
3686     TLOGI(WmsLogTag::WMS_PIP, "NotifyFloatingBallPrepareClose");
3687     MessageParcel data;
3688     MessageParcel reply;
3689     MessageOption option(MessageOption::TF_ASYNC);
3690     if (!data.WriteInterfaceToken(GetDescriptor())) {
3691         TLOGE(WmsLogTag::WMS_SYSTEM, "writeInterfaceToken failed");
3692         return;
3693     }
3694     sptr<IRemoteObject> remote = Remote();
3695     if (remote == nullptr) {
3696         TLOGE(WmsLogTag::WMS_SYSTEM, "remote is null");
3697         return;
3698     }
3699     auto errCode = remote->SendRequest(
3700         static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_FLOATING_BALL_PREPARE_CLOSE), data, reply, option);
3701     if (errCode != ERR_NONE) {
3702         TLOGE(WmsLogTag::WMS_SYSTEM, "SendRequest failed code: %{public}d", errCode);
3703         return;
3704     }
3705 }
3706 } // namespace OHOS::Rosen
3707