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 #include "rs_adapter.h"
21 #include "ui_effect_controller_client_interface.h"
22 #include "ui_effect_controller_stub.h"
23
24 namespace OHOS::Rosen {
25 namespace {
26 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerStub"};
27 constexpr uint32_t MAX_VECTOR_SIZE = 100;
28 }
29
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)30 int SceneSessionManagerStub::OnRemoteRequest(uint32_t code,
31 MessageParcel& data, MessageParcel& reply, MessageOption& option)
32 {
33 WLOGFD("Scene session on remote request!, code: %{public}u", code);
34 if (data.ReadInterfaceToken() != GetDescriptor()) {
35 WLOGFE("Failed to check interface token!");
36 return ERR_TRANSACTION_FAILED;
37 }
38 return ProcessRemoteRequest(code, data, reply, option);
39 }
40
ProcessRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)41 int SceneSessionManagerStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
42 MessageOption& option)
43 {
44 switch (code) {
45 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CREATE_AND_CONNECT_SPECIFIC_SESSION):
46 return HandleCreateAndConnectSpecificSession(data, reply);
47 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_CONNECT_SPECIFIC_SESSION):
48 return HandleRecoverAndConnectSpecificSession(data, reply);
49 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_RECONNECT_SCENE_SESSION):
50 return HandleRecoverAndReconnectSceneSession(data, reply);
51 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION):
52 return HandleDestroyAndDisconnectSpcificSession(data, reply);
53 case static_cast<uint32_t>(
54 SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION_WITH_DETACH_CALLBACK):
55 return HandleDestroyAndDisconnectSpcificSessionWithDetachCallback(data, reply);
56 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REQUEST_FOCUS):
57 return HandleRequestFocusStatus(data, reply);
58 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REQUEST_FOCUS_STATUS_BY_SA):
59 return HandleRequestFocusStatusBySA(data, reply);
60 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT):
61 return HandleRegisterWindowManagerAgent(data, reply);
62 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT):
63 return HandleUnregisterWindowManagerAgent(data, reply);
64 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_PROPERTY_CHANGE_AGENT):
65 return HandleRegisterWindowPropertyChangeAgent(data, reply);
66 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_PROPERTY_CHANGE_AGENT):
67 return HandleUnregisterWindowPropertyChangeAgent(data, reply);
68 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_INFO):
69 return HandleGetFocusSessionInfo(data, reply);
70 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_LABEL):
71 return HandleSetSessionLabel(data, reply);
72 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_ICON):
73 return HandleSetSessionIcon(data, reply);
74 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_VALID_SESSION_IDS):
75 return HandleIsValidSessionIds(data, reply);
76 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND):
77 return HandlePendingSessionToForeground(data, reply);
78 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR):
79 return HandlePendingSessionToBackgroundForDelegator(data, reply);
80 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN):
81 return HandleGetFocusSessionToken(data, reply);
82 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT):
83 return HandleGetFocusSessionElement(data, reply);
84 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CHECK_WINDOW_ID):
85 return HandleCheckWindowId(data, reply);
86 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_GESTURE_NAVIGATION_ENABLED):
87 return HandleSetGestureNavigationEnabled(data, reply);
88 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_INFO):
89 return HandleGetAccessibilityWindowInfo(data, reply);
90 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_UNRELIABLE_WINDOW_INFO):
91 return HandleGetUnreliableWindowInfo(data, reply);
92 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_SESSION_LISTENER):
93 return HandleRegisterSessionListener(data, reply);
94 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER):
95 return HandleUnRegisterSessionListener(data, reply);
96 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFOS):
97 return HandleGetSessionInfos(data, reply);
98 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFO_BY_ID):
99 return HandleGetSessionInfo(data, reply);
100 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID):
101 return HandleGetSessionInfoByContinueSessionId(data, reply);
102 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_ALL):
103 return HandleDumpSessionAll(data, reply);
104 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_WITH_ID):
105 return HandleDumpSessionWithId(data, reply);
106 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_TERMINATE_SESSION_NEW):
107 return HandleTerminateSessionNew(data, reply);
108 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_AVOIDAREA_LISTENER):
109 return HandleUpdateSessionAvoidAreaListener(data, reply);
110 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_DUMP_INFO):
111 return HandleGetSessionDump(data, reply);
112 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT):
113 return HandleGetSessionSnapshot(data, reply);
114 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT_BY_ID):
115 return HandleGetSessionSnapshotById(data, reply);
116 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ):
117 return HandleGetUIContentRemoteObj(data, reply);
118 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_BIND_DIALOG_TARGET):
119 return HandleBindDialogTarget(data, reply);
120 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_NOTIFY_DUMP_INFO_RESULT):
121 return HandleNotifyDumpInfoResult(data, reply);
122 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE):
123 return HandleSetSessionContinueState(data, reply);
124 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_SESSION):
125 return HandleClearSession(data, reply);
126 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_ALL_SESSIONS):
127 return HandleClearAllSessions(data, reply);
128 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_LOCK_SESSION):
129 return HandleLockSession(data, reply);
130 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNLOCK_SESSION):
131 return HandleUnlockSession(data, reply);
132 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND):
133 return HandleMoveSessionsToForeground(data, reply);
134 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND):
135 return HandleMoveSessionsToBackground(data, reply);
136 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_COLLABORATOR):
137 return HandleRegisterCollaborator(data, reply);
138 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_COLLABORATOR):
139 return HandleUnregisterCollaborator(data, reply);
140 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_TOUCHOUTSIDE_LISTENER):
141 return HandleUpdateSessionTouchOutsideListener(data, reply);
142 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RAISE_WINDOW_TO_TOP):
143 return HandleRaiseWindowToTop(data, reply);
144 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_TOP_WINDOW_ID):
145 return HandleGetTopWindowId(data, reply);
146 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PARENT_MAIN_WINDOW_ID):
147 return HandleGetParentMainWindowId(data, reply);
148 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_NOTIFY_WINDOW_EXTENSION_VISIBILITY_CHANGE):
149 return HandleNotifyWindowExtensionVisibilityChange(data, reply);
150 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_WINDOW_VISIBILITY_LISTENER):
151 return HandleUpdateSessionWindowVisibilityListener(data, reply);
152 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_FOCUS):
153 return HandleShiftAppWindowFocus(data, reply);
154 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_LIST_WINDOW_INFO):
155 return HandleListWindowInfo(data, reply);
156 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_LAYOUT_INFO):
157 return HandleGetAllWindowLayoutInfo(data, reply);
158 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_GLOBAL_WINDOW_MODE):
159 return HandleGetGlobalWindowMode(data, reply);
160 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_TOP_NAV_DEST_NAME):
161 return HandleGetTopNavDestinationName(data, reply);
162 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID):
163 return HandleGetVisibilityWindowInfo(data, reply);
164 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB):
165 return HandleAddExtensionWindowStageToSCB(data, reply);
166 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REMOVE_EXTENSION_WINDOW_STAGE_FROM_SCB):
167 return HandleRemoveExtensionWindowStageFromSCB(data, reply);
168 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_MODALEXTENSION_RECT_TO_SCB):
169 return HandleUpdateModalExtensionRect(data, reply);
170 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PROCESS_MODALEXTENSION_POINTDOWN_TO_SCB):
171 return HandleProcessModalExtensionPointDown(data, reply);
172 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION):
173 return HandleAddOrRemoveSecureSession(data, reply);
174 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS):
175 return HandleUpdateExtWindowFlags(data, reply);
176 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_HOST_WINDOW_RECT):
177 return HandleGetHostWindowRect(data, reply);
178 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_HOST_GLOBAL_SCALE_RECT):
179 return HandleGetHostGlobalScaledRect(data, reply);
180 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STATUS):
181 return HandleGetCallingWindowWindowStatus(data, reply);
182 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_RECT):
183 return HandleGetCallingWindowRect(data, reply);
184 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_MODE_TYPE):
185 return HandleGetWindowModeType(data, reply);
186 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FREE_MULTI_WINDOW_ENABLE_STATE):
187 return HandleGetFreeMultiWindowEnableState(data, reply);
188 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STYLE_TYPE):
189 return HandleGetWindowStyleType(data, reply);
190 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PROCESS_SURFACENODEID_BY_PERSISTENTID):
191 return HandleGetProcessSurfaceNodeIdByPersistentId(data, reply);
192 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_PROCESS_SNAPSHOT_SKIP):
193 return HandleSkipSnapshotForAppProcess(data, reply);
194 case static_cast<uint32_t>
195 (SceneSessionManagerMessage::TRANS_ID_SET_SNAPSHOT_SKIP_BY_USERID_AND_BUNDLENAMES):
196 return HandleSkipSnapshotByUserIdAndBundleNames(data, reply);
197 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_PROCESS_WATERMARK):
198 return HandleSetProcessWatermark(data, reply);
199 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_IDS_BY_COORDINATE):
200 return HandleGetWindowIdsByCoordinate(data, reply);
201 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_SESSION_SCREEN_LOCK):
202 return HandleUpdateSessionScreenLock(data, reply);
203 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_SKIP_SELF_ON_VIRTUAL_SCREEN):
204 return HandleAddSkipSelfWhenShowOnVirtualScreenList(data, reply);
205 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REMOVE_SKIP_SELF_ON_VIRTUAL_SCREEN):
206 return HandleRemoveSkipSelfWhenShowOnVirtualScreenList(data, reply);
207 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SCREEN_PRIVACY_WINDOW_TAG_SWITCH):
208 return HandleSetScreenPrivacyWindowTagSwitch(data, reply);
209 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_PC_WINDOW):
210 return HandleIsPcWindow(data, reply);
211 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_FREE_MULTI_WINDOW):
212 return HandleIsFreeMultiWindow(data, reply);
213 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_PC_OR_PAD_FREE_MULTI_WINDOW_MODE):
214 return HandleIsPcOrPadFreeMultiWindowMode(data, reply);
215 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_DISPLAYID_BY_WINDOWID):
216 return HandleGetDisplayIdByWindowId(data, reply);
217 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_WINDOW_RECT_AUTO_SAVE):
218 return HandleIsWindowRectAutoSave(data, reply);
219 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_GLOBAL_DRAG_RESIZE_TYPE):
220 return HandleSetGlobalDragResizeType(data, reply);
221 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_GLOBAL_DRAG_RESIZE_TYPE):
222 return HandleGetGlobalDragResizeType(data, reply);
223 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_APP_DRAG_RESIZE_TYPE):
224 return HandleSetAppDragResizeType(data, reply);
225 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_APP_DRAG_RESIZE_TYPE):
226 return HandleGetAppDragResizeType(data, reply);
227 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_APP_KEY_FRAME_POLICY):
228 return HandleSetAppKeyFramePolicy(data, reply);
229 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_WATCH_GESTURE_CONSUME_RESULT):
230 return HandleWatchGestureConsumeResult(data, reply);
231 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_WATCH_FOCUS_ACTIVE_CHANGE):
232 return HandleWatchFocusActiveChange(data, reply);
233 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_POINTER_EVENT):
234 return HandleShiftAppWindowPointerEvent(data, reply);
235 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_NOTIFY_SCREEN_SHOT_EVENT):
236 return HandleNotifyScreenshotEvent(data, reply);
237 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_START_WINDOW_BACKGROUND_COLOR):
238 return HandleSetStartWindowBackgroundColor(data, reply);
239 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MINIMIZE_BY_WINDOW_ID):
240 return HandleMinimizeByWindowId(data, reply);
241 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_PARENT_WINDOW):
242 return HandleSetParentWindow(data, reply);
243 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_FOREGROUND_WINDOW_NUM):
244 return HandleSetForegroundWindowNum(data, reply);
245 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_USE_IMPLICIT_ANIMATION):
246 return HandleUseImplicitAnimation(data, reply);
247 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_IMAGE_FOR_RECENT):
248 return HandleSetImageForRecent(data, reply);
249 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ANIMATE_TO_WINDOW):
250 return HandleAnimateTo(data, reply);
251 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CREATE_UI_EFFECT_CONTROLLER):
252 return HandleCreateUIEffectController(data, reply);
253 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_SESSION_BLACK_LIST):
254 return HandleAddSessionBlackList(data, reply);
255 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REMOVE_SESSION_BLACK_LIST):
256 return HandleRemoveSessionBlackList(data, reply);
257 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PIP_SWITCH_STATUS):
258 return HandleGetPiPSettingSwitchStatus(data, reply);
259 case static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RECOVER_WINDOW_PROPERTY_CHANGE_FLAG):
260 return HandleRecoverWindowPropertyChangeFlag(data, reply);
261 default:
262 WLOGFE("Failed to find function handler!");
263 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
264 }
265 }
266
HandleCreateAndConnectSpecificSession(MessageParcel & data,MessageParcel & reply)267 int SceneSessionManagerStub::HandleCreateAndConnectSpecificSession(MessageParcel& data, MessageParcel& reply)
268 {
269 TLOGD(WmsLogTag::WMS_LIFE, "run");
270 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
271 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
272 sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
273 sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
274 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
275 TLOGD(WmsLogTag::WMS_SCB, "Unmarshalling RSSurfaceNode: %{public}s",
276 RSAdapterUtil::RSNodeToStr(surfaceNode).c_str());
277 if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
278 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read scene session stage object or event channel object!");
279 return ERR_INVALID_DATA;
280 }
281 sptr<WindowSessionProperty> property = data.ReadStrongParcelable<WindowSessionProperty>();
282 if (property == nullptr) {
283 TLOGE(WmsLogTag::WMS_LIFE, "property is nullptr");
284 return ERR_INVALID_DATA;
285 }
286
287 sptr<IRemoteObject> token = nullptr;
288 if (property->GetTokenState()) {
289 token = data.ReadRemoteObject();
290 } else {
291 TLOGW(WmsLogTag::WMS_LIFE, "accept token is nullptr");
292 }
293
294 auto persistentId = INVALID_SESSION_ID;
295 sptr<ISession> sceneSession;
296 SystemSessionConfig systemConfig;
297 CreateAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode,
298 property, persistentId, sceneSession, systemConfig, token);
299 if (sceneSession== nullptr) {
300 return ERR_INVALID_STATE;
301 }
302 reply.WriteInt32(persistentId);
303 reply.WriteRemoteObject(sceneSession->AsObject());
304 reply.WriteParcelable(&systemConfig);
305 reply.WriteUint32(property->GetSubWindowLevel());
306 reply.WriteUint64(property->GetDisplayId());
307 reply.WriteUint32(static_cast<uint32_t>(WSError::WS_OK));
308 return ERR_NONE;
309 }
310
HandleRecoverAndConnectSpecificSession(MessageParcel & data,MessageParcel & reply)311 int SceneSessionManagerStub::HandleRecoverAndConnectSpecificSession(MessageParcel& data, MessageParcel& reply)
312 {
313 TLOGI(WmsLogTag::WMS_RECOVER, "run!");
314 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
315 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
316 sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
317 sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
318 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
319 if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
320 TLOGE(WmsLogTag::WMS_RECOVER, "Failed to read scene session stage object or event channel object!");
321 return ERR_INVALID_DATA;
322 }
323 bool hasProperty = false;
324 if (!data.ReadBool(hasProperty)) {
325 TLOGE(WmsLogTag::WMS_RECOVER, "Read hasProperty failed!");
326 return ERR_TRANSACTION_FAILED;
327 }
328 sptr<WindowSessionProperty> property = nullptr;
329 if (hasProperty) {
330 property = data.ReadStrongParcelable<WindowSessionProperty>();
331 } else {
332 TLOGW(WmsLogTag::WMS_RECOVER, "Property not exist!");
333 }
334
335 sptr<IRemoteObject> token = nullptr;
336 if (property && property->GetTokenState()) {
337 token = data.ReadRemoteObject();
338 } else {
339 TLOGI(WmsLogTag::WMS_RECOVER, "accept token is nullptr");
340 }
341
342 sptr<ISession> sceneSession;
343 auto ret = RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, sceneSession, token);
344 if (sceneSession== nullptr) {
345 return ERR_INVALID_STATE;
346 }
347 reply.WriteRemoteObject(sceneSession->AsObject());
348 reply.WriteUint32(static_cast<uint32_t>(ret));
349 return ERR_NONE;
350 }
351
HandleRecoverAndReconnectSceneSession(MessageParcel & data,MessageParcel & reply)352 int SceneSessionManagerStub::HandleRecoverAndReconnectSceneSession(MessageParcel& data, MessageParcel& reply)
353 {
354 TLOGI(WmsLogTag::WMS_RECOVER, "run");
355 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
356 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
357 sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
358 sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
359 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
360 if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
361 TLOGE(WmsLogTag::WMS_RECOVER, "Failed to read scene session stage object or event channel object!");
362 return ERR_INVALID_DATA;
363 }
364 bool hasProperty = false;
365 if (!data.ReadBool(hasProperty)) {
366 TLOGE(WmsLogTag::WMS_RECOVER, "Read hasProperty failed!");
367 return ERR_TRANSACTION_FAILED;
368 }
369 sptr<WindowSessionProperty> property = nullptr;
370 if (hasProperty) {
371 property = data.ReadStrongParcelable<WindowSessionProperty>();
372 } else {
373 TLOGW(WmsLogTag::WMS_RECOVER, "Property not exist!");
374 }
375
376 sptr<IRemoteObject> token = nullptr;
377 if (property && property->GetTokenState()) {
378 token = data.ReadRemoteObject();
379 } else {
380 TLOGI(WmsLogTag::WMS_RECOVER, "accept token is nullptr");
381 }
382
383 sptr<ISession> sceneSession;
384 RecoverAndReconnectSceneSession(sessionStage, eventChannel, surfaceNode, sceneSession, property, token);
385 if (sceneSession == nullptr) {
386 return ERR_INVALID_STATE;
387 }
388 reply.WriteRemoteObject(sceneSession->AsObject());
389 reply.WriteUint32(static_cast<uint32_t>(WSError::WS_OK));
390 return ERR_NONE;
391 }
392
HandleDestroyAndDisconnectSpcificSession(MessageParcel & data,MessageParcel & reply)393 int SceneSessionManagerStub::HandleDestroyAndDisconnectSpcificSession(MessageParcel& data, MessageParcel& reply)
394 {
395 int32_t persistentId = 0;
396 if (!data.ReadInt32(persistentId)) {
397 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId failed");
398 return ERR_TRANSACTION_FAILED;
399 }
400 TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d", persistentId);
401 WSError ret = DestroyAndDisconnectSpecificSession(persistentId);
402 reply.WriteUint32(static_cast<uint32_t>(ret));
403 return ERR_NONE;
404 }
405
HandleDestroyAndDisconnectSpcificSessionWithDetachCallback(MessageParcel & data,MessageParcel & reply)406 int SceneSessionManagerStub::HandleDestroyAndDisconnectSpcificSessionWithDetachCallback(MessageParcel& data,
407 MessageParcel& reply)
408 {
409 int32_t persistentId = 0;
410 if (!data.ReadInt32(persistentId)) {
411 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId failed");
412 return ERR_TRANSACTION_FAILED;
413 }
414 TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d", persistentId);
415 sptr<IRemoteObject> callback = data.ReadRemoteObject();
416 const WSError ret = DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
417 reply.WriteUint32(static_cast<uint32_t>(ret));
418 return ERR_NONE;
419 }
420
HandleSetParentWindow(MessageParcel & data,MessageParcel & reply)421 int SceneSessionManagerStub::HandleSetParentWindow(MessageParcel& data, MessageParcel& reply)
422 {
423 int32_t subWindowId = INVALID_WINDOW_ID;
424 if (!data.ReadInt32(subWindowId)) {
425 TLOGE(WmsLogTag::WMS_SUB, "read subWindowId failed");
426 return ERR_INVALID_DATA;
427 }
428 int32_t newParentWindowId = INVALID_WINDOW_ID;
429 if (!data.ReadInt32(newParentWindowId)) {
430 TLOGE(WmsLogTag::WMS_SUB, "read newParentWindowId failed");
431 return ERR_INVALID_DATA;
432 }
433 TLOGD(WmsLogTag::WMS_SUB, "subWindowId: %{public}d, newParentWindowId: %{public}d",
434 subWindowId, newParentWindowId);
435 WMError errCode = SetParentWindow(subWindowId, newParentWindowId);
436 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
437 TLOGE(WmsLogTag::WMS_SUB, "Write errCode failed.");
438 return ERR_INVALID_DATA;
439 }
440 return ERR_NONE;
441 }
442
HandleRequestFocusStatus(MessageParcel & data,MessageParcel & reply)443 int SceneSessionManagerStub::HandleRequestFocusStatus(MessageParcel& data, MessageParcel& reply)
444 {
445 TLOGD(WmsLogTag::WMS_FOCUS, "run");
446 int32_t persistentId = 0;
447 if (!data.ReadInt32(persistentId)) {
448 TLOGE(WmsLogTag::WMS_FOCUS, "read persistentId failed");
449 return ERR_INVALID_DATA;
450 }
451 bool isFocused = false;
452 if (!data.ReadBool(isFocused)) {
453 TLOGE(WmsLogTag::WMS_FOCUS, "read isFocused failed");
454 return ERR_INVALID_DATA;
455 }
456 WMError ret = RequestFocusStatus(persistentId, isFocused, true, FocusChangeReason::CLIENT_REQUEST);
457 reply.WriteInt32(static_cast<int32_t>(ret));
458 return ERR_NONE;
459 }
460
HandleRequestFocusStatusBySA(MessageParcel & data,MessageParcel & reply)461 int SceneSessionManagerStub::HandleRequestFocusStatusBySA(MessageParcel& data, MessageParcel& reply)
462 {
463 TLOGD(WmsLogTag::WMS_FOCUS, "run");
464 int32_t persistentId = 0;
465 if (!data.ReadInt32(persistentId)) {
466 TLOGE(WmsLogTag::WMS_FOCUS, "read persistentId failed");
467 return ERR_INVALID_DATA;
468 }
469 bool isFocused = false;
470 if (!data.ReadBool(isFocused)) {
471 TLOGE(WmsLogTag::WMS_FOCUS, "read isFocused failed");
472 return ERR_INVALID_DATA;
473 }
474 bool byForeground = false;
475 if (!data.ReadBool(byForeground)) {
476 TLOGE(WmsLogTag::WMS_FOCUS, "read byForeground failed");
477 return ERR_INVALID_DATA;
478 }
479 int32_t reason = static_cast<int32_t>(FocusChangeReason::SA_REQUEST);
480 if (!data.ReadInt32(reason)) {
481 TLOGE(WmsLogTag::WMS_FOCUS, "read reason failed");
482 return ERR_INVALID_DATA;
483 }
484 WMError ret = RequestFocusStatusBySA(persistentId, isFocused, byForeground,
485 static_cast<FocusChangeReason>(reason));
486 reply.WriteInt32(static_cast<int32_t>(ret));
487 return ERR_NONE;
488 }
489
HandleRegisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)490 int SceneSessionManagerStub::HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
491 {
492 uint32_t typeId = 0;
493 if (!data.ReadUint32(typeId) ||
494 typeId < static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS) ||
495 typeId >= static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_END)) {
496 return ERR_INVALID_DATA;
497 }
498 WindowManagerAgentType type = static_cast<WindowManagerAgentType>(typeId);
499 TLOGD(WmsLogTag::DEFAULT, "type=%{public}u", typeId);
500 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
501 sptr<IWindowManagerAgent> windowManagerAgentProxy =
502 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
503 WMError errCode = RegisterWindowManagerAgent(type, windowManagerAgentProxy);
504 reply.WriteInt32(static_cast<int32_t>(errCode));
505 return ERR_NONE;
506 }
507
HandleUnregisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)508 int SceneSessionManagerStub::HandleUnregisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
509 {
510 uint32_t typeId = 0;
511 if (!data.ReadUint32(typeId) ||
512 typeId < static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS) ||
513 typeId >= static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_END)) {
514 return ERR_INVALID_DATA;
515 }
516 WindowManagerAgentType type = static_cast<WindowManagerAgentType>(typeId);
517 TLOGD(WmsLogTag::DEFAULT, "type=%{public}u", typeId);
518 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
519 sptr<IWindowManagerAgent> windowManagerAgentProxy =
520 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
521 WMError errCode = UnregisterWindowManagerAgent(type, windowManagerAgentProxy);
522 reply.WriteInt32(static_cast<int32_t>(errCode));
523 return ERR_NONE;
524 }
525
HandleRecoverWindowPropertyChangeFlag(MessageParcel & data,MessageParcel & reply)526 int SceneSessionManagerStub::HandleRecoverWindowPropertyChangeFlag(MessageParcel& data, MessageParcel& reply)
527 {
528 uint32_t observedFlags = 0;
529 if (!data.ReadUint32(observedFlags)) {
530 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read observedFlags failed");
531 return ERR_TRANSACTION_FAILED;
532 }
533
534 uint32_t interestFlags = 0;
535 if (!data.ReadUint32(interestFlags)) {
536 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read interestFlags failed");
537 return ERR_TRANSACTION_FAILED;
538 }
539
540 WMError errCode = RecoverWindowPropertyChangeFlag(observedFlags, interestFlags);
541 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
542 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode failed");
543 return ERR_TRANSACTION_FAILED;
544 }
545
546 return ERR_NONE;
547 }
548
HandleRegisterWindowPropertyChangeAgent(MessageParcel & data,MessageParcel & reply)549 int SceneSessionManagerStub::HandleRegisterWindowPropertyChangeAgent(MessageParcel& data, MessageParcel& reply)
550 {
551 int32_t windowInfoKeyValue = 0;
552 if (!data.ReadInt32(windowInfoKeyValue)) {
553 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read window info key value failed");
554 return ERR_INVALID_DATA;
555 }
556 WindowInfoKey windowInfoKey = static_cast<WindowInfoKey>(windowInfoKeyValue);
557
558 uint32_t interestInfo = 0;
559 if (!data.ReadUint32(interestInfo)) {
560 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read interest info failed");
561 return ERR_INVALID_DATA;
562 }
563
564 WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_PROPERTY;
565 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
566 sptr<IWindowManagerAgent> windowManagerAgentProxy =
567 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
568 WMError errCode = RegisterWindowPropertyChangeAgent(windowInfoKey, interestInfo, windowManagerAgentProxy);
569 reply.WriteInt32(static_cast<int32_t>(errCode));
570 return ERR_NONE;
571 }
572
HandleUnregisterWindowPropertyChangeAgent(MessageParcel & data,MessageParcel & reply)573 int SceneSessionManagerStub::HandleUnregisterWindowPropertyChangeAgent(MessageParcel& data, MessageParcel& reply)
574 {
575 int32_t windowInfoKeyValue = 0;
576 if (!data.ReadInt32(windowInfoKeyValue)) {
577 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read window info key value failed");
578 return ERR_INVALID_DATA;
579 }
580 WindowInfoKey windowInfoKey = static_cast<WindowInfoKey>(windowInfoKeyValue);
581
582 uint32_t interestInfo = 0;
583 if (!data.ReadUint32(interestInfo)) {
584 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read interest info failed");
585 return ERR_INVALID_DATA;
586 }
587
588 WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_PROPERTY;
589 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
590 sptr<IWindowManagerAgent> windowManagerAgentProxy =
591 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
592 WMError errCode = UnregisterWindowPropertyChangeAgent(windowInfoKey, interestInfo, windowManagerAgentProxy);
593 reply.WriteInt32(static_cast<int32_t>(errCode));
594 return ERR_NONE;
595 }
596
HandleGetFocusSessionInfo(MessageParcel & data,MessageParcel & reply)597 int SceneSessionManagerStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply)
598 {
599 TLOGD(WmsLogTag::WMS_FOCUS, "Run");
600 FocusChangeInfo focusInfo;
601 uint64_t displayId = 0;
602 if (!data.ReadUint64(displayId)) {
603 TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId");
604 return ERR_INVALID_DATA;
605 }
606 GetFocusWindowInfo(focusInfo, displayId);
607 reply.WriteParcelable(&focusInfo);
608 return ERR_NONE;
609 }
610
HandleSetSessionLabel(MessageParcel & data,MessageParcel & reply)611 int SceneSessionManagerStub::HandleSetSessionLabel(MessageParcel& data, MessageParcel& reply)
612 {
613 TLOGD(WmsLogTag::DEFAULT, "In");
614 sptr<IRemoteObject> token = data.ReadRemoteObject();
615 std::string label;
616 if (!data.ReadString(label)) {
617 TLOGE(WmsLogTag::DEFAULT, "read label failed");
618 return ERR_INVALID_DATA;
619 }
620 WSError errCode = SetSessionLabel(token, label);
621 reply.WriteInt32(static_cast<int32_t>(errCode));
622 return ERR_NONE;
623 }
624
HandleSetSessionIcon(MessageParcel & data,MessageParcel & reply)625 int SceneSessionManagerStub::HandleSetSessionIcon(MessageParcel& data, MessageParcel& reply)
626 {
627 TLOGD(WmsLogTag::DEFAULT, "In");
628 sptr<IRemoteObject> token = data.ReadRemoteObject();
629 std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
630 if (icon == nullptr) {
631 TLOGE(WmsLogTag::DEFAULT, "icon is null");
632 return ERR_INVALID_DATA;
633 }
634 WSError errCode = SetSessionIcon(token, icon);
635 reply.WriteInt32(static_cast<int32_t>(errCode));
636 return ERR_NONE;
637 }
638
HandleIsValidSessionIds(MessageParcel & data,MessageParcel & reply)639 int SceneSessionManagerStub::HandleIsValidSessionIds(MessageParcel& data, MessageParcel& reply)
640 {
641 WLOGFI("run HandleIsValidSessionIds!");
642 std::vector<int32_t> sessionIds;
643 data.ReadInt32Vector(&sessionIds);
644 std::vector<bool> results;
645 reply.WriteBoolVector(results);
646 return ERR_NONE;
647 }
648
HandlePendingSessionToForeground(MessageParcel & data,MessageParcel & reply)649 int SceneSessionManagerStub::HandlePendingSessionToForeground(MessageParcel& data, MessageParcel& reply)
650 {
651 WLOGFI("run HandlePendingSessionToForeground!");
652 sptr<IRemoteObject> token = data.ReadRemoteObject();
653 if (token == nullptr) {
654 WLOGFE("token is nullptr");
655 return ERR_INVALID_DATA;
656 }
657 WSError errCode = PendingSessionToForeground(token);
658 reply.WriteUint32(static_cast<uint32_t>(errCode));
659 return ERR_NONE;
660 }
661
HandlePendingSessionToBackgroundForDelegator(MessageParcel & data,MessageParcel & reply)662 int SceneSessionManagerStub::HandlePendingSessionToBackgroundForDelegator(MessageParcel& data, MessageParcel& reply)
663 {
664 TLOGD(WmsLogTag::WMS_LIFE, "run");
665 sptr<IRemoteObject> token = data.ReadRemoteObject();
666 if (token == nullptr) {
667 TLOGE(WmsLogTag::WMS_LIFE, "token is nullptr");
668 return ERR_INVALID_DATA;
669 }
670 bool shouldBackToCaller = true;
671 if (!data.ReadBool(shouldBackToCaller)) {
672 TLOGE(WmsLogTag::WMS_LIFE, "Read shouldBackToCaller failed");
673 return ERR_INVALID_DATA;
674 }
675 WSError errCode = PendingSessionToBackgroundForDelegator(token, shouldBackToCaller);
676 reply.WriteInt32(static_cast<int32_t>(errCode));
677 return ERR_NONE;
678 }
679
HandleRegisterSessionListener(MessageParcel & data,MessageParcel & reply)680 int SceneSessionManagerStub::HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
681 {
682 WLOGFI("run HandleRegisterSessionListener!");
683 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
684 if (listener == nullptr) {
685 reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
686 WLOGFI("listener is nullptr");
687 return ERR_NONE;
688 }
689 WSError errCode = RegisterSessionListener(listener);
690 reply.WriteInt32(static_cast<int32_t>(errCode));
691 return ERR_NONE;
692 }
693
HandleUnRegisterSessionListener(MessageParcel & data,MessageParcel & reply)694 int SceneSessionManagerStub::HandleUnRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
695 {
696 WLOGFI("run HandleUnRegisterSessionListener!");
697 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
698 if (listener == nullptr) {
699 reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
700 WLOGFI("listener is nullptr");
701 return ERR_NONE;
702 }
703 WSError errCode = UnRegisterSessionListener(listener);
704 reply.WriteInt32(static_cast<int32_t>(errCode));
705 return ERR_NONE;
706 }
707
HandleGetSessionInfos(MessageParcel & data,MessageParcel & reply)708 int SceneSessionManagerStub::HandleGetSessionInfos(MessageParcel& data, MessageParcel& reply)
709 {
710 TLOGD(WmsLogTag::WMS_LIFE, "In!");
711 std::string deviceId = Str16ToStr8(data.ReadString16());
712 int32_t numMax = 0;
713 if (!data.ReadInt32(numMax)) {
714 TLOGE(WmsLogTag::WMS_LIFE, "Read numMax failed");
715 return ERR_INVALID_DATA;
716 }
717 std::vector<SessionInfoBean> missionInfos;
718 WSError errCode = GetSessionInfos(deviceId, numMax, missionInfos);
719 reply.WriteInt32(missionInfos.size());
720 for (auto& it : missionInfos) {
721 if (!reply.WriteParcelable(&it)) {
722 TLOGE(WmsLogTag::WMS_LIFE, "Write missionInfos error");
723 return ERR_INVALID_DATA;
724 }
725 }
726 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
727 TLOGE(WmsLogTag::WMS_LIFE, "Write result error");
728 return ERR_INVALID_DATA;
729 }
730 return ERR_NONE;
731 }
732
HandleGetSessionInfo(MessageParcel & data,MessageParcel & reply)733 int SceneSessionManagerStub::HandleGetSessionInfo(MessageParcel& data, MessageParcel& reply)
734 {
735 TLOGD(WmsLogTag::WMS_LIFE, "In!");
736 std::string deviceId = Str16ToStr8(data.ReadString16());
737 int32_t persistentId;
738 if (!data.ReadInt32(persistentId)) {
739 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId failed");
740 return ERR_INVALID_DATA;
741 }
742 SessionInfoBean info;
743 WSError errCode = GetSessionInfo(deviceId, persistentId, info);
744 if (!reply.WriteParcelable(&info)) {
745 TLOGE(WmsLogTag::WMS_LIFE, "Write sessionInfo error");
746 return ERR_INVALID_DATA;
747 }
748
749 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
750 TLOGE(WmsLogTag::WMS_LIFE, "Write result error");
751 return ERR_INVALID_DATA;
752 }
753 return ERR_NONE;
754 }
755
756
HandleGetSessionInfoByContinueSessionId(MessageParcel & data,MessageParcel & reply)757 int SceneSessionManagerStub::HandleGetSessionInfoByContinueSessionId(MessageParcel& data, MessageParcel& reply)
758 {
759 TLOGD(WmsLogTag::WMS_LIFE, "In!");
760 SessionInfoBean info;
761 std::string continueSessionId;
762 if (!data.ReadString(continueSessionId)) {
763 TLOGE(WmsLogTag::WMS_LIFE, "Read continueSessionId failed");
764 return ERR_INVALID_DATA;
765 }
766 TLOGI(WmsLogTag::WMS_LIFE, "continueSessionId: %{public}s", continueSessionId.c_str());
767 WSError errCode = GetSessionInfoByContinueSessionId(continueSessionId, info);
768 if (!reply.WriteParcelable(&info)) {
769 TLOGE(WmsLogTag::WMS_LIFE, "GetSessionInfo error");
770 return ERR_INVALID_DATA;
771 }
772
773 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
774 TLOGE(WmsLogTag::WMS_LIFE, "GetSessionInfo result error");
775 return ERR_INVALID_DATA;
776 }
777 return ERR_NONE;
778 }
779
HandleDumpSessionAll(MessageParcel & data,MessageParcel & reply)780 int SceneSessionManagerStub::HandleDumpSessionAll(MessageParcel& data, MessageParcel& reply)
781 {
782 WLOGFI("run HandleDumpSessionAll!");
783 std::vector<std::string> infos;
784 WSError errCode = DumpSessionAll(infos);
785 if (!reply.WriteStringVector(infos)) {
786 WLOGFE("HandleDumpSessionAll write info failed.");
787 return ERR_TRANSACTION_FAILED;
788 }
789
790 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
791 WLOGFE("HandleDumpSessionAll write errcode failed.");
792 return ERR_TRANSACTION_FAILED;
793 }
794 return ERR_NONE;
795 }
796
HandleDumpSessionWithId(MessageParcel & data,MessageParcel & reply)797 int SceneSessionManagerStub::HandleDumpSessionWithId(MessageParcel& data, MessageParcel& reply)
798 {
799 TLOGD(WmsLogTag::DEFAULT, "In!");
800 int32_t persistentId;
801 if (!data.ReadInt32(persistentId)) {
802 TLOGE(WmsLogTag::DEFAULT, "read persistentId failed.");
803 return ERR_INVALID_DATA;
804 }
805 std::vector<std::string> infos;
806 WSError errCode = DumpSessionWithId(persistentId, infos);
807 if (!reply.WriteStringVector(infos)) {
808 TLOGE(WmsLogTag::DEFAULT, "write info failed.");
809 return ERR_TRANSACTION_FAILED;
810 }
811
812 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
813 TLOGE(WmsLogTag::DEFAULT, "write errcode failed.");
814 return ERR_TRANSACTION_FAILED;
815 }
816 return ERR_NONE;
817 }
818
HandleTerminateSessionNew(MessageParcel & data,MessageParcel & reply)819 int SceneSessionManagerStub::HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply)
820 {
821 TLOGD(WmsLogTag::WMS_LIFE, "in");
822 sptr<AAFwk::SessionInfo> abilitySessionInfo = data.ReadParcelable<AAFwk::SessionInfo>();
823 if (abilitySessionInfo == nullptr) {
824 TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfo is null");
825 return ERR_INVALID_DATA;
826 }
827 bool needStartCaller = false;
828 if (!data.ReadBool(needStartCaller)) {
829 TLOGE(WmsLogTag::WMS_LIFE, "Read needStartCaller failed.");
830 return ERR_INVALID_DATA;
831 }
832 bool isFromBroker = false;
833 if (!data.ReadBool(isFromBroker)) {
834 TLOGE(WmsLogTag::WMS_LIFE, "Read isFromBroker failed.");
835 return ERR_INVALID_DATA;
836 }
837 WSError errCode = TerminateSessionNew(abilitySessionInfo, needStartCaller, isFromBroker);
838 reply.WriteUint32(static_cast<uint32_t>(errCode));
839 return ERR_NONE;
840 }
841
HandleGetFocusSessionToken(MessageParcel & data,MessageParcel & reply)842 int SceneSessionManagerStub::HandleGetFocusSessionToken(MessageParcel& data, MessageParcel& reply)
843 {
844 WLOGFD("run HandleGetFocusSessionToken!");
845 sptr<IRemoteObject> token = nullptr;
846 uint64_t displayId = 0;
847 if (!data.ReadUint64(displayId)) {
848 TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId");
849 return ERR_INVALID_DATA;
850 }
851 WSError errCode = GetFocusSessionToken(token, displayId);
852 reply.WriteRemoteObject(token);
853 reply.WriteInt32(static_cast<int32_t>(errCode));
854 return ERR_NONE;
855 }
856
HandleGetFocusSessionElement(MessageParcel & data,MessageParcel & reply)857 int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel& data, MessageParcel& reply)
858 {
859 WLOGFD("run HandleGetFocusSessionElement!");
860 AppExecFwk::ElementName element;
861 uint64_t displayId = 0;
862 if (!data.ReadUint64(displayId)) {
863 TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId");
864 return ERR_INVALID_DATA;
865 }
866 WSError errCode = GetFocusSessionElement(element, displayId);
867 reply.WriteParcelable(&element);
868 reply.WriteInt32(static_cast<int32_t>(errCode));
869 return ERR_NONE;
870 }
871
HandleCheckWindowId(MessageParcel & data,MessageParcel & reply)872 int SceneSessionManagerStub::HandleCheckWindowId(MessageParcel& data, MessageParcel& reply)
873 {
874 WLOGFI("run HandleCheckWindowId!");
875 int32_t windowId = INVALID_WINDOW_ID;
876 if (!data.ReadInt32(windowId)) {
877 WLOGE("Failed to readInt32 windowId");
878 return ERR_INVALID_DATA;
879 }
880 int32_t pid = INVALID_PID;
881 WMError errCode = CheckWindowId(windowId, pid);
882 if (errCode != WMError::WM_OK) {
883 WLOGE("Failed to checkWindowId(%{public}d)", pid);
884 return ERR_INVALID_DATA;
885 }
886 if (!reply.WriteInt32(pid)) {
887 WLOGE("Failed to WriteInt32 pid");
888 return ERR_INVALID_DATA;
889 }
890 return ERR_NONE;
891 }
892
HandleSetGestureNavigationEnabled(MessageParcel & data,MessageParcel & reply)893 int SceneSessionManagerStub::HandleSetGestureNavigationEnabled(MessageParcel& data, MessageParcel& reply)
894 {
895 TLOGD(WmsLogTag::DEFAULT, "Run");
896 bool enable = false;
897 if (!data.ReadBool(enable)) {
898 return ERR_INVALID_DATA;
899 }
900 const WMError &ret = SetGestureNavigationEnabled(enable);
901 reply.WriteInt32(static_cast<int32_t>(ret));
902 return ERR_NONE;
903 }
904
HandleGetAccessibilityWindowInfo(MessageParcel & data,MessageParcel & reply)905 int SceneSessionManagerStub::HandleGetAccessibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
906 {
907 std::vector<sptr<AccessibilityWindowInfo>> infos;
908 WMError errCode = GetAccessibilityWindowInfo(infos);
909 if (!MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(reply, infos)) {
910 WLOGFE("Write window infos failed.");
911 return ERR_TRANSACTION_FAILED;
912 }
913 reply.WriteInt32(static_cast<int32_t>(errCode));
914 return ERR_NONE;
915 }
916
HandleGetUnreliableWindowInfo(MessageParcel & data,MessageParcel & reply)917 int SceneSessionManagerStub::HandleGetUnreliableWindowInfo(MessageParcel& data, MessageParcel& reply)
918 {
919 TLOGD(WmsLogTag::DEFAULT, "run!");
920 std::vector<sptr<UnreliableWindowInfo>> infos;
921 int32_t windowId = INVALID_WINDOW_ID;
922 if (!data.ReadInt32(windowId)) {
923 TLOGE(WmsLogTag::DEFAULT, "Failed to readInt32 windowId");
924 return ERR_INVALID_DATA;
925 }
926 WMError errCode = GetUnreliableWindowInfo(windowId, infos);
927 if (!MarshallingHelper::MarshallingVectorParcelableObj<UnreliableWindowInfo>(reply, infos)) {
928 TLOGE(WmsLogTag::DEFAULT, "Write unreliable window infos failed.");
929 return ERR_TRANSACTION_FAILED;
930 }
931 reply.WriteInt32(static_cast<int32_t>(errCode));
932 return ERR_NONE;
933 }
934
HandleSetSessionContinueState(MessageParcel & data,MessageParcel & reply)935 int SceneSessionManagerStub::HandleSetSessionContinueState(MessageParcel& data, MessageParcel& reply)
936 {
937 WLOGFI("HandleSetSessionContinueState");
938 sptr <IRemoteObject> token = data.ReadRemoteObject();
939 auto continueState = static_cast<ContinueState>(data.ReadInt32());
940 const WSError &ret = SetSessionContinueState(token, continueState);
941 reply.WriteUint32(static_cast<uint32_t>(ret));
942 return ERR_NONE;
943 }
944
HandleGetSessionDump(MessageParcel & data,MessageParcel & reply)945 int SceneSessionManagerStub::HandleGetSessionDump(MessageParcel& data, MessageParcel& reply)
946 {
947 std::vector<std::string> params;
948 if (!data.ReadStringVector(¶ms)) {
949 WLOGFE("Fail to read params");
950 return ERR_INVALID_DATA;
951 }
952 std::string dumpInfo;
953 WSError errCode = GetSessionDumpInfo(params, dumpInfo);
954 uint32_t infoSize = static_cast<uint32_t>(dumpInfo.length());
955 TLOGD(WmsLogTag::DEFAULT, "HandleGetSessionDump, infoSize: %{public}d", infoSize);
956 reply.WriteUint32(infoSize);
957 if (infoSize != 0) {
958 if (!reply.WriteRawData(dumpInfo.c_str(), infoSize)) {
959 WLOGFE("Fail to write dumpInfo");
960 return ERR_INVALID_DATA;
961 }
962 }
963 reply.WriteInt32(static_cast<int32_t>(errCode));
964 return ERR_NONE;
965 }
966
HandleUpdateSessionAvoidAreaListener(MessageParcel & data,MessageParcel & reply)967 int SceneSessionManagerStub::HandleUpdateSessionAvoidAreaListener(MessageParcel& data, MessageParcel& reply)
968 {
969 int32_t persistentId = 0;
970 if (!data.ReadInt32(persistentId)) {
971 return ERR_INVALID_DATA;
972 }
973 bool haveAvoidAreaListener = false;
974 if (!data.ReadBool(haveAvoidAreaListener)) {
975 return ERR_INVALID_DATA;
976 }
977 WSError errCode = UpdateSessionAvoidAreaListener(persistentId, haveAvoidAreaListener);
978 reply.WriteUint32(static_cast<uint32_t>(errCode));
979 return ERR_NONE;
980 }
981
HandleGetSessionSnapshot(MessageParcel & data,MessageParcel & reply)982 int SceneSessionManagerStub::HandleGetSessionSnapshot(MessageParcel& data, MessageParcel& reply)
983 {
984 TLOGD(WmsLogTag::WMS_SYSTEM, "Handled!");
985 std::u16string deviceIdData;
986 if (!data.ReadString16(deviceIdData)) {
987 TLOGE(WmsLogTag::WMS_SYSTEM, "read deviceId fail");
988 return ERR_INVALID_DATA;
989 }
990 std::string deviceId = Str16ToStr8(deviceIdData);
991 int32_t persistentId = 0;
992 if (!data.ReadInt32(persistentId)) {
993 TLOGE(WmsLogTag::WMS_SYSTEM, "read persistentId fail");
994 return ERR_INVALID_DATA;
995 }
996 bool isLowResolution = false;
997 if (!data.ReadBool(isLowResolution)) {
998 TLOGE(WmsLogTag::WMS_SYSTEM, "read isLowResolution fail");
999 return ERR_INVALID_DATA;
1000 }
1001 std::shared_ptr<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
1002 WSError ret = GetSessionSnapshot(deviceId, persistentId, *snapshot, isLowResolution);
1003 reply.WriteParcelable(snapshot.get());
1004 reply.WriteUint32(static_cast<uint32_t>(ret));
1005 return ERR_NONE;
1006 }
1007
HandleGetSessionSnapshotById(MessageParcel & data,MessageParcel & reply)1008 int SceneSessionManagerStub::HandleGetSessionSnapshotById(MessageParcel& data, MessageParcel& reply)
1009 {
1010 TLOGD(WmsLogTag::WMS_SYSTEM, "Handled!");
1011 int32_t persistentId = 0;
1012 if (!data.ReadInt32(persistentId)) {
1013 TLOGE(WmsLogTag::WMS_SYSTEM, "read persistentId fail");
1014 return ERR_INVALID_DATA;
1015 }
1016 std::shared_ptr<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
1017 const WMError ret = GetSessionSnapshotById(persistentId, *snapshot);
1018 reply.WriteParcelable(snapshot.get());
1019 reply.WriteInt32(static_cast<int32_t>(ret));
1020 return ERR_NONE;
1021 }
1022
HandleGetUIContentRemoteObj(MessageParcel & data,MessageParcel & reply)1023 int SceneSessionManagerStub::HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply)
1024 {
1025 TLOGD(WmsLogTag::WMS_ATTRIBUTE, "In!");
1026 int32_t persistentId;
1027 if (!data.ReadInt32(persistentId)) {
1028 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read persistentId");
1029 return ERR_INVALID_DATA;
1030 }
1031 sptr<IRemoteObject> uiContentRemoteObj;
1032 WSError ret = GetUIContentRemoteObj(persistentId, uiContentRemoteObj);
1033 reply.WriteRemoteObject(uiContentRemoteObj);
1034 reply.WriteUint32(static_cast<uint32_t>(ret));
1035 return ERR_NONE;
1036 }
1037
HandleBindDialogTarget(MessageParcel & data,MessageParcel & reply)1038 int SceneSessionManagerStub::HandleBindDialogTarget(MessageParcel& data, MessageParcel& reply)
1039 {
1040 WLOGFI("run HandleBindDialogTarget!");
1041 uint64_t persistentId = 0;
1042 if (!data.ReadUint64(persistentId)) {
1043 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId failed");
1044 return ERR_TRANSACTION_FAILED;
1045 }
1046 sptr<IRemoteObject> remoteObject = data.ReadRemoteObject();
1047 WSError ret = BindDialogSessionTarget(persistentId, remoteObject);
1048 reply.WriteUint32(static_cast<uint32_t>(ret));
1049 return ERR_NONE;
1050 }
1051
HandleNotifyDumpInfoResult(MessageParcel & data,MessageParcel & reply)1052 int SceneSessionManagerStub::HandleNotifyDumpInfoResult(MessageParcel& data, MessageParcel& reply)
1053 {
1054 TLOGD(WmsLogTag::DEFAULT, "Enter");
1055 uint32_t vectorSize;
1056 if (!data.ReadUint32(vectorSize)) {
1057 TLOGE(WmsLogTag::DEFAULT, "Failed to read vectorSize");
1058 return ERR_INVALID_DATA;
1059 }
1060 if (vectorSize > MAX_VECTOR_SIZE) {
1061 TLOGE(WmsLogTag::DEFAULT, "Vector is too big!");
1062 return ERR_INVALID_DATA;
1063 }
1064 std::vector<std::string> info;
1065 for (uint32_t i = 0; i < vectorSize; i++) {
1066 uint32_t curSize = data.ReadUint32();
1067 std::string curInfo = "";
1068 if (curSize != 0) {
1069 const char* infoPtr = nullptr;
1070 infoPtr = reinterpret_cast<const char*>(data.ReadRawData(curSize));
1071 curInfo = (infoPtr) ? std::string(infoPtr, curSize) : "";
1072 }
1073 info.emplace_back(curInfo);
1074 TLOGD(WmsLogTag::DEFAULT, "InfoResult count: %{public}u, infoSize: %{public}u", i, curSize);
1075 }
1076 NotifyDumpInfoResult(info);
1077 return ERR_NONE;
1078 }
1079
HandleClearSession(MessageParcel & data,MessageParcel & reply)1080 int SceneSessionManagerStub::HandleClearSession(MessageParcel& data, MessageParcel& reply)
1081 {
1082 TLOGD(WmsLogTag::WMS_LIFE, "In!");
1083 int32_t persistentId;
1084 if (!data.ReadInt32(persistentId)) {
1085 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read persistentId");
1086 return ERR_INVALID_DATA;
1087 }
1088 WSError ret = ClearSession(persistentId);
1089 reply.WriteUint32(static_cast<uint32_t>(ret));
1090 return ERR_NONE;
1091 }
1092
HandleClearAllSessions(MessageParcel & data,MessageParcel & reply)1093 int SceneSessionManagerStub::HandleClearAllSessions(MessageParcel& data, MessageParcel& reply)
1094 {
1095 WLOGFI("run HandleClearAllSessions!");
1096 WSError ret = ClearAllSessions();
1097 reply.WriteUint32(static_cast<uint32_t>(ret));
1098 return ERR_NONE;
1099 }
1100
HandleLockSession(MessageParcel & data,MessageParcel & reply)1101 int SceneSessionManagerStub::HandleLockSession(MessageParcel& data, MessageParcel& reply)
1102 {
1103 TLOGD(WmsLogTag::WMS_LIFE, "In!");
1104 int32_t sessionId;
1105 if (!data.ReadInt32(sessionId)) {
1106 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read sessionId");
1107 return ERR_INVALID_DATA;
1108 }
1109 WSError ret = LockSession(sessionId);
1110 reply.WriteUint32(static_cast<uint32_t>(ret));
1111 return ERR_NONE;
1112 }
HandleUnlockSession(MessageParcel & data,MessageParcel & reply)1113 int SceneSessionManagerStub::HandleUnlockSession(MessageParcel& data, MessageParcel& reply)
1114 {
1115 TLOGD(WmsLogTag::WMS_LIFE, "In!");
1116 int32_t sessionId;
1117 if (!data.ReadInt32(sessionId)) {
1118 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read sessionId");
1119 return ERR_INVALID_DATA;
1120 }
1121 WSError ret = UnlockSession(sessionId);
1122 reply.WriteUint32(static_cast<uint32_t>(ret));
1123 return ERR_NONE;
1124 }
HandleMoveSessionsToForeground(MessageParcel & data,MessageParcel & reply)1125 int SceneSessionManagerStub::HandleMoveSessionsToForeground(MessageParcel& data, MessageParcel& reply)
1126 {
1127 TLOGD(WmsLogTag::WMS_LIFE, "In!");
1128 std::vector<int32_t> sessionIds;
1129 data.ReadInt32Vector(&sessionIds);
1130 int32_t topSessionId;
1131 if (!data.ReadInt32(topSessionId)) {
1132 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read topSessionId");
1133 return ERR_INVALID_DATA;
1134 }
1135 const WSError &ret = MoveSessionsToForeground(sessionIds, topSessionId);
1136 reply.WriteUint32(static_cast<uint32_t>(ret));
1137 return ERR_NONE;
1138 }
HandleMoveSessionsToBackground(MessageParcel & data,MessageParcel & reply)1139 int SceneSessionManagerStub::HandleMoveSessionsToBackground(MessageParcel& data, MessageParcel& reply)
1140 {
1141 WLOGFI("run HandleMoveSessionsToBackground!");
1142 std::vector<int32_t> sessionIds;
1143 data.ReadInt32Vector(&sessionIds);
1144 std::vector<int32_t> result;
1145 data.ReadInt32Vector(&result);
1146 const WSError &ret = MoveSessionsToBackground(sessionIds, result);
1147 reply.WriteInt32Vector(result);
1148 reply.WriteUint32(static_cast<uint32_t>(ret));
1149 return ERR_NONE;
1150 }
1151
HandleRegisterCollaborator(MessageParcel & data,MessageParcel & reply)1152 int SceneSessionManagerStub::HandleRegisterCollaborator(MessageParcel& data, MessageParcel& reply)
1153 {
1154 TLOGD(WmsLogTag::WMS_LIFE, "In!");
1155 int32_t type;
1156 if (!data.ReadInt32(type)) {
1157 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read type");
1158 return ERR_INVALID_DATA;
1159 }
1160 sptr<AAFwk::IAbilityManagerCollaborator> collaborator =
1161 iface_cast<AAFwk::IAbilityManagerCollaborator>(data.ReadRemoteObject());
1162 if (collaborator == nullptr) {
1163 TLOGE(WmsLogTag::WMS_LIFE, "collaborator is nullptr");
1164 return ERR_INVALID_DATA;
1165 }
1166 WSError ret = RegisterIAbilityManagerCollaborator(type, collaborator);
1167 reply.WriteUint32(static_cast<uint32_t>(ret));
1168 return ERR_NONE;
1169 }
1170
HandleUnregisterCollaborator(MessageParcel & data,MessageParcel & reply)1171 int SceneSessionManagerStub::HandleUnregisterCollaborator(MessageParcel& data, MessageParcel& reply)
1172 {
1173 TLOGD(WmsLogTag::WMS_LIFE, "In!");
1174 int32_t type;
1175 if (!data.ReadInt32(type)) {
1176 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read type");
1177 return ERR_INVALID_DATA;
1178 }
1179 WSError ret = UnregisterIAbilityManagerCollaborator(type);
1180 reply.WriteUint32(static_cast<uint32_t>(ret));
1181 return ERR_NONE;
1182 }
1183
HandleUpdateSessionTouchOutsideListener(MessageParcel & data,MessageParcel & reply)1184 int SceneSessionManagerStub::HandleUpdateSessionTouchOutsideListener(MessageParcel& data, MessageParcel& reply)
1185 {
1186 int32_t persistentId = 0;
1187 if (!data.ReadInt32(persistentId)) {
1188 TLOGE(WmsLogTag::WMS_INPUT_KEY_FLOW, "read persistentId failed");
1189 return ERR_INVALID_DATA;
1190 }
1191 bool haveAvoidAreaListener = false;
1192 if (!data.ReadBool(haveAvoidAreaListener)) {
1193 TLOGE(WmsLogTag::WMS_INPUT_KEY_FLOW, "read haveAvoidAreaListener fail");
1194 return ERR_INVALID_DATA;
1195 }
1196 WSError errCode = UpdateSessionTouchOutsideListener(persistentId, haveAvoidAreaListener);
1197 reply.WriteUint32(static_cast<uint32_t>(errCode));
1198 return ERR_NONE;
1199 }
1200
HandleRaiseWindowToTop(MessageParcel & data,MessageParcel & reply)1201 int SceneSessionManagerStub::HandleRaiseWindowToTop(MessageParcel& data, MessageParcel& reply)
1202 {
1203 auto persistentId = 0;
1204 if (!data.ReadInt32(persistentId)) {
1205 TLOGE(WmsLogTag::WMS_HIERARCHY, "read persistentId failed");
1206 return ERR_INVALID_DATA;
1207 }
1208 WSError errCode = RaiseWindowToTop(persistentId);
1209 reply.WriteUint32(static_cast<uint32_t>(errCode));
1210 return ERR_NONE;
1211 }
1212
HandleNotifyWindowExtensionVisibilityChange(MessageParcel & data,MessageParcel & reply)1213 int SceneSessionManagerStub::HandleNotifyWindowExtensionVisibilityChange(MessageParcel& data, MessageParcel& reply)
1214 {
1215 TLOGD(WmsLogTag::WMS_UIEXT, "In!");
1216 int32_t pid;
1217 if (!data.ReadInt32(pid)) {
1218 TLOGE(WmsLogTag::WMS_UIEXT, "read pid failed");
1219 return ERR_INVALID_DATA;
1220 }
1221 int32_t uid;
1222 if (!data.ReadInt32(uid)) {
1223 TLOGE(WmsLogTag::WMS_UIEXT, "read uid failed");
1224 return ERR_INVALID_DATA;
1225 }
1226 bool visible;
1227 if (!data.ReadBool(visible)) {
1228 TLOGE(WmsLogTag::WMS_UIEXT, "read visible failed");
1229 return ERR_INVALID_DATA;
1230 }
1231 TLOGD(WmsLogTag::WMS_UIEXT, "pid:%{public}d, uid:%{public}d, visible:%{public}d", pid, uid, visible);
1232 WSError ret = NotifyWindowExtensionVisibilityChange(pid, uid, visible);
1233 reply.WriteUint32(static_cast<uint32_t>(ret));
1234 return ERR_NONE;
1235 }
1236
HandleGetTopWindowId(MessageParcel & data,MessageParcel & reply)1237 int SceneSessionManagerStub::HandleGetTopWindowId(MessageParcel& data, MessageParcel& reply)
1238 {
1239 uint32_t mainWinId = 0;
1240 if (!data.ReadUint32(mainWinId)) {
1241 TLOGE(WmsLogTag::WMS_HIERARCHY, "read mainWinId failed");
1242 return ERR_INVALID_DATA;
1243 }
1244 uint32_t topWinId;
1245 WMError ret = GetTopWindowId(mainWinId, topWinId);
1246 reply.WriteUint32(topWinId);
1247 reply.WriteUint32(static_cast<uint32_t>(ret));
1248 return ERR_NONE;
1249 }
1250
HandleGetParentMainWindowId(MessageParcel & data,MessageParcel & reply)1251 int SceneSessionManagerStub::HandleGetParentMainWindowId(MessageParcel& data, MessageParcel& reply)
1252 {
1253 int32_t windowId = INVALID_SESSION_ID;
1254 if (!data.ReadInt32(windowId)) {
1255 TLOGE(WmsLogTag::WMS_FOCUS, "read windowId failed");
1256 return ERR_INVALID_DATA;
1257 }
1258 int32_t mainWindowId = INVALID_SESSION_ID;
1259 WMError errCode = GetParentMainWindowId(windowId, mainWindowId);
1260 if (!reply.WriteInt32(mainWindowId)) {
1261 return ERR_INVALID_DATA;
1262 }
1263 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1264 return ERR_INVALID_DATA;
1265 }
1266 return ERR_NONE;
1267 }
1268
HandleWatchGestureConsumeResult(MessageParcel & data,MessageParcel & reply)1269 int SceneSessionManagerStub::HandleWatchGestureConsumeResult(MessageParcel& data, MessageParcel& reply)
1270 {
1271 int32_t keyCode = 0;
1272 if (!data.ReadInt32(keyCode)) {
1273 TLOGE(WmsLogTag::WMS_EVENT, "read keyCode failed");
1274 return ERR_INVALID_DATA;
1275 }
1276 bool isConsumed = false;
1277 if (!data.ReadBool(isConsumed)) {
1278 TLOGE(WmsLogTag::WMS_EVENT, "read isConsumed failed");
1279 return ERR_INVALID_DATA;
1280 }
1281 TLOGD(WmsLogTag::WMS_EVENT, "keyCode:%{public}d isConsumed:%{public}d", keyCode, isConsumed);
1282 WMError ret = NotifyWatchGestureConsumeResult(keyCode, isConsumed);
1283 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1284 return ERR_INVALID_DATA;
1285 }
1286 return ERR_NONE;
1287 }
1288
HandleWatchFocusActiveChange(MessageParcel & data,MessageParcel & reply)1289 int SceneSessionManagerStub::HandleWatchFocusActiveChange(MessageParcel& data, MessageParcel& reply)
1290 {
1291 bool isActive = false;
1292 if (!data.ReadBool(isActive)) {
1293 TLOGE(WmsLogTag::WMS_FOCUS, "read isActive failed");
1294 return ERR_INVALID_DATA;
1295 }
1296 TLOGD(WmsLogTag::WMS_EVENT, "isActive:%{public}d", isActive);
1297 WMError ret = NotifyWatchFocusActiveChange(isActive);
1298 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1299 return ERR_INVALID_DATA;
1300 }
1301 return ERR_NONE;
1302 }
1303
HandleUpdateSessionWindowVisibilityListener(MessageParcel & data,MessageParcel & reply)1304 int SceneSessionManagerStub::HandleUpdateSessionWindowVisibilityListener(MessageParcel& data, MessageParcel& reply)
1305 {
1306 TLOGD(WmsLogTag::WMS_ATTRIBUTE, "Handled!");
1307 int32_t persistentId = 0;
1308 if (!data.ReadInt32(persistentId)) {
1309 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read persistentId fail");
1310 return ERR_INVALID_DATA;
1311 }
1312 bool haveListener = false;
1313 if (!data.ReadBool(haveListener)) {
1314 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read haveListener fail");
1315 return ERR_INVALID_DATA;
1316 }
1317 WSError ret = UpdateSessionWindowVisibilityListener(persistentId, haveListener);
1318 reply.WriteUint32(static_cast<uint32_t>(ret));
1319 return ERR_NONE;
1320 }
1321
HandleShiftAppWindowFocus(MessageParcel & data,MessageParcel & reply)1322 int SceneSessionManagerStub::HandleShiftAppWindowFocus(MessageParcel& data, MessageParcel& reply)
1323 {
1324 int32_t sourcePersistentId = 0;
1325 int32_t targetPersistentId = 0;
1326 if (!data.ReadInt32(sourcePersistentId) || !data.ReadInt32(targetPersistentId)) {
1327 TLOGE(WmsLogTag::WMS_FOCUS, "read sourcePersistentId or targetPersistentId failed");
1328 return ERR_INVALID_DATA;
1329 }
1330 WSError ret = ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1331 reply.WriteUint32(static_cast<uint32_t>(ret));
1332 return ERR_NONE;
1333 }
1334
HandleListWindowInfo(MessageParcel & data,MessageParcel & reply)1335 int SceneSessionManagerStub::HandleListWindowInfo(MessageParcel& data, MessageParcel& reply)
1336 {
1337 WindowInfoOption windowInfoOption;
1338 uint8_t windowInfoFilterOptionValue = static_cast<WindowInfoFilterOptionDataType>(WindowInfoFilterOption::ALL);
1339 if (!data.ReadUint8(windowInfoFilterOptionValue)) {
1340 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read windowInfoFilterOption");
1341 return ERR_INVALID_DATA;
1342 }
1343 windowInfoOption.windowInfoFilterOption = static_cast<WindowInfoFilterOption>(windowInfoFilterOptionValue);
1344 uint8_t windowInfoTypeOptionValue = static_cast<WindowInfoTypeOptionDataType>(WindowInfoTypeOption::ALL);
1345 if (!data.ReadUint8(windowInfoTypeOptionValue)) {
1346 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read windowInfoTypeOption");
1347 return ERR_INVALID_DATA;
1348 }
1349 windowInfoOption.windowInfoTypeOption = static_cast<WindowInfoTypeOption>(windowInfoTypeOptionValue);
1350 if (!data.ReadUint64(windowInfoOption.displayId)) {
1351 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read displayId");
1352 return ERR_INVALID_DATA;
1353 }
1354 if (!data.ReadInt32(windowInfoOption.windowId)) {
1355 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read windowId");
1356 return ERR_INVALID_DATA;
1357 }
1358 std::vector<sptr<WindowInfo>> infos;
1359 WMError errCode = ListWindowInfo(windowInfoOption, infos);
1360 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowInfo>(reply, infos)) {
1361 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to write window info");
1362 return ERR_INVALID_DATA;
1363 }
1364 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1365 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail");
1366 return ERR_INVALID_DATA;
1367 }
1368 return ERR_NONE;
1369 }
1370
HandleGetAllWindowLayoutInfo(MessageParcel & data,MessageParcel & reply)1371 int SceneSessionManagerStub::HandleGetAllWindowLayoutInfo(MessageParcel& data, MessageParcel& reply)
1372 {
1373 uint64_t displayId = 0;
1374 if (!data.ReadUint64(displayId)) {
1375 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read displayId");
1376 return ERR_INVALID_DATA;
1377 }
1378 std::vector<sptr<WindowLayoutInfo>> infos;
1379 WMError errCode = GetAllWindowLayoutInfo(displayId, infos);
1380 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowLayoutInfo>(reply, infos)) {
1381 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to write window layout info");
1382 return ERR_INVALID_DATA;
1383 }
1384 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1385 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail");
1386 return ERR_INVALID_DATA;
1387 }
1388 return ERR_NONE;
1389 }
1390
HandleGetGlobalWindowMode(MessageParcel & data,MessageParcel & reply)1391 int SceneSessionManagerStub::HandleGetGlobalWindowMode(MessageParcel& data, MessageParcel& reply)
1392 {
1393 uint64_t displayId = 0;
1394 if (!data.ReadUint64(displayId)) {
1395 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read displayId");
1396 return ERR_INVALID_DATA;
1397 }
1398 GlobalWindowMode globalWinMode = GlobalWindowMode::UNKNOWN;
1399 if (!reply.WriteInt32(static_cast<int32_t>(GetGlobalWindowMode(displayId, globalWinMode)))) {
1400 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail");
1401 return ERR_INVALID_DATA;
1402 }
1403 if (!reply.WriteUint32(static_cast<uint32_t>(globalWinMode))) {
1404 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to write global window mode");
1405 return ERR_INVALID_DATA;
1406 }
1407 return ERR_NONE;
1408 }
1409
HandleGetTopNavDestinationName(MessageParcel & data,MessageParcel & reply)1410 int SceneSessionManagerStub::HandleGetTopNavDestinationName(MessageParcel& data, MessageParcel& reply)
1411 {
1412 int32_t windowId = 0;
1413 if (!data.ReadInt32(windowId)) {
1414 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read windowId fail");
1415 return ERR_INVALID_DATA;
1416 }
1417 std::string topNavDestName;
1418 WMError errCode = GetTopNavDestinationName(windowId, topNavDestName);
1419 if (errCode != WMError::WM_OK) {
1420 TLOGW(WmsLogTag::WMS_ATTRIBUTE, "get top page name failed");
1421 }
1422 uint32_t size = static_cast<uint32_t>(topNavDestName.length());
1423 if (!reply.WriteUint32(size)) {
1424 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write the size of top page name failed");
1425 return ERR_INVALID_DATA;
1426 }
1427 if (size > 0 && !reply.WriteRawData(topNavDestName.c_str(), size)) {
1428 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write top page name failed");
1429 return ERR_INVALID_DATA;
1430 }
1431 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1432 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write error code failed");
1433 return ERR_INVALID_DATA;
1434 }
1435 return ERR_NONE;
1436 }
1437
HandleGetVisibilityWindowInfo(MessageParcel & data,MessageParcel & reply)1438 int SceneSessionManagerStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
1439 {
1440 std::vector<sptr<WindowVisibilityInfo>> infos;
1441 WMError errCode = GetVisibilityWindowInfo(infos);
1442 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowVisibilityInfo>(reply, infos)) {
1443 WLOGFE("Write visibility window infos failed");
1444 return ERR_INVALID_DATA;
1445 }
1446 reply.WriteInt32(static_cast<int32_t>(errCode));
1447 return ERR_NONE;
1448 }
1449
HandleAddExtensionWindowStageToSCB(MessageParcel & data,MessageParcel & reply)1450 int SceneSessionManagerStub::HandleAddExtensionWindowStageToSCB(MessageParcel& data, MessageParcel& reply)
1451 {
1452 TLOGD(WmsLogTag::WMS_UIEXT, "In!");
1453 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
1454 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
1455 if (sessionStage == nullptr) {
1456 TLOGE(WmsLogTag::WMS_UIEXT, "sessionStage is nullptr");
1457 return ERR_INVALID_DATA;
1458 }
1459 sptr<IRemoteObject> token = data.ReadRemoteObject();
1460 uint64_t surfaceNodeId;
1461 if (!data.ReadUint64(surfaceNodeId)) {
1462 TLOGE(WmsLogTag::WMS_UIEXT, "read surfaceNodeId failed");
1463 return ERR_INVALID_DATA;
1464 }
1465 bool isConstrainedModal = false;
1466 if (!data.ReadBool(isConstrainedModal)) {
1467 TLOGE(WmsLogTag::WMS_UIEXT, "read isConstrainedModal failed");
1468 return ERR_INVALID_DATA;
1469 }
1470 AddExtensionWindowStageToSCB(sessionStage, token, surfaceNodeId, isConstrainedModal);
1471 return ERR_NONE;
1472 }
1473
HandleRemoveExtensionWindowStageFromSCB(MessageParcel & data,MessageParcel & reply)1474 int SceneSessionManagerStub::HandleRemoveExtensionWindowStageFromSCB(MessageParcel& data, MessageParcel& reply)
1475 {
1476 sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
1477 sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
1478 if (sessionStage == nullptr) {
1479 WLOGFE("sessionStage is nullptr");
1480 return ERR_INVALID_DATA;
1481 }
1482 sptr<IRemoteObject> token = data.ReadRemoteObject();
1483 bool isConstrainedModal = false;
1484 if (!data.ReadBool(isConstrainedModal)) {
1485 TLOGE(WmsLogTag::WMS_UIEXT, "read isConstrainedModal failed");
1486 return ERR_INVALID_DATA;
1487 }
1488 RemoveExtensionWindowStageFromSCB(sessionStage, token, isConstrainedModal);
1489 return ERR_NONE;
1490 }
1491
HandleUpdateModalExtensionRect(MessageParcel & data,MessageParcel & reply)1492 int SceneSessionManagerStub::HandleUpdateModalExtensionRect(MessageParcel& data, MessageParcel& reply)
1493 {
1494 TLOGD(WmsLogTag::WMS_UIEXT, "In!");
1495 sptr<IRemoteObject> token = data.ReadRemoteObject();
1496 if (token == nullptr) {
1497 TLOGE(WmsLogTag::WMS_UIEXT, "token is nullptr");
1498 return ERR_INVALID_DATA;
1499 }
1500 int32_t rectX;
1501 if (!data.ReadInt32(rectX)) {
1502 TLOGE(WmsLogTag::WMS_UIEXT, "read rectX failed");
1503 return ERR_INVALID_DATA;
1504 }
1505 int32_t rectY;
1506 if (!data.ReadInt32(rectY)) {
1507 TLOGE(WmsLogTag::WMS_UIEXT, "read rectY failed");
1508 return ERR_INVALID_DATA;
1509 }
1510 int32_t rectWidth;
1511 if (!data.ReadInt32(rectWidth)) {
1512 TLOGE(WmsLogTag::WMS_UIEXT, "read rectWidth failed");
1513 return ERR_INVALID_DATA;
1514 }
1515 int32_t rectHeight;
1516 if (!data.ReadInt32(rectHeight)) {
1517 TLOGE(WmsLogTag::WMS_UIEXT, "read rectHeight failed");
1518 return ERR_INVALID_DATA;
1519 }
1520 Rect windowRect{rectX, rectY, rectWidth, rectHeight};
1521 UpdateModalExtensionRect(token, windowRect);
1522 return ERR_NONE;
1523 }
1524
HandleProcessModalExtensionPointDown(MessageParcel & data,MessageParcel & reply)1525 int SceneSessionManagerStub::HandleProcessModalExtensionPointDown(MessageParcel& data, MessageParcel& reply)
1526 {
1527 TLOGD(WmsLogTag::WMS_UIEXT, "In!");
1528 sptr<IRemoteObject> token = data.ReadRemoteObject();
1529 if (token == nullptr) {
1530 TLOGE(WmsLogTag::WMS_UIEXT, "token is nullptr");
1531 return ERR_INVALID_DATA;
1532 }
1533 int32_t posX;
1534 if (!data.ReadInt32(posX)) {
1535 TLOGE(WmsLogTag::WMS_UIEXT, "read posX failed");
1536 return ERR_INVALID_DATA;
1537 }
1538 int32_t posY;
1539 if (!data.ReadInt32(posY)) {
1540 TLOGE(WmsLogTag::WMS_UIEXT, "read posY failed");
1541 return ERR_INVALID_DATA;
1542 }
1543 ProcessModalExtensionPointDown(token, posX, posY);
1544 return ERR_NONE;
1545 }
1546
HandleAddOrRemoveSecureSession(MessageParcel & data,MessageParcel & reply)1547 int SceneSessionManagerStub::HandleAddOrRemoveSecureSession(MessageParcel& data, MessageParcel& reply)
1548 {
1549 TLOGD(WmsLogTag::WMS_UIEXT, "In!");
1550 int32_t persistentId;
1551 if (!data.ReadInt32(persistentId)) {
1552 TLOGE(WmsLogTag::WMS_UIEXT, "read persistentId failed");
1553 return ERR_INVALID_DATA;
1554 }
1555 bool shouldHide;
1556 if (!data.ReadBool(shouldHide)) {
1557 TLOGE(WmsLogTag::WMS_UIEXT, "read shouldHide failed");
1558 return ERR_INVALID_DATA;
1559 }
1560 WSError ret = AddOrRemoveSecureSession(persistentId, shouldHide);
1561 reply.WriteInt32(static_cast<int32_t>(ret));
1562 return ERR_NONE;
1563 }
1564
HandleUpdateExtWindowFlags(MessageParcel & data,MessageParcel & reply)1565 int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel& data, MessageParcel& reply)
1566 {
1567 TLOGD(WmsLogTag::WMS_UIEXT, "In!");
1568 sptr<IRemoteObject> token = data.ReadRemoteObject();
1569 if (token == nullptr) {
1570 TLOGE(WmsLogTag::WMS_UIEXT, "token is nullptr");
1571 return ERR_INVALID_DATA;
1572 }
1573 uint32_t extWindowFlags;
1574 if (!data.ReadUint32(extWindowFlags)) {
1575 TLOGE(WmsLogTag::WMS_UIEXT, "read extWindowFlags failed");
1576 return ERR_INVALID_DATA;
1577 }
1578 uint32_t extWindowActions;
1579 if (!data.ReadUint32(extWindowActions)) {
1580 TLOGE(WmsLogTag::WMS_UIEXT, "read extWindowActions failed");
1581 return ERR_INVALID_DATA;
1582 }
1583 WSError ret = UpdateExtWindowFlags(token, extWindowFlags, extWindowActions);
1584 reply.WriteInt32(static_cast<int32_t>(ret));
1585 return ERR_NONE;
1586 }
1587
HandleGetHostWindowRect(MessageParcel & data,MessageParcel & reply)1588 int SceneSessionManagerStub::HandleGetHostWindowRect(MessageParcel& data, MessageParcel& reply)
1589 {
1590 TLOGD(WmsLogTag::WMS_UIEXT, "Handled!");
1591 int32_t hostWindowId = 0;
1592 if (!data.ReadInt32(hostWindowId)) {
1593 TLOGE(WmsLogTag::WMS_UIEXT, "read hostWindowId fail");
1594 return ERR_INVALID_DATA;
1595 }
1596 Rect rect;
1597 WSError ret = GetHostWindowRect(hostWindowId, rect);
1598 reply.WriteInt32(rect.posX_);
1599 reply.WriteInt32(rect.posY_);
1600 reply.WriteUint32(rect.width_);
1601 reply.WriteUint32(rect.height_);
1602 reply.WriteInt32(static_cast<int32_t>(ret));
1603 return ERR_NONE;
1604 }
1605
HandleGetHostGlobalScaledRect(MessageParcel & data,MessageParcel & reply)1606 int SceneSessionManagerStub::HandleGetHostGlobalScaledRect(MessageParcel& data, MessageParcel& reply)
1607 {
1608 TLOGD(WmsLogTag::WMS_UIEXT, "Handled!");
1609 int32_t hostWindowId = 0;
1610 if (!data.ReadInt32(hostWindowId)) {
1611 TLOGE(WmsLogTag::WMS_UIEXT, "read hostWindowId fail");
1612 return ERR_INVALID_DATA;
1613 }
1614 Rect rect;
1615 WSError ret = GetHostGlobalScaledRect(hostWindowId, rect);
1616 reply.WriteInt32(rect.posX_);
1617 reply.WriteInt32(rect.posY_);
1618 reply.WriteUint32(rect.width_);
1619 reply.WriteUint32(rect.height_);
1620 reply.WriteInt32(static_cast<int32_t>(ret));
1621 return ERR_NONE;
1622 }
1623
HandleGetFreeMultiWindowEnableState(MessageParcel & data,MessageParcel & reply)1624 int SceneSessionManagerStub::HandleGetFreeMultiWindowEnableState(MessageParcel& data, MessageParcel& reply)
1625 {
1626 TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "run HandleGetFreeMultiWindowEnableState!");
1627 bool enable = false;
1628 WSError ret = GetFreeMultiWindowEnableState(enable);
1629 reply.WriteBool(enable);
1630 reply.WriteInt32(static_cast<int32_t>(ret));
1631 return ERR_NONE;
1632 }
1633
HandleGetCallingWindowWindowStatus(MessageParcel & data,MessageParcel & reply)1634 int SceneSessionManagerStub::HandleGetCallingWindowWindowStatus(MessageParcel&data, MessageParcel&reply)
1635 {
1636 TLOGD(WmsLogTag::WMS_KEYBOARD, "In!");
1637 int32_t persistentId;
1638 if (!data.ReadInt32(persistentId)) {
1639 TLOGE(WmsLogTag::WMS_KEYBOARD, "read persistentId failed");
1640 return ERR_INVALID_DATA;
1641 }
1642 WindowStatus windowStatus = WindowStatus::WINDOW_STATUS_UNDEFINED;
1643 WMError ret = GetCallingWindowWindowStatus(persistentId, windowStatus);
1644 reply.WriteUint32(static_cast<int32_t>(ret));
1645 if (ret != WMError::WM_OK) {
1646 TLOGE(WmsLogTag::WMS_KEYBOARD, "Failed to GetCallingWindowWindowStatus(%{public}d)", persistentId);
1647 return ERR_INVALID_DATA;
1648 }
1649 reply.WriteUint32(static_cast<uint32_t>(windowStatus));
1650 return ERR_NONE;
1651 }
1652
HandleGetCallingWindowRect(MessageParcel & data,MessageParcel & reply)1653 int SceneSessionManagerStub::HandleGetCallingWindowRect(MessageParcel&data, MessageParcel& reply)
1654 {
1655 TLOGD(WmsLogTag::WMS_KEYBOARD, "In!");
1656 int32_t persistentId;
1657 if (!data.ReadInt32(persistentId)) {
1658 TLOGE(WmsLogTag::WMS_KEYBOARD, "read persistentId failed");
1659 return ERR_INVALID_DATA;
1660 }
1661 Rect rect = {0, 0, 0, 0};
1662 WMError ret = GetCallingWindowRect(persistentId, rect);
1663 reply.WriteInt32(static_cast<int32_t>(ret));
1664 if (ret != WMError::WM_OK) {
1665 TLOGE(WmsLogTag::WMS_KEYBOARD, "Failed to GetCallingWindowRect(%{public}d)", persistentId);
1666 return ERR_INVALID_DATA;
1667 }
1668 reply.WriteInt32(rect.posX_);
1669 reply.WriteInt32(rect.posY_);
1670 reply.WriteUint32(rect.width_);
1671 reply.WriteUint32(rect.height_);
1672 return ERR_NONE;
1673 }
1674
HandleGetWindowModeType(MessageParcel & data,MessageParcel & reply)1675 int SceneSessionManagerStub::HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply)
1676 {
1677 WindowModeType windowModeType = Rosen::WindowModeType::WINDOW_MODE_OTHER;
1678 WMError errCode = GetWindowModeType(windowModeType);
1679 WLOGFI("run HandleGetWindowModeType, windowModeType:%{public}d!", static_cast<int32_t>(windowModeType));
1680 if (!reply.WriteUint32(static_cast<int32_t>(windowModeType))) {
1681 WLOGE("Failed to WriteBool");
1682 return ERR_INVALID_DATA;
1683 }
1684 reply.WriteInt32(static_cast<int32_t>(errCode));
1685 return ERR_NONE;
1686 }
1687
HandleGetWindowStyleType(MessageParcel & data,MessageParcel & reply)1688 int SceneSessionManagerStub::HandleGetWindowStyleType(MessageParcel& data, MessageParcel& reply)
1689 {
1690 WindowStyleType windowStyleType = Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT;
1691 WMError errCode = GetWindowStyleType(windowStyleType);
1692 TLOGI(WmsLogTag::WMS_LIFE, "windowStyleType:%{public}d!", static_cast<int32_t>(windowStyleType));
1693 if (!reply.WriteUint32(static_cast<int32_t>(windowStyleType))) {
1694 TLOGE(WmsLogTag::WMS_LIFE, "Failed to WriteBool");
1695 return ERR_INVALID_DATA;
1696 }
1697 reply.WriteInt32(static_cast<int32_t>(errCode));
1698 return ERR_NONE;
1699 }
1700
HandleGetProcessSurfaceNodeIdByPersistentId(MessageParcel & data,MessageParcel & reply)1701 int SceneSessionManagerStub::HandleGetProcessSurfaceNodeIdByPersistentId(MessageParcel& data, MessageParcel& reply)
1702 {
1703 TLOGD(WmsLogTag::WMS_ATTRIBUTE, "Handled!");
1704 int32_t pid = 0;
1705 if (!data.ReadInt32(pid)) {
1706 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readInt32 pid");
1707 return ERR_INVALID_DATA;
1708 }
1709 std::vector<int32_t> persistentIds;
1710 if (!data.ReadInt32Vector(&persistentIds)) {
1711 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readInt32Vector persistentIds");
1712 return ERR_INVALID_DATA;
1713 }
1714 std::vector<uint64_t> surfaceNodeIds;
1715 WMError errCode = GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds);
1716 if (!reply.WriteUInt64Vector(surfaceNodeIds)) {
1717 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write surfaceNodeIds fail.");
1718 return ERR_INVALID_DATA;
1719 }
1720 reply.WriteInt32(static_cast<int32_t>(errCode));
1721 return ERR_NONE;
1722 }
1723
HandleSkipSnapshotForAppProcess(MessageParcel & data,MessageParcel & reply)1724 int SceneSessionManagerStub::HandleSkipSnapshotForAppProcess(MessageParcel& data, MessageParcel& reply)
1725 {
1726 int32_t pid = INVALID_PID;
1727 if (!data.ReadInt32(pid)) {
1728 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readInt32 pid");
1729 return ERR_INVALID_DATA;
1730 }
1731 bool skip = false;
1732 if (!data.ReadBool(skip)) {
1733 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readBool skip");
1734 return ERR_INVALID_DATA;
1735 }
1736 WMError errCode = SkipSnapshotForAppProcess(pid, skip);
1737 reply.WriteInt32(static_cast<int32_t>(errCode));
1738 return ERR_NONE;
1739 }
1740
HandleSkipSnapshotByUserIdAndBundleNames(MessageParcel & data,MessageParcel & reply)1741 int SceneSessionManagerStub::HandleSkipSnapshotByUserIdAndBundleNames(MessageParcel& data, MessageParcel& reply)
1742 {
1743 int32_t userId = -1;
1744 if (!data.ReadInt32(userId)) {
1745 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readInt32 userId");
1746 return ERR_INVALID_DATA;
1747 }
1748 std::vector<std::string> bundleNameList;
1749 if (!data.ReadStringVector(&bundleNameList)) {
1750 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Fail to read bundleNameList");
1751 return ERR_INVALID_DATA;
1752 }
1753 WMError errCode = SkipSnapshotByUserIdAndBundleNames(userId, bundleNameList);
1754 reply.WriteInt32(static_cast<int32_t>(errCode));
1755 return ERR_NONE;
1756 }
1757
1758 // LCOV_EXCL_START
HandleSetProcessWatermark(MessageParcel & data,MessageParcel & reply)1759 int SceneSessionManagerStub::HandleSetProcessWatermark(MessageParcel& data, MessageParcel& reply)
1760 {
1761 int32_t pid = INVALID_PID;
1762 if (!data.ReadInt32(pid)) {
1763 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readInt32 pid");
1764 return ERR_INVALID_DATA;
1765 }
1766 std::string watermarkName;
1767 if (!data.ReadString(watermarkName)) {
1768 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readString watermarkName");
1769 return ERR_INVALID_DATA;
1770 }
1771 bool isEnabled = false;
1772 if (!data.ReadBool(isEnabled)) {
1773 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to readBool isEnabled");
1774 return ERR_INVALID_DATA;
1775 }
1776 WMError errCode = SetProcessWatermark(pid, watermarkName, isEnabled);
1777 reply.WriteInt32(static_cast<int32_t>(errCode));
1778 return ERR_NONE;
1779 }
1780
HandleGetWindowIdsByCoordinate(MessageParcel & data,MessageParcel & reply)1781 int SceneSessionManagerStub::HandleGetWindowIdsByCoordinate(MessageParcel& data, MessageParcel& reply)
1782 {
1783 uint64_t displayId;
1784 if (!data.ReadUint64(displayId)) {
1785 TLOGE(WmsLogTag::DEFAULT, "read displayId failed");
1786 return ERR_INVALID_DATA;
1787 }
1788 int32_t windowNumber;
1789 if (!data.ReadInt32(windowNumber)) {
1790 TLOGE(WmsLogTag::DEFAULT, "read windowNumber failed");
1791 return ERR_INVALID_DATA;
1792 }
1793 int32_t x;
1794 int32_t y;
1795 if (!data.ReadInt32(x) || !data.ReadInt32(y)) {
1796 TLOGE(WmsLogTag::DEFAULT, "read coordinate failed");
1797 return ERR_INVALID_DATA;
1798 }
1799 std::vector<int32_t> windowIds;
1800 WMError errCode = GetWindowIdsByCoordinate(displayId, windowNumber, x, y, windowIds);
1801 reply.WriteInt32(static_cast<int32_t>(errCode));
1802 if (errCode != WMError::WM_OK) {
1803 TLOGE(WmsLogTag::DEFAULT, "failed.");
1804 return ERR_INVALID_DATA;
1805 }
1806 reply.WriteInt32Vector(windowIds);
1807 return ERR_NONE;
1808 }
1809
HandleUpdateSessionScreenLock(MessageParcel & data,MessageParcel & reply)1810 int SceneSessionManagerStub::HandleUpdateSessionScreenLock(MessageParcel& data, MessageParcel& reply)
1811 {
1812 std::string bundleName;
1813 if (!data.ReadString(bundleName)) {
1814 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read bundleName failed.");
1815 return ERR_INVALID_DATA;
1816 }
1817 bool isRelease = false;
1818 if (!data.ReadBool(isRelease)) {
1819 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read isRelease failed.");
1820 return ERR_INVALID_DATA;
1821 }
1822 WMError errCode = UpdateScreenLockStatusForApp(bundleName, isRelease);
1823 reply.WriteInt32(static_cast<int32_t>(errCode));
1824 return ERR_NONE;
1825 }
1826
HandleAddSkipSelfWhenShowOnVirtualScreenList(MessageParcel & data,MessageParcel & reply)1827 int SceneSessionManagerStub::HandleAddSkipSelfWhenShowOnVirtualScreenList(MessageParcel& data, MessageParcel& reply)
1828 {
1829 uint64_t size = 0;
1830 if (!data.ReadUint64(size)) {
1831 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read size failed.");
1832 return ERR_INVALID_DATA;
1833 }
1834 static constexpr uint64_t MAX_SIZE = 100;
1835 if (size > MAX_SIZE) {
1836 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Size too large.");
1837 return ERR_INVALID_DATA;
1838 }
1839 std::vector<int32_t> persistentIds;
1840 for (uint64_t i = 0; i < size; i++) {
1841 int32_t persistentId = 0;
1842 if (!data.ReadInt32(persistentId)) {
1843 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read persistentId failed.");
1844 return ERR_INVALID_DATA;
1845 }
1846 persistentIds.push_back(persistentId);
1847 }
1848 WMError errCode = AddSkipSelfWhenShowOnVirtualScreenList(persistentIds);
1849 reply.WriteInt32(static_cast<int32_t>(errCode));
1850 return ERR_NONE;
1851 }
1852
HandleRemoveSkipSelfWhenShowOnVirtualScreenList(MessageParcel & data,MessageParcel & reply)1853 int SceneSessionManagerStub::HandleRemoveSkipSelfWhenShowOnVirtualScreenList(MessageParcel& data, MessageParcel& reply)
1854 {
1855 uint64_t size = 0;
1856 if (!data.ReadUint64(size)) {
1857 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read size failed.");
1858 return ERR_INVALID_DATA;
1859 }
1860 static constexpr uint64_t MAX_SIZE = 100;
1861 if (size > MAX_SIZE) {
1862 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Size too large.");
1863 return ERR_INVALID_DATA;
1864 }
1865 std::vector<int32_t> persistentIds;
1866 for (uint64_t i = 0; i < size; i++) {
1867 int32_t persistentId = 0;
1868 if (!data.ReadInt32(persistentId)) {
1869 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read persistentId failed.");
1870 return ERR_INVALID_DATA;
1871 }
1872 persistentIds.push_back(persistentId);
1873 }
1874 WMError errCode = RemoveSkipSelfWhenShowOnVirtualScreenList(persistentIds);
1875 reply.WriteInt32(static_cast<int32_t>(errCode));
1876 return ERR_NONE;
1877 }
1878
HandleSetScreenPrivacyWindowTagSwitch(MessageParcel & data,MessageParcel & reply)1879 int SceneSessionManagerStub::HandleSetScreenPrivacyWindowTagSwitch(MessageParcel& data, MessageParcel& reply)
1880 {
1881 uint64_t screenId = INVALID_SCREEN_ID;
1882 if (!data.ReadUint64(screenId)) {
1883 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read screenId failed.");
1884 return ERR_INVALID_DATA;
1885 }
1886
1887 uint64_t size = 0;
1888 if (!data.ReadUint64(size)) {
1889 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read size failed.");
1890 return ERR_INVALID_DATA;
1891 }
1892
1893 if (size > MAX_VECTOR_SIZE) {
1894 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Vector is too big, size is %{public}" PRIu64, size);
1895 return ERR_INVALID_DATA;
1896 }
1897
1898 std::vector<std::string> privacyWindowTags;
1899 for (uint64_t i = 0; i < size; i++) {
1900 std::string privacyWidnowTag;
1901 if (!data.ReadString(privacyWidnowTag)) {
1902 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read privacyWidnowTag failed.");
1903 return ERR_INVALID_DATA;
1904 }
1905 privacyWindowTags.push_back(privacyWidnowTag);
1906 }
1907
1908 bool enable;
1909 if (!data.ReadBool(enable)) {
1910 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read enable failed.");
1911 return ERR_INVALID_DATA;
1912 }
1913
1914 WMError errCode = SetScreenPrivacyWindowTagSwitch(screenId, privacyWindowTags, enable);
1915 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1916 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail.");
1917 return ERR_INVALID_DATA;
1918 }
1919 return ERR_NONE;
1920 }
1921
HandleIsPcWindow(MessageParcel & data,MessageParcel & reply)1922 int SceneSessionManagerStub::HandleIsPcWindow(MessageParcel& data, MessageParcel& reply)
1923 {
1924 bool isPcWindow = false;
1925 WMError errCode = IsPcWindow(isPcWindow);
1926 if (!reply.WriteBool(isPcWindow)) {
1927 TLOGE(WmsLogTag::WMS_UIEXT, "Write isPcWindow fail.");
1928 return ERR_INVALID_DATA;
1929 }
1930 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1931 TLOGE(WmsLogTag::WMS_UIEXT, "Write errCode fail.");
1932 return ERR_INVALID_DATA;
1933 }
1934 return ERR_NONE;
1935 }
1936
HandleIsFreeMultiWindow(MessageParcel & data,MessageParcel & reply)1937 int SceneSessionManagerStub::HandleIsFreeMultiWindow(MessageParcel& data, MessageParcel& reply)
1938 {
1939 bool isFreeMultiWindow = false;
1940 WMError errCode = IsFreeMultiWindow(isFreeMultiWindow);
1941 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1942 TLOGE(WmsLogTag::WMS_PC, "Write errorCode fail.");
1943 return ERR_INVALID_DATA;
1944 }
1945
1946 if (WMError::WM_OK == errCode && !reply.WriteBool(isFreeMultiWindow)) {
1947 TLOGE(WmsLogTag::WMS_PC, "Write isFreeMultiWindow fail.");
1948 return ERR_INVALID_DATA;
1949 }
1950 return ERR_NONE;
1951 }
1952
HandleIsPcOrPadFreeMultiWindowMode(MessageParcel & data,MessageParcel & reply)1953 int SceneSessionManagerStub::HandleIsPcOrPadFreeMultiWindowMode(MessageParcel& data, MessageParcel& reply)
1954 {
1955 bool isPcOrPadFreeMultiWindowMode = false;
1956 WMError errCode = IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
1957 if (!reply.WriteBool(isPcOrPadFreeMultiWindowMode)) {
1958 TLOGE(WmsLogTag::WMS_SUB, "Write isPcOrPadFreeMultiWindowMode fail.");
1959 return ERR_INVALID_DATA;
1960 }
1961 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1962 TLOGE(WmsLogTag::WMS_SUB, "Write errCode fail.");
1963 return ERR_INVALID_DATA;
1964 }
1965 return ERR_NONE;
1966 }
1967
HandleGetDisplayIdByWindowId(MessageParcel & data,MessageParcel & reply)1968 int SceneSessionManagerStub::HandleGetDisplayIdByWindowId(MessageParcel& data, MessageParcel& reply)
1969 {
1970 std::vector<uint64_t> windowIds;
1971 if (!data.ReadUInt64Vector(&windowIds)) {
1972 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read windowIds Failed");
1973 return ERR_INVALID_DATA;
1974 }
1975 std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
1976 WMError errCode = GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
1977 if (!reply.WriteInt32(static_cast<int32_t>(windowDisplayIdMap.size()))) {
1978 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowDisplayIdMap size faild");
1979 return ERR_INVALID_DATA;
1980 }
1981 for (auto it = windowDisplayIdMap.begin(); it != windowDisplayIdMap.end(); ++it) {
1982 if (!reply.WriteUint64(it->first)) {
1983 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowId failed");
1984 return ERR_INVALID_DATA;
1985 }
1986 if (!reply.WriteUint64(it->second)) {
1987 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write displayId failed");
1988 return ERR_INVALID_DATA;
1989 }
1990 }
1991 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1992 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail.");
1993 return ERR_INVALID_DATA;
1994 }
1995 return ERR_NONE;
1996 }
1997 // LCOV_EXCL_STOP
1998
HandleIsWindowRectAutoSave(MessageParcel & data,MessageParcel & reply)1999 int SceneSessionManagerStub::HandleIsWindowRectAutoSave(MessageParcel& data, MessageParcel& reply)
2000 {
2001 std::string key;
2002 if (!data.ReadString(key)) {
2003 TLOGE(WmsLogTag::WMS_MAIN, "Read key failed.");
2004 return ERR_INVALID_DATA;
2005 }
2006 int persistentId = 0;
2007 if (!data.ReadInt32(persistentId)) {
2008 TLOGE(WmsLogTag::WMS_MAIN, "Read persistentId failed.");
2009 return ERR_INVALID_DATA;
2010 }
2011 bool enabled = false;
2012 WMError errCode = IsWindowRectAutoSave(key, enabled, persistentId);
2013 if (!reply.WriteBool(enabled)) {
2014 TLOGE(WmsLogTag::WMS_MAIN, "Write enabled failed.");
2015 return ERR_INVALID_DATA;
2016 }
2017 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
2018 TLOGE(WmsLogTag::WMS_MAIN, "Write errCode failed.");
2019 return ERR_INVALID_DATA;
2020 }
2021 return ERR_NONE;
2022 }
2023
HandleSetImageForRecent(MessageParcel & data,MessageParcel & reply)2024 int SceneSessionManagerStub::HandleSetImageForRecent(MessageParcel& data, MessageParcel& reply)
2025 {
2026 uint32_t imgResourceId = 0;
2027 if (!data.ReadUint32(imgResourceId)) {
2028 TLOGE(WmsLogTag::WMS_PATTERN, "Read imgResourceId failed.");
2029 return ERR_INVALID_DATA;
2030 }
2031 uint32_t imageFit = 0;
2032 if (!data.ReadUint32(imageFit)) {
2033 TLOGE(WmsLogTag::WMS_PATTERN, "Read imageFit failed.");
2034 return ERR_INVALID_DATA;
2035 }
2036 int32_t persistentId = 0;
2037 if (!data.ReadInt32(persistentId)) {
2038 TLOGE(WmsLogTag::WMS_PATTERN, "Read persistentId failed.");
2039 return ERR_INVALID_DATA;
2040 }
2041 WMError errCode = SetImageForRecent(imgResourceId, static_cast<ImageFit>(imageFit), persistentId);
2042 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
2043 TLOGE(WmsLogTag::WMS_PATTERN, "Write errCode failed.");
2044 return ERR_INVALID_DATA;
2045 }
2046 return ERR_NONE;
2047 }
2048
HandleSetGlobalDragResizeType(MessageParcel & data,MessageParcel & reply)2049 int SceneSessionManagerStub::HandleSetGlobalDragResizeType(MessageParcel& data, MessageParcel& reply)
2050 {
2051 uint32_t dragResizeType;
2052 if (!data.ReadUint32(dragResizeType)) {
2053 TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed.");
2054 return ERR_INVALID_DATA;
2055 }
2056 if (dragResizeType >= static_cast<uint32_t>(DragResizeType::RESIZE_MAX_VALUE)) {
2057 TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
2058 return ERR_INVALID_DATA;
2059 }
2060 WMError errCode = SetGlobalDragResizeType(static_cast<DragResizeType>(dragResizeType));
2061 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
2062 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
2063 return ERR_INVALID_DATA;
2064 }
2065 return ERR_NONE;
2066 }
2067
HandleGetGlobalDragResizeType(MessageParcel & data,MessageParcel & reply)2068 int SceneSessionManagerStub::HandleGetGlobalDragResizeType(MessageParcel& data, MessageParcel& reply)
2069 {
2070 DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2071 WMError errCode = GetGlobalDragResizeType(dragResizeType);
2072 if (!reply.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
2073 TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed.");
2074 return ERR_INVALID_DATA;
2075 }
2076 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
2077 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
2078 return ERR_INVALID_DATA;
2079 }
2080 return ERR_NONE;
2081 }
2082
HandleSetAppDragResizeType(MessageParcel & data,MessageParcel & reply)2083 int SceneSessionManagerStub::HandleSetAppDragResizeType(MessageParcel& data, MessageParcel& reply)
2084 {
2085 std::string bundleName;
2086 if (!data.ReadString(bundleName)) {
2087 TLOGE(WmsLogTag::WMS_LAYOUT, "Read bundleName failed.");
2088 return ERR_INVALID_DATA;
2089 }
2090 uint32_t dragResizeType;
2091 if (!data.ReadUint32(dragResizeType)) {
2092 TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed.");
2093 return ERR_INVALID_DATA;
2094 }
2095 if (dragResizeType >= static_cast<uint32_t>(DragResizeType::RESIZE_MAX_VALUE)) {
2096 TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
2097 return ERR_INVALID_DATA;
2098 }
2099 WMError errCode = SetAppDragResizeType(bundleName, static_cast<DragResizeType>(dragResizeType));
2100 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
2101 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
2102 return ERR_INVALID_DATA;
2103 }
2104 return ERR_NONE;
2105 }
2106
HandleGetAppDragResizeType(MessageParcel & data,MessageParcel & reply)2107 int SceneSessionManagerStub::HandleGetAppDragResizeType(MessageParcel& data, MessageParcel& reply)
2108 {
2109 std::string bundleName;
2110 if (!data.ReadString(bundleName)) {
2111 TLOGE(WmsLogTag::WMS_LAYOUT, "Read bundleName failed.");
2112 return ERR_INVALID_DATA;
2113 }
2114 DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2115 WMError errCode = GetAppDragResizeType(bundleName, dragResizeType);
2116 if (!reply.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
2117 TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed.");
2118 return ERR_INVALID_DATA;
2119 }
2120 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
2121 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode failed.");
2122 return ERR_INVALID_DATA;
2123 }
2124 return ERR_NONE;
2125 }
2126
HandleSetAppKeyFramePolicy(MessageParcel & data,MessageParcel & reply)2127 int SceneSessionManagerStub::HandleSetAppKeyFramePolicy(MessageParcel& data, MessageParcel& reply)
2128 {
2129 std::string bundleName;
2130 if (!data.ReadString(bundleName)) {
2131 TLOGE(WmsLogTag::WMS_LAYOUT, "Read bundleName failed.");
2132 return ERR_INVALID_DATA;
2133 }
2134 sptr<KeyFramePolicy> keyFramePolicy = data.ReadParcelable<KeyFramePolicy>();
2135 if (!keyFramePolicy) {
2136 TLOGE(WmsLogTag::WMS_LAYOUT, "Read keyFramePolicy failed.");
2137 return ERR_INVALID_DATA;
2138 }
2139 WMError errCode = SetAppKeyFramePolicy(bundleName, *keyFramePolicy);
2140 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2141 TLOGE(WmsLogTag::WMS_LAYOUT, "Write errCode fail.");
2142 return ERR_INVALID_DATA;
2143 }
2144 return ERR_NONE;
2145 }
2146
2147 // LCOV_EXCL_START
HandleShiftAppWindowPointerEvent(MessageParcel & data,MessageParcel & reply)2148 int SceneSessionManagerStub::HandleShiftAppWindowPointerEvent(MessageParcel& data, MessageParcel& reply)
2149 {
2150 int32_t sourcePersistentId = INVALID_WINDOW_ID;
2151 if (!data.ReadInt32(sourcePersistentId)) {
2152 TLOGE(WmsLogTag::WMS_PC, "read sourcePersistentId failed");
2153 return ERR_INVALID_DATA;
2154 }
2155 int32_t targetPersistentId = INVALID_WINDOW_ID;
2156 if (!data.ReadInt32(targetPersistentId)) {
2157 TLOGE(WmsLogTag::WMS_PC, "read targetPersistentId failed");
2158 return ERR_INVALID_DATA;
2159 }
2160 int32_t fingerId = INVALID_FINGER_ID;
2161 if (!data.ReadInt32(fingerId)) {
2162 TLOGE(WmsLogTag::WMS_PC, "read fingerId failed");
2163 return ERR_INVALID_DATA;
2164 }
2165 WMError errCode = ShiftAppWindowPointerEvent(sourcePersistentId, targetPersistentId, fingerId);
2166 reply.WriteInt32(static_cast<int32_t>(errCode));
2167 return ERR_NONE;
2168 }
2169
HandleNotifyScreenshotEvent(MessageParcel & data,MessageParcel & reply)2170 int SceneSessionManagerStub::HandleNotifyScreenshotEvent(MessageParcel& data, MessageParcel& reply)
2171 {
2172 int32_t screenshotEventType = static_cast<int32_t>(ScreenshotEventType::END);
2173 if (!data.ReadInt32(screenshotEventType)) {
2174 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read screenshotEventType");
2175 return ERR_INVALID_DATA;
2176 }
2177 WMError errCode = NotifyScreenshotEvent(static_cast<ScreenshotEventType>(screenshotEventType));
2178 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2179 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail");
2180 return ERR_INVALID_DATA;
2181 }
2182 return ERR_NONE;
2183 }
2184
HandleSetStartWindowBackgroundColor(MessageParcel & data,MessageParcel & reply)2185 int SceneSessionManagerStub::HandleSetStartWindowBackgroundColor(MessageParcel& data, MessageParcel& reply)
2186 {
2187 std::string moduleName;
2188 if (!data.ReadString(moduleName)) {
2189 TLOGE(WmsLogTag::WMS_PATTERN, "read moduleName failed");
2190 return ERR_INVALID_DATA;
2191 }
2192 std::string abilityName;
2193 if (!data.ReadString(abilityName)) {
2194 TLOGE(WmsLogTag::WMS_PATTERN, "read abilityName failed");
2195 return ERR_INVALID_DATA;
2196 }
2197 uint32_t color;
2198 if (!data.ReadUint32(color)) {
2199 TLOGE(WmsLogTag::WMS_PATTERN, "read color failed");
2200 return ERR_INVALID_DATA;
2201 }
2202 int32_t uid;
2203 if (!data.ReadInt32(uid)) {
2204 TLOGE(WmsLogTag::WMS_PATTERN, "read uid failed");
2205 return ERR_INVALID_DATA;
2206 }
2207 WMError errCode = SetStartWindowBackgroundColor(moduleName, abilityName, color, uid);
2208 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2209 TLOGE(WmsLogTag::WMS_PATTERN, "Write errCode failed.");
2210 return ERR_INVALID_DATA;
2211 }
2212 return ERR_NONE;
2213 }
2214 // LCOV_EXCL_STOP
2215
HandleMinimizeByWindowId(MessageParcel & data,MessageParcel & reply)2216 int SceneSessionManagerStub::HandleMinimizeByWindowId(MessageParcel& data, MessageParcel& reply)
2217 {
2218 std::vector<int32_t> windowIds;
2219 if (!data.ReadInt32Vector(&windowIds)) {
2220 TLOGE(WmsLogTag::WMS_LIFE, "read windowIds failed");
2221 return ERR_INVALID_DATA;
2222 }
2223 WMError errCode = MinimizeByWindowId(windowIds);
2224 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2225 TLOGE(WmsLogTag::WMS_LIFE, "Write errCode failed.");
2226 return ERR_INVALID_DATA;
2227 }
2228 return ERR_NONE;
2229 }
2230
HandleSetForegroundWindowNum(MessageParcel & data,MessageParcel & reply)2231 int SceneSessionManagerStub::HandleSetForegroundWindowNum(MessageParcel& data, MessageParcel& reply)
2232 {
2233 uint32_t windowNum = 0;
2234 if (!data.ReadUint32(windowNum)) {
2235 TLOGE(WmsLogTag::WMS_PC, "read windowNum failed");
2236 return ERR_INVALID_DATA;
2237 }
2238 WMError errCode = SetForegroundWindowNum(windowNum);
2239 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2240 TLOGE(WmsLogTag::WMS_PC, "Write errCode failed.");
2241 return ERR_INVALID_DATA;
2242 }
2243 return ERR_NONE;
2244 }
2245
HandleUseImplicitAnimation(MessageParcel & data,MessageParcel & reply)2246 int SceneSessionManagerStub::HandleUseImplicitAnimation(MessageParcel& data, MessageParcel& reply)
2247 {
2248 TLOGD(WmsLogTag::WMS_UIEXT, "Handled!");
2249 int32_t hostWindowId = 0;
2250 if (!data.ReadInt32(hostWindowId)) {
2251 TLOGE(WmsLogTag::WMS_UIEXT, "read hostWindowId fail");
2252 return ERR_INVALID_DATA;
2253 }
2254 bool useImplicit = false;
2255 if (!data.ReadBool(useImplicit)) {
2256 TLOGE(WmsLogTag::WMS_UIEXT, "Read useImplicit failed!");
2257 return ERR_INVALID_DATA;
2258 }
2259 WSError errCode = UseImplicitAnimation(hostWindowId, useImplicit);
2260 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2261 TLOGE(WmsLogTag::WMS_UIEXT, "Write errCode failed.");
2262 return ERR_INVALID_DATA;
2263 }
2264 return ERR_NONE;
2265 }
2266
2267 // LCOV_EXCL_START
HandleAnimateTo(MessageParcel & data,MessageParcel & reply)2268 int SceneSessionManagerStub::HandleAnimateTo(MessageParcel& data, MessageParcel& reply)
2269 {
2270 int32_t windowId = 0;
2271 if (!data.ReadInt32(windowId)) {
2272 TLOGE(WmsLogTag::WMS_ANIMATION, "Read windowId failed");
2273 return ERR_INVALID_DATA;
2274 }
2275 sptr<WindowAnimationProperty> animationProperty = data.ReadStrongParcelable<WindowAnimationProperty>();
2276 if (animationProperty == nullptr) {
2277 TLOGE(WmsLogTag::WMS_ANIMATION, "Read animationProperty failed");
2278 return ERR_INVALID_DATA;
2279 }
2280 sptr<WindowAnimationOption> animationOption = data.ReadStrongParcelable<WindowAnimationOption>();
2281 if (animationOption == nullptr) {
2282 TLOGE(WmsLogTag::WMS_ANIMATION, "Read animationOption failed");
2283 return ERR_INVALID_DATA;
2284 }
2285 WMError errCode = AnimateTo(windowId, *animationProperty, *animationOption);
2286 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2287 TLOGE(WmsLogTag::WMS_ANIMATION, "Write errCode failed");
2288 return ERR_INVALID_DATA;
2289 }
2290 return ERR_NONE;
2291 }
HandleCreateUIEffectController(MessageParcel & data,MessageParcel & reply)2292 int SceneSessionManagerStub::HandleCreateUIEffectController(MessageParcel& data, MessageParcel& reply)
2293 {
2294 sptr<IRemoteObject> controllerObject = data.ReadRemoteObject();
2295 sptr<IUIEffectControllerClient> controllerClient = iface_cast<IUIEffectControllerClient>(controllerObject);
2296 if (controllerObject == nullptr || controllerClient == nullptr) {
2297 TLOGE(WmsLogTag::WMS_ANIMATION, "get client controller failed");
2298 return ERR_INVALID_DATA;
2299 }
2300 sptr<IUIEffectController> controller;
2301 int32_t controllerId = -1;
2302 WMError errCode = CreateUIEffectController(controllerClient, controller, controllerId);
2303 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2304 TLOGE(WmsLogTag::WMS_ANIMATION, "Write errCode failed.");
2305 return ERR_INVALID_DATA;
2306 }
2307 if (errCode != WMError::WM_OK) {
2308 return ERR_NONE;
2309 }
2310 if (!reply.WriteInt32(static_cast<int32_t>(controllerId))) {
2311 TLOGE(WmsLogTag::WMS_ANIMATION, "Write id failed.");
2312 return ERR_INVALID_DATA;
2313 }
2314 if (controller == nullptr) {
2315 TLOGE(WmsLogTag::WMS_ANIMATION, "controller is nullptr.");
2316 return ERR_INVALID_DATA;
2317 }
2318 if (!reply.WriteRemoteObject(controller->AsObject())) {
2319 TLOGE(WmsLogTag::WMS_ANIMATION, "Write controller failed.");
2320 return ERR_INVALID_DATA;
2321 }
2322 return ERR_NONE;
2323 }
2324
HandleAddSessionBlackList(MessageParcel & data,MessageParcel & reply)2325 int SceneSessionManagerStub::HandleAddSessionBlackList(MessageParcel& data, MessageParcel& reply)
2326 {
2327 uint64_t size = 0;
2328 if (!data.ReadUint64(size)) {
2329 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read size failed");
2330 return ERR_INVALID_DATA;
2331 }
2332 if (size > MAX_VECTOR_SIZE) {
2333 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Vector is too big, size is %{public}" PRIu64, size);
2334 return ERR_INVALID_DATA;
2335 }
2336 std::unordered_set<std::string> bundleNames;
2337 for (uint64_t i = 0; i < size; i++) {
2338 std::string bundleName;
2339 if (!data.ReadString(bundleName)) {
2340 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read windowId failed");
2341 return ERR_INVALID_DATA;
2342 }
2343 bundleNames.insert(bundleName);
2344 }
2345
2346 size = 0;
2347 if (!data.ReadUint64(size)) {
2348 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read size failed");
2349 return ERR_INVALID_DATA;
2350 }
2351 if (size > MAX_VECTOR_SIZE) {
2352 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Vector is too big, size is %{public}" PRIu64, size);
2353 return ERR_INVALID_DATA;
2354 }
2355 std::unordered_set<std::string> privacyWindowTags;
2356 for (uint64_t i = 0; i < size; i++) {
2357 std::string privacyWindowTag = 0;
2358 if (!data.ReadString(privacyWindowTag)) {
2359 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read privacyWindowTag failed");
2360 return ERR_INVALID_DATA;
2361 }
2362 privacyWindowTags.insert(privacyWindowTag);
2363 }
2364 WMError errCode = AddSessionBlackList(bundleNames, privacyWindowTags);
2365 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2366 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode failed");
2367 return ERR_INVALID_DATA;
2368 }
2369 return ERR_NONE;
2370 }
2371
HandleRemoveSessionBlackList(MessageParcel & data,MessageParcel & reply)2372 int SceneSessionManagerStub::HandleRemoveSessionBlackList(MessageParcel& data, MessageParcel& reply)
2373 {
2374 uint64_t size = 0;
2375 if (!data.ReadUint64(size)) {
2376 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read size failed");
2377 return ERR_INVALID_DATA;
2378 }
2379 if (size > MAX_VECTOR_SIZE) {
2380 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Vector is too big, size is %{public}" PRIu64, size);
2381 return ERR_INVALID_DATA;
2382 }
2383 std::unordered_set<std::string> bundleNames;
2384 for (uint64_t i = 0; i < size; i++) {
2385 std::string bundleName;
2386 if (!data.ReadString(bundleName)) {
2387 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read bundleName failed");
2388 return ERR_INVALID_DATA;
2389 }
2390 bundleNames.insert(bundleName);
2391 }
2392
2393 size = 0;
2394 if (!data.ReadUint64(size)) {
2395 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read size failed");
2396 return ERR_INVALID_DATA;
2397 }
2398 if (size > MAX_VECTOR_SIZE) {
2399 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Vector is too big, size is %{public}" PRIu64, size);
2400 return ERR_INVALID_DATA;
2401 }
2402 std::unordered_set<std::string> privacyWindowTags;
2403 for (uint64_t i = 0; i < size; i++) {
2404 std::string privacyWindowTag = 0;
2405 if (!data.ReadString(privacyWindowTag)) {
2406 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read privacyWindowTag failed");
2407 return ERR_INVALID_DATA;
2408 }
2409 privacyWindowTags.insert(privacyWindowTag);
2410 }
2411 WMError errCode = RemoveSessionBlackList(bundleNames, privacyWindowTags);
2412 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2413 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode failed");
2414 return ERR_INVALID_DATA;
2415 }
2416 return ERR_NONE;
2417 }
2418 // LCOV_EXCL_STOP
2419
HandleGetPiPSettingSwitchStatus(MessageParcel & data,MessageParcel & reply)2420 int SceneSessionManagerStub::HandleGetPiPSettingSwitchStatus(MessageParcel& data, MessageParcel& reply)
2421 {
2422 bool switchStatus = false;
2423 WMError errCode = GetPiPSettingSwitchStatus(switchStatus);
2424 if (!reply.WriteBool(switchStatus)) {
2425 TLOGE(WmsLogTag::WMS_PIP, "Write switchStatus fail.");
2426 return ERR_INVALID_DATA;
2427 }
2428 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
2429 TLOGE(WmsLogTag::WMS_PIP, "Write errCode fail.");
2430 return ERR_INVALID_DATA;
2431 }
2432 return ERR_NONE;
2433 }
2434 } // namespace OHOS::Rosen