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