• 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_stub.h"
17 
18 #include "ability_start_setting.h"
19 #include <ipc_types.h>
20 #include <ui/rs_surface_node.h>
21 #include "want.h"
22 #include "pointer_event.h"
23 #include "key_event.h"
24 
25 #include "parcel/accessibility_event_info_parcel.h"
26 #include "process_options.h"
27 #include "session/host/include/zidl/session_ipc_interface_code.h"
28 #include "window_manager_hilog.h"
29 #include "wm_common.h"
30 
31 namespace OHOS::Accessibility {
32 class AccessibilityEventInfo;
33 }
34 namespace OHOS::Rosen {
35 namespace {
36 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStub" };
37 } // namespace
38 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)39 int SessionStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
40 {
41     WLOGFD("Scene session on remote request!, code: %{public}u", code);
42     if (data.ReadInterfaceToken() != GetDescriptor()) {
43         WLOGFE("Failed to check interface token!");
44         return ERR_TRANSACTION_FAILED;
45     }
46 
47     return ProcessRemoteRequest(code, data, reply, option);
48 }
49 
ProcessRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)50 int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
51     MessageOption& option)
52 {
53     switch (code) {
54         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_CONNECT):
55             return HandleConnect(data, reply);
56         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_FOREGROUND):
57             return HandleForeground(data, reply);
58         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKGROUND):
59             return HandleBackground(data, reply);
60         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DISCONNECT):
61             return HandleDisconnect(data, reply);
62         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SHOW):
63             return HandleShow(data, reply);
64         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_HIDE):
65             return HandleHide(data, reply);
66         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DRAWING_COMPLETED):
67             return HandleDrawingCompleted(data, reply);
68         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED):
69             return HandleUpdateRectChangeListenerRegistered(data, reply);
70         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SESSION_EVENT):
71             return HandleSessionEvent(data, reply);
72         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_RECT):
73             return HandleUpdateSessionRect(data, reply);
74         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_GLOBAL_SCALED_RECT):
75             return HandleGetGlobalScaledRect(data, reply);
76         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_TO_APP_TOP):
77             return HandleRaiseToAppTop(data, reply);
78         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKPRESSED):
79             return HandleBackPressed(data, reply);
80         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_MARK_PROCESSED):
81             return HandleMarkProcessed(data, reply);
82         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_MAXIMIZE_MODE):
83             return HandleSetGlobalMaximizeMode(data, reply);
84         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_MAXIMIZE_MODE):
85             return HandleGetGlobalMaximizeMode(data, reply);
86         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NEED_AVOID):
87             return HandleNeedAvoid(data, reply);
88         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_AVOID_AREA):
89             return HandleGetAvoidAreaByType(data, reply);
90         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_ALL_AVOID_AREAS):
91             return HandleGetAllAvoidAreas(data, reply);
92         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_ASPECT_RATIO):
93             return HandleSetAspectRatio(data, reply);
94         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG):
95             return HandleSetWindowAnimationFlag(data, reply);
96         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_CUSTOM_ANIMATION):
97             return HandleUpdateWindowSceneAfterCustomAnimation(data, reply);
98         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW):
99             return HandleSetLandscapeMultiWindow(data, reply);
100         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_ABOVE_TARGET):
101             return HandleRaiseAboveTarget(data, reply);
102         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_APP_MAIN_WINDOW):
103             return HandleRaiseAppMainWindowToTop(data, reply);
104         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_CHANGE_SESSION_VISIBILITY_WITH_STATUS_BAR):
105             return HandleChangeSessionVisibilityWithStatusBar(data, reply);
106         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_ACTIVE_PENDING_SESSION):
107             return HandlePendingSessionActivation(data, reply);
108         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TERMINATE):
109             return HandleTerminateSession(data, reply);
110         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_EXCEPTION):
111             return HandleSessionException(data, reply);
112         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_PROCESS_POINT_DOWN_SESSION):
113             return HandleProcessPointDownSession(data, reply);
114         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SEND_POINTEREVENT_FOR_MOVE_DRAG):
115             return HandleSendPointerEvenForMoveDrag(data, reply);
116         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_CLIENT_RECT):
117             return HandleUpdateClientRect(data, reply);
118         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_KEYBOARD_SESSION_GRAVITY):
119             return HandleSetKeyboardSessionGravity(data, reply);
120         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CALLING_SESSION_ID):
121             return HandleSetCallingSessionId(data, reply);
122         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_CUSTOM_DECOR_HEIGHT):
123             return HandleSetCustomDecorHeight(data, reply);
124         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_PROPERTY):
125             return HandleUpdatePropertyByAction(data, reply);
126         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_ADJUST_KEYBOARD_LAYOUT):
127             return HandleAdjustKeyboardLayout(data, reply);
128         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_ABILITY_RESULT):
129             return HandleTransferAbilityResult(data, reply);
130         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_EXTENSION_DATA):
131             return HandleTransferExtensionData(data, reply);
132         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_ASYNC_ON):
133             return HandleNotifyAsyncOn(data, reply);
134         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_SYNC_ON):
135             return HandleNotifySyncOn(data, reply);
136         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED):
137             return HandleNotifyExtensionDied(data, reply);
138         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT):
139             return HandleNotifyExtensionTimeout(data, reply);
140         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION):
141             return HandleTriggerBindModalUIExtension(data, reply);
142         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT):
143             return HandleTransferAccessibilityEvent(data, reply);
144         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE):
145             return HandleNotifyPiPWindowPrepareClose(data, reply);
146         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_RECT):
147             return HandleUpdatePiPRect(data, reply);
148         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_CONTROL_STATUS):
149             return HandleUpdatePiPControlStatus(data, reply);
150         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_AUTOSTART_PIP):
151             return HandleSetAutoStartPiP(data, reply);
152         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_LAYOUT_FULL_SCREEN_CHANGE):
153             return HandleLayoutFullScreenChange(data, reply);
154         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DEFAULT_DENSITY_ENABLED):
155             return HandleDefaultDensityEnabled(data, reply);
156         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_FORCE_LANDSCAPE_CONFIG):
157             return HandleGetAppForceLandscapeConfig(data, reply);
158         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_DIALOG_SESSION_BACKGESTURE_ENABLE):
159             return HandleSetDialogSessionBackGestureEnabled(data, reply);
160         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_FRAME_LAYOUT_FINISH):
161             return HandleNotifyFrameLayoutFinish(data, reply);
162         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_REQUEST_FOCUS):
163             return HandleRequestFocus(data, reply);
164         case static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_GESTURE_BACK_ENABLE):
165             return HandleSetGestureBackEnabled(data, reply);
166         default:
167             WLOGFE("Failed to find function handler!");
168             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
169     }
170 }
171 
HandleSetWindowAnimationFlag(MessageParcel & data,MessageParcel & reply)172 int SessionStub::HandleSetWindowAnimationFlag(MessageParcel& data, MessageParcel& reply)
173 {
174     WLOGFD("HandleSetWindowAnimationFlag!");
175     bool isNeedWindowAnimationFlag = data.ReadBool();
176     WSError errCode = UpdateWindowAnimationFlag(isNeedWindowAnimationFlag);
177     reply.WriteUint32(static_cast<uint32_t>(errCode));
178     return ERR_NONE;
179 }
180 
HandleForeground(MessageParcel & data,MessageParcel & reply)181 int SessionStub::HandleForeground(MessageParcel& data, MessageParcel& reply)
182 {
183     WLOGFD("[WMSCom] Foreground!");
184     sptr<WindowSessionProperty> property = nullptr;
185     if (data.ReadBool()) {
186         property = data.ReadStrongParcelable<WindowSessionProperty>();
187         if (property == nullptr) {
188             return ERR_INVALID_DATA;
189         }
190     } else {
191         WLOGFW("[WMSCom] Property not exist!");
192         property = sptr<WindowSessionProperty>::MakeSptr();
193     }
194     bool isFromClient = data.ReadBool();
195     std::string identityToken;
196     if (!data.ReadString(identityToken)) {
197         TLOGE(WmsLogTag::WMS_LIFE, "Read identityToken failed.");
198         return ERR_INVALID_DATA;
199     }
200     const WSError errCode = Foreground(property, isFromClient, identityToken);
201     reply.WriteUint32(static_cast<uint32_t>(errCode));
202     return ERR_NONE;
203 }
204 
HandleBackground(MessageParcel & data,MessageParcel & reply)205 int SessionStub::HandleBackground(MessageParcel& data, MessageParcel& reply)
206 {
207     WLOGFD("[WMSCom] Background!");
208     bool isFromClient = data.ReadBool();
209     std::string identityToken;
210     if (!data.ReadString(identityToken)) {
211         TLOGE(WmsLogTag::WMS_LIFE, "Read identityToken failed.");
212         return ERR_INVALID_DATA;
213     }
214     const WSError errCode = Background(isFromClient, identityToken);
215     reply.WriteUint32(static_cast<uint32_t>(errCode));
216     return ERR_NONE;
217 }
218 
HandleDisconnect(MessageParcel & data,MessageParcel & reply)219 int SessionStub::HandleDisconnect(MessageParcel& data, MessageParcel& reply)
220 {
221     WLOGFD("Disconnect!");
222     bool isFromClient = data.ReadBool();
223     std::string identityToken;
224     if (!data.ReadString(identityToken)) {
225         TLOGE(WmsLogTag::WMS_LIFE, "Read identityToken failed.");
226         return ERR_INVALID_DATA;
227     }
228     WSError errCode = Disconnect(isFromClient, identityToken);
229     reply.WriteUint32(static_cast<uint32_t>(errCode));
230     return ERR_NONE;
231 }
232 
HandleShow(MessageParcel & data,MessageParcel & reply)233 int SessionStub::HandleShow(MessageParcel& data, MessageParcel& reply)
234 {
235     WLOGFD("Show!");
236     sptr<WindowSessionProperty> property = nullptr;
237     if (data.ReadBool()) {
238         property = data.ReadStrongParcelable<WindowSessionProperty>();
239         if (property == nullptr) {
240             return ERR_INVALID_DATA;
241         }
242     } else {
243         WLOGFW("Property not exist!");
244         property = sptr<WindowSessionProperty>::MakeSptr();
245     }
246     WSError errCode = Show(property);
247     reply.WriteUint32(static_cast<uint32_t>(errCode));
248     return ERR_NONE;
249 }
250 
HandleHide(MessageParcel & data,MessageParcel & reply)251 int SessionStub::HandleHide(MessageParcel& data, MessageParcel& reply)
252 {
253     WLOGFD("Hide!");
254     WSError errCode = Hide();
255     reply.WriteUint32(static_cast<uint32_t>(errCode));
256     return ERR_NONE;
257 }
258 
HandleConnect(MessageParcel & data,MessageParcel & reply)259 int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply)
260 {
261     WLOGFD("Connect!");
262     sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
263     sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
264     sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
265     sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
266     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
267     if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
268         WLOGFE("Failed to read scene session stage object or event channel object!");
269         return ERR_INVALID_DATA;
270     }
271 
272     sptr<WindowSessionProperty> property = nullptr;
273     if (data.ReadBool()) {
274         property = data.ReadStrongParcelable<WindowSessionProperty>();
275         if (property == nullptr) {
276             return ERR_INVALID_DATA;
277         }
278     } else {
279         WLOGFW("Property not exist!");
280     }
281 
282     sptr<IRemoteObject> token = nullptr;
283     if (property && property->GetTokenState()) {
284         token = data.ReadRemoteObject();
285         if (token == nullptr) {
286             return ERR_INVALID_DATA;
287         }
288     } else {
289         WLOGI("accept token is nullptr");
290     }
291     std::string identityToken = data.ReadString();
292     SystemSessionConfig systemConfig;
293     WSError errCode = Connect(sessionStage, eventChannel, surfaceNode, systemConfig, property, token,
294         identityToken);
295     reply.WriteParcelable(&systemConfig);
296     if (property) {
297         reply.WriteInt32(property->GetPersistentId());
298         reply.WriteUint64(property->GetDisplayId());
299         bool needUpdate = property->GetIsNeedUpdateWindowMode();
300         reply.WriteBool(needUpdate);
301         if (needUpdate) {
302             reply.WriteUint32(static_cast<uint32_t>(property->GetWindowMode()));
303         }
304         property->SetIsNeedUpdateWindowMode(false);
305 
306         Rect winRect = property->GetWindowRect();
307         reply.WriteInt32(winRect.posX_);
308         reply.WriteInt32(winRect.posY_);
309         reply.WriteUint32(winRect.width_);
310         reply.WriteUint32(winRect.height_);
311         reply.WriteInt32(property->GetCollaboratorType());
312         reply.WriteBool(property->GetFullScreenStart());
313         reply.WriteBool(property->GetCompatibleModeInPc());
314         reply.WriteInt32(property->GetCompatibleInPcPortraitWidth());
315         reply.WriteInt32(property->GetCompatibleInPcPortraitHeight());
316         reply.WriteInt32(property->GetCompatibleInPcLandscapeWidth());
317         reply.WriteInt32(property->GetCompatibleInPcLandscapeHeight());
318         reply.WriteBool(property->GetIsSupportDragInPcCompatibleMode());
319         reply.WriteBool(property->GetIsPcAppInPad());
320         reply.WriteBool(property->GetCompatibleModeEnableInPad());
321         reply.WriteBool(property->GetDragEnabled());
322     }
323     reply.WriteUint32(static_cast<uint32_t>(errCode));
324     return ERR_NONE;
325 }
326 
HandleNotifyFrameLayoutFinish(MessageParcel & data,MessageParcel & reply)327 int SessionStub::HandleNotifyFrameLayoutFinish(MessageParcel& data, MessageParcel& reply)
328 {
329     bool notifyListener = data.ReadBool();
330     WSRect rect = { data.ReadInt32(), data.ReadInt32(), data.ReadInt32(), data.ReadInt32() };
331     NotifyFrameLayoutFinishFromApp(notifyListener, rect);
332     return ERR_NONE;
333 }
334 
HandleDrawingCompleted(MessageParcel & data,MessageParcel & reply)335 int SessionStub::HandleDrawingCompleted(MessageParcel& data, MessageParcel& reply)
336 {
337     TLOGD(WmsLogTag::WMS_LIFE, "Called!");
338     const WSError errCode = DrawingCompleted();
339     reply.WriteInt32(static_cast<int32_t>(errCode));
340     return ERR_NONE;
341 }
342 
HandleSessionEvent(MessageParcel & data,MessageParcel & reply)343 int SessionStub::HandleSessionEvent(MessageParcel& data, MessageParcel& reply)
344 {
345     uint32_t eventId = data.ReadUint32();
346     WLOGFD("HandleSessionEvent eventId: %{public}d", eventId);
347     WSError errCode = OnSessionEvent(static_cast<SessionEvent>(eventId));
348     reply.WriteUint32(static_cast<uint32_t>(errCode));
349     return ERR_NONE;
350 }
351 
HandleLayoutFullScreenChange(MessageParcel & data,MessageParcel & reply)352 int SessionStub::HandleLayoutFullScreenChange(MessageParcel& data, MessageParcel& reply)
353 {
354     bool isLayoutFullScreen = data.ReadBool();
355     TLOGD(WmsLogTag::WMS_LAYOUT, "isLayoutFullScreen: %{public}d", isLayoutFullScreen);
356     WSError errCode = OnLayoutFullScreenChange(isLayoutFullScreen);
357     reply.WriteUint32(static_cast<uint32_t>(errCode));
358     return ERR_NONE;
359 }
360 
HandleDefaultDensityEnabled(MessageParcel & data,MessageParcel & reply)361 int SessionStub::HandleDefaultDensityEnabled(MessageParcel& data, MessageParcel& reply)
362 {
363     bool isDefaultDensityEnabled = false;
364     if (!data.ReadBool(isDefaultDensityEnabled)) {
365         TLOGE(WmsLogTag::WMS_LAYOUT, "Read isDefaultDensityEnabled failed");
366         return ERR_INVALID_DATA;
367     }
368     TLOGD(WmsLogTag::WMS_LAYOUT, "isDefaultDensityEnabled: %{public}d", isDefaultDensityEnabled);
369     WSError errCode = OnDefaultDensityEnabled(isDefaultDensityEnabled);
370     reply.WriteInt32(static_cast<int32_t>(errCode));
371     return ERR_NONE;
372 }
373 
HandleTerminateSession(MessageParcel & data,MessageParcel & reply)374 int SessionStub::HandleTerminateSession(MessageParcel& data, MessageParcel& reply)
375 {
376     WLOGFD("run HandleTerminateSession");
377     std::shared_ptr<AAFwk::Want> localWant(data.ReadParcelable<AAFwk::Want>());
378     if (localWant == nullptr) {
379         TLOGE(WmsLogTag::WMS_LIFE, "localWant is nullptr");
380         return ERR_INVALID_VALUE;
381     }
382     sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
383     abilitySessionInfo->want = *localWant;
384     if (data.ReadBool()) {
385         abilitySessionInfo->callerToken = data.ReadRemoteObject();
386     }
387     abilitySessionInfo->resultCode = data.ReadInt32();
388     WSError errCode = TerminateSession(abilitySessionInfo);
389     reply.WriteUint32(static_cast<uint32_t>(errCode));
390     return ERR_NONE;
391 }
392 
HandleSessionException(MessageParcel & data,MessageParcel & reply)393 int SessionStub::HandleSessionException(MessageParcel& data, MessageParcel& reply)
394 {
395     WLOGFD("run HandleSessionException");
396     std::shared_ptr<AAFwk::Want> localWant(data.ReadParcelable<AAFwk::Want>());
397     if (localWant == nullptr) {
398         TLOGE(WmsLogTag::WMS_LIFE, "localWant is nullptr");
399         return ERR_INVALID_VALUE;
400     }
401     sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
402     abilitySessionInfo->want = *localWant;
403     if (data.ReadBool()) {
404         abilitySessionInfo->callerToken = data.ReadRemoteObject();
405     }
406 
407     abilitySessionInfo->persistentId = data.ReadInt32();
408     abilitySessionInfo->errorCode = data.ReadInt32();
409     abilitySessionInfo->errorReason = data.ReadString();
410     abilitySessionInfo->identityToken = data.ReadString();
411     WSError errCode = NotifySessionException(abilitySessionInfo);
412     reply.WriteUint32(static_cast<uint32_t>(errCode));
413     return ERR_NONE;
414 }
415 
HandleChangeSessionVisibilityWithStatusBar(MessageParcel & data,MessageParcel & reply)416 int SessionStub::HandleChangeSessionVisibilityWithStatusBar(MessageParcel& data, MessageParcel& reply)
417 {
418     WLOGFD("HandleChangeSessionVisibilityWithStatusBar");
419     sptr<AAFwk::Want> localWant = data.ReadParcelable<AAFwk::Want>();
420     if (localWant == nullptr) {
421         TLOGE(WmsLogTag::WMS_LIFE, "localWant is nullptr");
422         return ERR_INVALID_VALUE;
423     }
424     sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
425     abilitySessionInfo->want = *localWant;
426     abilitySessionInfo->requestCode = data.ReadInt32();
427     abilitySessionInfo->persistentId = data.ReadInt32();
428     abilitySessionInfo->state = static_cast<AAFwk::CallToState>(data.ReadInt32());
429     abilitySessionInfo->uiAbilityId = data.ReadInt64();
430     abilitySessionInfo->callingTokenId = data.ReadUint32();
431     abilitySessionInfo->reuse = data.ReadBool();
432     abilitySessionInfo->processOptions =
433         std::shared_ptr<AAFwk::ProcessOptions>(data.ReadParcelable<AAFwk::ProcessOptions>());
434     if (data.ReadBool()) {
435         abilitySessionInfo->callerToken = data.ReadRemoteObject();
436     }
437     if (data.ReadBool()) {
438         abilitySessionInfo->startSetting.reset(data.ReadParcelable<AAFwk::AbilityStartSetting>());
439     }
440     bool visible = data.ReadBool();
441     WSError errCode = ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible);
442     reply.WriteUint32(static_cast<uint32_t>(errCode));
443     return ERR_NONE;
444 }
445 
HandlePendingSessionActivation(MessageParcel & data,MessageParcel & reply)446 int SessionStub::HandlePendingSessionActivation(MessageParcel& data, MessageParcel& reply)
447 {
448     WLOGFD("PendingSessionActivation!");
449     sptr<AAFwk::Want> localWant = data.ReadParcelable<AAFwk::Want>();
450     if (localWant == nullptr) {
451         TLOGE(WmsLogTag::WMS_LIFE, "localWant is nullptr");
452         return ERR_INVALID_VALUE;
453     }
454     sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
455     abilitySessionInfo->want = *localWant;
456     abilitySessionInfo->requestCode = data.ReadInt32();
457     abilitySessionInfo->persistentId = data.ReadInt32();
458     abilitySessionInfo->state = static_cast<AAFwk::CallToState>(data.ReadInt32());
459     abilitySessionInfo->uiAbilityId = data.ReadInt64();
460     abilitySessionInfo->callingTokenId = data.ReadUint32();
461     abilitySessionInfo->reuse = data.ReadBool();
462     abilitySessionInfo->processOptions.reset(data.ReadParcelable<AAFwk::ProcessOptions>());
463     abilitySessionInfo->canStartAbilityFromBackground = data.ReadBool();
464     abilitySessionInfo->isAtomicService = data.ReadBool();
465     abilitySessionInfo->isBackTransition = data.ReadBool();
466     abilitySessionInfo->needClearInNotShowRecent = data.ReadBool();
467     if (data.ReadBool()) {
468         abilitySessionInfo->callerToken = data.ReadRemoteObject();
469     }
470     if (data.ReadBool()) {
471         abilitySessionInfo->startSetting.reset(data.ReadParcelable<AAFwk::AbilityStartSetting>());
472     }
473     if (!data.ReadBool(abilitySessionInfo->isFromIcon)) {
474         TLOGE(WmsLogTag::WMS_LIFE, "Read isFromIcon failed.");
475         return ERR_INVALID_DATA;
476     }
477     WSError errCode = PendingSessionActivation(abilitySessionInfo);
478     reply.WriteUint32(static_cast<uint32_t>(errCode));
479     return ERR_NONE;
480 }
481 
HandleUpdateSessionRect(MessageParcel & data,MessageParcel & reply)482 int SessionStub::HandleUpdateSessionRect(MessageParcel& data, MessageParcel& reply)
483 {
484     TLOGD(WmsLogTag::WMS_LAYOUT, "In");
485     auto posX = data.ReadInt32();
486     auto posY = data.ReadInt32();
487     auto width = data.ReadUint32();
488     auto height = data.ReadUint32();
489     WSRect rect = {posX, posY, width, height};
490     TLOGI(WmsLogTag::WMS_LAYOUT, "Rect [%{public}d, %{public}d, %{public}u, %{public}u]",
491         posX, posY, width, height);
492     const SizeChangeReason& reason = static_cast<SizeChangeReason>(data.ReadUint32());
493     auto isGlobal = data.ReadBool();
494     auto isFromMoveToGlobal = false;
495     if (!data.ReadBool(isFromMoveToGlobal)) {
496         TLOGE(WmsLogTag::WMS_LAYOUT, "read isFromMoveToGlobal failed");
497         return ERR_INVALID_DATA;
498     }
499     WSError errCode = UpdateSessionRect(rect, reason, isGlobal, isFromMoveToGlobal);
500     reply.WriteUint32(static_cast<uint32_t>(errCode));
501     return ERR_NONE;
502 }
503 
504 /** @note @window.layout */
HandleUpdateClientRect(MessageParcel & data,MessageParcel & reply)505 int SessionStub::HandleUpdateClientRect(MessageParcel& data, MessageParcel& reply)
506 {
507     TLOGD(WmsLogTag::WMS_LAYOUT, "In");
508     int32_t posX = 0;
509     int32_t posY = 0;
510     int32_t width = 0;
511     int32_t height = 0;
512     if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadInt32(width) || !data.ReadInt32(height)) {
513         TLOGE(WmsLogTag::WMS_LAYOUT, "read rect failed");
514         return ERR_INVALID_DATA;
515     }
516     WSRect rect = { posX, posY, width, height };
517     WSError errCode = UpdateClientRect(rect);
518     reply.WriteInt32(static_cast<int32_t>(errCode));
519     return ERR_NONE;
520 }
521 
522 /** @note @window.layout */
HandleGetGlobalScaledRect(MessageParcel & data,MessageParcel & reply)523 int SessionStub::HandleGetGlobalScaledRect(MessageParcel& data, MessageParcel& reply)
524 {
525     TLOGD(WmsLogTag::WMS_LAYOUT, "In");
526     Rect globalScaledRect;
527     WMError errorCode = GetGlobalScaledRect(globalScaledRect);
528     if (!reply.WriteInt32(globalScaledRect.posX_) || !reply.WriteInt32(globalScaledRect.posY_) ||
529         !reply.WriteUint32(globalScaledRect.width_) || !reply.WriteUint32(globalScaledRect.height_) ||
530         !reply.WriteInt32(static_cast<int32_t>(errorCode))) {
531         TLOGE(WmsLogTag::WMS_LAYOUT, "Write failed");
532         return ERR_INVALID_DATA;
533     }
534     return ERR_NONE;
535 }
536 
HandleRaiseToAppTop(MessageParcel & data,MessageParcel & reply)537 int SessionStub::HandleRaiseToAppTop(MessageParcel& data, MessageParcel& reply)
538 {
539     WLOGFD("RaiseToAppTop!");
540     WSError errCode = RaiseToAppTop();
541     reply.WriteUint32(static_cast<uint32_t>(errCode));
542     return ERR_NONE;
543 }
544 
HandleRaiseAboveTarget(MessageParcel & data,MessageParcel & reply)545 int SessionStub::HandleRaiseAboveTarget(MessageParcel& data, MessageParcel& reply)
546 {
547     WLOGFD("RaiseAboveTarget!");
548     auto subWindowId = data.ReadInt32();
549     WSError errCode = RaiseAboveTarget(subWindowId);
550     reply.WriteUint32(static_cast<uint32_t>(errCode));
551     return ERR_NONE;
552 }
553 
HandleRaiseAppMainWindowToTop(MessageParcel & data,MessageParcel & reply)554 int SessionStub::HandleRaiseAppMainWindowToTop(MessageParcel& data, MessageParcel& reply)
555 {
556     WLOGFD("RaiseAppMainWindowToTop!");
557     WSError errCode = RaiseAppMainWindowToTop();
558     reply.WriteUint32(static_cast<uint32_t>(errCode));
559     return ERR_NONE;
560 }
561 
HandleBackPressed(MessageParcel & data,MessageParcel & reply)562 int SessionStub::HandleBackPressed(MessageParcel& data, MessageParcel& reply)
563 {
564     WLOGFD("HandleBackPressed!");
565     bool needMoveToBackground = false;
566     if (!data.ReadBool(needMoveToBackground)) {
567         WLOGFE("Read needMoveToBackground from parcel failed!");
568         return ERR_INVALID_DATA;
569     }
570     WSError errCode = RequestSessionBack(needMoveToBackground);
571     reply.WriteUint32(static_cast<uint32_t>(errCode));
572     return ERR_NONE;
573 }
574 
HandleMarkProcessed(MessageParcel & data,MessageParcel & reply)575 int SessionStub::HandleMarkProcessed(MessageParcel& data, MessageParcel& reply)
576 {
577     WLOGFD("HandleMarkProcessed!");
578     int32_t eventId = 0;
579     if (!data.ReadInt32(eventId)) {
580         WLOGFE("Read eventId from parcel failed!");
581         return ERR_INVALID_DATA;
582     }
583     WSError errCode = MarkProcessed(eventId);
584     reply.WriteUint32(static_cast<uint32_t>(errCode));
585     return ERR_NONE;
586 }
587 
HandleSetGlobalMaximizeMode(MessageParcel & data,MessageParcel & reply)588 int SessionStub::HandleSetGlobalMaximizeMode(MessageParcel& data, MessageParcel& reply)
589 {
590     WLOGFD("HandleSetGlobalMaximizeMode!");
591     auto mode = data.ReadUint32();
592     WSError errCode = SetGlobalMaximizeMode(static_cast<MaximizeMode>(mode));
593     reply.WriteUint32(static_cast<uint32_t>(errCode));
594     return ERR_NONE;
595 }
596 
HandleGetGlobalMaximizeMode(MessageParcel & data,MessageParcel & reply)597 int SessionStub::HandleGetGlobalMaximizeMode(MessageParcel& data, MessageParcel& reply)
598 {
599     WLOGFD("HandleGetGlobalMaximizeMode!");
600     MaximizeMode mode = MaximizeMode::MODE_FULL_FILL;
601     WSError errCode = GetGlobalMaximizeMode(mode);
602     reply.WriteUint32(static_cast<uint32_t>(mode));
603     reply.WriteUint32(static_cast<uint32_t>(errCode));
604     return ERR_NONE;
605 }
606 
HandleNeedAvoid(MessageParcel & data,MessageParcel & reply)607 int SessionStub::HandleNeedAvoid(MessageParcel& data, MessageParcel& reply)
608 {
609     bool status = static_cast<bool>(data.ReadUint32());
610     WLOGFD("HandleNeedAvoid status:%{public}d", static_cast<int32_t>(status));
611     WSError errCode = OnNeedAvoid(status);
612     reply.WriteUint32(static_cast<uint32_t>(errCode));
613     return ERR_NONE;
614 }
615 
HandleGetAvoidAreaByType(MessageParcel & data,MessageParcel & reply)616 int SessionStub::HandleGetAvoidAreaByType(MessageParcel& data, MessageParcel& reply)
617 {
618     AvoidAreaType type = static_cast<AvoidAreaType>(data.ReadUint32());
619     WLOGFD("HandleGetAvoidArea type:%{public}d", static_cast<int32_t>(type));
620     AvoidArea avoidArea = GetAvoidAreaByType(type);
621     reply.WriteParcelable(&avoidArea);
622     return ERR_NONE;
623 }
624 
HandleGetAllAvoidAreas(MessageParcel & data,MessageParcel & reply)625 int SessionStub::HandleGetAllAvoidAreas(MessageParcel& data, MessageParcel& reply)
626 {
627     TLOGD(WmsLogTag::WMS_IMMS, "in");
628     std::map<AvoidAreaType, AvoidArea> avoidAreas;
629     WSError errCode = GetAllAvoidAreas(avoidAreas);
630     reply.WriteUint32(avoidAreas.size());
631     for (const auto& [type, avoidArea] : avoidAreas) {
632         reply.WriteUint32(static_cast<uint32_t>(type));
633         reply.WriteParcelable(&avoidArea);
634     }
635     reply.WriteUint32(static_cast<uint32_t>(errCode));
636     return ERR_NONE;
637 }
638 
HandleSetAspectRatio(MessageParcel & data,MessageParcel & reply)639 int SessionStub::HandleSetAspectRatio(MessageParcel& data, MessageParcel& reply)
640 {
641     WLOGFD("HandleSetAspectRatio!");
642     float ratio = data.ReadFloat();
643     WSError errCode = SetAspectRatio(ratio);
644     reply.WriteUint32(static_cast<uint32_t>(errCode));
645     return ERR_NONE;
646 }
647 
HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel & data,MessageParcel & reply)648 int SessionStub::HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel& data, MessageParcel& reply)
649 {
650     WLOGD("HandleUpdateWindowSceneAfterCustomAnimation!");
651     bool isAdd = data.ReadBool();
652     WSError errCode = UpdateWindowSceneAfterCustomAnimation(isAdd);
653     reply.WriteUint32(static_cast<uint32_t>(errCode));
654     return ERR_NONE;
655 }
656 
HandleSetLandscapeMultiWindow(MessageParcel & data,MessageParcel & reply)657 int SessionStub::HandleSetLandscapeMultiWindow(MessageParcel& data, MessageParcel& reply)
658 {
659     TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "HandleSetLandscapeMultiWindow!");
660     bool isLandscapeMultiWindow = data.ReadBool();
661     const WSError errCode = SetLandscapeMultiWindow(isLandscapeMultiWindow);
662     reply.WriteUint32(static_cast<uint32_t>(errCode));
663     return ERR_NONE;
664 }
665 
HandleTransferAbilityResult(MessageParcel & data,MessageParcel & reply)666 int SessionStub::HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply)
667 {
668     WLOGFD("HandleTransferAbilityResult!");
669     uint32_t resultCode = data.ReadUint32();
670     std::shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
671     if (want == nullptr) {
672         WLOGFE("want is nullptr");
673         return ERR_INVALID_VALUE;
674     }
675     WSError errCode = TransferAbilityResult(resultCode, *want);
676     reply.WriteUint32(static_cast<uint32_t>(errCode));
677     return ERR_NONE;
678 }
679 
HandleTransferExtensionData(MessageParcel & data,MessageParcel & reply)680 int SessionStub::HandleTransferExtensionData(MessageParcel& data, MessageParcel& reply)
681 {
682     WLOGFD("HandleTransferExtensionData!");
683     std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
684     if (wantParams == nullptr) {
685         WLOGFE("wantParams is nullptr");
686         return ERR_INVALID_VALUE;
687     }
688     WSError errCode = TransferExtensionData(*wantParams);
689     reply.WriteUint32(static_cast<uint32_t>(errCode));
690     return ERR_NONE;
691 }
692 
HandleNotifySyncOn(MessageParcel & data,MessageParcel & reply)693 int SessionStub::HandleNotifySyncOn(MessageParcel& data, MessageParcel& reply)
694 {
695     NotifySyncOn();
696     return ERR_NONE;
697 }
698 
HandleNotifyAsyncOn(MessageParcel & data,MessageParcel & reply)699 int SessionStub::HandleNotifyAsyncOn(MessageParcel& data, MessageParcel& reply)
700 {
701     NotifyAsyncOn();
702     return ERR_NONE;
703 }
704 
HandleNotifyExtensionDied(MessageParcel & data,MessageParcel & reply)705 int SessionStub::HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& reply)
706 {
707     WLOGFD("called");
708     NotifyExtensionDied();
709     return ERR_NONE;
710 }
711 
HandleNotifyExtensionTimeout(MessageParcel & data,MessageParcel & reply)712 int SessionStub::HandleNotifyExtensionTimeout(MessageParcel& data, MessageParcel& reply)
713 {
714     int32_t errorCode = 0;
715     if (!data.ReadInt32(errorCode)) {
716         TLOGE(WmsLogTag::WMS_UIEXT, "Read eventId from parcel failed!");
717         return ERR_INVALID_DATA;
718     }
719     NotifyExtensionTimeout(errorCode);
720     return ERR_NONE;
721 }
722 
HandleTriggerBindModalUIExtension(MessageParcel & data,MessageParcel & reply)723 int SessionStub::HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply)
724 {
725     WLOGFD("called");
726     TriggerBindModalUIExtension();
727     return ERR_NONE;
728 }
729 
HandleTransferAccessibilityEvent(MessageParcel & data,MessageParcel & reply)730 int SessionStub::HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply)
731 {
732     sptr<Accessibility::AccessibilityEventInfoParcel> infoPtr =
733         data.ReadStrongParcelable<Accessibility::AccessibilityEventInfoParcel>();
734     if (infoPtr == nullptr) {
735         return ERR_INVALID_DATA;
736     }
737     int64_t uiExtensionIdLevel = 0;
738     if (!data.ReadInt64(uiExtensionIdLevel)) {
739         WLOGFE("read uiExtensionIdLevel error");
740         return ERR_INVALID_DATA;
741     }
742     NotifyTransferAccessibilityEvent(*infoPtr, uiExtensionIdLevel);
743     return ERR_NONE;
744 }
745 
HandleNotifyPiPWindowPrepareClose(MessageParcel & data,MessageParcel & reply)746 int SessionStub::HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply)
747 {
748     TLOGD(WmsLogTag::WMS_PIP, "HandleNotifyPiPWindowPrepareClose");
749     NotifyPiPWindowPrepareClose();
750     return ERR_NONE;
751 }
752 
HandleUpdatePiPRect(MessageParcel & data,MessageParcel & reply)753 int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply)
754 {
755     TLOGD(WmsLogTag::WMS_PIP, "HandleUpdatePiPRect!");
756     Rect rect = {data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32()};
757     auto reason = static_cast<SizeChangeReason>(data.ReadInt32());
758     WSError errCode = UpdatePiPRect(rect, reason);
759     reply.WriteUint32(static_cast<uint32_t>(errCode));
760     return ERR_NONE;
761 }
762 
HandleUpdatePiPControlStatus(MessageParcel & data,MessageParcel & reply)763 int SessionStub::HandleUpdatePiPControlStatus(MessageParcel& data, MessageParcel& reply)
764 {
765     TLOGI(WmsLogTag::WMS_PIP, "called");
766     uint32_t controlType = 0;
767     int32_t status = 0;
768     if (data.ReadUint32(controlType) && data.ReadInt32(status)) {
769         WSError errCode = UpdatePiPControlStatus(static_cast<WsPiPControlType>(controlType),
770             static_cast<WsPiPControlStatus>(status));
771         reply.WriteInt32(static_cast<int32_t>(errCode));
772         return ERR_NONE;
773     } else {
774         return ERR_INVALID_DATA;
775     }
776 }
777 
HandleSetAutoStartPiP(MessageParcel & data,MessageParcel & reply)778 int SessionStub::HandleSetAutoStartPiP(MessageParcel& data, MessageParcel& reply)
779 {
780     TLOGD(WmsLogTag::WMS_PIP, "in");
781     bool isAutoStart = false;
782     if (!data.ReadBool(isAutoStart)) {
783         TLOGE(WmsLogTag::WMS_PIP, "read isAutoStart error");
784         return ERR_INVALID_DATA;
785     }
786     uint32_t priority = 0;
787     if (!data.ReadUint32(priority)) {
788         TLOGE(WmsLogTag::WMS_PIP, "read priority error");
789         return ERR_INVALID_DATA;
790     }
791     WSError errCode = SetAutoStartPiP(isAutoStart, priority);
792     reply.WriteInt32(static_cast<int32_t>(errCode));
793     return ERR_NONE;
794 }
795 
HandleProcessPointDownSession(MessageParcel & data,MessageParcel & reply)796 int SessionStub::HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply)
797 {
798     WLOGFD("HandleProcessPointDownSession!");
799     int32_t posX = data.ReadInt32();
800     int32_t posY = data.ReadInt32();
801     WSError errCode = ProcessPointDownSession(posX, posY);
802     reply.WriteUint32(static_cast<uint32_t>(errCode));
803     return ERR_NONE;
804 }
805 
HandleSendPointerEvenForMoveDrag(MessageParcel & data,MessageParcel & reply)806 int SessionStub::HandleSendPointerEvenForMoveDrag(MessageParcel& data, MessageParcel& reply)
807 {
808     WLOGFD("HandleSendPointerEvenForMoveDrag!");
809     auto pointerEvent = MMI::PointerEvent::Create();
810     if (!pointerEvent) {
811         TLOGE(WmsLogTag::WMS_EVENT, "create pointer event failed");
812         return ERR_INVALID_DATA;
813     }
814     if (!pointerEvent->ReadFromParcel(data)) {
815         TLOGE(WmsLogTag::WMS_EVENT, "Read pointer event failed");
816         return ERR_INVALID_DATA;
817     }
818     WSError errCode = SendPointEventForMoveDrag(pointerEvent);
819     reply.WriteUint32(static_cast<uint32_t>(errCode));
820     return ERR_NONE;
821 }
822 
HandleUpdateRectChangeListenerRegistered(MessageParcel & data,MessageParcel & reply)823 int SessionStub::HandleUpdateRectChangeListenerRegistered(MessageParcel& data, MessageParcel& reply)
824 {
825     bool isRegister = data.ReadBool();
826     WSError errCode = UpdateRectChangeListenerRegistered(isRegister);
827     reply.WriteUint32(static_cast<uint32_t>(errCode));
828     return ERR_NONE;
829 }
830 
HandleSetKeyboardSessionGravity(MessageParcel & data,MessageParcel & reply)831 int SessionStub::HandleSetKeyboardSessionGravity(MessageParcel& data, MessageParcel& reply)
832 {
833     TLOGD(WmsLogTag::WMS_KEYBOARD, "run HandleSetKeyboardSessionGravity!");
834     SessionGravity gravity = static_cast<SessionGravity>(data.ReadUint32());
835     uint32_t percent = data.ReadUint32();
836     WSError ret = SetKeyboardSessionGravity(gravity, percent);
837     reply.WriteInt32(static_cast<int32_t>(ret));
838     return ERR_NONE;
839 }
840 
HandleSetCallingSessionId(MessageParcel & data,MessageParcel & reply)841 int SessionStub::HandleSetCallingSessionId(MessageParcel& data, MessageParcel& reply)
842 {
843     TLOGD(WmsLogTag::WMS_KEYBOARD, "run HandleSetCallingSessionId!");
844     uint32_t callingSessionId = data.ReadUint32();
845 
846     SetCallingSessionId(callingSessionId);
847     reply.WriteInt32(static_cast<int32_t>(WSError::WS_OK));
848     return ERR_NONE;
849 }
850 
HandleSetCustomDecorHeight(MessageParcel & data,MessageParcel & reply)851 int SessionStub::HandleSetCustomDecorHeight(MessageParcel& data, MessageParcel& reply)
852 {
853     TLOGD(WmsLogTag::WMS_LAYOUT, "run HandleSetCustomDecorHeight!");
854     int32_t height = data.ReadInt32();
855     SetCustomDecorHeight(height);
856     return ERR_NONE;
857 }
858 
HandleAdjustKeyboardLayout(MessageParcel & data,MessageParcel & reply)859 int SessionStub::HandleAdjustKeyboardLayout(MessageParcel& data, MessageParcel& reply)
860 {
861     TLOGD(WmsLogTag::WMS_KEYBOARD, "run HandleAdjustKeyboardLayout!");
862     sptr<KeyboardLayoutParams> keyboardLayoutParams = data.ReadParcelable<KeyboardLayoutParams>();
863     if (keyboardLayoutParams == nullptr) {
864         TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardLayoutParams is nullptr.");
865         return ERR_INVALID_DATA;
866     }
867     WSError ret = AdjustKeyboardLayout(*keyboardLayoutParams);
868     reply.WriteInt32(static_cast<int32_t>(ret));
869     return ERR_NONE;
870 }
871 
HandleUpdatePropertyByAction(MessageParcel & data,MessageParcel & reply)872 int SessionStub::HandleUpdatePropertyByAction(MessageParcel& data, MessageParcel& reply)
873 {
874     auto action = static_cast<WSPropertyChangeAction>(data.ReadUint32());
875     TLOGD(WmsLogTag::DEFAULT, "action:%{public}u", action);
876     sptr<WindowSessionProperty> property = nullptr;
877     if (data.ReadBool()) {
878         property = sptr<WindowSessionProperty>::MakeSptr();
879         if (property != nullptr) {
880             property->Read(data, action);
881         }
882     } else {
883         TLOGW(WmsLogTag::DEFAULT, "Property not exist!");
884     }
885     const WMError ret = UpdateSessionPropertyByAction(property, action);
886     reply.WriteInt32(static_cast<int32_t>(ret));
887     return ERR_NONE;
888 }
889 
HandleGetAppForceLandscapeConfig(MessageParcel & data,MessageParcel & reply)890 int SessionStub::HandleGetAppForceLandscapeConfig(MessageParcel& data, MessageParcel& reply)
891 {
892     TLOGD(WmsLogTag::DEFAULT, "called");
893     AppForceLandscapeConfig config;
894     WMError ret = GetAppForceLandscapeConfig(config);
895     reply.WriteParcelable(&config);
896     reply.WriteInt32(static_cast<int32_t>(ret));
897     return ERR_NONE;
898 }
899 
HandleSetDialogSessionBackGestureEnabled(MessageParcel & data,MessageParcel & reply)900 int SessionStub::HandleSetDialogSessionBackGestureEnabled(MessageParcel& data, MessageParcel& reply)
901 {
902     TLOGD(WmsLogTag::WMS_DIALOG, "called");
903     bool isEnabled = data.ReadBool();
904     WSError ret = SetDialogSessionBackGestureEnabled(isEnabled);
905     reply.WriteInt32(static_cast<int32_t>(ret));
906     return ERR_NONE;
907 }
908 
HandleRequestFocus(MessageParcel & data,MessageParcel & reply)909 int SessionStub::HandleRequestFocus(MessageParcel& data, MessageParcel& reply)
910 {
911     TLOGD(WmsLogTag::WMS_FOCUS, "called");
912     bool isFocused = false;
913     if (!data.ReadBool(isFocused)) {
914         TLOGE(WmsLogTag::WMS_FOCUS, "read isFocused failed");
915         return ERR_INVALID_DATA;
916     }
917     WSError ret = RequestFocus(isFocused);
918     reply.WriteInt32(static_cast<int32_t>(ret));
919     return ERR_NONE;
920 }
921 
HandleSetGestureBackEnabled(MessageParcel & data,MessageParcel & reply)922 int SessionStub::HandleSetGestureBackEnabled(MessageParcel& data, MessageParcel& reply)
923 {
924     TLOGD(WmsLogTag::WMS_IMMS, "in");
925     bool isEnabled;
926     if (!data.ReadBool(isEnabled)) {
927         return ERR_INVALID_DATA;
928     }
929     WMError ret = SetGestureBackEnabled(isEnabled);
930     reply.WriteInt32(static_cast<int32_t>(ret));
931     return ERR_NONE;
932 }
933 } // namespace OHOS::Rosen
934