• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_REGISTER_SESSION_LISTENER):
61             return HandleRegisterSessionListener(data, reply);
62         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER):
63             return HandleUnRegisterSessionListener(data, reply);
64         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFOS):
65             return HandleGetSessionInfos(data, reply);
66         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID):
67             return HandleGetMainWindowStatesByPid(data, reply);
68         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFO_BY_ID):
69             return HandleGetSessionInfo(data, reply);
70         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID):
71             return HandleGetSessionInfoByContinueSessionId(data, reply);
72         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_NEW):
73             return HandleTerminateSessionNew(data, reply);
74         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_SNAPSHOT):
75             return HandleGetSessionSnapshot(data, reply);
76         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE):
77             return HandleSetSessionContinueState(data, reply);
78         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_SESSION):
79             return HandleClearSession(data, reply);
80         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_ALL_SESSIONS):
81             return HandleClearAllSessions(data, reply);
82         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION):
83             return HandleLockSession(data, reply);
84         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNLOCK_SESSION):
85             return HandleUnlockSession(data, reply);
86         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND):
87             return HandleMoveSessionsToForeground(data, reply);
88         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND):
89             return HandleMoveSessionsToBackground(data, reply);
90         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_INFO):
91             return HandleGetFocusSessionInfo(data, reply);
92         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT):
93             return HandleRegisterWindowManagerAgent(data, reply);
94         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT):
95             return HandleUnregisterWindowManagerAgent(data, reply);
96         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CHECK_WINDOW_ID):
97             return HandleCheckWindowId(data, reply);
98         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UI_EXTENSION_CREATION_CHECK):
99             return HandleCheckUIExtensionCreation(data, reply);
100         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID):
101             return HandleGetVisibilityWindowInfo(data, reply);
102         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_MODE_TYPE):
103             return HandleGetWindowModeType(data, reply);
104         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_RAISE_WINDOW_TO_TOP):
105             return HandleRaiseWindowToTop(data, reply);
106         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_TOPN_MAIN_WINDOW_INFO):
107             return HandleGetMainWinodowInfo(data, reply);
108         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_COLLABORATOR):
109             return HandleRegisterCollaborator(data, reply);
110         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_COLLABORATOR):
111             return HandleUnregisterCollaborator(data, reply);
112         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_ALL_MAIN_WINDOW_INFO):
113             return HandleGetAllMainWindowInfos(data, reply);
114         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_MAIN_SESSIONS):
115             return HandleClearMainSessions(data, reply);
116         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_STYLE_TYPE):
117             return HandleGetWindowStyleType(data, reply);
118         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_BY_PERSISTENT_ID):
119             return HandleTerminateSessionByPersistentId(data, reply);
120         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_INFO):
121             return HandleGetAccessibilityWindowInfo(data, reply);
122         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLOSE_TARGET_FLOAT_WINDOW):
123             return HandleCloseTargetFloatWindow(data, reply);
124         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_CLOSE_TARGET_PIP_WINDOW):
125             return HandleCloseTargetPiPWindow(data, reply);
126         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO):
127             return HandleGetCurrentPiPWindowInfo(data, reply);
128         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_NOTIFY_APP_USE_CONTROL_LIST):
129             return HandleNotifyAppUseControlList(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_MINIMIZE_MAIN_SESSION):
133             return HandleMinimizeMainSession(data, reply);
134         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_HAS_FLOAT_FOREGROUND):
135             return HandleHasFloatingWindowForeground(data, reply);
136         case static_cast<uint32_t>(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION_BY_ABILITY_INFO):
137             return HandleLockSessionByAbilityInfo(data, reply);
138         default:
139             WLOGFE("Failed to find function handler!");
140             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
141     }
142 }
143 
HandleSetSessionLabel(MessageParcel & data,MessageParcel & reply)144 int SceneSessionManagerLiteStub::HandleSetSessionLabel(MessageParcel& data, MessageParcel& reply)
145 {
146     WLOGFD("run HandleSetSessionLabel!");
147     sptr<IRemoteObject> token = data.ReadRemoteObject();
148     std::string label = data.ReadString();
149     WSError errCode = SetSessionLabel(token, label);
150     reply.WriteInt32(static_cast<int32_t>(errCode));
151     return ERR_NONE;
152 }
153 
HandleSetSessionIcon(MessageParcel & data,MessageParcel & reply)154 int SceneSessionManagerLiteStub::HandleSetSessionIcon(MessageParcel& data, MessageParcel& reply)
155 {
156     WLOGFD("run HandleSetSessionIcon!");
157     sptr<IRemoteObject> token = data.ReadRemoteObject();
158     std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
159     if (icon == nullptr) {
160         WLOGFE("icon is null");
161         return ERR_INVALID_DATA;
162     }
163     WSError errCode = SetSessionIcon(token, icon);
164     reply.WriteInt32(static_cast<int32_t>(errCode));
165     return ERR_NONE;
166 }
167 
HandleIsValidSessionIds(MessageParcel & data,MessageParcel & reply)168 int SceneSessionManagerLiteStub::HandleIsValidSessionIds(MessageParcel& data, MessageParcel& reply)
169 {
170     WLOGFD("run HandleIsValidSessionIds!");
171     std::vector<int32_t> sessionIds;
172     data.ReadInt32Vector(&sessionIds);
173     std::vector<bool> results;
174     WSError errCode = IsValidSessionIds(sessionIds, results);
175     reply.WriteBoolVector(results);
176     reply.WriteUint32(static_cast<uint32_t>(errCode));
177     return ERR_NONE;
178 }
179 
HandlePendingSessionToForeground(MessageParcel & data,MessageParcel & reply)180 int SceneSessionManagerLiteStub::HandlePendingSessionToForeground(MessageParcel& data, MessageParcel& reply)
181 {
182     WLOGFD("run HandlePendingSessionToForeground!");
183     sptr<IRemoteObject> token = data.ReadRemoteObject();
184     if (token == nullptr) {
185         WLOGFE("token is nullptr");
186         return ERR_INVALID_DATA;
187     }
188     WSError errCode = PendingSessionToForeground(token);
189     reply.WriteUint32(static_cast<uint32_t>(errCode));
190     return ERR_NONE;
191 }
192 
HandlePendingSessionToBackgroundForDelegator(MessageParcel & data,MessageParcel & reply)193 int SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator(MessageParcel& data, MessageParcel& reply)
194 {
195     TLOGD(WmsLogTag::WMS_LIFE, "run");
196     sptr<IRemoteObject> token = data.ReadRemoteObject();
197     if (token == nullptr) {
198         TLOGE(WmsLogTag::WMS_LIFE, "token is nullptr");
199         return ERR_INVALID_DATA;
200     }
201     bool shouldBackToCaller = true;
202     if (!data.ReadBool(shouldBackToCaller)) {
203         TLOGE(WmsLogTag::WMS_LIFE, "Read shouldBackToCaller failed");
204         return ERR_INVALID_DATA;
205     }
206     WSError errCode = PendingSessionToBackgroundForDelegator(token, shouldBackToCaller);
207     reply.WriteInt32(static_cast<int32_t>(errCode));
208     return ERR_NONE;
209 }
210 
HandleRegisterSessionListener(MessageParcel & data,MessageParcel & reply)211 int SceneSessionManagerLiteStub::HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
212 {
213     WLOGFD("run HandleRegisterSessionListener!");
214     sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
215     if (listener == nullptr) {
216         TLOGE(WmsLogTag::DEFAULT, "listener is nullptr!");
217         reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
218         return ERR_NONE;
219     }
220     WSError errCode = RegisterSessionListener(listener);
221     reply.WriteInt32(static_cast<int32_t>(errCode));
222     return ERR_NONE;
223 }
224 
HandleUnRegisterSessionListener(MessageParcel & data,MessageParcel & reply)225 int SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(MessageParcel& data, MessageParcel& reply)
226 {
227     WLOGFD("run HandleUnRegisterSessionListener!");
228     sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
229     if (listener == nullptr) {
230         reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_INVALID_PARAM));
231         return ERR_NONE;
232     }
233     WSError errCode = UnRegisterSessionListener(listener);
234     reply.WriteInt32(static_cast<int32_t>(errCode));
235     return ERR_NONE;
236 }
237 
HandleGetSessionInfos(MessageParcel & data,MessageParcel & reply)238 int SceneSessionManagerLiteStub::HandleGetSessionInfos(MessageParcel& data, MessageParcel& reply)
239 {
240     WLOGFD("run HandleGetSessionInfos!");
241     std::string deviceId = Str16ToStr8(data.ReadString16());
242     int numMax = data.ReadInt32();
243     std::vector<SessionInfoBean> missionInfos;
244     WSError errCode = GetSessionInfos(deviceId, numMax, missionInfos);
245     reply.WriteInt32(missionInfos.size());
246     for (auto& it : missionInfos) {
247         if (!reply.WriteParcelable(&it)) {
248             WLOGFE("GetSessionInfos error");
249             return ERR_INVALID_DATA;
250         }
251     }
252     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
253         return ERR_INVALID_DATA;
254     }
255     return ERR_NONE;
256 }
257 
HandleGetMainWindowStatesByPid(MessageParcel & data,MessageParcel & reply)258 int SceneSessionManagerLiteStub::HandleGetMainWindowStatesByPid(MessageParcel& data, MessageParcel& reply)
259 {
260     int32_t pid = 0;
261     if (!data.ReadInt32(pid)) {
262         TLOGE(WmsLogTag::WMS_LIFE, "read pid fail");
263         return ERR_INVALID_DATA;
264     }
265     std::vector<MainWindowState> windowStates;
266     WSError errCode = GetMainWindowStatesByPid(pid, windowStates);
267     if (!reply.WriteInt32(windowStates.size())) {
268         TLOGE(WmsLogTag::WMS_LIFE, "write windowStates size fail");
269         return ERR_INVALID_DATA;
270     }
271     for (auto& state : windowStates) {
272         if (!reply.WriteParcelable(&state)) {
273             TLOGE(WmsLogTag::WMS_LIFE, "write windowState fail");
274             return ERR_INVALID_DATA;
275         }
276     }
277     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
278         return ERR_INVALID_DATA;
279     }
280     return ERR_NONE;
281 }
282 
HandleGetSessionInfo(MessageParcel & data,MessageParcel & reply)283 int SceneSessionManagerLiteStub::HandleGetSessionInfo(MessageParcel& data, MessageParcel& reply)
284 {
285     WLOGFD("run HandleGetSessionInfo!");
286     SessionInfoBean info;
287     std::string deviceId = Str16ToStr8(data.ReadString16());
288     int32_t persistentId = data.ReadInt32();
289     WSError errCode = GetSessionInfo(deviceId, persistentId, info);
290     if (!reply.WriteParcelable(&info)) {
291         WLOGFE("GetSessionInfo error");
292         return ERR_INVALID_DATA;
293     }
294 
295     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
296         WLOGFE("GetSessionInfo result error");
297         return ERR_INVALID_DATA;
298     }
299     return ERR_NONE;
300 }
301 
HandleGetSessionInfoByContinueSessionId(MessageParcel & data,MessageParcel & reply)302 int SceneSessionManagerLiteStub::HandleGetSessionInfoByContinueSessionId(MessageParcel& data, MessageParcel& reply)
303 {
304     SessionInfoBean info;
305     std::string continueSessionId = data.ReadString();
306     TLOGI(WmsLogTag::WMS_LIFE, "continueSessionId: %{public}s", continueSessionId.c_str());
307     WSError errCode = GetSessionInfoByContinueSessionId(continueSessionId, info);
308     if (!reply.WriteParcelable(&info)) {
309         TLOGE(WmsLogTag::WMS_LIFE, "Get sessionInfo by continueSessionId error");
310         return ERR_INVALID_DATA;
311     }
312 
313     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
314         TLOGE(WmsLogTag::WMS_LIFE, "Get sessionInfo by continueSessionId result error");
315         return ERR_INVALID_DATA;
316     }
317     return ERR_NONE;
318 }
319 
HandleTerminateSessionNew(MessageParcel & data,MessageParcel & reply)320 int SceneSessionManagerLiteStub::HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply)
321 {
322     WLOGFD("run HandleTerminateSessionNew");
323     sptr<AAFwk::SessionInfo> abilitySessionInfo = data.ReadParcelable<AAFwk::SessionInfo>();
324     if (abilitySessionInfo == nullptr) {
325         WLOGFE("abilitySessionInfo is null");
326         return ERR_INVALID_DATA;
327     }
328     bool needStartCaller = data.ReadBool();
329     bool isFromBroker = data.ReadBool();
330     WSError errCode = TerminateSessionNew(abilitySessionInfo, needStartCaller, isFromBroker);
331     reply.WriteUint32(static_cast<uint32_t>(errCode));
332     return ERR_NONE;
333 }
334 
HandleGetFocusSessionToken(MessageParcel & data,MessageParcel & reply)335 int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel& data, MessageParcel& reply)
336 {
337     WLOGFD("run HandleGetFocusSessionToken!");
338     sptr<IRemoteObject> token = nullptr;
339     WSError errCode = GetFocusSessionToken(token);
340     reply.WriteRemoteObject(token);
341     reply.WriteInt32(static_cast<int32_t>(errCode));
342     return ERR_NONE;
343 }
344 
HandleGetFocusSessionElement(MessageParcel & data,MessageParcel & reply)345 int SceneSessionManagerLiteStub::HandleGetFocusSessionElement(MessageParcel& data, MessageParcel& reply)
346 {
347     WLOGFD("run HandleGetFocusSessionElement!");
348     AppExecFwk::ElementName element;
349     WSError errCode = GetFocusSessionElement(element);
350     reply.WriteParcelable(&element);
351     reply.WriteInt32(static_cast<int32_t>(errCode));
352     return ERR_NONE;
353 }
354 
HandleSetSessionContinueState(MessageParcel & data,MessageParcel & reply)355 int SceneSessionManagerLiteStub::HandleSetSessionContinueState(MessageParcel& data, MessageParcel& reply)
356 {
357     WLOGFD("HandleSetSessionContinueState");
358     sptr <IRemoteObject> token = data.ReadRemoteObject();
359     auto continueState = static_cast<ContinueState>(data.ReadInt32());
360     const WSError &ret = SetSessionContinueState(token, continueState);
361     reply.WriteUint32(static_cast<uint32_t>(ret));
362     return ERR_NONE;
363 }
364 
HandleGetSessionSnapshot(MessageParcel & data,MessageParcel & reply)365 int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel& data, MessageParcel& reply)
366 {
367     WLOGFD("run HandleGetSessionSnapshot!");
368     std::string deviceId = Str16ToStr8(data.ReadString16());
369     int32_t persistentId = data.ReadInt32();
370     bool isLowResolution = data.ReadBool();
371     std::shared_ptr<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
372     WSError ret = GetSessionSnapshot(deviceId, persistentId, *snapshot, isLowResolution);
373     reply.WriteParcelable(snapshot.get());
374     reply.WriteUint32(static_cast<uint32_t>(ret));
375     return ERR_NONE;
376 }
377 
HandleClearSession(MessageParcel & data,MessageParcel & reply)378 int SceneSessionManagerLiteStub::HandleClearSession(MessageParcel& data, MessageParcel& reply)
379 {
380     WLOGFD("run HandleClearSession!");
381     int32_t persistentId = data.ReadInt32();
382     WSError ret = ClearSession(persistentId);
383     reply.WriteUint32(static_cast<uint32_t>(ret));
384     return ERR_NONE;
385 }
386 
HandleClearAllSessions(MessageParcel & data,MessageParcel & reply)387 int SceneSessionManagerLiteStub::HandleClearAllSessions(MessageParcel& data, MessageParcel& reply)
388 {
389     WLOGFD("run HandleClearAllSessions!");
390     WSError ret = ClearAllSessions();
391     reply.WriteUint32(static_cast<uint32_t>(ret));
392     return ERR_NONE;
393 }
394 
HandleLockSession(MessageParcel & data,MessageParcel & reply)395 int SceneSessionManagerLiteStub::HandleLockSession(MessageParcel& data, MessageParcel& reply)
396 {
397     WLOGFD("run HandleLockSession!");
398     int32_t sessionId = data.ReadInt32();
399     WSError ret = LockSession(sessionId);
400     reply.WriteUint32(static_cast<uint32_t>(ret));
401     return ERR_NONE;
402 }
403 
HandleUnlockSession(MessageParcel & data,MessageParcel & reply)404 int SceneSessionManagerLiteStub::HandleUnlockSession(MessageParcel& data, MessageParcel& reply)
405 {
406     WLOGFD("run HandleUnlockSession!");
407     int32_t sessionId = data.ReadInt32();
408     WSError ret = UnlockSession(sessionId);
409     reply.WriteUint32(static_cast<uint32_t>(ret));
410     return ERR_NONE;
411 }
412 
HandleMoveSessionsToForeground(MessageParcel & data,MessageParcel & reply)413 int SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(MessageParcel& data, MessageParcel& reply)
414 {
415     WLOGFD("run HandleMoveSessionsToForeground!");
416     std::vector<int32_t> sessionIds;
417     data.ReadInt32Vector(&sessionIds);
418     int32_t topSessionId = data.ReadInt32();
419     const WSError &ret = MoveSessionsToForeground(sessionIds, topSessionId);
420     reply.WriteUint32(static_cast<uint32_t>(ret));
421     return ERR_NONE;
422 }
423 
HandleMoveSessionsToBackground(MessageParcel & data,MessageParcel & reply)424 int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel& data, MessageParcel& reply)
425 {
426     WLOGFD("run HandleMoveSessionsToBackground!");
427     std::vector<int32_t> sessionIds;
428     data.ReadInt32Vector(&sessionIds);
429     std::vector<int32_t> result;
430     data.ReadInt32Vector(&result);
431     const WSError &ret = MoveSessionsToBackground(sessionIds, result);
432     reply.WriteInt32Vector(result);
433     reply.WriteUint32(static_cast<uint32_t>(ret));
434     return ERR_NONE;
435 }
436 
HandleGetFocusSessionInfo(MessageParcel & data,MessageParcel & reply)437 int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply)
438 {
439     WLOGFD("run");
440     FocusChangeInfo focusInfo;
441     GetFocusWindowInfo(focusInfo);
442     reply.WriteParcelable(&focusInfo);
443     return ERR_NONE;
444 }
445 
HandleCheckWindowId(MessageParcel & data,MessageParcel & reply)446 int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel& data, MessageParcel& reply)
447 {
448     WLOGFI("run HandleCheckWindowId!");
449     int32_t windowId = INVALID_WINDOW_ID;
450     if (!data.ReadInt32(windowId)) {
451         WLOGE("Failed to readInt32 windowId");
452         return ERR_INVALID_DATA;
453     }
454     int32_t pid = INVALID_PID;
455     WMError errCode = CheckWindowId(windowId, pid);
456     if (errCode != WMError::WM_OK) {
457         WLOGE("Failed to checkWindowId(%{public}d)", pid);
458         return ERR_INVALID_DATA;
459     }
460     if (!reply.WriteInt32(pid)) {
461         WLOGE("Failed to WriteInt32 pid");
462         return ERR_INVALID_DATA;
463     }
464     return ERR_NONE;
465 }
466 
HandleCheckUIExtensionCreation(MessageParcel & data,MessageParcel & reply)467 int SceneSessionManagerLiteStub::HandleCheckUIExtensionCreation(MessageParcel& data, MessageParcel& reply)
468 {
469     TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: called");
470     int32_t windowId = INVALID_WINDOW_ID;
471     if (!data.ReadInt32(windowId)) {
472         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get windowId");
473         return ERR_INVALID_DATA;
474     }
475     uint32_t tokenId = -1;
476     if (!data.ReadUint32(tokenId)) {
477         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get token");
478         return ERR_INVALID_DATA;
479     }
480     int32_t extAbilityTypeValue = -1;
481     if (!data.ReadInt32(extAbilityTypeValue)) {
482         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get extensionAbilityType");
483         return ERR_INVALID_DATA;
484     }
485     if (extAbilityTypeValue < 0) {
486         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get extensionAbilityType(out of range)");
487         return ERR_INVALID_DATA;
488     }
489     auto extAbilityType = static_cast<AppExecFwk::ExtensionAbilityType>(extAbilityTypeValue);
490     sptr<AppExecFwk::ElementName> element = data.ReadParcelable<AppExecFwk::ElementName>();
491     if (!element) {
492         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get element");
493         return ERR_INVALID_DATA;
494     }
495     int32_t pid = INVALID_PID;
496     WMError errCode = CheckUIExtensionCreation(windowId, tokenId, *element, extAbilityType, pid);
497     TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: ret %{public}u", errCode);
498     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
499         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write errcode");
500         return ERR_INVALID_DATA;
501     }
502     if (!reply.WriteInt32(pid)) {
503         TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write pid");
504         return ERR_INVALID_DATA;
505     }
506     return ERR_NONE;
507 }
508 
HandleRegisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)509 int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
510 {
511     auto type = static_cast<WindowManagerAgentType>(data.ReadUint32());
512     WLOGFI("run HandleRegisterWindowManagerAgent!, type=%{public}u", static_cast<uint32_t>(type));
513     sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
514     sptr<IWindowManagerAgent> windowManagerAgentProxy =
515             iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
516     WMError errCode = RegisterWindowManagerAgent(type, windowManagerAgentProxy);
517     reply.WriteInt32(static_cast<int32_t>(errCode));
518     return ERR_NONE;
519 }
520 
HandleUnregisterWindowManagerAgent(MessageParcel & data,MessageParcel & reply)521 int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply)
522 {
523     auto type = static_cast<WindowManagerAgentType>(data.ReadUint32());
524     WLOGFI("run HandleUnregisterWindowManagerAgent!, type=%{public}u", static_cast<uint32_t>(type));
525     sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject();
526     sptr<IWindowManagerAgent> windowManagerAgentProxy =
527             iface_cast<IWindowManagerAgent>(windowManagerAgentObject);
528     WMError errCode = UnregisterWindowManagerAgent(type, windowManagerAgentProxy);
529     reply.WriteInt32(static_cast<int32_t>(errCode));
530     return ERR_NONE;
531 }
532 
HandleGetVisibilityWindowInfo(MessageParcel & data,MessageParcel & reply)533 int SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
534 {
535     std::vector<sptr<WindowVisibilityInfo>> infos;
536     WMError errCode = GetVisibilityWindowInfo(infos);
537     if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowVisibilityInfo>(reply, infos)) {
538         WLOGFE("Write visibility window infos failed");
539         return -1;
540     }
541     reply.WriteInt32(static_cast<int32_t>(errCode));
542     return ERR_NONE;
543 }
544 
HandleGetWindowModeType(MessageParcel & data,MessageParcel & reply)545 int SceneSessionManagerLiteStub::HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply)
546 {
547     WindowModeType windowModeType = Rosen::WindowModeType::WINDOW_MODE_OTHER;
548     WMError errCode = GetWindowModeType(windowModeType);
549     WLOGFI("run HandleGetWindowModeType, windowModeType:%{public}d!", static_cast<int32_t>(windowModeType));
550     if (!reply.WriteUint32(static_cast<int32_t>(windowModeType))) {
551         WLOGE("Failed to WriteBool");
552         return ERR_INVALID_DATA;
553     }
554     reply.WriteInt32(static_cast<int32_t>(errCode));
555     return ERR_NONE;
556 }
557 
HandleRaiseWindowToTop(MessageParcel & data,MessageParcel & reply)558 int SceneSessionManagerLiteStub::HandleRaiseWindowToTop(MessageParcel& data, MessageParcel& reply)
559 {
560     auto persistentId = data.ReadInt32();
561     WSError errCode = RaiseWindowToTop(persistentId);
562     reply.WriteUint32(static_cast<uint32_t>(errCode));
563     return ERR_NONE;
564 }
565 
566 
HandleGetMainWinodowInfo(MessageParcel & data,MessageParcel & reply)567 int SceneSessionManagerLiteStub::HandleGetMainWinodowInfo(MessageParcel &data, MessageParcel &reply)
568 {
569     TLOGI(WmsLogTag::WMS_MAIN, "run HandleGetMainWinodowInfo lite");
570     int32_t topN = 0;
571     if (!data.ReadInt32(topN)) {
572         TLOGE(WmsLogTag::WMS_MAIN, "failed to read topN");
573         return ERR_INVALID_DATA;
574     }
575     TLOGD(WmsLogTag::WMS_MAIN, "topN :%{public}d", topN);
576     std::vector<MainWindowInfo> topNInfos;
577     WMError errCode = GetMainWindowInfos(topN, topNInfos);
578     if ((topNInfos.size() <= 0) || (topNInfos.size() >= MAX_TOPN_INFO_SIZE)) {
579         return ERR_INVALID_DATA;
580     }
581     reply.WriteInt32(topNInfos.size());
582     for (auto& it : topNInfos) {
583         if (!reply.WriteParcelable(&it)) {
584             TLOGE(WmsLogTag::WMS_MAIN, "write topNinfo fail");
585             return ERR_INVALID_DATA;
586         }
587 
588         TLOGI(WmsLogTag::WMS_MAIN, "pid %{public}d, name %{public}s",
589             it.pid_, it.bundleName_.c_str());
590     }
591 
592     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
593         return ERR_INVALID_DATA;
594     }
595 
596     return ERR_NONE;
597 }
598 
HandleRegisterCollaborator(MessageParcel & data,MessageParcel & reply)599 int SceneSessionManagerLiteStub::HandleRegisterCollaborator(MessageParcel& data, MessageParcel& reply)
600 {
601     TLOGD(WmsLogTag::WMS_MAIN, "called.");
602     int32_t type = data.ReadInt32();
603     sptr<IRemoteObject> collaboratorObject = data.ReadRemoteObject();
604     if (collaboratorObject == nullptr) {
605         TLOGE(WmsLogTag::WMS_MAIN, "collaboratorObject is null.");
606         return ERR_NULL_OBJECT;
607     }
608     sptr<AAFwk::IAbilityManagerCollaborator> collaborator =
609         iface_cast<AAFwk::IAbilityManagerCollaborator>(collaboratorObject);
610     WSError ret = RegisterIAbilityManagerCollaborator(type, collaborator);
611     reply.WriteInt32(static_cast<int32_t>(ret));
612     return ERR_NONE;
613 }
614 
HandleUnregisterCollaborator(MessageParcel & data,MessageParcel & reply)615 int SceneSessionManagerLiteStub::HandleUnregisterCollaborator(MessageParcel& data, MessageParcel& reply)
616 {
617     TLOGD(WmsLogTag::WMS_MAIN, "called.");
618     int32_t type = data.ReadInt32();
619     WSError ret = UnregisterIAbilityManagerCollaborator(type);
620     reply.WriteInt32(static_cast<int32_t>(ret));
621     return ERR_NONE;
622 }
623 
HandleGetAllMainWindowInfos(MessageParcel & data,MessageParcel & reply)624 int SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos(MessageParcel& data, MessageParcel& reply)
625 {
626     std::vector<MainWindowInfo> infos;
627     WMError errCode = GetAllMainWindowInfos(infos);
628     reply.WriteInt32(infos.size());
629     for (auto& info : infos) {
630         if (!reply.WriteParcelable(&info)) {
631             TLOGE(WmsLogTag::WMS_MAIN, "write main window info fail");
632             return ERR_INVALID_DATA;
633         }
634     }
635     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
636         return ERR_INVALID_DATA;
637     }
638     return ERR_NONE;
639 }
640 
HandleClearMainSessions(MessageParcel & data,MessageParcel & reply)641 int SceneSessionManagerLiteStub::HandleClearMainSessions(MessageParcel& data, MessageParcel& reply)
642 {
643     std::vector<int32_t> persistentIds;
644     std::vector<int32_t> clearFailedIds;
645     if (!data.ReadInt32Vector(&persistentIds)) {
646         TLOGE(WmsLogTag::WMS_MAIN, "failed to read persistentIds.");
647         return ERR_INVALID_DATA;
648     }
649     WMError errCode = ClearMainSessions(persistentIds, clearFailedIds);
650     if (!reply.WriteInt32Vector(clearFailedIds)) {
651         TLOGE(WmsLogTag::WMS_MAIN, "write clearFailedIds fail.");
652         return ERR_INVALID_DATA;
653     }
654     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
655         return ERR_INVALID_DATA;
656     }
657     return ERR_NONE;
658 }
659 
HandleGetWindowStyleType(MessageParcel & data,MessageParcel & reply)660 int SceneSessionManagerLiteStub::HandleGetWindowStyleType(MessageParcel& data, MessageParcel& reply)
661 {
662     WindowStyleType windowStyleType = Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT;
663     WMError errCode = GetWindowStyleType(windowStyleType);
664     TLOGI(WmsLogTag::WMS_MAIN, "windowStyleType:%{public}d!", static_cast<int32_t>(windowStyleType));
665     if (!reply.WriteUint32(static_cast<int32_t>(windowStyleType))) {
666         TLOGE(WmsLogTag::WMS_MAIN, "Failed to WriteBool");
667         return ERR_INVALID_DATA;
668     }
669     reply.WriteInt32(static_cast<int32_t>(errCode));
670     return ERR_NONE;
671 }
672 
HandleTerminateSessionByPersistentId(MessageParcel & data,MessageParcel & reply)673 int SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(MessageParcel& data, MessageParcel& reply)
674 {
675     int32_t persistentId = data.ReadInt32();
676     WMError errCode = TerminateSessionByPersistentId(persistentId);
677     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
678         return ERR_INVALID_DATA;
679     }
680     return ERR_NONE;
681 }
682 
HandleGetAccessibilityWindowInfo(MessageParcel & data,MessageParcel & reply)683 int SceneSessionManagerLiteStub::HandleGetAccessibilityWindowInfo(MessageParcel& data, MessageParcel& reply)
684 {
685     std::vector<sptr<AccessibilityWindowInfo>> infos;
686     WMError errCode = GetAccessibilityWindowInfo(infos);
687     if (!MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(reply, infos)) {
688         WLOGFE("Write window infos failed.");
689         return ERR_TRANSACTION_FAILED;
690     }
691     reply.WriteInt32(static_cast<int32_t>(errCode));
692     return ERR_NONE;
693 }
694 
HandleCloseTargetFloatWindow(MessageParcel & data,MessageParcel & reply)695 int SceneSessionManagerLiteStub::HandleCloseTargetFloatWindow(MessageParcel& data, MessageParcel& reply)
696 {
697     std::string bundleName = data.ReadString();
698     CloseTargetFloatWindow(bundleName);
699     return ERR_NONE;
700 }
701 
HandleCloseTargetPiPWindow(MessageParcel & data,MessageParcel & reply)702 int SceneSessionManagerLiteStub::HandleCloseTargetPiPWindow(MessageParcel& data, MessageParcel& reply)
703 {
704     std::string bundleName = data.ReadString();
705     WMError errCode = CloseTargetPiPWindow(bundleName);
706     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
707         return ERR_INVALID_DATA;
708     }
709     return ERR_NONE;
710 }
711 
HandleGetCurrentPiPWindowInfo(MessageParcel & data,MessageParcel & reply)712 int SceneSessionManagerLiteStub::HandleGetCurrentPiPWindowInfo(MessageParcel& data, MessageParcel& reply)
713 {
714     std::string bundleName;
715     WMError errCode = GetCurrentPiPWindowInfo(bundleName);
716     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
717         return ERR_INVALID_DATA;
718     }
719     if (!reply.WriteString(bundleName)) {
720         return ERR_INVALID_DATA;
721     }
722     return ERR_NONE;
723 }
724 
HandleNotifyAppUseControlList(MessageParcel & data,MessageParcel & reply)725 int SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(MessageParcel& data, MessageParcel& reply)
726 {
727     TLOGD(WmsLogTag::WMS_LIFE, "In!");
728     uint8_t controlType = 0;
729     if (!data.ReadUint8(controlType) || controlType <= static_cast<uint8_t>(ControlAppType::CONTROL_APP_TYPE_BEGIN) ||
730         controlType >= static_cast<uint8_t>(ControlAppType::CONTROL_APP_TYPE_END)) {
731         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read controlType");
732         return ERR_INVALID_DATA;
733     }
734     ControlAppType type = static_cast<ControlAppType>(controlType);
735 
736     int32_t userId;
737     if (!data.ReadInt32(userId)) {
738         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read userId");
739         return ERR_INVALID_DATA;
740     }
741 
742     int32_t size = 0;
743     if (!data.ReadInt32(size) || size < 0 || size > MAX_CONTROL_APP_INFO) {
744         TLOGE(WmsLogTag::WMS_LIFE, "Read controlList size failed");
745         return ERR_INVALID_DATA;
746     }
747     TLOGD(WmsLogTag::WMS_LIFE, "app control list size: %{public}d", size);
748     std::vector<AppUseControlInfo> controlList;
749     controlList.resize(size);
750     for (int32_t i = 0; i < size; i++) {
751         if (!data.ReadString(controlList[i].bundleName_) ||
752             !data.ReadInt32(controlList[i].appIndex_) ||
753             !data.ReadBool(controlList[i].isNeedControl_)) {
754             TLOGE(WmsLogTag::WMS_LIFE, "Read controlList failed");
755             return ERR_INVALID_DATA;
756         }
757     }
758 
759     WSError ret = NotifyAppUseControlList(type, userId, controlList);
760     reply.WriteInt32(static_cast<int32_t>(ret));
761     return ERR_NONE;
762 }
763 
HandleGetRootMainWindowId(MessageParcel & data,MessageParcel & reply)764 int SceneSessionManagerLiteStub::HandleGetRootMainWindowId(MessageParcel &data, MessageParcel &reply)
765 {
766     TLOGI(WmsLogTag::WMS_MAIN, "call");
767     int32_t persistentId = INVALID_WINDOW_ID;
768     if (!data.ReadInt32(persistentId)) {
769         TLOGE(WmsLogTag::WMS_MAIN, "Failed to readInt32 windowId");
770         return ERR_INVALID_DATA;
771     }
772     int32_t hostWindowId = INVALID_WINDOW_ID;
773     WMError errCode = GetRootMainWindowId(persistentId, hostWindowId);
774     if (errCode != WMError::WM_OK) {
775         TLOGE(WmsLogTag::WMS_MAIN, "Failed to GetRootMainWindowId(%{public}d)", hostWindowId);
776         return ERR_INVALID_DATA;
777     }
778     if (!reply.WriteInt32(hostWindowId)) {
779         TLOGE(WmsLogTag::WMS_MAIN, "Failed to WriteInt32 hostWindowId");
780         return ERR_INVALID_DATA;
781     }
782     return ERR_NONE;
783 }
784 
HandleMinimizeMainSession(MessageParcel & data,MessageParcel & reply)785 int SceneSessionManagerLiteStub::HandleMinimizeMainSession(MessageParcel& data, MessageParcel& reply)
786 {
787     TLOGD(WmsLogTag::WMS_LIFE, "in");
788     std::string bundleName;
789     if (!data.ReadString(bundleName)) {
790         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read bundleName");
791         return ERR_INVALID_DATA;
792     }
793     int32_t appIndex = 0;
794     if (!data.ReadInt32(appIndex)) {
795         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read appIndex");
796         return ERR_INVALID_DATA;
797     }
798     int32_t userId = 0;
799     if (!data.ReadInt32(userId)) {
800         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read userId");
801         return ERR_INVALID_DATA;
802     }
803     WMError ret = MinimizeMainSession(bundleName, appIndex, userId);
804     if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
805         TLOGE(WmsLogTag::WMS_LIFE, "Write ret failed.");
806         return ERR_INVALID_DATA;
807     };
808     return ERR_NONE;
809 }
810 
HandleHasFloatingWindowForeground(MessageParcel & data,MessageParcel & reply)811 int SceneSessionManagerLiteStub::HandleHasFloatingWindowForeground(MessageParcel& data, MessageParcel& reply)
812 {
813     TLOGD(WmsLogTag::WMS_SYSTEM, "in");
814     sptr<IRemoteObject> abilityToken = data.ReadRemoteObject();
815     if (!abilityToken) {
816         TLOGE(WmsLogTag::WMS_SYSTEM, "AbilityToken is null.");
817         return ERR_INVALID_DATA;
818     }
819     bool hasOrNot = false;
820     WMError errCode = HasFloatingWindowForeground(abilityToken, hasOrNot);
821     if (!reply.WriteBool(hasOrNot)) {
822         TLOGE(WmsLogTag::WMS_SYSTEM, "Write hasOrNot failed.");
823         return ERR_INVALID_DATA;
824     }
825     if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
826         TLOGE(WmsLogTag::WMS_SYSTEM, "Write errCode failed.");
827         return ERR_INVALID_DATA;
828     }
829     return ERR_NONE;
830 }
831 
HandleLockSessionByAbilityInfo(MessageParcel & data,MessageParcel & reply)832 int SceneSessionManagerLiteStub::HandleLockSessionByAbilityInfo(MessageParcel& data, MessageParcel& reply)
833 {
834     TLOGD(WmsLogTag::WMS_LIFE, "in");
835     AbilityInfoBase abilityInfo;
836     if (!data.ReadString(abilityInfo.bundleName)) {
837         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read bundleName");
838         return ERR_INVALID_DATA;
839     }
840     if (!data.ReadString(abilityInfo.moduleName)) {
841         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read moduleName");
842         return ERR_INVALID_DATA;
843     }
844     if (!data.ReadString(abilityInfo.abilityName)) {
845         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read abilityName");
846         return ERR_INVALID_DATA;
847     }
848     if (!data.ReadInt32(abilityInfo.appIndex)) {
849         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read appIndex");
850         return ERR_INVALID_DATA;
851     }
852     bool isLock = false;
853     if (!data.ReadBool(isLock)) {
854         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read isLock");
855         return ERR_INVALID_DATA;
856     }
857     WMError ret = LockSessionByAbilityInfo(abilityInfo, isLock);
858     if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
859         return ERR_INVALID_DATA;
860     }
861     return ERR_NONE;
862 }
863 } // namespace OHOS::Rosen
864