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