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_manager/include/zidl/scene_session_manager_stub.h"
17
18 #include <ui/rs_surface_node.h>
19 #include "marshalling_helper.h"
20
21 namespace OHOS::Rosen {
22 namespace {
23 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerStub"};
24 constexpr uint32_t MAX_VECTOR_SIZE = 100;
25 }
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int SceneSessionManagerStub::OnRemoteRequest(uint32_t code,
28 MessageParcel& data, MessageParcel& reply, MessageOption& option)
29 {
30 WLOGFD("Scene session on remote request!, code: %{public}u", code);
31 if (data.ReadInterfaceToken() != GetDescriptor()) {
32 WLOGFE("Failed to check interface token!");
33 return ERR_TRANSACTION_FAILED;
34 }
35 return ProcessRemoteRequest(code, data, reply, option);
36 }
37
ProcessRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)38 int SceneSessionManagerStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
39 MessageOption& option)
40 {
41 switch (code) {
42 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CREATE_AND_CONNECT_SPECIFIC_SESSION):
43 return HandleCreateAndConnectSpecificSession(data, reply);
44 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_CONNECT_SPECIFIC_SESSION):
45 return HandleRecoverAndConnectSpecificSession(data, reply);
46 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_RECONNECT_SCENE_SESSION):
47 return HandleRecoverAndReconnectSceneSession(data, reply);
48 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION):
49 return HandleDestroyAndDisconnectSpcificSession(data, reply);
50 case static_cast<uint32_t>(
51 SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION_WITH_DETACH_CALLBACK):
52 return HandleDestroyAndDisconnectSpcificSessionWithDetachCallback(data, reply);
53 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REQUEST_FOCUS):
54 return HandleRequestFocusStatus(data, reply);
55 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT):
56 return HandleRegisterWindowManagerAgent(data, reply);
57 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT):
58 return HandleUnregisterWindowManagerAgent(data, reply);
59 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_INFO):
60 return HandleGetFocusSessionInfo(data, reply);
61 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_LABEL):
62 return HandleSetSessionLabel(data, reply);
63 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_ICON):
64 return HandleSetSessionIcon(data, reply);
65 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_VALID_SESSION_IDS):
66 return HandleIsValidSessionIds(data, reply);
67 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND):
68 return HandlePendingSessionToForeground(data, reply);
69 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR):
70 return HandlePendingSessionToBackgroundForDelegator(data, reply);
71 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN):
72 return HandleGetFocusSessionToken(data, reply);
73 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT):
74 return HandleGetFocusSessionElement(data, reply);
75 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CHECK_WINDOW_ID):
76 return HandleCheckWindowId(data, reply);
77 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_GESTURE_NAVIGATION_ENABLED):
78 return HandleSetGestureNavigationEnabled(data, reply);
79 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_INFO):
80 return HandleGetAccessibilityWindowInfo(data, reply);
81 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_UNRELIABLE_WINDOW_INFO):
82 return HandleGetUnreliableWindowInfo(data, reply);
83 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_SESSION_LISTENER):
84 return HandleRegisterSessionListener(data, reply);
85 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER):
86 return HandleUnRegisterSessionListener(data, reply);
87 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFOS):
88 return HandleGetSessionInfos(data, reply);
89 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFO_BY_ID):
90 return HandleGetSessionInfo(data, reply);
91 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID):
92 return HandleGetSessionInfoByContinueSessionId(data, reply);
93 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_ALL):
94 return HandleDumpSessionAll(data, reply);
95 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_WITH_ID):
96 return HandleDumpSessionWithId(data, reply);
97 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_TERMINATE_SESSION_NEW):
98 return HandleTerminateSessionNew(data, reply);
99 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_AVOIDAREA_LISTENER):
100 return HandleUpdateSessionAvoidAreaListener(data, reply);
101 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_DUMP_INFO):
102 return HandleGetSessionDump(data, reply);
103 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT):
104 return HandleGetSessionSnapshot(data, reply);
105 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT_BY_ID):
106 return HandleGetSessionSnapshotById(data, reply);
107 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ):
108 return HandleGetUIContentRemoteObj(data, reply);
109 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_BIND_DIALOG_TARGET):
110 return HandleBindDialogTarget(data, reply);
111 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_NOTIFY_DUMP_INFO_RESULT):
112 return HandleNotifyDumpInfoResult(data, reply);
113 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE):
114 return HandleSetSessionContinueState(data, reply);
115 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_SESSION):
116 return HandleClearSession(data, reply);
117 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_ALL_SESSIONS):
118 return HandleClearAllSessions(data, reply);
119 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_LOCK_SESSION):
120 return HandleLockSession(data, reply);
121 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNLOCK_SESSION):
122 return HandleUnlockSession(data, reply);
123 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND):
124 return HandleMoveSessionsToForeground(data, reply);
125 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND):
126 return HandleMoveSessionsToBackground(data, reply);
127 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_COLLABORATOR):
128 return HandleRegisterCollaborator(data, reply);
129 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_COLLABORATOR):
130 return HandleUnregisterCollaborator(data, reply);
131 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_TOUCHOUTSIDE_LISTENER):
132 return HandleUpdateSessionTouchOutsideListener(data, reply);
133 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RAISE_WINDOW_TO_TOP):
134 return HandleRaiseWindowToTop(data, reply);
135 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_TOP_WINDOW_ID):
136 return HandleGetTopWindowId(data, reply);
137 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PARENT_MAIN_WINDOW_ID):
138 return HandleGetParentMainWindowId(data, reply);
139 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_NOTIFY_WINDOW_EXTENSION_VISIBILITY_CHANGE):
140 return HandleNotifyWindowExtensionVisibilityChange(data, reply);
141 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_WINDOW_VISIBILITY_LISTENER):
142 return HandleUpdateSessionWindowVisibilityListener(data, reply);
143 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_FOCUS):
144 return HandleShiftAppWindowFocus(data, reply);
145 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_LAYOUT_INFO):
146 return HandleGetAllWindowLayoutInfo(data, reply);
147 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID):
148 return HandleGetVisibilityWindowInfo(data, reply);
149 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_MODALEXTENSION_RECT_TO_SCB):
150 return HandleUpdateModalExtensionRect(data, reply);
151 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PROCESS_MODALEXTENSION_POINTDOWN_TO_SCB):
152 return HandleProcessModalExtensionPointDown(data, reply);
153 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB):
154 return HandleAddExtensionWindowStageToSCB(data, reply);
155 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REMOVE_EXTENSION_WINDOW_STAGE_FROM_SCB):
156 return HandleRemoveExtensionWindowStageFromSCB(data, reply);
157 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION):
158 return HandleAddOrRemoveSecureSession(data, reply);
159 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS):
160 return HandleUpdateExtWindowFlags(data, reply);
161 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_HOST_WINDOW_RECT):
162 return HandleGetHostWindowRect(data, reply);
163 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STATUS):
164 return HandleGetCallingWindowWindowStatus(data, reply);
165 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_RECT):
166 return HandleGetCallingWindowRect(data, reply);
167 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_MODE_TYPE):
168 return HandleGetWindowModeType(data, reply);
169 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FREE_MULTI_WINDOW_ENABLE_STATE):
170 return HandleGetFreeMultiWindowEnableState(data, reply);
171 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STYLE_TYPE):
172 return HandleGetWindowStyleType(data, reply);
173 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PROCESS_SURFACENODEID_BY_PERSISTENTID):
174 return HandleGetProcessSurfaceNodeIdByPersistentId(data, reply);
175 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_IDS_BY_COORDINATE):
176 return HandleGetWindowIdsByCoordinate(data, reply);
177 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RELEASE_SESSION_SCREEN_LOCK):
178 return HandleReleaseForegroundSessionScreenLock(data, reply);
179 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_PC_WINDOW):
180 return HandleIsPcWindow(data, reply);
181 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_DISPLAYID_BY_WINDOWID):
182 return HandleGetDisplayIdByWindowId(data, reply);
183 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_PC_OR_PAD_FREE_MULTI_WINDOW_MODE):
184 return HandleIsPcOrPadFreeMultiWindowMode(data, reply);
185 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_WINDOW_RECT_AUTO_SAVE):
186 return HandleIsWindowRectAutoSave(data, reply);
187 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_GLOBAL_DRAG_RESIZE_TYPE):
188 return HandleSetGlobalDragResizeType(data, reply);
189 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_GLOBAL_DRAG_RESIZE_TYPE):
190 return HandleGetGlobalDragResizeType(data, reply);
191 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_APP_DRAG_RESIZE_TYPE):
192 return HandleSetAppDragResizeType(data, reply);
193 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_APP_DRAG_RESIZE_TYPE):
194 return HandleGetAppDragResizeType(data, reply);
195 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_POINTER_EVENT):
196 return HandleShiftAppWindowPointerEvent(data, reply);
197 default:
198 WLOGFE("Failed to find function handler!");
199 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
200 }
201 }
202
HandleCreateAndConnectSpecificSession(MessageParcel & data,MessageParcel & reply)203 int SceneSessionManagerStub::HandleCreateAndConnectSpecificSession(MessageParcel& data, MessageParcel& reply)
204 {
205 WLOGFI("run HandleCreateAndConnectSpecificSession!");
206 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
207 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
208 sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
209 sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
210 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
211 if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
212 WLOGFE("Failed to read scene session stage object or event channel object!");
213 return ERR_INVALID_DATA;
214 }
215
216 sptr<WindowSessionProperty> property = nullptr;
217 if (data.ReadBool()) {
218 property = data.ReadStrongParcelable<WindowSessionProperty>();
219 } else {
220 WLOGFW("Property not exist!");
221 }
222
223 sptr<IRemoteObject> token = nullptr;
224 if (property && property->GetTokenState()) {
225 token = data.ReadRemoteObject();
226 } else {
227 WLOGI("accept token is nullptr");
228 }
229
230 auto persistentId = INVALID_SESSION_ID;
231 sptr<ISession> sceneSession;
232 SystemSessionConfig systemConfig;
233 CreateAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode,
234 property, persistentId, sceneSession, systemConfig, token);
235 if (sceneSession== nullptr) {
236 return ERR_INVALID_STATE;
237 }
238 reply.WriteInt32(persistentId);
239 reply.WriteRemoteObject(sceneSession->AsObject());
240 reply.WriteParcelable(&systemConfig);
241 reply.WriteUint32(static_cast<uint32_t>(WSError::WS_OK));
242 return ERR_NONE;
243 }
244
HandleRecoverAndConnectSpecificSession(MessageParcel & data,MessageParcel & reply)245 int SceneSessionManagerStub::HandleRecoverAndConnectSpecificSession(MessageParcel& data, MessageParcel& reply)
246 {
247 TLOGI(WmsLogTag::WMS_RECOVER, "run!");
248 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
249 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
250 sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
251 sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
252 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
253 if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
254 TLOGE(WmsLogTag::WMS_RECOVER, "Failed to read scene session stage object or event channel object!");
255 return ERR_INVALID_DATA;
256 }
257
258 sptr<WindowSessionProperty> property = nullptr;
259 if (data.ReadBool()) {
260 property = data.ReadStrongParcelable<WindowSessionProperty>();
261 } else {
262 TLOGW(WmsLogTag::WMS_RECOVER, "Property not exist!");
263 }
264
265 sptr<IRemoteObject> token = nullptr;
266 if (property && property->GetTokenState()) {
267 token = data.ReadRemoteObject();
268 } else {
269 TLOGI(WmsLogTag::WMS_RECOVER, "accept token is nullptr");
270 }
271
272 sptr<ISession> sceneSession;
273 auto ret = RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, sceneSession, token);
274 if (sceneSession== nullptr) {
275 return ERR_INVALID_STATE;
276 }
277 reply.WriteRemoteObject(sceneSession->AsObject());
278 reply.WriteUint32(static_cast<uint32_t>(ret));
279 return ERR_NONE;
280 }
281
HandleRecoverAndReconnectSceneSession(MessageParcel & data,MessageParcel & reply)282 int SceneSessionManagerStub::HandleRecoverAndReconnectSceneSession(MessageParcel& data, MessageParcel& reply)
283 {
284 TLOGI(WmsLogTag::WMS_RECOVER, "run");
285 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
286 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
287 sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
288 sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
289 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
290 if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
291 TLOGE(WmsLogTag::WMS_RECOVER, "Failed to read scene session stage object or event channel object!");
292 return ERR_INVALID_DATA;
293 }
294
295 sptr<WindowSessionProperty> property = nullptr;
296 if (data.ReadBool()) {
297 property = data.ReadStrongParcelable<WindowSessionProperty>();
298 } else {
299 TLOGW(WmsLogTag::WMS_RECOVER, "Property not exist!");
300 }
301
302 sptr<IRemoteObject> token = nullptr;
303 if (property && property->GetTokenState()) {
304 token = data.ReadRemoteObject();
305 } else {
306 TLOGI(WmsLogTag::WMS_RECOVER, "accept token is nullptr");
307 }
308
309 sptr<ISession> sceneSession;
310 RecoverAndReconnectSceneSession(sessionStage, eventChannel, surfaceNode, sceneSession, property, token);
311 if (sceneSession == nullptr) {
312 return ERR_INVALID_STATE;
313 }
314 reply.WriteRemoteObject(sceneSession->AsObject());
315 reply.WriteUint32(static_cast<uint32_t>(WSError::WS_OK));
316 return ERR_NONE;
317 }
318
HandleDestroyAndDisconnectSpcificSession(MessageParcel & data,MessageParcel & reply)319 int SceneSessionManagerStub::HandleDestroyAndDisconnectSpcificSession(MessageParcel& data, MessageParcel& reply)
320 {
321 auto persistentId = data.ReadInt32();
322 TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d", persistentId);
323 WSError ret = DestroyAndDisconnectSpecificSession(persistentId);
324 reply.WriteUint32(static_cast<uint32_t>(ret));
325 return ERR_NONE;
326 }
327
HandleDestroyAndDisconnectSpcificSessionWithDetachCallback(MessageParcel & data,MessageParcel & reply)328 int SceneSessionManagerStub::HandleDestroyAndDisconnectSpcificSessionWithDetachCallback(MessageParcel& data,
329 MessageParcel& reply)
330 {
331 auto persistentId = data.ReadInt32();
332 TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d", persistentId);
333 sptr<IRemoteObject> callback = data.ReadRemoteObject();
334 const WSError ret = DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
335 reply.WriteUint32(static_cast<uint32_t>(ret));
336 return ERR_NONE;
337 }
338
HandleRequestFocusStatus(MessageParcel & data,MessageParcel & reply)339 int SceneSessionManagerStub::HandleRequestFocusStatus(MessageParcel& data, MessageParcel& reply)
340 {
341 WLOGFI("run");
342 int32_t persistentId = data.ReadInt32();
343 bool isFocused = data.ReadBool();
344 WMError ret = RequestFocusStatus(persistentId, isFocused, true, FocusChangeReason::CLIENT_REQUEST);
345 reply.WriteInt32(static_cast<int32_t>(ret));
346 return ERR_NONE;
347 }
348
HandleRegisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)349 int SceneSessionManagerStub::HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
350 {
351 auto type = static_cast<WindowManagerAgentType>(data.ReadUint32());
352 WLOGFI("run HandleRegisterWindowManagerAgent!, type=%{public}u", static_cast<uint32_t>(type));
353 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
354 sptr<IWindowManagerAgent> windowManagerAgentProxy =
355 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
356 WMError errCode = RegisterWindowManagerAgent(type, windowManagerAgentProxy);
357 reply.WriteInt32(static_cast<int32_t>(errCode));
358 return ERR_NONE;
359 }
360
HandleUnregisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)361 int SceneSessionManagerStub::HandleUnregisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
362 {
363 auto type = static_cast<WindowManagerAgentType>(data.ReadUint32());
364 WLOGFI("run HandleUnregisterWindowManagerAgent!, type=%{public}u", static_cast<uint32_t>(type));
365 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
366 sptr<IWindowManagerAgent> windowManagerAgentProxy =
367 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
368 WMError errCode = UnregisterWindowManagerAgent(type, windowManagerAgentProxy);
369 reply.WriteInt32(static_cast<int32_t>(errCode));
370 return ERR_NONE;
371 }
372
HandleGetFocusSessionInfo(MessageParcel & data,MessageParcel & reply)373 int SceneSessionManagerStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply)
374 {
375 WLOGFI("run HandleGetFocusSessionInfo!");
376 FocusChangeInfo focusInfo;
377 GetFocusWindowInfo(focusInfo);
378 reply.WriteParcelable(&focusInfo);
379 return ERR_NONE;
380 }
381
HandleSetSessionLabel(MessageParcel & data,MessageParcel & reply)382 int SceneSessionManagerStub::HandleSetSessionLabel(MessageParcel& data, MessageParcel& reply)
383 {
384 WLOGFI("run HandleSetSessionLabel!");
385 sptr<IRemoteObject> token = data.ReadRemoteObject();
386 std::string label = data.ReadString();
387 WSError errCode = SetSessionLabel(token, label);
388 reply.WriteInt32(static_cast<int32_t>(errCode));
389 return ERR_NONE;
390 }
391
HandleSetSessionIcon(MessageParcel & data,MessageParcel & reply)392 int SceneSessionManagerStub::HandleSetSessionIcon(MessageParcel& data, MessageParcel& reply)
393 {
394 WLOGFI("run HandleSetSessionIcon!");
395 sptr<IRemoteObject> token = data.ReadRemoteObject();
396 std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
397 if (icon == nullptr) {
398 WLOGFE("icon is null");
399 return ERR_INVALID_DATA;
400 }
401 WSError errCode = SetSessionIcon(token, icon);
402 reply.WriteInt32(static_cast<int32_t>(errCode));
403 return ERR_NONE;
404 }
405
HandleIsValidSessionIds(MessageParcel & data,MessageParcel & reply)406 int SceneSessionManagerStub::HandleIsValidSessionIds(MessageParcel& data, MessageParcel& reply)
407 {
408 WLOGFI("run HandleIsValidSessionIds!");
409 std::vector<int32_t> sessionIds;
410 data.ReadInt32Vector(&sessionIds);
411 std::vector<bool> results;
412 reply.WriteBoolVector(results);
413 return ERR_NONE;
414 }
415
HandlePendingSessionToForeground(MessageParcel & data,MessageParcel & reply)416 int SceneSessionManagerStub::HandlePendingSessionToForeground(MessageParcel& data, MessageParcel& reply)
417 {
418 WLOGFI("run HandlePendingSessionToForeground!");
419 sptr<IRemoteObject> token = data.ReadRemoteObject();
420 if (token == nullptr) {
421 WLOGFE("token is nullptr");
422 return ERR_INVALID_DATA;
423 }
424 WSError errCode = PendingSessionToForeground(token);
425 reply.WriteUint32(static_cast<uint32_t>(errCode));
426 return ERR_NONE;
427 }
428
HandlePendingSessionToBackgroundForDelegator(MessageParcel & data,MessageParcel & reply)429 int SceneSessionManagerStub::HandlePendingSessionToBackgroundForDelegator(MessageParcel& data, MessageParcel& reply)
430 {
431 TLOGD(WmsLogTag::WMS_LIFE, "run");
432 sptr<IRemoteObject> token = data.ReadRemoteObject();
433 if (token == nullptr) {
434 TLOGE(WmsLogTag::WMS_LIFE, "token is nullptr");
435 return ERR_INVALID_DATA;
436 }
437 bool shouldBackToCaller = true;
438 if (!data.ReadBool(shouldBackToCaller)) {
439 TLOGE(WmsLogTag::WMS_LIFE, "Read shouldBackToCaller failed");
440 return ERR_INVALID_DATA;
441 }
442 WSError errCode = PendingSessionToBackgroundForDelegator(token, shouldBackToCaller);
443 reply.WriteInt32(static_cast<int32_t>(errCode));
444 return ERR_NONE;
445 }
446
HandleRegisterSessionListener(MessageParcel & data,MessageParcel & reply)447 int SceneSessionManagerStub::HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
448 {
449 WLOGFI("run HandleRegisterSessionListener!");
450 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
451 if (listener == nullptr) {
452 reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
453 WLOGFI("listener is nullptr");
454 return ERR_NONE;
455 }
456 WSError errCode = RegisterSessionListener(listener);
457 reply.WriteInt32(static_cast<int32_t>(errCode));
458 return ERR_NONE;
459 }
460
HandleUnRegisterSessionListener(MessageParcel & data,MessageParcel & reply)461 int SceneSessionManagerStub::HandleUnRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
462 {
463 WLOGFI("run HandleUnRegisterSessionListener!");
464 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
465 if (listener == nullptr) {
466 reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
467 WLOGFI("listener is nullptr");
468 return ERR_NONE;
469 }
470 WSError errCode = UnRegisterSessionListener(listener);
471 reply.WriteInt32(static_cast<int32_t>(errCode));
472 return ERR_NONE;
473 }
474
HandleGetSessionInfos(MessageParcel & data,MessageParcel & reply)475 int SceneSessionManagerStub::HandleGetSessionInfos(MessageParcel& data, MessageParcel& reply)
476 {
477 WLOGFI("run HandleGetSessionInfos!");
478 std::string deviceId = Str16ToStr8(data.ReadString16());
479 int numMax = data.ReadInt32();
480 std::vector<SessionInfoBean> missionInfos;
481 WSError errCode = GetSessionInfos(deviceId, numMax, missionInfos);
482 reply.WriteInt32(missionInfos.size());
483 for (auto& it : missionInfos) {
484 if (!reply.WriteParcelable(&it)) {
485 WLOGFE("GetSessionInfos error");
486 return ERR_INVALID_DATA;
487 }
488 }
489 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
490 return ERR_INVALID_DATA;
491 }
492 return ERR_NONE;
493 }
494
HandleGetSessionInfo(MessageParcel & data,MessageParcel & reply)495 int SceneSessionManagerStub::HandleGetSessionInfo(MessageParcel& data, MessageParcel& reply)
496 {
497 WLOGFI("run HandleGetSessionInfo!");
498 SessionInfoBean info;
499 std::string deviceId = Str16ToStr8(data.ReadString16());
500 int32_t persistentId = data.ReadInt32();
501 WSError errCode = GetSessionInfo(deviceId, persistentId, info);
502 if (!reply.WriteParcelable(&info)) {
503 WLOGFE("GetSessionInfo error");
504 return ERR_INVALID_DATA;
505 }
506
507 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
508 WLOGFE("GetSessionInfo result error");
509 return ERR_INVALID_DATA;
510 }
511 return ERR_NONE;
512 }
513
514
HandleGetSessionInfoByContinueSessionId(MessageParcel & data,MessageParcel & reply)515 int SceneSessionManagerStub::HandleGetSessionInfoByContinueSessionId(MessageParcel& data, MessageParcel& reply)
516 {
517 SessionInfoBean info;
518 std::string continueSessionId = data.ReadString();
519 TLOGI(WmsLogTag::WMS_LIFE, "continueSessionId: %{public}s", continueSessionId.c_str());
520 WSError errCode = GetSessionInfoByContinueSessionId(continueSessionId, info);
521 if (!reply.WriteParcelable(&info)) {
522 TLOGE(WmsLogTag::WMS_LIFE, "GetSessionInfo error");
523 return ERR_INVALID_DATA;
524 }
525
526 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
527 TLOGE(WmsLogTag::WMS_LIFE, "GetSessionInfo result error");
528 return ERR_INVALID_DATA;
529 }
530 return ERR_NONE;
531 }
532
HandleDumpSessionAll(MessageParcel & data,MessageParcel & reply)533 int SceneSessionManagerStub::HandleDumpSessionAll(MessageParcel& data, MessageParcel& reply)
534 {
535 WLOGFI("run HandleDumpSessionAll!");
536 std::vector<std::string> infos;
537 WSError errCode = DumpSessionAll(infos);
538 if (!reply.WriteStringVector(infos)) {
539 WLOGFE("HandleDumpSessionAll write info failed.");
540 return ERR_TRANSACTION_FAILED;
541 }
542
543 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
544 WLOGFE("HandleDumpSessionAll write errcode failed.");
545 return ERR_TRANSACTION_FAILED;
546 }
547 return ERR_NONE;
548 }
549
HandleDumpSessionWithId(MessageParcel & data,MessageParcel & reply)550 int SceneSessionManagerStub::HandleDumpSessionWithId(MessageParcel& data, MessageParcel& reply)
551 {
552 WLOGFI("run HandleDumpSessionWithId!");
553 int32_t persistentId = data.ReadInt32();
554 std::vector<std::string> infos;
555 WSError errCode = DumpSessionWithId(persistentId, infos);
556 if (!reply.WriteStringVector(infos)) {
557 WLOGFE("HandleDumpSessionWithId write info failed.");
558 return ERR_TRANSACTION_FAILED;
559 }
560
561 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
562 WLOGFE("HandleDumpSessionWithId write errcode failed.");
563 return ERR_TRANSACTION_FAILED;
564 }
565 return ERR_NONE;
566 }
567
HandleTerminateSessionNew(MessageParcel & data,MessageParcel & reply)568 int SceneSessionManagerStub::HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply)
569 {
570 WLOGFD("run HandleTerminateSessionNew");
571 sptr<AAFwk::SessionInfo> abilitySessionInfo = data.ReadParcelable<AAFwk::SessionInfo>();
572 if (abilitySessionInfo == nullptr) {
573 WLOGFE("abilitySessionInfo is null");
574 return ERR_INVALID_DATA;
575 }
576 bool needStartCaller = data.ReadBool();
577 bool isFromBroker = data.ReadBool();
578 WSError errCode = TerminateSessionNew(abilitySessionInfo, needStartCaller, isFromBroker);
579 reply.WriteUint32(static_cast<uint32_t>(errCode));
580 return ERR_NONE;
581 }
582
HandleGetFocusSessionToken(MessageParcel & data,MessageParcel & reply)583 int SceneSessionManagerStub::HandleGetFocusSessionToken(MessageParcel& data, MessageParcel& reply)
584 {
585 WLOGFD("run HandleGetFocusSessionToken!");
586 sptr<IRemoteObject> token = nullptr;
587 WSError errCode = GetFocusSessionToken(token);
588 reply.WriteRemoteObject(token);
589 reply.WriteInt32(static_cast<int32_t>(errCode));
590 return ERR_NONE;
591 }
592
HandleGetFocusSessionElement(MessageParcel & data,MessageParcel & reply)593 int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel& data, MessageParcel& reply)
594 {
595 WLOGFD("run HandleGetFocusSessionElement!");
596 AppExecFwk::ElementName element;
597 WSError errCode = GetFocusSessionElement(element);
598 reply.WriteParcelable(&element);
599 reply.WriteInt32(static_cast<int32_t>(errCode));
600 return ERR_NONE;
601 }
602
HandleCheckWindowId(MessageParcel & data,MessageParcel & reply)603 int SceneSessionManagerStub::HandleCheckWindowId(MessageParcel& data, MessageParcel& reply)
604 {
605 WLOGFI("run HandleCheckWindowId!");
606 int32_t windowId = INVALID_WINDOW_ID;
607 if (!data.ReadInt32(windowId)) {
608 WLOGE("Failed to readInt32 windowId");
609 return ERR_INVALID_DATA;
610 }
611 int32_t pid = INVALID_PID;
612 WMError errCode = CheckWindowId(windowId, pid);
613 if (errCode != WMError::WM_OK) {
614 WLOGE("Failed to checkWindowId(%{public}d)", pid);
615 return ERR_INVALID_DATA;
616 }
617 if (!reply.WriteInt32(pid)) {
618 WLOGE("Failed to WriteInt32 pid");
619 return ERR_INVALID_DATA;
620 }
621 return ERR_NONE;
622 }
623
HandleSetGestureNavigationEnabled(MessageParcel & data,MessageParcel & reply)624 int SceneSessionManagerStub::HandleSetGestureNavigationEnabled(MessageParcel& data, MessageParcel& reply)
625 {
626 WLOGFI("run HandleSetGestureNavigationEnabled!");
627 bool enable = data.ReadBool();
628 const WMError &ret = SetGestureNavigaionEnabled(enable);
629 reply.WriteInt32(static_cast<int32_t>(ret));
630 return ERR_NONE;
631 }
632
HandleGetAccessibilityWindowInfo(MessageParcel & data,MessageParcel & reply)633 int SceneSessionManagerStub::HandleGetAccessibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
634 {
635 std::vector<sptr<AccessibilityWindowInfo>> infos;
636 WMError errCode = GetAccessibilityWindowInfo(infos);
637 if (!MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(reply, infos)) {
638 WLOGFE("Write window infos failed.");
639 return ERR_TRANSACTION_FAILED;
640 }
641 reply.WriteInt32(static_cast<int32_t>(errCode));
642 return ERR_NONE;
643 }
644
HandleGetUnreliableWindowInfo(MessageParcel & data,MessageParcel & reply)645 int SceneSessionManagerStub::HandleGetUnreliableWindowInfo(MessageParcel& data, MessageParcel& reply)
646 {
647 TLOGD(WmsLogTag::DEFAULT, "run!");
648 std::vector<sptr<UnreliableWindowInfo>> infos;
649 int32_t windowId = INVALID_WINDOW_ID;
650 if (!data.ReadInt32(windowId)) {
651 TLOGE(WmsLogTag::DEFAULT, "Failed to readInt32 windowId");
652 return ERR_INVALID_DATA;
653 }
654 WMError errCode = GetUnreliableWindowInfo(windowId, infos);
655 if (!MarshallingHelper::MarshallingVectorParcelableObj<UnreliableWindowInfo>(reply, infos)) {
656 TLOGE(WmsLogTag::DEFAULT, "Write unreliable window infos failed.");
657 return ERR_TRANSACTION_FAILED;
658 }
659 reply.WriteInt32(static_cast<int32_t>(errCode));
660 return ERR_NONE;
661 }
662
HandleSetSessionContinueState(MessageParcel & data,MessageParcel & reply)663 int SceneSessionManagerStub::HandleSetSessionContinueState(MessageParcel& data, MessageParcel& reply)
664 {
665 WLOGFI("HandleSetSessionContinueState");
666 sptr <IRemoteObject> token = data.ReadRemoteObject();
667 auto continueState = static_cast<ContinueState>(data.ReadInt32());
668 const WSError &ret = SetSessionContinueState(token, continueState);
669 reply.WriteUint32(static_cast<uint32_t>(ret));
670 return ERR_NONE;
671 }
672
HandleGetSessionDump(MessageParcel & data,MessageParcel & reply)673 int SceneSessionManagerStub::HandleGetSessionDump(MessageParcel& data, MessageParcel& reply)
674 {
675 std::vector<std::string> params;
676 if (!data.ReadStringVector(¶ms)) {
677 WLOGFE("Fail to read params");
678 return ERR_INVALID_DATA;
679 }
680 std::string dumpInfo;
681 WSError errCode = GetSessionDumpInfo(params, dumpInfo);
682 const char* info = dumpInfo.c_str();
683 uint32_t infoSize = static_cast<uint32_t>(strlen(info));
684 WLOGFI("HandleGetSessionDump, infoSize: %{public}d", infoSize);
685 reply.WriteUint32(infoSize);
686 if (infoSize != 0) {
687 if (!reply.WriteRawData(info, infoSize)) {
688 WLOGFE("Fail to write dumpInfo");
689 return ERR_INVALID_DATA;
690 }
691 }
692 reply.WriteInt32(static_cast<int32_t>(errCode));
693 return ERR_NONE;
694 }
695
HandleUpdateSessionAvoidAreaListener(MessageParcel & data,MessageParcel & reply)696 int SceneSessionManagerStub::HandleUpdateSessionAvoidAreaListener(MessageParcel& data, MessageParcel& reply)
697 {
698 auto persistentId = data.ReadInt32();
699 bool haveAvoidAreaListener = data.ReadBool();
700 WSError errCode = UpdateSessionAvoidAreaListener(persistentId, haveAvoidAreaListener);
701 reply.WriteUint32(static_cast<uint32_t>(errCode));
702 return ERR_NONE;
703 }
704
HandleGetSessionSnapshot(MessageParcel & data,MessageParcel & reply)705 int SceneSessionManagerStub::HandleGetSessionSnapshot(MessageParcel& data, MessageParcel& reply)
706 {
707 WLOGFI("run HandleGetSessionSnapshot!");
708 std::string deviceId = Str16ToStr8(data.ReadString16());
709 int32_t persistentId = data.ReadInt32();
710 bool isLowResolution = data.ReadBool();
711 std::shared_ptr<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
712 WSError ret = GetSessionSnapshot(deviceId, persistentId, *snapshot, isLowResolution);
713 reply.WriteParcelable(snapshot.get());
714 reply.WriteUint32(static_cast<uint32_t>(ret));
715 return ERR_NONE;
716 }
717
HandleGetSessionSnapshotById(MessageParcel & data,MessageParcel & reply)718 int SceneSessionManagerStub::HandleGetSessionSnapshotById(MessageParcel& data, MessageParcel& reply)
719 {
720 TLOGI(WmsLogTag::WMS_SYSTEM, "Handled!");
721 int32_t persistentId = data.ReadInt32();
722 std::shared_ptr<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
723 const WMError ret = GetSessionSnapshotById(persistentId, *snapshot);
724 reply.WriteParcelable(snapshot.get());
725 reply.WriteInt32(static_cast<int32_t>(ret));
726 return ERR_NONE;
727 }
728
HandleGetUIContentRemoteObj(MessageParcel & data,MessageParcel & reply)729 int SceneSessionManagerStub::HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply)
730 {
731 TLOGD(WmsLogTag::DEFAULT, "Called");
732 int32_t persistentId = data.ReadInt32();
733 sptr<IRemoteObject> uiContentRemoteObj;
734 WSError ret = GetUIContentRemoteObj(persistentId, uiContentRemoteObj);
735 reply.WriteRemoteObject(uiContentRemoteObj);
736 reply.WriteUint32(static_cast<uint32_t>(ret));
737 return ERR_NONE;
738 }
739
HandleBindDialogTarget(MessageParcel & data,MessageParcel & reply)740 int SceneSessionManagerStub::HandleBindDialogTarget(MessageParcel& data, MessageParcel& reply)
741 {
742 WLOGFI("run HandleBindDialogTarget!");
743 uint64_t persistentId = data.ReadUint64();
744 sptr<IRemoteObject> remoteObject = data.ReadRemoteObject();
745 WSError ret = BindDialogSessionTarget(persistentId, remoteObject);
746 reply.WriteUint32(static_cast<uint32_t>(ret));
747 return ERR_NONE;
748 }
749
HandleNotifyDumpInfoResult(MessageParcel & data,MessageParcel & reply)750 int SceneSessionManagerStub::HandleNotifyDumpInfoResult(MessageParcel& data, MessageParcel& reply)
751 {
752 WLOGFI("HandleNotifyDumpInfoResult");
753 std::vector<std::string> info;
754 uint32_t vectorSize = data.ReadUint32();
755 if (vectorSize > MAX_VECTOR_SIZE) {
756 WLOGFI("Vector is too big!");
757 return ERR_INVALID_DATA;
758 }
759 for (uint32_t i = 0; i < vectorSize; i++) {
760 uint32_t curSize = data.ReadUint32();
761 std::string curInfo = "";
762 if (curSize != 0) {
763 const char* infoPtr = nullptr;
764 infoPtr = reinterpret_cast<const char*>(data.ReadRawData(curSize));
765 curInfo = (infoPtr) ? std::string(infoPtr, curSize) : "";
766 }
767 info.emplace_back(curInfo);
768 WLOGFD("HandleNotifyDumpInfoResult count: %{public}u, infoSize: %{public}u", i, curSize);
769 }
770 NotifyDumpInfoResult(info);
771 return ERR_NONE;
772 }
773
HandleClearSession(MessageParcel & data,MessageParcel & reply)774 int SceneSessionManagerStub::HandleClearSession(MessageParcel& data, MessageParcel& reply)
775 {
776 WLOGFI("run HandleClearSession!");
777 int32_t persistentId = data.ReadInt32();
778 WSError ret = ClearSession(persistentId);
779 reply.WriteUint32(static_cast<uint32_t>(ret));
780 return ERR_NONE;
781 }
782
HandleClearAllSessions(MessageParcel & data,MessageParcel & reply)783 int SceneSessionManagerStub::HandleClearAllSessions(MessageParcel& data, MessageParcel& reply)
784 {
785 WLOGFI("run HandleClearAllSessions!");
786 WSError ret = ClearAllSessions();
787 reply.WriteUint32(static_cast<uint32_t>(ret));
788 return ERR_NONE;
789 }
790
HandleLockSession(MessageParcel & data,MessageParcel & reply)791 int SceneSessionManagerStub::HandleLockSession(MessageParcel& data, MessageParcel& reply)
792 {
793 WLOGFI("run HandleLockSession!");
794 int32_t sessionId = data.ReadInt32();
795 WSError ret = LockSession(sessionId);
796 reply.WriteUint32(static_cast<uint32_t>(ret));
797 return ERR_NONE;
798 }
HandleUnlockSession(MessageParcel & data,MessageParcel & reply)799 int SceneSessionManagerStub::HandleUnlockSession(MessageParcel& data, MessageParcel& reply)
800 {
801 WLOGFI("run HandleUnlockSession!");
802 int32_t sessionId = data.ReadInt32();
803 WSError ret = UnlockSession(sessionId);
804 reply.WriteUint32(static_cast<uint32_t>(ret));
805 return ERR_NONE;
806 }
HandleMoveSessionsToForeground(MessageParcel & data,MessageParcel & reply)807 int SceneSessionManagerStub::HandleMoveSessionsToForeground(MessageParcel& data, MessageParcel& reply)
808 {
809 WLOGFI("run HandleMoveSessionsToForeground!");
810 std::vector<int32_t> sessionIds;
811 data.ReadInt32Vector(&sessionIds);
812 int32_t topSessionId = data.ReadInt32();
813 const WSError &ret = MoveSessionsToForeground(sessionIds, topSessionId);
814 reply.WriteUint32(static_cast<uint32_t>(ret));
815 return ERR_NONE;
816 }
HandleMoveSessionsToBackground(MessageParcel & data,MessageParcel & reply)817 int SceneSessionManagerStub::HandleMoveSessionsToBackground(MessageParcel& data, MessageParcel& reply)
818 {
819 WLOGFI("run HandleMoveSessionsToBackground!");
820 std::vector<int32_t> sessionIds;
821 data.ReadInt32Vector(&sessionIds);
822 std::vector<int32_t> result;
823 data.ReadInt32Vector(&result);
824 const WSError &ret = MoveSessionsToBackground(sessionIds, result);
825 reply.WriteInt32Vector(result);
826 reply.WriteUint32(static_cast<uint32_t>(ret));
827 return ERR_NONE;
828 }
829
HandleRegisterCollaborator(MessageParcel & data,MessageParcel & reply)830 int SceneSessionManagerStub::HandleRegisterCollaborator(MessageParcel& data, MessageParcel& reply)
831 {
832 WLOGFI("run HandleRegisterCollaborator!");
833 int32_t type = data.ReadInt32();
834 sptr<AAFwk::IAbilityManagerCollaborator> collaborator =
835 iface_cast<AAFwk::IAbilityManagerCollaborator>(data.ReadRemoteObject());
836 if (collaborator == nullptr) {
837 WLOGFE("collaborator is nullptr");
838 return ERR_INVALID_DATA;
839 }
840 WSError ret = RegisterIAbilityManagerCollaborator(type, collaborator);
841 reply.WriteUint32(static_cast<uint32_t>(ret));
842 return ERR_NONE;
843 }
844
HandleUnregisterCollaborator(MessageParcel & data,MessageParcel & reply)845 int SceneSessionManagerStub::HandleUnregisterCollaborator(MessageParcel& data, MessageParcel& reply)
846 {
847 WLOGFI("run HandleUnregisterCollaborator!");
848 int32_t type = data.ReadInt32();
849 WSError ret = UnregisterIAbilityManagerCollaborator(type);
850 reply.WriteUint32(static_cast<uint32_t>(ret));
851 return ERR_NONE;
852 }
853
HandleUpdateSessionTouchOutsideListener(MessageParcel & data,MessageParcel & reply)854 int SceneSessionManagerStub::HandleUpdateSessionTouchOutsideListener(MessageParcel& data, MessageParcel& reply)
855 {
856 auto persistentId = data.ReadInt32();
857 bool haveAvoidAreaListener = data.ReadBool();
858 WSError errCode = UpdateSessionTouchOutsideListener(persistentId, haveAvoidAreaListener);
859 reply.WriteUint32(static_cast<uint32_t>(errCode));
860 return ERR_NONE;
861 }
862
HandleRaiseWindowToTop(MessageParcel & data,MessageParcel & reply)863 int SceneSessionManagerStub::HandleRaiseWindowToTop(MessageParcel& data, MessageParcel& reply)
864 {
865 auto persistentId = data.ReadInt32();
866 WSError errCode = RaiseWindowToTop(persistentId);
867 reply.WriteUint32(static_cast<uint32_t>(errCode));
868 return ERR_NONE;
869 }
870
HandleNotifyWindowExtensionVisibilityChange(MessageParcel & data,MessageParcel & reply)871 int SceneSessionManagerStub::HandleNotifyWindowExtensionVisibilityChange(MessageParcel& data, MessageParcel& reply)
872 {
873 auto pid = data.ReadInt32();
874 auto uid = data.ReadInt32();
875 bool visible = data.ReadBool();
876 WSError ret = NotifyWindowExtensionVisibilityChange(pid, uid, visible);
877 reply.WriteUint32(static_cast<uint32_t>(ret));
878 return ERR_NONE;
879 }
880
HandleGetTopWindowId(MessageParcel & data,MessageParcel & reply)881 int SceneSessionManagerStub::HandleGetTopWindowId(MessageParcel& data, MessageParcel& reply)
882 {
883 uint32_t mainWinId = data.ReadUint32();
884 uint32_t topWinId;
885 WMError ret = GetTopWindowId(mainWinId, topWinId);
886 reply.WriteUint32(topWinId);
887 reply.WriteUint32(static_cast<uint32_t>(ret));
888 return ERR_NONE;
889 }
890
HandleGetParentMainWindowId(MessageParcel & data,MessageParcel & reply)891 int SceneSessionManagerStub::HandleGetParentMainWindowId(MessageParcel& data, MessageParcel& reply)
892 {
893 int32_t windowId = INVALID_SESSION_ID;
894 if (!data.ReadInt32(windowId)) {
895 TLOGE(WmsLogTag::WMS_FOCUS, "read windowId failed");
896 return ERR_INVALID_DATA;
897 }
898 int32_t mainWindowId = INVALID_SESSION_ID;
899 WMError errCode = GetParentMainWindowId(windowId, mainWindowId);
900 if (!reply.WriteInt32(mainWindowId)) {
901 return ERR_INVALID_DATA;
902 }
903 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
904 return ERR_INVALID_DATA;
905 }
906 return ERR_NONE;
907 }
908
HandleUpdateSessionWindowVisibilityListener(MessageParcel & data,MessageParcel & reply)909 int SceneSessionManagerStub::HandleUpdateSessionWindowVisibilityListener(MessageParcel& data, MessageParcel& reply)
910 {
911 int32_t persistentId = data.ReadInt32();
912 bool haveListener = data.ReadBool();
913 WSError ret = UpdateSessionWindowVisibilityListener(persistentId, haveListener);
914 reply.WriteUint32(static_cast<uint32_t>(ret));
915 return ERR_NONE;
916 }
917
HandleShiftAppWindowFocus(MessageParcel & data,MessageParcel & reply)918 int SceneSessionManagerStub::HandleShiftAppWindowFocus(MessageParcel& data, MessageParcel& reply)
919 {
920 int32_t sourcePersistentId = data.ReadInt32();
921 int32_t targetPersistentId = data.ReadInt32();
922 WSError ret = ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
923 reply.WriteUint32(static_cast<uint32_t>(ret));
924 return ERR_NONE;
925 }
926
HandleGetAllWindowLayoutInfo(MessageParcel & data,MessageParcel & reply)927 int SceneSessionManagerStub::HandleGetAllWindowLayoutInfo(MessageParcel& data, MessageParcel& reply)
928 {
929 uint64_t displayId = 0;
930 if (!data.ReadUint64(displayId)) {
931 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read displayId");
932 return ERR_INVALID_DATA;
933 }
934 std::vector<sptr<WindowLayoutInfo>> infos;
935 WMError errCode = GetAllWindowLayoutInfo(displayId, infos);
936 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowLayoutInfo>(reply, infos)) {
937 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to write window layout info");
938 return ERR_INVALID_DATA;
939 }
940 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
941 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail");
942 return ERR_INVALID_DATA;
943 }
944 return ERR_NONE;
945 }
946
HandleGetVisibilityWindowInfo(MessageParcel & data,MessageParcel & reply)947 int SceneSessionManagerStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
948 {
949 std::vector<sptr<WindowVisibilityInfo>> infos;
950 WMError errCode = GetVisibilityWindowInfo(infos);
951 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowVisibilityInfo>(reply, infos)) {
952 WLOGFE("Write visibility window infos failed");
953 return ERR_INVALID_DATA;
954 }
955 reply.WriteInt32(static_cast<int32_t>(errCode));
956 return ERR_NONE;
957 }
958
HandleAddExtensionWindowStageToSCB(MessageParcel & data,MessageParcel & reply)959 int SceneSessionManagerStub::HandleAddExtensionWindowStageToSCB(MessageParcel& data, MessageParcel& reply)
960 {
961 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
962 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
963 if (sessionStage == nullptr) {
964 WLOGFE("sessionStage is nullptr");
965 return ERR_INVALID_DATA;
966 }
967 sptr<IRemoteObject> token = data.ReadRemoteObject();
968 uint64_t surfaceNodeId;
969 if (!data.ReadUint64(surfaceNodeId)) {
970 TLOGE(WmsLogTag::WMS_UIEXT, "read surfaceNodeId failed");
971 return ERR_INVALID_DATA;
972 }
973 bool isConstrainedModal = false;
974 if (!data.ReadBool(isConstrainedModal)) {
975 TLOGE(WmsLogTag::WMS_UIEXT, "read isConstrainedModal failed");
976 return ERR_INVALID_DATA;
977 }
978 AddExtensionWindowStageToSCB(sessionStage, token, surfaceNodeId, isConstrainedModal);
979 return ERR_NONE;
980 }
981
HandleRemoveExtensionWindowStageFromSCB(MessageParcel & data,MessageParcel & reply)982 int SceneSessionManagerStub::HandleRemoveExtensionWindowStageFromSCB(MessageParcel& data, MessageParcel& reply)
983 {
984 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
985 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
986 if (sessionStage == nullptr) {
987 WLOGFE("sessionStage is nullptr");
988 return ERR_INVALID_DATA;
989 }
990 sptr<IRemoteObject> token = data.ReadRemoteObject();
991 bool isConstrainedModal = false;
992 if (!data.ReadBool(isConstrainedModal)) {
993 TLOGE(WmsLogTag::WMS_UIEXT, "read isConstrainedModal failed");
994 return ERR_INVALID_DATA;
995 }
996 RemoveExtensionWindowStageFromSCB(sessionStage, token, isConstrainedModal);
997 return ERR_NONE;
998 }
999
HandleUpdateModalExtensionRect(MessageParcel & data,MessageParcel & reply)1000 int SceneSessionManagerStub::HandleUpdateModalExtensionRect(MessageParcel& data, MessageParcel& reply)
1001 {
1002 sptr<IRemoteObject> token = data.ReadRemoteObject();
1003 if (token == nullptr) {
1004 WLOGFE("token is nullptr");
1005 return ERR_INVALID_DATA;
1006 }
1007 int32_t rectX = data.ReadInt32();
1008 int32_t rectY = data.ReadInt32();
1009 int32_t rectWidth = data.ReadInt32();
1010 int32_t rectHeight = data.ReadInt32();
1011 Rect windowRect{rectX, rectY, rectWidth, rectHeight};
1012 UpdateModalExtensionRect(token, windowRect);
1013 return ERR_NONE;
1014 }
1015
HandleProcessModalExtensionPointDown(MessageParcel & data,MessageParcel & reply)1016 int SceneSessionManagerStub::HandleProcessModalExtensionPointDown(MessageParcel& data, MessageParcel& reply)
1017 {
1018 sptr<IRemoteObject> token = data.ReadRemoteObject();
1019 if (token == nullptr) {
1020 WLOGFE("token is nullptr");
1021 return ERR_INVALID_DATA;
1022 }
1023 int32_t posX = data.ReadInt32();
1024 int32_t posY = data.ReadInt32();
1025 ProcessModalExtensionPointDown(token, posX, posY);
1026 return ERR_NONE;
1027 }
1028
HandleAddOrRemoveSecureSession(MessageParcel & data,MessageParcel & reply)1029 int SceneSessionManagerStub::HandleAddOrRemoveSecureSession(MessageParcel& data, MessageParcel& reply)
1030 {
1031 int32_t persistentId = data.ReadInt32();
1032 bool shouldHide = data.ReadBool();
1033 WSError ret = AddOrRemoveSecureSession(persistentId, shouldHide);
1034 reply.WriteInt32(static_cast<int32_t>(ret));
1035 return ERR_NONE;
1036 }
1037
HandleUpdateExtWindowFlags(MessageParcel & data,MessageParcel & reply)1038 int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel& data, MessageParcel& reply)
1039 {
1040 sptr<IRemoteObject> token = data.ReadRemoteObject();
1041 if (token == nullptr) {
1042 WLOGFE("token is nullptr");
1043 return ERR_INVALID_DATA;
1044 }
1045 uint32_t extWindowFlags = data.ReadUint32();
1046 uint32_t extWindowActions = data.ReadUint32();
1047 WSError ret = UpdateExtWindowFlags(token, extWindowFlags, extWindowActions);
1048 reply.WriteInt32(static_cast<int32_t>(ret));
1049 return ERR_NONE;
1050 }
1051
HandleGetHostWindowRect(MessageParcel & data,MessageParcel & reply)1052 int SceneSessionManagerStub::HandleGetHostWindowRect(MessageParcel& data, MessageParcel& reply)
1053 {
1054 TLOGD(WmsLogTag::WMS_UIEXT, "run HandleGetHostWindowRect!");
1055 int32_t hostWindowId = data.ReadInt32();
1056 Rect rect;
1057 WSError ret = GetHostWindowRect(hostWindowId, rect);
1058 reply.WriteInt32(rect.posX_);
1059 reply.WriteInt32(rect.posY_);
1060 reply.WriteUint32(rect.width_);
1061 reply.WriteUint32(rect.height_);
1062 reply.WriteInt32(static_cast<int32_t>(ret));
1063 return ERR_NONE;
1064 }
1065
HandleGetFreeMultiWindowEnableState(MessageParcel & data,MessageParcel & reply)1066 int SceneSessionManagerStub::HandleGetFreeMultiWindowEnableState(MessageParcel& data, MessageParcel& reply)
1067 {
1068 TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "run HandleGetFreeMultiWindowEnableState!");
1069 bool enable = false;
1070 WSError ret = GetFreeMultiWindowEnableState(enable);
1071 reply.WriteBool(enable);
1072 reply.WriteInt32(static_cast<int32_t>(ret));
1073 return ERR_NONE;
1074 }
1075
HandleGetCallingWindowWindowStatus(MessageParcel & data,MessageParcel & reply)1076 int SceneSessionManagerStub::HandleGetCallingWindowWindowStatus(MessageParcel&data, MessageParcel&reply)
1077 {
1078 TLOGI(WmsLogTag::WMS_KEYBOARD, "run HandleGetCallingWindowWindowStatus!");
1079 int32_t persistentId = data.ReadInt32();
1080 WindowStatus windowStatus = WindowStatus::WINDOW_STATUS_UNDEFINED;
1081 WMError ret = GetCallingWindowWindowStatus(persistentId, windowStatus);
1082 reply.WriteUint32(static_cast<int32_t>(ret));
1083 if (ret != WMError::WM_OK) {
1084 TLOGE(WmsLogTag::WMS_KEYBOARD, "Failed to GetCallingWindowWindowStatus(%{public}d)", persistentId);
1085 return ERR_INVALID_DATA;
1086 }
1087 reply.WriteUint32(static_cast<uint32_t>(windowStatus));
1088 return ERR_NONE;
1089 }
1090
HandleGetCallingWindowRect(MessageParcel & data,MessageParcel & reply)1091 int SceneSessionManagerStub::HandleGetCallingWindowRect(MessageParcel&data, MessageParcel& reply)
1092 {
1093 TLOGI(WmsLogTag::WMS_KEYBOARD, "run HandleGetCallingWindowRect!");
1094 int32_t persistentId = data.ReadInt32();
1095 Rect rect = {0, 0, 0, 0};
1096 WMError ret = GetCallingWindowRect(persistentId, rect);
1097 reply.WriteInt32(static_cast<int32_t>(ret));
1098 if (ret != WMError::WM_OK) {
1099 TLOGE(WmsLogTag::WMS_KEYBOARD, "Failed to GetCallingWindowRect(%{public}d)", persistentId);
1100 return ERR_INVALID_DATA;
1101 }
1102 reply.WriteInt32(rect.posX_);
1103 reply.WriteInt32(rect.posY_);
1104 reply.WriteUint32(rect.width_);
1105 reply.WriteUint32(rect.height_);
1106 return ERR_NONE;
1107 }
1108
HandleGetWindowModeType(MessageParcel & data,MessageParcel & reply)1109 int SceneSessionManagerStub::HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply)
1110 {
1111 WindowModeType windowModeType = Rosen::WindowModeType::WINDOW_MODE_OTHER;
1112 WMError errCode = GetWindowModeType(windowModeType);
1113 WLOGFI("run HandleGetWindowModeType, windowModeType:%{public}d!", static_cast<int32_t>(windowModeType));
1114 if (!reply.WriteUint32(static_cast<int32_t>(windowModeType))) {
1115 WLOGE("Failed to WriteBool");
1116 return ERR_INVALID_DATA;
1117 }
1118 reply.WriteInt32(static_cast<int32_t>(errCode));
1119 return ERR_NONE;
1120 }
1121
HandleGetWindowStyleType(MessageParcel & data,MessageParcel & reply)1122 int SceneSessionManagerStub::HandleGetWindowStyleType(MessageParcel& data, MessageParcel& reply)
1123 {
1124 WindowStyleType windowStyleType = Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT;
1125 WMError errCode = GetWindowStyleType(windowStyleType);
1126 TLOGI(WmsLogTag::WMS_LIFE, "windowStyleType:%{public}d!", static_cast<int32_t>(windowStyleType));
1127 if (!reply.WriteUint32(static_cast<int32_t>(windowStyleType))) {
1128 TLOGE(WmsLogTag::WMS_LIFE, "Failed to WriteBool");
1129 return ERR_INVALID_DATA;
1130 }
1131 reply.WriteInt32(static_cast<int32_t>(errCode));
1132 return ERR_NONE;
1133 }
1134
HandleGetProcessSurfaceNodeIdByPersistentId(MessageParcel & data,MessageParcel & reply)1135 int SceneSessionManagerStub::HandleGetProcessSurfaceNodeIdByPersistentId(MessageParcel& data, MessageParcel& reply)
1136 {
1137 int32_t pid = data.ReadInt32();
1138 std::vector<int32_t> persistentIds;
1139 data.ReadInt32Vector(&persistentIds);
1140 std::vector<uint64_t> surfaceNodeIds;
1141 WMError errCode = GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds);
1142 if (!reply.WriteUInt64Vector(surfaceNodeIds)) {
1143 TLOGE(WmsLogTag::DEFAULT, "Write surfaceNodeIds fail.");
1144 return ERR_INVALID_DATA;
1145 }
1146 reply.WriteInt32(static_cast<int32_t>(errCode));
1147 return ERR_NONE;
1148 }
1149
HandleGetWindowIdsByCoordinate(MessageParcel & data,MessageParcel & reply)1150 int SceneSessionManagerStub::HandleGetWindowIdsByCoordinate(MessageParcel& data, MessageParcel& reply)
1151 {
1152 uint64_t displayId;
1153 if (!data.ReadUint64(displayId)) {
1154 TLOGE(WmsLogTag::DEFAULT, "read displayId failed");
1155 return ERR_INVALID_DATA;
1156 }
1157 int32_t windowNumber;
1158 if (!data.ReadInt32(windowNumber)) {
1159 TLOGE(WmsLogTag::DEFAULT, "read windowNumber failed");
1160 return ERR_INVALID_DATA;
1161 }
1162 int32_t x;
1163 int32_t y;
1164 if (!data.ReadInt32(x) || !data.ReadInt32(y)) {
1165 TLOGE(WmsLogTag::DEFAULT, "read coordinate failed");
1166 return ERR_INVALID_DATA;
1167 }
1168 std::vector<int32_t> windowIds;
1169 WMError errCode = GetWindowIdsByCoordinate(displayId, windowNumber, x, y, windowIds);
1170 reply.WriteInt32(static_cast<int32_t>(errCode));
1171 if (errCode != WMError::WM_OK) {
1172 TLOGE(WmsLogTag::DEFAULT, "failed.");
1173 return ERR_INVALID_DATA;
1174 }
1175 reply.WriteInt32Vector(windowIds);
1176 return ERR_NONE;
1177 }
1178
HandleReleaseForegroundSessionScreenLock(MessageParcel & data,MessageParcel & reply)1179 int SceneSessionManagerStub::HandleReleaseForegroundSessionScreenLock(MessageParcel& data, MessageParcel& reply)
1180 {
1181 WMError errCode = ReleaseForegroundSessionScreenLock();
1182 reply.WriteInt32(static_cast<int32_t>(errCode));
1183 return ERR_NONE;
1184 }
1185
HandleIsPcWindow(MessageParcel & data,MessageParcel & reply)1186 int SceneSessionManagerStub::HandleIsPcWindow(MessageParcel& data, MessageParcel& reply)
1187 {
1188 bool isPcWindow = false;
1189 WMError errCode = IsPcWindow(isPcWindow);
1190 if (!reply.WriteBool(isPcWindow)) {
1191 TLOGE(WmsLogTag::WMS_UIEXT, "Write isPcWindow fail.");
1192 return ERR_INVALID_DATA;
1193 }
1194 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1195 TLOGE(WmsLogTag::WMS_UIEXT, "Write errCode fail.");
1196 return ERR_INVALID_DATA;
1197 }
1198 return ERR_NONE;
1199 }
1200
HandleGetDisplayIdByWindowId(MessageParcel & data,MessageParcel & reply)1201 int SceneSessionManagerStub::HandleGetDisplayIdByWindowId(MessageParcel& data, MessageParcel& reply)
1202 {
1203 std::vector<uint64_t> windowIds;
1204 if (!data.ReadUInt64Vector(&windowIds)) {
1205 TLOGE(WmsLogTag::DEFAULT, "Read windowIds Failed");
1206 return ERR_INVALID_DATA;
1207 }
1208 std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
1209 WMError errCode = GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
1210 if (!reply.WriteInt32(static_cast<int32_t>(windowDisplayIdMap.size()))) {
1211 TLOGE(WmsLogTag::DEFAULT, "Write windowDisplayIdMap size faild");
1212 return ERR_INVALID_DATA;
1213 }
1214 for (auto it = windowDisplayIdMap.begin(); it != windowDisplayIdMap.end(); ++it) {
1215 if (!reply.WriteUint64(it->first)) {
1216 TLOGE(WmsLogTag::DEFAULT, "Write windowId failed");
1217 return ERR_INVALID_DATA;
1218 }
1219 if (!reply.WriteUint64(it->second)) {
1220 TLOGE(WmsLogTag::DEFAULT, "Write displayId failed");
1221 return ERR_INVALID_DATA;
1222 }
1223 }
1224 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1225 TLOGE(WmsLogTag::DEFAULT, "Write errCode fail.");
1226 return ERR_INVALID_DATA;
1227 }
1228 return ERR_NONE;
1229 }
1230
HandleIsPcOrPadFreeMultiWindowMode(MessageParcel & data,MessageParcel & reply)1231 int SceneSessionManagerStub::HandleIsPcOrPadFreeMultiWindowMode(MessageParcel& data, MessageParcel& reply)
1232 {
1233 bool isPcOrPadFreeMultiWindowMode = false;
1234 WMError errCode = IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
1235 if (!reply.WriteBool(isPcOrPadFreeMultiWindowMode)) {
1236 TLOGE(WmsLogTag::WMS_SUB, "Write isPcOrPadFreeMultiWindowMode fail.");
1237 return ERR_INVALID_DATA;
1238 }
1239 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1240 TLOGE(WmsLogTag::WMS_SUB, "Write errCode fail.");
1241 return ERR_INVALID_DATA;
1242 }
1243 return ERR_NONE;
1244 }
1245
HandleIsWindowRectAutoSave(MessageParcel & data,MessageParcel & reply)1246 int SceneSessionManagerStub::HandleIsWindowRectAutoSave(MessageParcel& data, MessageParcel& reply)
1247 {
1248 std::string key;
1249 if (!data.ReadString(key)) {
1250 TLOGE(WmsLogTag::WMS_MAIN, "Read key failed.");
1251 return ERR_INVALID_DATA;
1252 }
1253 bool enabled = false;
1254 WMError errCode = IsWindowRectAutoSave(key, enabled);
1255 if (!reply.WriteBool(enabled)) {
1256 TLOGE(WmsLogTag::WMS_MAIN, "Write enabled failed.");
1257 return ERR_INVALID_DATA;
1258 }
1259 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
1260 TLOGE(WmsLogTag::WMS_MAIN, "Write errCode failed.");
1261 return ERR_INVALID_DATA;
1262 }
1263 return ERR_NONE;
1264 }
1265
HandleSetGlobalDragResizeType(MessageParcel & data,MessageParcel & reply)1266 int SceneSessionManagerStub::HandleSetGlobalDragResizeType(MessageParcel& data, MessageParcel& reply)
1267 {
1268 uint32_t dragResizeType;
1269 if (!data.ReadUint32(dragResizeType)) {
1270 TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed.");
1271 return ERR_INVALID_DATA;
1272 }
1273 if (dragResizeType > static_cast<uint32_t>(DragResizeType::RESIZE_WHEN_DRAG_END)) {
1274 TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
1275 return ERR_INVALID_DATA;
1276 }
1277 WMError errCode = SetGlobalDragResizeType(static_cast<DragResizeType>(dragResizeType));
1278 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
1279 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
1280 return ERR_INVALID_DATA;
1281 }
1282 return ERR_NONE;
1283 }
1284
HandleGetGlobalDragResizeType(MessageParcel & data,MessageParcel & reply)1285 int SceneSessionManagerStub::HandleGetGlobalDragResizeType(MessageParcel& data, MessageParcel& reply)
1286 {
1287 DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
1288 WMError errCode = GetGlobalDragResizeType(dragResizeType);
1289 if (!reply.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
1290 TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed.");
1291 return ERR_INVALID_DATA;
1292 }
1293 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
1294 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
1295 return ERR_INVALID_DATA;
1296 }
1297 return ERR_NONE;
1298 }
1299
HandleSetAppDragResizeType(MessageParcel & data,MessageParcel & reply)1300 int SceneSessionManagerStub::HandleSetAppDragResizeType(MessageParcel& data, MessageParcel& reply)
1301 {
1302 std::string bundleName;
1303 if (!data.ReadString(bundleName)) {
1304 TLOGE(WmsLogTag::WMS_LAYOUT, "Read bundleName failed.");
1305 return ERR_INVALID_DATA;
1306 }
1307 uint32_t dragResizeType;
1308 if (!data.ReadUint32(dragResizeType)) {
1309 TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed.");
1310 return ERR_INVALID_DATA;
1311 }
1312 if (dragResizeType > static_cast<uint32_t>(DragResizeType::RESIZE_WHEN_DRAG_END)) {
1313 TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
1314 return ERR_INVALID_DATA;
1315 }
1316 WMError errCode = SetAppDragResizeType(bundleName, static_cast<DragResizeType>(dragResizeType));
1317 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
1318 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
1319 return ERR_INVALID_DATA;
1320 }
1321 return ERR_NONE;
1322 }
1323
HandleGetAppDragResizeType(MessageParcel & data,MessageParcel & reply)1324 int SceneSessionManagerStub::HandleGetAppDragResizeType(MessageParcel& data, MessageParcel& reply)
1325 {
1326 std::string bundleName;
1327 if (!data.ReadString(bundleName)) {
1328 TLOGE(WmsLogTag::WMS_LAYOUT, "Read bundleName failed.");
1329 return ERR_INVALID_DATA;
1330 }
1331 DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
1332 WMError errCode = GetAppDragResizeType(bundleName, dragResizeType);
1333 if (!reply.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
1334 TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed.");
1335 return ERR_INVALID_DATA;
1336 }
1337 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
1338 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
1339 return ERR_INVALID_DATA;
1340 }
1341 return ERR_NONE;
1342 }
1343
HandleShiftAppWindowPointerEvent(MessageParcel & data,MessageParcel & reply)1344 int SceneSessionManagerStub::HandleShiftAppWindowPointerEvent(MessageParcel& data, MessageParcel& reply)
1345 {
1346 int32_t sourcePersistentId = INVALID_WINDOW_ID;
1347 if (!data.ReadInt32(sourcePersistentId)) {
1348 TLOGE(WmsLogTag::WMS_PC, "read sourcePersistentId failed");
1349 return ERR_INVALID_DATA;
1350 }
1351 int32_t targetPersistentId = INVALID_WINDOW_ID;
1352 if (!data.ReadInt32(targetPersistentId)) {
1353 TLOGE(WmsLogTag::WMS_PC, "read targetPersistentId failed");
1354 return ERR_INVALID_DATA;
1355 }
1356 WMError errCode = ShiftAppWindowPointerEvent(sourcePersistentId, targetPersistentId);
1357 reply.WriteInt32(static_cast<int32_t>(errCode));
1358 return ERR_NONE;
1359 }
1360 } // namespace OHOS::Rosen