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