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_lite_stub.h"
17
18 #include "marshalling_helper.h"
19 #include "window_manager_hilog.h"
20
21 namespace OHOS::Rosen {
22 namespace {
23 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerLiteStub"};
24 constexpr uint32_t MAX_VECTOR_SIZE = 100;
25 constexpr uint32_t MAX_TOPN_INFO_SIZE = 200;
26 constexpr int32_t MAX_CONTROL_APP_INFO = 200;
27 }
28
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)29 int SceneSessionManagerLiteStub::OnRemoteRequest(uint32_t code,
30 MessageParcel& data, MessageParcel& reply, MessageOption& option)
31 {
32 WLOGFD("Scene session on remote request!, code: %{public}u", code);
33 if (data.ReadInterfaceToken() != GetDescriptor()) {
34 WLOGFE("Failed to check interface token!");
35 return ERR_TRANSACTION_FAILED;
36 }
37
38 return ProcessRemoteRequest(code, data, reply, option);
39 }
40
ProcessRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)41 int SceneSessionManagerLiteStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
42 MessageOption& option)
43 {
44 switch (code) {
45 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL):
46 return HandleSetSessionLabel(data, reply);
47 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_ICON):
48 return HandleSetSessionIcon(data, reply);
49 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_IS_VALID_SESSION_IDS):
50 return HandleIsValidSessionIds(data, reply);
51 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND):
52 return HandlePendingSessionToForeground(data, reply);
53 case static_cast<uint32_t>(
54 SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR):
55 return HandlePendingSessionToBackgroundForDelegator(data, reply);
56 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN):
57 return HandleGetFocusSessionToken(data, reply);
58 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT):
59 return HandleGetFocusSessionElement(data, reply);
60 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_IS_FOCUS_WINDOW_PARENT):
61 return HandleIsFocusWindowParent(data, reply);
62 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_SESSION_LISTENER):
63 return HandleRegisterSessionListener(data, reply);
64 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER):
65 return HandleUnRegisterSessionListener(data, reply);
66 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFOS):
67 return HandleGetSessionInfos(data, reply);
68 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID):
69 return HandleGetMainWindowStatesByPid(data, reply);
70 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFO_BY_ID):
71 return HandleGetSessionInfo(data, reply);
72 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID):
73 return HandleGetSessionInfoByContinueSessionId(data, reply);
74 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_NEW):
75 return HandleTerminateSessionNew(data, reply);
76 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_SNAPSHOT):
77 return HandleGetSessionSnapshot(data, reply);
78 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE):
79 return HandleSetSessionContinueState(data, reply);
80 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_SESSION):
81 return HandleClearSession(data, reply);
82 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_ALL_SESSIONS):
83 return HandleClearAllSessions(data, reply);
84 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION):
85 return HandleLockSession(data, reply);
86 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNLOCK_SESSION):
87 return HandleUnlockSession(data, reply);
88 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND):
89 return HandleMoveSessionsToForeground(data, reply);
90 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND):
91 return HandleMoveSessionsToBackground(data, reply);
92 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_INFO):
93 return HandleGetFocusSessionInfo(data, reply);
94 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT):
95 return HandleRegisterWindowManagerAgent(data, reply);
96 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT):
97 return HandleUnregisterWindowManagerAgent(data, reply);
98 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CHECK_WINDOW_ID):
99 return HandleCheckWindowId(data, reply);
100 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UI_EXTENSION_CREATION_CHECK):
101 return HandleCheckUIExtensionCreation(data, reply);
102 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_LIST_WINDOW_INFO):
103 return HandleListWindowInfo(data, reply);
104 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID):
105 return HandleGetVisibilityWindowInfo(data, reply);
106 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_MODE_TYPE):
107 return HandleGetWindowModeType(data, reply);
108 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_RAISE_WINDOW_TO_TOP):
109 return HandleRaiseWindowToTop(data, reply);
110 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_TOPN_MAIN_WINDOW_INFO):
111 return HandleGetMainWinodowInfo(data, reply);
112 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_COLLABORATOR):
113 return HandleRegisterCollaborator(data, reply);
114 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_COLLABORATOR):
115 return HandleUnregisterCollaborator(data, reply);
116 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_ALL_MAIN_WINDOW_INFO):
117 return HandleGetAllMainWindowInfos(data, reply);
118 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_MAIN_SESSIONS):
119 return HandleClearMainSessions(data, reply);
120 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_STYLE_TYPE):
121 return HandleGetWindowStyleType(data, reply);
122 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_BY_PERSISTENT_ID):
123 return HandleTerminateSessionByPersistentId(data, reply);
124 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLOSE_TARGET_FLOAT_WINDOW):
125 return HandleCloseTargetFloatWindow(data, reply);
126 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLOSE_TARGET_PIP_WINDOW):
127 return HandleCloseTargetPiPWindow(data, reply);
128 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO):
129 return HandleGetCurrentPiPWindowInfo(data, reply);
130 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_ROOT_MAIN_WINDOW_ID):
131 return HandleGetRootMainWindowId(data, reply);
132 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_INFO):
133 return HandleGetAccessibilityWindowInfo(data, reply);
134 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_NOTIFY_APP_USE_CONTROL_LIST):
135 return HandleNotifyAppUseControlList(data, reply);
136 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_MINIMIZE_MAIN_SESSION):
137 return HandleMinimizeMainSession(data, reply);
138 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_HAS_FLOAT_FOREGROUND):
139 return HandleHasFloatingWindowForeground(data, reply);
140 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION_BY_ABILITY_INFO):
141 return HandleLockSessionByAbilityInfo(data, reply);
142 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_CALLING_WINDOW_INFO):
143 return HandleGetCallingWindowInfo(data, reply);
144 case static_cast<uint32_t>(
145 SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_SESSION_LIFECYCLE_LISTENER_BY_IDS):
146 return HandleRegisterSessionLifecycleListenerByIds(data, reply);
147 case static_cast<uint32_t>(
148 SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_SESSION_LIFECYCLE_LISTENER_BY_BUNDLES):
149 return HandleRegisterSessionLifecycleListenerByBundles(data, reply);
150 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_SESSION_LIFECYCLE_LISTENER):
151 return HandleUnregisterSessionLifecycleListener(data, reply);
152 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_RECENT_MAIN_SESSION_INFO_LIST):
153 return HandleGetRecentMainSessionInfoList(data, reply);
154 case static_cast<uint32_t>(
155 SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_BY_PERSISTENTID):
156 return HandlePendingSessionToBackgroundByPersistentId(data, reply);
157 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CREATE_NEW_INSTANCE_KEY):
158 return HandleCreateNewInstanceKey(data, reply);
159 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_ROUTER_STACK_INFO):
160 return HandleGetRouterStackInfo(data, reply);
161 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_REMOVE_INSTANCE_KEY):
162 return HandleRemoveInstanceKey(data, reply);
163 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_TRANSFER_SESSION_TO_TARGET_SCREEN):
164 return HandleTransferSessionToTargetScreen(data, reply);
165 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND):
166 return HandlePendingSessionToBackground(data, reply);
167 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UPDATE_KIOSK_APP_LIST):
168 return HandleUpdateKioskAppList(data, reply);
169 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_ENTER_KIOSK_MODE):
170 return HandleEnterKioskMode(data, reply);
171 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_EXIT_KIOSK_MODE):
172 return HandleExitKioskMode(data, reply);
173 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_SEND_POINTER_EVENT_FOR_HOVER):
174 return HandleSendPointerEventForHover(data, reply);
175 case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UPDATE_WINDOW_MODE_BY_ID_FOR_UI_TEST):
176 return HandleUpdateWindowModeByIdForUITest(data, reply);
177 default:
178 WLOGFE("Failed to find function handler!");
179 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
180 }
181 }
182
HandleSetSessionLabel(MessageParcel & data,MessageParcel & reply)183 int SceneSessionManagerLiteStub::HandleSetSessionLabel(MessageParcel& data, MessageParcel& reply)
184 {
185 TLOGD(WmsLogTag::WMS_LIFE, "In");
186 sptr<IRemoteObject> token = data.ReadRemoteObject();
187 std::string label;
188 if (!data.ReadString(label)) {
189 TLOGD(WmsLogTag::WMS_LIFE, "Read label failed.");
190 return ERR_INVALID_DATA;
191 }
192 WSError errCode = SetSessionLabel(token, label);
193 reply.WriteInt32(static_cast<int32_t>(errCode));
194 return ERR_NONE;
195 }
196
HandleSetSessionIcon(MessageParcel & data,MessageParcel & reply)197 int SceneSessionManagerLiteStub::HandleSetSessionIcon(MessageParcel& data, MessageParcel& reply)
198 {
199 WLOGFD("run HandleSetSessionIcon!");
200 sptr<IRemoteObject> token = data.ReadRemoteObject();
201 std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
202 if (icon == nullptr) {
203 WLOGFE("icon is null");
204 return ERR_INVALID_DATA;
205 }
206 WSError errCode = SetSessionIcon(token, icon);
207 reply.WriteInt32(static_cast<int32_t>(errCode));
208 return ERR_NONE;
209 }
210
HandleIsValidSessionIds(MessageParcel & data,MessageParcel & reply)211 int SceneSessionManagerLiteStub::HandleIsValidSessionIds(MessageParcel& data, MessageParcel& reply)
212 {
213 WLOGFD("run HandleIsValidSessionIds!");
214 std::vector<int32_t> sessionIds;
215 data.ReadInt32Vector(&sessionIds);
216 std::vector<bool> results;
217 WSError errCode = IsValidSessionIds(sessionIds, results);
218 reply.WriteBoolVector(results);
219 reply.WriteUint32(static_cast<uint32_t>(errCode));
220 return ERR_NONE;
221 }
222
HandlePendingSessionToForeground(MessageParcel & data,MessageParcel & reply)223 int SceneSessionManagerLiteStub::HandlePendingSessionToForeground(MessageParcel& data, MessageParcel& reply)
224 {
225 WLOGFD("run HandlePendingSessionToForeground!");
226 sptr<IRemoteObject> token = data.ReadRemoteObject();
227 if (token == nullptr) {
228 WLOGFE("token is nullptr");
229 return ERR_INVALID_DATA;
230 }
231 WSError errCode = PendingSessionToForeground(token);
232 reply.WriteUint32(static_cast<uint32_t>(errCode));
233 return ERR_NONE;
234 }
235
HandlePendingSessionToBackground(MessageParcel & data,MessageParcel & reply)236 int SceneSessionManagerLiteStub::HandlePendingSessionToBackground(MessageParcel& data, MessageParcel& reply)
237 {
238 TLOGD(WmsLogTag::WMS_LIFE, "run");
239 sptr<IRemoteObject> token = data.ReadRemoteObject();
240 if (token == nullptr) {
241 TLOGE(WmsLogTag::WMS_LIFE, "token is nullptr");
242 return ERR_INVALID_DATA;
243 }
244 BackgroundParams params;
245 if (!data.ReadInt32(params.persistentId)) {
246 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId failed");
247 return ERR_INVALID_DATA;
248 }
249 if (!data.ReadBool(params.shouldBackToCaller)) {
250 TLOGE(WmsLogTag::WMS_LIFE, "Read shouldBackToCaller failed");
251 return ERR_INVALID_DATA;
252 }
253 std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
254 if (wantParams == nullptr) {
255 TLOGI(WmsLogTag::WMS_LIFE, "wantParams is nullptr");
256 } else {
257 params.wantParams = *wantParams;
258 }
259 WSError ret = PendingSessionToBackground(token, params);
260 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
261 TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed");
262 return ERR_INVALID_DATA;
263 }
264 return ERR_NONE;
265 }
266
HandlePendingSessionToBackgroundForDelegator(MessageParcel & data,MessageParcel & reply)267 int SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator(MessageParcel& data, MessageParcel& reply)
268 {
269 TLOGD(WmsLogTag::WMS_LIFE, "run");
270 sptr<IRemoteObject> token = data.ReadRemoteObject();
271 if (token == nullptr) {
272 TLOGE(WmsLogTag::WMS_LIFE, "token is nullptr");
273 return ERR_INVALID_DATA;
274 }
275 bool shouldBackToCaller = true;
276 if (!data.ReadBool(shouldBackToCaller)) {
277 TLOGE(WmsLogTag::WMS_LIFE, "Read shouldBackToCaller failed");
278 return ERR_INVALID_DATA;
279 }
280 WSError errCode = PendingSessionToBackgroundForDelegator(token, shouldBackToCaller);
281 reply.WriteInt32(static_cast<int32_t>(errCode));
282 return ERR_NONE;
283 }
284
HandleRegisterSessionListener(MessageParcel & data,MessageParcel & reply)285 int SceneSessionManagerLiteStub::HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
286 {
287 WLOGFD("run HandleRegisterSessionListener!");
288 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
289 if (listener == nullptr) {
290 TLOGE(WmsLogTag::WMS_MAIN, "listener is nullptr!");
291 reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
292 return ERR_NONE;
293 }
294 WSError errCode = RegisterSessionListener(listener);
295 reply.WriteInt32(static_cast<int32_t>(errCode));
296 return ERR_NONE;
297 }
298
HandleUnRegisterSessionListener(MessageParcel & data,MessageParcel & reply)299 int SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
300 {
301 WLOGFD("run HandleUnRegisterSessionListener!");
302 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
303 if (listener == nullptr) {
304 reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
305 return ERR_NONE;
306 }
307 WSError errCode = UnRegisterSessionListener(listener);
308 reply.WriteInt32(static_cast<int32_t>(errCode));
309 return ERR_NONE;
310 }
311
HandleGetSessionInfos(MessageParcel & data,MessageParcel & reply)312 int SceneSessionManagerLiteStub::HandleGetSessionInfos(MessageParcel& data, MessageParcel& reply)
313 {
314 WLOGFD("run HandleGetSessionInfos!");
315 std::u16string deviceIdU16;
316 if (!data.ReadString16(deviceIdU16)) {
317 TLOGE(WmsLogTag::WMS_LIFE, "Read deviceId fail");
318 return ERR_TRANSACTION_FAILED;
319 }
320 std::string deviceId = Str16ToStr8(deviceIdU16);
321 int32_t numMax = 0;
322 if (!data.ReadInt32(numMax)) {
323 TLOGE(WmsLogTag::WMS_LIFE, "Read numMax fail");
324 return ERR_TRANSACTION_FAILED;
325 }
326 std::vector<SessionInfoBean> missionInfos;
327 WSError errCode = GetSessionInfos(deviceId, numMax, missionInfos);
328 reply.WriteInt32(missionInfos.size());
329 for (auto& it : missionInfos) {
330 if (!reply.WriteParcelable(&it)) {
331 WLOGFE("GetSessionInfos error");
332 return ERR_INVALID_DATA;
333 }
334 }
335 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
336 return ERR_INVALID_DATA;
337 }
338 return ERR_NONE;
339 }
340
HandleGetMainWindowStatesByPid(MessageParcel & data,MessageParcel & reply)341 int SceneSessionManagerLiteStub::HandleGetMainWindowStatesByPid(MessageParcel& data, MessageParcel& reply)
342 {
343 int32_t pid = 0;
344 if (!data.ReadInt32(pid)) {
345 TLOGE(WmsLogTag::WMS_LIFE, "read pid fail");
346 return ERR_INVALID_DATA;
347 }
348 std::vector<MainWindowState> windowStates;
349 WSError errCode = GetMainWindowStatesByPid(pid, windowStates);
350 if (!reply.WriteInt32(windowStates.size())) {
351 TLOGE(WmsLogTag::WMS_LIFE, "write windowStates size fail");
352 return ERR_INVALID_DATA;
353 }
354 for (auto& state : windowStates) {
355 if (!reply.WriteParcelable(&state)) {
356 TLOGE(WmsLogTag::WMS_LIFE, "write windowState fail");
357 return ERR_INVALID_DATA;
358 }
359 }
360 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
361 return ERR_INVALID_DATA;
362 }
363 return ERR_NONE;
364 }
365
HandleGetSessionInfo(MessageParcel & data,MessageParcel & reply)366 int SceneSessionManagerLiteStub::HandleGetSessionInfo(MessageParcel& data, MessageParcel& reply)
367 {
368 TLOGD(WmsLogTag::WMS_LIFE, "In!");
369 SessionInfoBean info;
370 std::u16string deviceIdU16;
371 if (!data.ReadString16(deviceIdU16)) {
372 TLOGE(WmsLogTag::WMS_LIFE, "Read deviceId fail");
373 return ERR_TRANSACTION_FAILED;
374 }
375 std::string deviceId = Str16ToStr8(deviceIdU16);
376 int32_t persistentId = 0;
377 if (!data.ReadInt32(persistentId)) {
378 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId fail");
379 return ERR_TRANSACTION_FAILED;
380 }
381 WSError errCode = GetSessionInfo(deviceId, persistentId, info);
382 if (!reply.WriteParcelable(&info)) {
383 TLOGE(WmsLogTag::WMS_LIFE, "Write sessionInfo fail");
384 return ERR_INVALID_DATA;
385 }
386
387 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
388 TLOGE(WmsLogTag::WMS_LIFE, "Write sessionInfo result fail");
389 return ERR_INVALID_DATA;
390 }
391 return ERR_NONE;
392 }
393
HandleGetSessionInfoByContinueSessionId(MessageParcel & data,MessageParcel & reply)394 int SceneSessionManagerLiteStub::HandleGetSessionInfoByContinueSessionId(MessageParcel& data, MessageParcel& reply)
395 {
396 TLOGD(WmsLogTag::WMS_LIFE, "In!");
397 std::string continueSessionId;
398 if (!data.ReadString(continueSessionId)) {
399 TLOGE(WmsLogTag::WMS_LIFE, "read continueSessionId fail");
400 return ERR_INVALID_DATA;
401 }
402 TLOGI(WmsLogTag::WMS_LIFE, "continueSessionId: %{public}s", continueSessionId.c_str());
403 SessionInfoBean info;
404 WSError errCode = GetSessionInfoByContinueSessionId(continueSessionId, info);
405 if (!reply.WriteParcelable(&info)) {
406 TLOGE(WmsLogTag::WMS_LIFE, "Get sessionInfo by continueSessionId error");
407 return ERR_INVALID_DATA;
408 }
409
410 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
411 TLOGE(WmsLogTag::WMS_LIFE, "Get sessionInfo by continueSessionId result error");
412 return ERR_INVALID_DATA;
413 }
414 return ERR_NONE;
415 }
416
HandleTerminateSessionNew(MessageParcel & data,MessageParcel & reply)417 int SceneSessionManagerLiteStub::HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply)
418 {
419 TLOGD(WmsLogTag::WMS_LIFE, "in");
420 sptr<AAFwk::SessionInfo> abilitySessionInfo = data.ReadParcelable<AAFwk::SessionInfo>();
421 if (abilitySessionInfo == nullptr) {
422 TLOGE(WmsLogTag::WMS_LIFE, "abilitySessionInfo is null");
423 return ERR_INVALID_DATA;
424 }
425 bool needStartCaller = false;
426 if (!data.ReadBool(needStartCaller)) {
427 TLOGE(WmsLogTag::WMS_LIFE, "Read needStartCaller failed.");
428 return ERR_INVALID_DATA;
429 }
430 bool isFromBroker = false;
431 if (!data.ReadBool(isFromBroker)) {
432 TLOGE(WmsLogTag::WMS_LIFE, "Read isFromBroker failed.");
433 return ERR_INVALID_DATA;
434 }
435 WSError errCode = TerminateSessionNew(abilitySessionInfo, needStartCaller, isFromBroker);
436 reply.WriteUint32(static_cast<uint32_t>(errCode));
437 return ERR_NONE;
438 }
439
HandleGetFocusSessionToken(MessageParcel & data,MessageParcel & reply)440 int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel& data, MessageParcel& reply)
441 {
442 TLOGD(WmsLogTag::WMS_FOCUS, "run");
443 uint64_t displayId = 0;
444 if (!data.ReadUint64(displayId)) {
445 TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId");
446 return ERR_INVALID_DATA;
447 }
448 sptr<IRemoteObject> token = nullptr;
449 WSError errCode = GetFocusSessionToken(token, displayId);
450 reply.WriteRemoteObject(token);
451 reply.WriteInt32(static_cast<int32_t>(errCode));
452 return ERR_NONE;
453 }
454
HandleGetFocusSessionElement(MessageParcel & data,MessageParcel & reply)455 int SceneSessionManagerLiteStub::HandleGetFocusSessionElement(MessageParcel& data, MessageParcel& reply)
456 {
457 TLOGD(WmsLogTag::WMS_FOCUS, "run");
458 uint64_t displayId = 0;
459 if (!data.ReadUint64(displayId)) {
460 TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId");
461 return ERR_INVALID_DATA;
462 }
463 AppExecFwk::ElementName element;
464 WSError errCode = GetFocusSessionElement(element, displayId);
465 reply.WriteParcelable(&element);
466 reply.WriteInt32(static_cast<int32_t>(errCode));
467 return ERR_NONE;
468 }
469
HandleIsFocusWindowParent(MessageParcel & data,MessageParcel & reply)470 int SceneSessionManagerLiteStub::HandleIsFocusWindowParent(MessageParcel& data, MessageParcel& reply)
471 {
472 TLOGD(WmsLogTag::WMS_FOCUS, "run");
473 sptr<IRemoteObject> token = data.ReadRemoteObject();
474 if (token == nullptr) {
475 TLOGE(WmsLogTag::WMS_FOCUS, "Token is nullptr");
476 return ERR_INVALID_DATA;
477 }
478 bool isParent = false;
479 WSError errCode = IsFocusWindowParent(token, isParent);
480 TLOGD(WmsLogTag::WMS_FOCUS, "isParent: %{public}d", isParent);
481 if (!reply.WriteBool(isParent)) {
482 TLOGE(WmsLogTag::WMS_FOCUS, "Write isParent failed.");
483 return ERR_INVALID_DATA;
484 }
485 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
486 TLOGE(WmsLogTag::WMS_FOCUS, "Write errCode failed.");
487 return ERR_INVALID_DATA;
488 }
489 return ERR_NONE;
490 }
491
HandleSetSessionContinueState(MessageParcel & data,MessageParcel & reply)492 int SceneSessionManagerLiteStub::HandleSetSessionContinueState(MessageParcel& data, MessageParcel& reply)
493 {
494 WLOGFD("HandleSetSessionContinueState");
495 sptr <IRemoteObject> token = data.ReadRemoteObject();
496 int32_t continueStateValue = 0;
497 if (!data.ReadInt32(continueStateValue)) {
498 TLOGE(WmsLogTag::WMS_LIFE, "Read continueState fail");
499 return ERR_TRANSACTION_FAILED;
500 }
501 if (continueStateValue < static_cast<int32_t>(ContinueState::CONTINUESTATE_UNKNOWN) ||
502 continueStateValue > static_cast<int32_t>(ContinueState::CONTINUESTATE_MAX)) {
503 TLOGE(WmsLogTag::WMS_LIFE, "Invalid continueState");
504 return ERR_INVALID_DATA;
505 }
506 auto continueState = static_cast<ContinueState>(continueStateValue);
507 const WSError &ret = SetSessionContinueState(token, continueState);
508 reply.WriteUint32(static_cast<uint32_t>(ret));
509 return ERR_NONE;
510 }
511
HandleGetSessionSnapshot(MessageParcel & data,MessageParcel & reply)512 int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel& data, MessageParcel& reply)
513 {
514 TLOGD(WmsLogTag::WMS_SYSTEM, "Handled!");
515 std::u16string deviceIdData;
516 if (!data.ReadString16(deviceIdData)) {
517 TLOGE(WmsLogTag::WMS_SYSTEM, "read deviceId fail");
518 return ERR_INVALID_DATA;
519 }
520 std::string deviceId = Str16ToStr8(deviceIdData);
521 int32_t persistentId = 0;
522 if (!data.ReadInt32(persistentId)) {
523 TLOGE(WmsLogTag::WMS_SYSTEM, "read persistentId fail");
524 return ERR_INVALID_DATA;
525 }
526 bool isLowResolution = false;
527 if (!data.ReadBool(isLowResolution)) {
528 TLOGE(WmsLogTag::WMS_SYSTEM, "read isLowResolution fail");
529 return ERR_INVALID_DATA;
530 }
531 std::shared_ptr<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
532 WSError ret = GetSessionSnapshot(deviceId, persistentId, *snapshot, isLowResolution);
533 reply.WriteParcelable(snapshot.get());
534 reply.WriteUint32(static_cast<uint32_t>(ret));
535 return ERR_NONE;
536 }
537
HandleClearSession(MessageParcel & data,MessageParcel & reply)538 int SceneSessionManagerLiteStub::HandleClearSession(MessageParcel& data, MessageParcel& reply)
539 {
540 WLOGFD("run HandleClearSession!");
541 int32_t persistentId = 0;
542 if (!data.ReadInt32(persistentId)) {
543 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId fail");
544 return ERR_TRANSACTION_FAILED;
545 }
546 WSError ret = ClearSession(persistentId);
547 reply.WriteUint32(static_cast<uint32_t>(ret));
548 return ERR_NONE;
549 }
550
HandleClearAllSessions(MessageParcel & data,MessageParcel & reply)551 int SceneSessionManagerLiteStub::HandleClearAllSessions(MessageParcel& data, MessageParcel& reply)
552 {
553 WLOGFD("run HandleClearAllSessions!");
554 WSError ret = ClearAllSessions();
555 reply.WriteUint32(static_cast<uint32_t>(ret));
556 return ERR_NONE;
557 }
558
HandleLockSession(MessageParcel & data,MessageParcel & reply)559 int SceneSessionManagerLiteStub::HandleLockSession(MessageParcel& data, MessageParcel& reply)
560 {
561 WLOGFD("run HandleLockSession!");
562 int32_t sessionId = 0;
563 if (!data.ReadInt32(sessionId)) {
564 TLOGE(WmsLogTag::WMS_LIFE, "Read sessionId fail");
565 return ERR_TRANSACTION_FAILED;
566 }
567 WSError ret = LockSession(sessionId);
568 reply.WriteUint32(static_cast<uint32_t>(ret));
569 return ERR_NONE;
570 }
571
HandleUnlockSession(MessageParcel & data,MessageParcel & reply)572 int SceneSessionManagerLiteStub::HandleUnlockSession(MessageParcel& data, MessageParcel& reply)
573 {
574 WLOGFD("run HandleUnlockSession!");
575 int32_t sessionId = 0;
576 if (!data.ReadInt32(sessionId)) {
577 TLOGE(WmsLogTag::WMS_LIFE, "Read sessionId fail");
578 return ERR_TRANSACTION_FAILED;
579 }
580 WSError ret = UnlockSession(sessionId);
581 reply.WriteUint32(static_cast<uint32_t>(ret));
582 return ERR_NONE;
583 }
584
HandleMoveSessionsToForeground(MessageParcel & data,MessageParcel & reply)585 int SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(MessageParcel& data, MessageParcel& reply)
586 {
587 WLOGFD("run HandleMoveSessionsToForeground!");
588 std::vector<int32_t> sessionIds;
589 data.ReadInt32Vector(&sessionIds);
590 int32_t topSessionId = 0;
591 if (!data.ReadInt32(topSessionId)) {
592 TLOGE(WmsLogTag::WMS_LIFE, "Read topSessionId fail");
593 return ERR_TRANSACTION_FAILED;
594 }
595 const WSError &ret = MoveSessionsToForeground(sessionIds, topSessionId);
596 reply.WriteUint32(static_cast<uint32_t>(ret));
597 return ERR_NONE;
598 }
599
HandleMoveSessionsToBackground(MessageParcel & data,MessageParcel & reply)600 int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel& data, MessageParcel& reply)
601 {
602 WLOGFD("run HandleMoveSessionsToBackground!");
603 std::vector<int32_t> sessionIds;
604 data.ReadInt32Vector(&sessionIds);
605 std::vector<int32_t> result;
606 data.ReadInt32Vector(&result);
607 const WSError &ret = MoveSessionsToBackground(sessionIds, result);
608 reply.WriteInt32Vector(result);
609 reply.WriteUint32(static_cast<uint32_t>(ret));
610 return ERR_NONE;
611 }
612
HandleGetFocusSessionInfo(MessageParcel & data,MessageParcel & reply)613 int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply)
614 {
615 TLOGI(WmsLogTag::WMS_FOCUS, "run");
616 uint64_t displayId = 0;
617 if (!data.ReadUint64(displayId)) {
618 TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId");
619 return ERR_INVALID_DATA;
620 }
621 FocusChangeInfo focusInfo;
622 GetFocusWindowInfo(focusInfo, displayId);
623 TLOGI(WmsLogTag::WMS_FOCUS, "start reply");
624 reply.WriteParcelable(&focusInfo);
625 return ERR_NONE;
626 }
627
HandleCheckWindowId(MessageParcel & data,MessageParcel & reply)628 int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel& data, MessageParcel& reply)
629 {
630 WLOGFI("run HandleCheckWindowId!");
631 int32_t windowId = INVALID_WINDOW_ID;
632 if (!data.ReadInt32(windowId)) {
633 WLOGE("Failed to readInt32 windowId");
634 return ERR_INVALID_DATA;
635 }
636 int32_t pid = INVALID_PID;
637 WMError errCode = CheckWindowId(windowId, pid);
638 if (errCode != WMError::WM_OK) {
639 WLOGE("Failed to checkWindowId(%{public}d)", pid);
640 return ERR_INVALID_DATA;
641 }
642 if (!reply.WriteInt32(pid)) {
643 WLOGE("Failed to WriteInt32 pid");
644 return ERR_INVALID_DATA;
645 }
646 return ERR_NONE;
647 }
648
HandleUpdateWindowModeByIdForUITest(MessageParcel & data,MessageParcel & reply)649 int SceneSessionManagerLiteStub::HandleUpdateWindowModeByIdForUITest(MessageParcel& data, MessageParcel& reply)
650 {
651 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
652 int32_t windowId = INVALID_WINDOW_ID;
653 int32_t updateMode = 0;
654 if (!data.ReadInt32(windowId)) {
655 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to read windowId");
656 return ERR_INVALID_DATA;
657 }
658 if (!data.ReadInt32(updateMode)) {
659 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to read updateMode");
660 return ERR_INVALID_DATA;
661 }
662 WMError errCode = UpdateWindowModeByIdForUITest(windowId, updateMode);
663 if (errCode != WMError::WM_OK) {
664 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to UpdateWindowModeByIdForUITest, "
665 "windowId:%{public}d, updateMode:%{public}d", windowId, updateMode);
666 return ERR_INVALID_DATA;
667 }
668 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
669 TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to UpdateWindowModeByIdForUITest, errCode:%{public}d", errCode);
670 return ERR_INVALID_DATA;
671 }
672 return ERR_NONE;
673 }
674
HandleCheckUIExtensionCreation(MessageParcel & data,MessageParcel & reply)675 int SceneSessionManagerLiteStub::HandleCheckUIExtensionCreation(MessageParcel& data, MessageParcel& reply)
676 {
677 TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: called");
678
679 int32_t windowId = INVALID_WINDOW_ID;
680 if (!data.ReadInt32(windowId)) {
681 TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get windowId");
682 return ERR_INVALID_DATA;
683 }
684
685 uint32_t token = -1;
686 if (!data.ReadUint32(token)) {
687 TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get token");
688 return ERR_INVALID_DATA;
689 }
690
691 int32_t extAbilityTypeValue = -1;
692 if (!data.ReadInt32(extAbilityTypeValue)) {
693 TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get extensionAbilityType");
694 return ERR_INVALID_DATA;
695 }
696 if (extAbilityTypeValue < 0) {
697 TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get extensionAbilityType(out of range)");
698 return ERR_INVALID_DATA;
699 }
700 auto extAbilityType = static_cast<AppExecFwk::ExtensionAbilityType>(extAbilityTypeValue);
701
702 sptr<AppExecFwk::ElementName> element = data.ReadParcelable<AppExecFwk::ElementName>();
703 if (!element) {
704 TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get element");
705 return ERR_INVALID_DATA;
706 }
707
708 int32_t pid = INVALID_PID;
709 WMError errCode = CheckUIExtensionCreation(windowId, token, *element, extAbilityType, pid);
710 TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: ret %{public}u", errCode);
711
712 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
713 TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write errcode");
714 return ERR_INVALID_DATA;
715 }
716
717 if (!reply.WriteInt32(pid)) {
718 TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write pid");
719 return ERR_INVALID_DATA;
720 }
721
722 return ERR_NONE;
723 }
724
HandleRegisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)725 int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
726 {
727 uint32_t typeId = 0;
728 if (!data.ReadUint32(typeId) ||
729 typeId < static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS) ||
730 typeId >= static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_END)) {
731 return ERR_INVALID_DATA;
732 }
733 WindowManagerAgentType type = static_cast<WindowManagerAgentType>(typeId);
734 TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId);
735 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
736 sptr<IWindowManagerAgent> windowManagerAgentProxy =
737 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
738 WMError errCode = RegisterWindowManagerAgent(type, windowManagerAgentProxy);
739 reply.WriteInt32(static_cast<int32_t>(errCode));
740 return ERR_NONE;
741 }
742
HandleUnregisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)743 int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
744 {
745 uint32_t typeId = 0;
746 if (!data.ReadUint32(typeId) ||
747 typeId < static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS) ||
748 typeId >= static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_END)) {
749 return ERR_INVALID_DATA;
750 }
751 WindowManagerAgentType type = static_cast<WindowManagerAgentType>(typeId);
752 TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId);
753 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
754 sptr<IWindowManagerAgent> windowManagerAgentProxy =
755 iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
756 WMError errCode = UnregisterWindowManagerAgent(type, windowManagerAgentProxy);
757 reply.WriteInt32(static_cast<int32_t>(errCode));
758 return ERR_NONE;
759 }
760
HandleListWindowInfo(MessageParcel & data,MessageParcel & reply)761 int SceneSessionManagerLiteStub::HandleListWindowInfo(MessageParcel& data, MessageParcel& reply)
762 {
763 WindowInfoOption windowInfoOption;
764 uint8_t windowInfoFilterOptionValue = static_cast<WindowInfoFilterOptionDataType>(WindowInfoFilterOption::ALL);
765 if (!data.ReadUint8(windowInfoFilterOptionValue)) {
766 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read windowInfoFilterOption");
767 return ERR_INVALID_DATA;
768 }
769 windowInfoOption.windowInfoFilterOption = static_cast<WindowInfoFilterOption>(windowInfoFilterOptionValue);
770 uint8_t windowInfoTypeOptionValue = static_cast<WindowInfoTypeOptionDataType>(WindowInfoTypeOption::ALL);
771 if (!data.ReadUint8(windowInfoTypeOptionValue)) {
772 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read windowInfoTypeOption");
773 return ERR_INVALID_DATA;
774 }
775 windowInfoOption.windowInfoTypeOption = static_cast<WindowInfoTypeOption>(windowInfoTypeOptionValue);
776 if (!data.ReadUint64(windowInfoOption.displayId)) {
777 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read displayId");
778 return ERR_INVALID_DATA;
779 }
780 if (!data.ReadInt32(windowInfoOption.windowId)) {
781 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to read windowId");
782 return ERR_INVALID_DATA;
783 }
784 std::vector<sptr<WindowInfo>> infos;
785 WMError errCode = ListWindowInfo(windowInfoOption, infos);
786 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowInfo>(reply, infos)) {
787 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Failed to write window info");
788 return ERR_INVALID_DATA;
789 }
790 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
791 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write errCode fail");
792 return ERR_INVALID_DATA;
793 }
794 return ERR_NONE;
795 }
796
HandleGetVisibilityWindowInfo(MessageParcel & data,MessageParcel & reply)797 int SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
798 {
799 std::vector<sptr<WindowVisibilityInfo>> infos;
800 WMError errCode = GetVisibilityWindowInfo(infos);
801 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowVisibilityInfo>(reply, infos)) {
802 WLOGFE("Write visibility window infos failed");
803 return -1;
804 }
805 reply.WriteInt32(static_cast<int32_t>(errCode));
806 return ERR_NONE;
807 }
808
HandleGetWindowModeType(MessageParcel & data,MessageParcel & reply)809 int SceneSessionManagerLiteStub::HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply)
810 {
811 WindowModeType windowModeType = Rosen::WindowModeType::WINDOW_MODE_OTHER;
812 WMError errCode = GetWindowModeType(windowModeType);
813 WLOGFI("run HandleGetWindowModeType, windowModeType:%{public}d!", static_cast<int32_t>(windowModeType));
814 if (!reply.WriteUint32(static_cast<int32_t>(windowModeType))) {
815 WLOGE("Failed to WriteBool");
816 return ERR_INVALID_DATA;
817 }
818 reply.WriteInt32(static_cast<int32_t>(errCode));
819 return ERR_NONE;
820 }
821
HandleGetMainWinodowInfo(MessageParcel & data,MessageParcel & reply)822 int SceneSessionManagerLiteStub::HandleGetMainWinodowInfo(MessageParcel& data, MessageParcel& reply)
823 {
824 TLOGI(WmsLogTag::WMS_MAIN, "run HandleGetMainWinodowInfo lite");
825 int32_t topN = 0;
826 if (!data.ReadInt32(topN)) {
827 TLOGE(WmsLogTag::WMS_MAIN, "failed to read topN");
828 return ERR_INVALID_DATA;
829 }
830 TLOGD(WmsLogTag::WMS_MAIN, "topN :%{public}d", topN);
831 std::vector<MainWindowInfo> topNInfos;
832 WMError errCode = GetMainWindowInfos(topN, topNInfos);
833 if ((topNInfos.size() <= 0) || (topNInfos.size() >= MAX_TOPN_INFO_SIZE)) {
834 return ERR_INVALID_DATA;
835 }
836 reply.WriteInt32(topNInfos.size());
837 for (auto& it : topNInfos) {
838 if (!reply.WriteParcelable(&it)) {
839 TLOGE(WmsLogTag::WMS_MAIN, "write topNinfo fail");
840 return ERR_INVALID_DATA;
841 }
842
843 TLOGI(WmsLogTag::WMS_MAIN, "pid %{public}d, name %{public}s",
844 it.pid_, it.bundleName_.c_str());
845 }
846
847 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
848 return ERR_INVALID_DATA;
849 }
850
851 return ERR_NONE;
852 }
853
HandleGetCallingWindowInfo(MessageParcel & data,MessageParcel & reply)854 int SceneSessionManagerLiteStub::HandleGetCallingWindowInfo(MessageParcel& data, MessageParcel& reply)
855 {
856 TLOGD(WmsLogTag::WMS_KEYBOARD, "In");
857 sptr<CallingWindowInfo> callingWindowInfo = data.ReadParcelable<CallingWindowInfo>();
858 if (callingWindowInfo == nullptr) {
859 TLOGE(WmsLogTag::WMS_KEYBOARD, "Read callingWindowInfo failed");
860 return ERR_INVALID_DATA;
861 }
862 WMError ret = GetCallingWindowInfo(*callingWindowInfo);
863 if (ret != WMError::WM_OK) {
864 TLOGE(WmsLogTag::WMS_KEYBOARD, "Get callingWindowInfo failed, id: %{public}d, userId: %{public}d",
865 callingWindowInfo->windowId_, callingWindowInfo->userId_);
866 return ERR_INVALID_DATA;
867 }
868 if (!reply.WriteInt32(static_cast<int32_t>(ret)) || !reply.WriteParcelable(callingWindowInfo)) {
869 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write callingWindowInfo failed, id: %{public}d, userId: %{public}d",
870 callingWindowInfo->windowId_, callingWindowInfo->userId_);
871 return ERR_INVALID_DATA;
872 }
873 return ERR_NONE;
874 }
875
HandleGetAllMainWindowInfos(MessageParcel & data,MessageParcel & reply)876 int SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos(MessageParcel& data, MessageParcel& reply)
877 {
878 std::vector<MainWindowInfo> infos;
879 WMError errCode = GetAllMainWindowInfos(infos);
880 reply.WriteInt32(infos.size());
881 for (auto& info : infos) {
882 if (!reply.WriteParcelable(&info)) {
883 TLOGE(WmsLogTag::WMS_MAIN, "write main window info fail");
884 return ERR_INVALID_DATA;
885 }
886 }
887 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
888 return ERR_INVALID_DATA;
889 }
890 return ERR_NONE;
891 }
892
HandleClearMainSessions(MessageParcel & data,MessageParcel & reply)893 int SceneSessionManagerLiteStub::HandleClearMainSessions(MessageParcel& data, MessageParcel& reply)
894 {
895 std::vector<int32_t> persistentIds;
896 std::vector<int32_t> clearFailedIds;
897 if (!data.ReadInt32Vector(&persistentIds)) {
898 TLOGE(WmsLogTag::WMS_MAIN, "failed to read persistentIds.");
899 return ERR_INVALID_DATA;
900 }
901 WMError errCode = ClearMainSessions(persistentIds, clearFailedIds);
902 if (!reply.WriteInt32Vector(clearFailedIds)) {
903 TLOGE(WmsLogTag::WMS_MAIN, "write clearFailedIds fail.");
904 return ERR_INVALID_DATA;
905 }
906 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
907 return ERR_INVALID_DATA;
908 }
909 return ERR_NONE;
910 }
911
HandleRaiseWindowToTop(MessageParcel & data,MessageParcel & reply)912 int SceneSessionManagerLiteStub::HandleRaiseWindowToTop(MessageParcel& data, MessageParcel& reply)
913 {
914 auto persistentId = 0;
915 if (!data.ReadInt32(persistentId)) {
916 TLOGE(WmsLogTag::WMS_HIERARCHY, "read persistentId failed");
917 return ERR_INVALID_DATA;
918 }
919 WSError errCode = RaiseWindowToTop(persistentId);
920 reply.WriteUint32(static_cast<uint32_t>(errCode));
921 return ERR_NONE;
922 }
923
HandleRegisterCollaborator(MessageParcel & data,MessageParcel & reply)924 int SceneSessionManagerLiteStub::HandleRegisterCollaborator(MessageParcel& data, MessageParcel& reply)
925 {
926 TLOGD(WmsLogTag::WMS_MAIN, "called.");
927 int32_t type = 0;
928 if (!data.ReadInt32(type)) {
929 TLOGE(WmsLogTag::WMS_LIFE, "Read type fail");
930 return ERR_TRANSACTION_FAILED;
931 }
932 sptr<IRemoteObject> collaboratorObject = data.ReadRemoteObject();
933 if (collaboratorObject == nullptr) {
934 TLOGE(WmsLogTag::WMS_MAIN, "collaboratorObject is null.");
935 return ERR_NULL_OBJECT;
936 }
937 sptr<AAFwk::IAbilityManagerCollaborator> collaborator =
938 iface_cast<AAFwk::IAbilityManagerCollaborator>(collaboratorObject);
939 WSError ret = RegisterIAbilityManagerCollaborator(type, collaborator);
940 reply.WriteInt32(static_cast<int32_t>(ret));
941 return ERR_NONE;
942 }
943
HandleUnregisterCollaborator(MessageParcel & data,MessageParcel & reply)944 int SceneSessionManagerLiteStub::HandleUnregisterCollaborator(MessageParcel& data, MessageParcel& reply)
945 {
946 TLOGD(WmsLogTag::WMS_MAIN, "called.");
947 int32_t type = 0;
948 if (!data.ReadInt32(type)) {
949 TLOGE(WmsLogTag::WMS_LIFE, "Read type fail");
950 return ERR_TRANSACTION_FAILED;
951 }
952 WSError ret = UnregisterIAbilityManagerCollaborator(type);
953 reply.WriteInt32(static_cast<int32_t>(ret));
954 return ERR_NONE;
955 }
956
HandleGetWindowStyleType(MessageParcel & data,MessageParcel & reply)957 int SceneSessionManagerLiteStub::HandleGetWindowStyleType(MessageParcel& data, MessageParcel& reply)
958 {
959 WindowStyleType windowStyleType = Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT;
960 WMError errCode = GetWindowStyleType(windowStyleType);
961 TLOGI(WmsLogTag::WMS_MAIN, "windowStyleType:%{public}d!", static_cast<int32_t>(windowStyleType));
962 if (!reply.WriteUint32(static_cast<int32_t>(windowStyleType))) {
963 TLOGE(WmsLogTag::WMS_MAIN, "Failed to WriteBool");
964 return ERR_INVALID_DATA;
965 }
966 reply.WriteInt32(static_cast<int32_t>(errCode));
967 return ERR_NONE;
968 }
969
HandleTerminateSessionByPersistentId(MessageParcel & data,MessageParcel & reply)970 int SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(MessageParcel& data, MessageParcel& reply)
971 {
972 TLOGD(WmsLogTag::WMS_LIFE, "In!");
973 int32_t persistentId;
974 if (!data.ReadInt32(persistentId)) {
975 TLOGE(WmsLogTag::WMS_LIFE, "read persistentId failed");
976 return ERR_INVALID_DATA;
977 }
978 WMError errCode = TerminateSessionByPersistentId(persistentId);
979 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
980 return ERR_INVALID_DATA;
981 }
982 return ERR_NONE;
983 }
984
HandleCloseTargetFloatWindow(MessageParcel & data,MessageParcel & reply)985 int SceneSessionManagerLiteStub::HandleCloseTargetFloatWindow(MessageParcel& data, MessageParcel& reply)
986 {
987 std::string bundleName = data.ReadString();
988 CloseTargetFloatWindow(bundleName);
989 return ERR_NONE;
990 }
991
HandleCloseTargetPiPWindow(MessageParcel & data,MessageParcel & reply)992 int SceneSessionManagerLiteStub::HandleCloseTargetPiPWindow(MessageParcel& data, MessageParcel& reply)
993 {
994 std::string bundleName = data.ReadString();
995 WMError errCode = CloseTargetPiPWindow(bundleName);
996 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
997 return ERR_INVALID_DATA;
998 }
999 return ERR_NONE;
1000 }
1001
HandleGetCurrentPiPWindowInfo(MessageParcel & data,MessageParcel & reply)1002 int SceneSessionManagerLiteStub::HandleGetCurrentPiPWindowInfo(MessageParcel& data, MessageParcel& reply)
1003 {
1004 std::string bundleName;
1005 WMError errCode = GetCurrentPiPWindowInfo(bundleName);
1006 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1007 return ERR_INVALID_DATA;
1008 }
1009 if (!reply.WriteString(bundleName)) {
1010 return ERR_INVALID_DATA;
1011 }
1012 return ERR_NONE;
1013 }
1014
HandleGetRootMainWindowId(MessageParcel & data,MessageParcel & reply)1015 int SceneSessionManagerLiteStub::HandleGetRootMainWindowId(MessageParcel &data, MessageParcel &reply)
1016 {
1017 TLOGI(WmsLogTag::WMS_MAIN, "call");
1018 int32_t persistentId = INVALID_WINDOW_ID;
1019 if (!data.ReadInt32(persistentId)) {
1020 TLOGE(WmsLogTag::WMS_MAIN, "Failed to readInt32 windowId");
1021 return ERR_INVALID_DATA;
1022 }
1023 int32_t hostWindowId = INVALID_WINDOW_ID;
1024 WMError errCode = GetRootMainWindowId(persistentId, hostWindowId);
1025 if (errCode != WMError::WM_OK) {
1026 TLOGE(WmsLogTag::WMS_MAIN, "Failed to GetRootMainWindowId(%{public}d)", hostWindowId);
1027 return ERR_INVALID_DATA;
1028 }
1029 if (!reply.WriteInt32(hostWindowId)) {
1030 TLOGE(WmsLogTag::WMS_MAIN, "Failed to WriteInt32 hostWindowId");
1031 return ERR_INVALID_DATA;
1032 }
1033 return ERR_NONE;
1034 }
1035
HandleGetAccessibilityWindowInfo(MessageParcel & data,MessageParcel & reply)1036 int SceneSessionManagerLiteStub::HandleGetAccessibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
1037 {
1038 std::vector<sptr<AccessibilityWindowInfo>> infos;
1039 WMError errCode = GetAccessibilityWindowInfo(infos);
1040 if (!MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(reply, infos)) {
1041 WLOGFE("Write window infos failed.");
1042 return ERR_TRANSACTION_FAILED;
1043 }
1044 reply.WriteInt32(static_cast<int32_t>(errCode));
1045 return ERR_NONE;
1046 }
1047
HandleNotifyAppUseControlList(MessageParcel & data,MessageParcel & reply)1048 int SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(MessageParcel& data, MessageParcel& reply)
1049 {
1050 TLOGD(WmsLogTag::WMS_LIFE, "In!");
1051 uint8_t controlType = 0;
1052 if (!data.ReadUint8(controlType) || controlType <= static_cast<uint8_t>(ControlAppType::CONTROL_APP_TYPE_BEGIN) ||
1053 controlType >= static_cast<uint8_t>(ControlAppType::CONTROL_APP_TYPE_END)) {
1054 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read controlType");
1055 return ERR_INVALID_DATA;
1056 }
1057 ControlAppType type = static_cast<ControlAppType>(controlType);
1058
1059 int32_t userId;
1060 if (!data.ReadInt32(userId)) {
1061 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read userId");
1062 return ERR_INVALID_DATA;
1063 }
1064
1065 int32_t size = 0;
1066 if (!data.ReadInt32(size) || size < 0 || size > MAX_CONTROL_APP_INFO) {
1067 TLOGE(WmsLogTag::WMS_LIFE, "Read controlList size failed");
1068 return ERR_INVALID_DATA;
1069 }
1070 TLOGD(WmsLogTag::WMS_LIFE, "app control list size: %{public}d", size);
1071 std::vector<AppUseControlInfo> controlList;
1072 controlList.resize(size);
1073 for (int32_t i = 0; i < size; i++) {
1074 if (!data.ReadString(controlList[i].bundleName_) ||
1075 !data.ReadInt32(controlList[i].appIndex_) ||
1076 !data.ReadBool(controlList[i].isNeedControl_) ||
1077 !data.ReadBool(controlList[i].isControlRecentOnly_)) {
1078 TLOGE(WmsLogTag::WMS_LIFE, "Read controlList failed");
1079 return ERR_INVALID_DATA;
1080 }
1081 }
1082
1083 WSError ret = NotifyAppUseControlList(type, userId, controlList);
1084 reply.WriteInt32(static_cast<int32_t>(ret));
1085 return ERR_NONE;
1086 }
1087
HandleMinimizeMainSession(MessageParcel & data,MessageParcel & reply)1088 int SceneSessionManagerLiteStub::HandleMinimizeMainSession(MessageParcel& data, MessageParcel& reply)
1089 {
1090 TLOGD(WmsLogTag::WMS_LIFE, "in");
1091 std::string bundleName;
1092 if (!data.ReadString(bundleName)) {
1093 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read bundleName");
1094 return ERR_INVALID_DATA;
1095 }
1096 int32_t appIndex = 0;
1097 if (!data.ReadInt32(appIndex)) {
1098 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read appIndex");
1099 return ERR_INVALID_DATA;
1100 }
1101 int32_t userId = 0;
1102 if (!data.ReadInt32(userId)) {
1103 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read userId");
1104 return ERR_INVALID_DATA;
1105 }
1106 WMError ret = MinimizeMainSession(bundleName, appIndex, userId);
1107 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1108 TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed.");
1109 return ERR_INVALID_DATA;
1110 }
1111 return ERR_NONE;
1112 }
1113
HandleLockSessionByAbilityInfo(MessageParcel & data,MessageParcel & reply)1114 int SceneSessionManagerLiteStub::HandleLockSessionByAbilityInfo(MessageParcel& data, MessageParcel& reply)
1115 {
1116 TLOGD(WmsLogTag::WMS_LIFE, "in");
1117 AbilityInfoBase abilityInfo;
1118 if (!data.ReadString(abilityInfo.bundleName)) {
1119 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read bundleName");
1120 return ERR_INVALID_DATA;
1121 }
1122 if (!data.ReadString(abilityInfo.moduleName)) {
1123 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read moduleName");
1124 return ERR_INVALID_DATA;
1125 }
1126 if (!data.ReadString(abilityInfo.abilityName)) {
1127 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read abilityName");
1128 return ERR_INVALID_DATA;
1129 }
1130 if (!data.ReadInt32(abilityInfo.appIndex)) {
1131 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read appIndex");
1132 return ERR_INVALID_DATA;
1133 }
1134 bool isLock = false;
1135 if (!data.ReadBool(isLock)) {
1136 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read isLock");
1137 return ERR_INVALID_DATA;
1138 }
1139 WMError ret = LockSessionByAbilityInfo(abilityInfo, isLock);
1140 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1141 return ERR_INVALID_DATA;
1142 }
1143 return ERR_NONE;
1144 }
1145
HandleHasFloatingWindowForeground(MessageParcel & data,MessageParcel & reply)1146 int SceneSessionManagerLiteStub::HandleHasFloatingWindowForeground(MessageParcel& data, MessageParcel& reply)
1147 {
1148 TLOGD(WmsLogTag::WMS_SYSTEM, "in");
1149 sptr<IRemoteObject> abilityToken = data.ReadRemoteObject();
1150 if (!abilityToken) {
1151 TLOGE(WmsLogTag::WMS_SYSTEM, "AbilityToken is null.");
1152 return ERR_INVALID_DATA;
1153 }
1154 bool hasOrNot = false;
1155 WMError errCode = HasFloatingWindowForeground(abilityToken, hasOrNot);
1156 if (!reply.WriteBool(hasOrNot)) {
1157 TLOGE(WmsLogTag::WMS_SYSTEM, "Write hasOrNot failed.");
1158 return ERR_INVALID_DATA;
1159 }
1160 if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
1161 TLOGE(WmsLogTag::WMS_SYSTEM, "Write errCode failed.");
1162 return ERR_INVALID_DATA;
1163 }
1164 return ERR_NONE;
1165 }
1166
HandleRegisterSessionLifecycleListenerByIds(MessageParcel & data,MessageParcel & reply)1167 int SceneSessionManagerLiteStub::HandleRegisterSessionLifecycleListenerByIds(MessageParcel& data, MessageParcel& reply)
1168 {
1169 TLOGD(WmsLogTag::WMS_LIFE, "in");
1170 sptr<IRemoteObject> listenerObject = data.ReadRemoteObject();
1171 if (listenerObject == nullptr) {
1172 TLOGE(WmsLogTag::WMS_LIFE, "remote object is nullptr!");
1173 return ERR_INVALID_DATA;
1174 }
1175 sptr<ISessionLifecycleListener> listener = iface_cast<ISessionLifecycleListener>(listenerObject);
1176 if (listener == nullptr) {
1177 TLOGE(WmsLogTag::WMS_LIFE, "listener is nullptr!");
1178 return ERR_INVALID_DATA;
1179 }
1180 std::vector<int32_t> persistentIdList;
1181 if (!data.ReadInt32Vector(&persistentIdList)) {
1182 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read persistentIdList");
1183 return ERR_INVALID_DATA;
1184 }
1185 WMError ret = RegisterSessionLifecycleListenerByIds(listener, persistentIdList);
1186 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1187 return ERR_INVALID_DATA;
1188 }
1189 return ERR_NONE;
1190 }
1191
HandleRegisterSessionLifecycleListenerByBundles(MessageParcel & data,MessageParcel & reply)1192 int SceneSessionManagerLiteStub::HandleRegisterSessionLifecycleListenerByBundles(
1193 MessageParcel& data, MessageParcel& reply)
1194 {
1195 TLOGD(WmsLogTag::WMS_LIFE, "in");
1196 sptr<IRemoteObject> listenerObject = data.ReadRemoteObject();
1197 if (listenerObject == nullptr) {
1198 TLOGE(WmsLogTag::WMS_LIFE, "remote object is nullptr!");
1199 return ERR_INVALID_DATA;
1200 }
1201 sptr<ISessionLifecycleListener> listener = iface_cast<ISessionLifecycleListener>(listenerObject);
1202 if (listener == nullptr) {
1203 TLOGE(WmsLogTag::WMS_LIFE, "listener is nullptr!");
1204 return ERR_INVALID_DATA;
1205 }
1206 std::vector<std::string> bundleNameList;
1207 if (!data.ReadStringVector(&bundleNameList)) {
1208 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read bundleNameList");
1209 return ERR_INVALID_DATA;
1210 }
1211 WMError ret = RegisterSessionLifecycleListenerByBundles(listener, bundleNameList);
1212 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1213 return ERR_INVALID_DATA;
1214 }
1215 return ERR_NONE;
1216 }
1217
HandleUnregisterSessionLifecycleListener(MessageParcel & data,MessageParcel & reply)1218 int SceneSessionManagerLiteStub::HandleUnregisterSessionLifecycleListener(MessageParcel& data, MessageParcel& reply)
1219 {
1220 TLOGD(WmsLogTag::WMS_LIFE, "in");
1221 sptr<IRemoteObject> listenerObject = data.ReadRemoteObject();
1222 if (listenerObject == nullptr) {
1223 TLOGE(WmsLogTag::WMS_LIFE, "remote object is nullptr!");
1224 return ERR_INVALID_DATA;
1225 }
1226 sptr<ISessionLifecycleListener> listener = iface_cast<ISessionLifecycleListener>(listenerObject);
1227 if (listener == nullptr) {
1228 TLOGE(WmsLogTag::WMS_LIFE, "listener is nullptr!");
1229 return ERR_INVALID_DATA;
1230 }
1231 WMError ret = UnregisterSessionLifecycleListener(listener);
1232 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1233 return ERR_INVALID_DATA;
1234 }
1235 return ERR_NONE;
1236 }
1237
HandleGetRecentMainSessionInfoList(MessageParcel & data,MessageParcel & reply)1238 int SceneSessionManagerLiteStub::HandleGetRecentMainSessionInfoList(MessageParcel& data, MessageParcel& reply)
1239 {
1240 TLOGD(WmsLogTag::WMS_LIFE, "in");
1241 std::vector<RecentSessionInfo> recentSessionInfoList;
1242 WSError errCode = GetRecentMainSessionInfoList(recentSessionInfoList);
1243 if (!reply.WriteInt32(recentSessionInfoList.size())) {
1244 TLOGE(WmsLogTag::WMS_LIFE, "write recent main session info list failed");
1245 return ERR_INVALID_DATA;
1246 }
1247 for (auto& sessionInfo : recentSessionInfoList) {
1248 if (!reply.WriteParcelable(&sessionInfo)) {
1249 TLOGE(WmsLogTag::WMS_LIFE, "write recent main session info failed");
1250 return ERR_INVALID_DATA;
1251 }
1252 }
1253 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1254 return ERR_INVALID_DATA;
1255 }
1256 return ERR_NONE;
1257 }
1258
HandleGetRouterStackInfo(MessageParcel & data,MessageParcel & reply)1259 int SceneSessionManagerLiteStub::HandleGetRouterStackInfo(MessageParcel& data, MessageParcel& reply)
1260 {
1261 TLOGD(WmsLogTag::WMS_LIFE, "in");
1262 int32_t persistentId = INVALID_WINDOW_ID;
1263 if (!data.ReadInt32(persistentId)) {
1264 TLOGE(WmsLogTag::WMS_LIFE, "Failed to readInt32 persistentId.");
1265 return ERR_INVALID_DATA;
1266 }
1267 sptr<IRemoteObject> listenerObject = data.ReadRemoteObject();
1268 if (listenerObject == nullptr) {
1269 TLOGE(WmsLogTag::WMS_LIFE, "remote object is nullptr.");
1270 return ERR_INVALID_DATA;
1271 }
1272 sptr<ISessionRouterStackListener> listener = iface_cast<ISessionRouterStackListener>(listenerObject);
1273 if (listener == nullptr) {
1274 TLOGE(WmsLogTag::WMS_LIFE, "listener is null");
1275 return ERR_INVALID_DATA;
1276 }
1277 WMError errCode = GetRouterStackInfo(persistentId, listener);
1278 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1279 return ERR_INVALID_DATA;
1280 }
1281 return ERR_NONE;
1282 }
1283
HandlePendingSessionToBackgroundByPersistentId(MessageParcel & data,MessageParcel & reply)1284 int SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundByPersistentId(MessageParcel& data,
1285 MessageParcel& reply)
1286 {
1287 TLOGD(WmsLogTag::WMS_LIFE, "in");
1288 int32_t persistentId;
1289 if (!data.ReadInt32(persistentId)) {
1290 TLOGE(WmsLogTag::WMS_LIFE, "read persistentId failed");
1291 return ERR_INVALID_DATA;
1292 }
1293 bool shouldBackToCaller = true;
1294 if (!data.ReadBool(shouldBackToCaller)) {
1295 TLOGE(WmsLogTag::WMS_LIFE, "Read shouldBackToCaller failed");
1296 return ERR_INVALID_DATA;
1297 }
1298 WSError errCode = PendingSessionToBackgroundByPersistentId(persistentId, shouldBackToCaller);
1299 reply.WriteInt32(static_cast<int32_t>(errCode));
1300 return ERR_NONE;
1301 }
1302
HandleCreateNewInstanceKey(MessageParcel & data,MessageParcel & reply)1303 int SceneSessionManagerLiteStub::HandleCreateNewInstanceKey(MessageParcel& data, MessageParcel& reply)
1304 {
1305 TLOGD(WmsLogTag::WMS_LIFE, "in");
1306 std::string bundleName;
1307 if (!data.ReadString(bundleName)) {
1308 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read bundleName");
1309 return ERR_INVALID_DATA;
1310 }
1311 std::string instanceKey;
1312 WMError ret = CreateNewInstanceKey(bundleName, instanceKey);
1313 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1314 TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed");
1315 return ERR_INVALID_DATA;
1316 }
1317 if (!reply.WriteString(instanceKey)) {
1318 TLOGE(WmsLogTag::WMS_LIFE, "Failed to write instanceKey");
1319 return ERR_INVALID_DATA;
1320 }
1321 return ERR_NONE;
1322 }
1323
HandleRemoveInstanceKey(MessageParcel & data,MessageParcel & reply)1324 int SceneSessionManagerLiteStub::HandleRemoveInstanceKey(MessageParcel& data, MessageParcel& reply)
1325 {
1326 TLOGD(WmsLogTag::WMS_LIFE, "in");
1327 std::string bundleName;
1328 if (!data.ReadString(bundleName)) {
1329 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read bundleName");
1330 return ERR_INVALID_DATA;
1331 }
1332 std::string instanceKey;
1333 if (!reply.ReadString(instanceKey)) {
1334 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read instanceKey");
1335 return ERR_INVALID_DATA;
1336 }
1337 WMError ret = RemoveInstanceKey(bundleName, instanceKey);
1338 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1339 TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed");
1340 return ERR_INVALID_DATA;
1341 }
1342 return ERR_NONE;
1343 }
1344
HandleTransferSessionToTargetScreen(MessageParcel & data,MessageParcel & reply)1345 int SceneSessionManagerLiteStub::HandleTransferSessionToTargetScreen(MessageParcel& data, MessageParcel& reply)
1346 {
1347 TLOGD(WmsLogTag::WMS_LIFE, "in");
1348 TransferSessionInfo info;
1349 if (!data.ReadInt32(info.persistentId)) {
1350 TLOGE(WmsLogTag::WMS_LIFE, "Read persistentId failed");
1351 return ERR_INVALID_DATA;
1352 }
1353 if (!data.ReadInt32(info.toScreenId)) {
1354 TLOGE(WmsLogTag::WMS_LIFE, "Read toScreenId failed");
1355 return ERR_INVALID_DATA;
1356 }
1357 std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
1358 if (wantParams == nullptr) {
1359 TLOGI(WmsLogTag::WMS_LIFE, "wantParams is nullptr");
1360 } else {
1361 info.wantParams = *wantParams;
1362 }
1363 WMError ret = TransferSessionToTargetScreen(info);
1364 reply.WriteInt32(static_cast<int32_t>(ret));
1365 return ERR_NONE;
1366 }
1367
HandleUpdateKioskAppList(MessageParcel & data,MessageParcel & reply)1368 int SceneSessionManagerLiteStub::HandleUpdateKioskAppList(MessageParcel& data, MessageParcel& reply)
1369 {
1370 TLOGD(WmsLogTag::WMS_LIFE, "in");
1371 std::vector<std::string> kioskAppList;
1372 if (!data.ReadStringVector(&kioskAppList)) {
1373 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read kioskAppList");
1374 return ERR_INVALID_DATA;
1375 }
1376 WMError ret = UpdateKioskAppList(kioskAppList);
1377 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1378 TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed");
1379 return ERR_INVALID_DATA;
1380 }
1381 return ERR_NONE;
1382 }
1383
HandleEnterKioskMode(MessageParcel & data,MessageParcel & reply)1384 int SceneSessionManagerLiteStub::HandleEnterKioskMode(MessageParcel& data, MessageParcel& reply)
1385 {
1386 TLOGD(WmsLogTag::WMS_LIFE, "in");
1387 sptr<IRemoteObject> token = data.ReadRemoteObject();
1388 if (token == nullptr) {
1389 TLOGE(WmsLogTag::WMS_LIFE, "Failed to read token");
1390 return ERR_INVALID_DATA;
1391 }
1392 WMError ret = EnterKioskMode(token);
1393 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1394 TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed");
1395 return ERR_INVALID_DATA;
1396 }
1397 return ERR_NONE;
1398 }
1399
HandleExitKioskMode(MessageParcel & data,MessageParcel & reply)1400 int SceneSessionManagerLiteStub::HandleExitKioskMode(MessageParcel& data, MessageParcel& reply)
1401 {
1402 TLOGD(WmsLogTag::WMS_LIFE, "in");
1403 sptr<IRemoteObject> token = nullptr;
1404 WMError ret = ExitKioskMode(token);
1405 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1406 TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed");
1407 return ERR_INVALID_DATA;
1408 }
1409 return ERR_NONE;
1410 }
1411
HandleSendPointerEventForHover(MessageParcel & data,MessageParcel & reply)1412 int SceneSessionManagerLiteStub::HandleSendPointerEventForHover(MessageParcel& data, MessageParcel& reply)
1413 {
1414 TLOGD(WmsLogTag::WMS_EVENT, "in");
1415 auto pointerEvent = MMI::PointerEvent::Create();
1416 if (pointerEvent == nullptr) {
1417 TLOGE(WmsLogTag::WMS_EVENT, "Failed to create pointer event");
1418 return ERR_INVALID_DATA;
1419 }
1420 if (!pointerEvent->ReadFromParcel(data)) {
1421 TLOGE(WmsLogTag::WMS_EVENT, "Read pointer event failed");
1422 return ERR_INVALID_DATA;
1423 }
1424 WSError ret = SendPointerEventForHover(pointerEvent);
1425 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
1426 TLOGE(WmsLogTag::WMS_EVENT, "Write ret failed");
1427 return ERR_INVALID_DATA;
1428 }
1429 return ERR_NONE;
1430 }
1431 } // namespace OHOS::Rosen
1432