1 /*
2 * Copyright (c) 2023-2024 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 "ability_manager_stub.h"
17
18 #include "ability_manager_errors.h"
19 #include "ability_manager_radar.h"
20 #include "hilog_tag_wrapper.h"
21 #include "hitrace_meter.h"
22 #include "status_bar_delegate_interface.h"
23 #include <iterator>
24
25 namespace OHOS {
26 namespace AAFwk {
27 using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
28 namespace {
29 const std::u16string extensionDescriptor = u"ohos.aafwk.ExtensionManager";
30 constexpr int32_t CYCLE_LIMIT = 1000;
31 constexpr int32_t MAX_KILL_PROCESS_PID_COUNT = 100;
32 constexpr int32_t MAX_UPDATE_CONFIG_SIZE = 100;
33 } // namespace
AbilityManagerStub()34 AbilityManagerStub::AbilityManagerStub()
35 {}
36
~AbilityManagerStub()37 AbilityManagerStub::~AbilityManagerStub()
38 {}
39
OnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)40 int AbilityManagerStub::OnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data,
41 MessageParcel &reply, MessageOption &option)
42 {
43 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
44 if (interfaceCode == AbilityManagerInterfaceCode::TERMINATE_ABILITY) {
45 return TerminateAbilityInner(data, reply);
46 }
47 if (interfaceCode == AbilityManagerInterfaceCode::MINIMIZE_ABILITY) {
48 return MinimizeAbilityInner(data, reply);
49 }
50 if (interfaceCode == AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD) {
51 return AttachAbilityThreadInner(data, reply);
52 }
53 if (interfaceCode == AbilityManagerInterfaceCode::ABILITY_TRANSITION_DONE) {
54 return AbilityTransitionDoneInner(data, reply);
55 }
56 if (interfaceCode == AbilityManagerInterfaceCode::ABILITY_WINDOW_CONFIG_TRANSITION_DONE) {
57 return AbilityWindowConfigTransitionDoneInner(data, reply);
58 }
59 if (interfaceCode == AbilityManagerInterfaceCode::CONNECT_ABILITY_DONE) {
60 return ScheduleConnectAbilityDoneInner(data, reply);
61 }
62 if (interfaceCode == AbilityManagerInterfaceCode::DISCONNECT_ABILITY_DONE) {
63 return ScheduleDisconnectAbilityDoneInner(data, reply);
64 }
65 if (interfaceCode == AbilityManagerInterfaceCode::COMMAND_ABILITY_DONE) {
66 return ScheduleCommandAbilityDoneInner(data, reply);
67 }
68 if (interfaceCode == AbilityManagerInterfaceCode::COMMAND_ABILITY_WINDOW_DONE) {
69 return ScheduleCommandAbilityWindowDoneInner(data, reply);
70 }
71 if (interfaceCode == AbilityManagerInterfaceCode::ACQUIRE_DATA_ABILITY) {
72 return AcquireDataAbilityInner(data, reply);
73 }
74 if (interfaceCode == AbilityManagerInterfaceCode::RELEASE_DATA_ABILITY) {
75 return ReleaseDataAbilityInner(data, reply);
76 }
77 if (interfaceCode == AbilityManagerInterfaceCode::BACK_TO_CALLER_UIABILITY) {
78 return BackToCallerInner(data, reply);
79 }
80 return ERR_CODE_NOT_EXIST;
81 }
82
OnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)83 int AbilityManagerStub::OnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data,
84 MessageParcel &reply, MessageOption &option)
85 {
86 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
87 if (interfaceCode == AbilityManagerInterfaceCode::KILL_PROCESS) {
88 return KillProcessInner(data, reply);
89 }
90 if (interfaceCode == AbilityManagerInterfaceCode::UNINSTALL_APP) {
91 return UninstallAppInner(data, reply);
92 }
93 if (interfaceCode == AbilityManagerInterfaceCode::UPGRADE_APP) {
94 return UpgradeAppInner(data, reply);
95 }
96 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY) {
97 return StartAbilityInner(data, reply);
98 }
99 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_ADD_CALLER) {
100 return StartAbilityAddCallerInner(data, reply);
101 }
102 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_WITH_SPECIFY_TOKENID) {
103 return StartAbilityInnerSpecifyTokenId(data, reply);
104 }
105 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_BY_TOKEN) {
106 return StartAbilityAsCallerByTokenInner(data, reply);
107 }
108 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_FOR_OPTIONS) {
109 return StartAbilityAsCallerForOptionInner(data, reply);
110 }
111 if (interfaceCode == AbilityManagerInterfaceCode::START_UI_SESSION_ABILITY_ADD_CALLER) {
112 return StartAbilityByUIContentSessionAddCallerInner(data, reply);
113 }
114 if (interfaceCode == AbilityManagerInterfaceCode::START_UI_SESSION_ABILITY_FOR_OPTIONS) {
115 return StartAbilityByUIContentSessionForOptionsInner(data, reply);
116 }
117 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_ONLY_UI_ABILITY) {
118 return StartAbilityOnlyUIAbilityInner(data, reply);
119 }
120 return ERR_CODE_NOT_EXIST;
121 }
122
OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)123 int AbilityManagerStub::OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data,
124 MessageParcel &reply, MessageOption &option)
125 {
126 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
127 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_BY_INSIGHT_INTENT) {
128 return StartAbilityByInsightIntentInner(data, reply);
129 }
130 if (interfaceCode == AbilityManagerInterfaceCode::CONNECT_ABILITY) {
131 return ConnectAbilityInner(data, reply);
132 }
133 if (interfaceCode == AbilityManagerInterfaceCode::DISCONNECT_ABILITY) {
134 return DisconnectAbilityInner(data, reply);
135 }
136 if (interfaceCode == AbilityManagerInterfaceCode::STOP_SERVICE_ABILITY) {
137 return StopServiceAbilityInner(data, reply);
138 }
139 if (interfaceCode == AbilityManagerInterfaceCode::DUMP_STATE) {
140 return DumpStateInner(data, reply);
141 }
142 if (interfaceCode == AbilityManagerInterfaceCode::DUMPSYS_STATE) {
143 return DumpSysStateInner(data, reply);
144 }
145 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_FOR_SETTINGS) {
146 return StartAbilityForSettingsInner(data, reply);
147 }
148 if (interfaceCode == AbilityManagerInterfaceCode::CONTINUE_MISSION) {
149 return ContinueMissionInner(data, reply);
150 }
151 if (interfaceCode == AbilityManagerInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME) {
152 return ContinueMissionOfBundleNameInner(data, reply);
153 }
154 if (interfaceCode == AbilityManagerInterfaceCode::CONTINUE_ABILITY) {
155 return ContinueAbilityInner(data, reply);
156 }
157 return ERR_CODE_NOT_EXIST;
158 }
159
OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)160 int AbilityManagerStub::OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &data,
161 MessageParcel &reply, MessageOption &option)
162 {
163 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
164 if (interfaceCode == AbilityManagerInterfaceCode::START_CONTINUATION) {
165 return StartContinuationInner(data, reply);
166 }
167 if (interfaceCode == AbilityManagerInterfaceCode::NOTIFY_COMPLETE_CONTINUATION) {
168 return NotifyCompleteContinuationInner(data, reply);
169 }
170 if (interfaceCode == AbilityManagerInterfaceCode::NOTIFY_CONTINUATION_RESULT) {
171 return NotifyContinuationResultInner(data, reply);
172 }
173 if (interfaceCode == AbilityManagerInterfaceCode::SEND_RESULT_TO_ABILITY) {
174 return SendResultToAbilityInner(data, reply);
175 }
176 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_REMOTE_MISSION_LISTENER) {
177 return RegisterRemoteMissionListenerInner(data, reply);
178 }
179 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_REMOTE_ON_LISTENER) {
180 return RegisterRemoteOnListenerInner(data, reply);
181 }
182 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_REMOTE_OFF_LISTENER) {
183 return RegisterRemoteOffListenerInner(data, reply);
184 }
185 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_REMOTE_MISSION_LISTENER) {
186 return UnRegisterRemoteMissionListenerInner(data, reply);
187 }
188 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_FOR_OPTIONS) {
189 return StartAbilityForOptionsInner(data, reply);
190 }
191 if (interfaceCode == AbilityManagerInterfaceCode::START_SYNC_MISSIONS) {
192 return StartSyncRemoteMissionsInner(data, reply);
193 }
194 return ERR_CODE_NOT_EXIST;
195 }
196
OnRemoteRequestInnerFifth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)197 int AbilityManagerStub::OnRemoteRequestInnerFifth(uint32_t code, MessageParcel &data,
198 MessageParcel &reply, MessageOption &option)
199 {
200 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
201 if (interfaceCode == AbilityManagerInterfaceCode::STOP_SYNC_MISSIONS) {
202 return StopSyncRemoteMissionsInner(data, reply);
203 }
204 #ifdef ABILITY_COMMAND_FOR_TEST
205 if (interfaceCode == AbilityManagerInterfaceCode::FORCE_TIMEOUT) {
206 return ForceTimeoutForTestInner(data, reply);
207 }
208 #endif
209 if (interfaceCode == AbilityManagerInterfaceCode::FREE_INSTALL_ABILITY_FROM_REMOTE) {
210 return FreeInstallAbilityFromRemoteInner(data, reply);
211 }
212 if (interfaceCode == AbilityManagerInterfaceCode::ADD_FREE_INSTALL_OBSERVER) {
213 return AddFreeInstallObserverInner(data, reply);
214 }
215 if (interfaceCode == AbilityManagerInterfaceCode::CONNECT_ABILITY_WITH_TYPE) {
216 return ConnectAbilityWithTypeInner(data, reply);
217 }
218 if (interfaceCode == AbilityManagerInterfaceCode::ABILITY_RECOVERY) {
219 return ScheduleRecoverAbilityInner(data, reply);
220 }
221 if (interfaceCode == AbilityManagerInterfaceCode::ABILITY_RECOVERY_ENABLE) {
222 return EnableRecoverAbilityInner(data, reply);
223 }
224 if (interfaceCode == AbilityManagerInterfaceCode::ABILITY_RECOVERY_SUBMITINFO) {
225 return SubmitSaveRecoveryInfoInner(data, reply);
226 }
227 if (interfaceCode == AbilityManagerInterfaceCode::CLEAR_RECOVERY_PAGE_STACK) {
228 return ScheduleClearRecoveryPageStackInner(data, reply);
229 }
230 if (interfaceCode == AbilityManagerInterfaceCode::MINIMIZE_UI_ABILITY_BY_SCB) {
231 return MinimizeUIAbilityBySCBInner(data, reply);
232 }
233 if (interfaceCode == AbilityManagerInterfaceCode::CLOSE_UI_ABILITY_BY_SCB) {
234 return CloseUIAbilityBySCBInner(data, reply);
235 }
236 return ERR_CODE_NOT_EXIST;
237 }
238
OnRemoteRequestInnerSixth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)239 int AbilityManagerStub::OnRemoteRequestInnerSixth(uint32_t code, MessageParcel &data,
240 MessageParcel &reply, MessageOption &option)
241 {
242 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
243 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_COLLABORATOR) {
244 return RegisterIAbilityManagerCollaboratorInner(data, reply);
245 }
246 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_COLLABORATOR) {
247 return UnregisterIAbilityManagerCollaboratorInner(data, reply);
248 }
249 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_APP_DEBUG_LISTENER) {
250 return RegisterAppDebugListenerInner(data, reply);
251 }
252 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_APP_DEBUG_LISTENER) {
253 return UnregisterAppDebugListenerInner(data, reply);
254 }
255 if (interfaceCode == AbilityManagerInterfaceCode::ATTACH_APP_DEBUG) {
256 return AttachAppDebugInner(data, reply);
257 }
258 if (interfaceCode == AbilityManagerInterfaceCode::DETACH_APP_DEBUG) {
259 return DetachAppDebugInner(data, reply);
260 }
261 if (interfaceCode == AbilityManagerInterfaceCode::IS_ABILITY_CONTROLLER_START) {
262 return IsAbilityControllerStartInner(data, reply);
263 }
264 if (interfaceCode == AbilityManagerInterfaceCode::EXECUTE_INTENT) {
265 return ExecuteIntentInner(data, reply);
266 }
267 if (interfaceCode == AbilityManagerInterfaceCode::EXECUTE_INSIGHT_INTENT_DONE) {
268 return ExecuteInsightIntentDoneInner(data, reply);
269 }
270 if (interfaceCode == AbilityManagerInterfaceCode::OPEN_FILE) {
271 return OpenFileInner(data, reply);
272 }
273 return ERR_CODE_NOT_EXIST;
274 }
275
OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)276 int AbilityManagerStub::OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel &data,
277 MessageParcel &reply, MessageOption &option)
278 {
279 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
280 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER) {
281 return GetWantSenderInner(data, reply);
282 }
283 if (interfaceCode == AbilityManagerInterfaceCode::SEND_PENDING_WANT_SENDER) {
284 return SendWantSenderInner(data, reply);
285 }
286 if (interfaceCode == AbilityManagerInterfaceCode::CANCEL_PENDING_WANT_SENDER) {
287 return CancelWantSenderInner(data, reply);
288 }
289 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_WANT_UID) {
290 return GetPendingWantUidInner(data, reply);
291 }
292 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_WANT_USERID) {
293 return GetPendingWantUserIdInner(data, reply);
294 }
295 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_WANT_BUNDLENAME) {
296 return GetPendingWantBundleNameInner(data, reply);
297 }
298 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_WANT_CODE) {
299 return GetPendingWantCodeInner(data, reply);
300 }
301 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_WANT_TYPE) {
302 return GetPendingWantTypeInner(data, reply);
303 }
304 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_CANCEL_LISTENER) {
305 return RegisterCancelListenerInner(data, reply);
306 }
307 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_CANCEL_LISTENER) {
308 return UnregisterCancelListenerInner(data, reply);
309 }
310 return ERR_CODE_NOT_EXIST;
311 }
312
OnRemoteRequestInnerEighth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)313 int AbilityManagerStub::OnRemoteRequestInnerEighth(uint32_t code, MessageParcel &data,
314 MessageParcel &reply, MessageOption &option)
315 {
316 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
317 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_REQUEST_WANT) {
318 return GetPendingRequestWantInner(data, reply);
319 }
320 if (interfaceCode == AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER_INFO) {
321 return GetWantSenderInfoInner(data, reply);
322 }
323 if (interfaceCode == AbilityManagerInterfaceCode::GET_APP_MEMORY_SIZE) {
324 return GetAppMemorySizeInner(data, reply);
325 }
326 if (interfaceCode == AbilityManagerInterfaceCode::IS_RAM_CONSTRAINED_DEVICE) {
327 return IsRamConstrainedDeviceInner(data, reply);
328 }
329 if (interfaceCode == AbilityManagerInterfaceCode::LOCK_MISSION_FOR_CLEANUP) {
330 return LockMissionForCleanupInner(data, reply);
331 }
332 if (interfaceCode == AbilityManagerInterfaceCode::UNLOCK_MISSION_FOR_CLEANUP) {
333 return UnlockMissionForCleanupInner(data, reply);
334 }
335 if (interfaceCode == AbilityManagerInterfaceCode::SET_SESSION_LOCKED_STATE) {
336 return SetLockedStateInner(data, reply);
337 }
338 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_MISSION_LISTENER) {
339 return RegisterMissionListenerInner(data, reply);
340 }
341 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_MISSION_LISTENER) {
342 return UnRegisterMissionListenerInner(data, reply);
343 }
344 return ERR_CODE_NOT_EXIST;
345 }
346
OnRemoteRequestInnerNinth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)347 int AbilityManagerStub::OnRemoteRequestInnerNinth(uint32_t code, MessageParcel &data,
348 MessageParcel &reply, MessageOption &option)
349 {
350 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
351 if (interfaceCode == AbilityManagerInterfaceCode::GET_MISSION_INFOS) {
352 return GetMissionInfosInner(data, reply);
353 }
354 if (interfaceCode == AbilityManagerInterfaceCode::GET_MISSION_INFO_BY_ID) {
355 return GetMissionInfoInner(data, reply);
356 }
357 if (interfaceCode == AbilityManagerInterfaceCode::CLEAN_MISSION) {
358 return CleanMissionInner(data, reply);
359 }
360 if (interfaceCode == AbilityManagerInterfaceCode::CLEAN_ALL_MISSIONS) {
361 return CleanAllMissionsInner(data, reply);
362 }
363 if (interfaceCode == AbilityManagerInterfaceCode::MOVE_MISSION_TO_FRONT) {
364 return MoveMissionToFrontInner(data, reply);
365 }
366 if (interfaceCode == AbilityManagerInterfaceCode::MOVE_MISSION_TO_FRONT_BY_OPTIONS) {
367 return MoveMissionToFrontByOptionsInner(data, reply);
368 }
369 if (interfaceCode == AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_FOREGROUND) {
370 return MoveMissionsToForegroundInner(data, reply);
371 }
372 if (interfaceCode == AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_BACKGROUND) {
373 return MoveMissionsToBackgroundInner(data, reply);
374 }
375 if (interfaceCode == AbilityManagerInterfaceCode::START_CALL_ABILITY) {
376 return StartAbilityByCallInner(data, reply);
377 }
378 if (interfaceCode == AbilityManagerInterfaceCode::CALL_REQUEST_DONE) {
379 return CallRequestDoneInner(data, reply);
380 }
381 return ERR_CODE_NOT_EXIST;
382 }
383
OnRemoteRequestInnerTenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)384 int AbilityManagerStub::OnRemoteRequestInnerTenth(uint32_t code, MessageParcel &data,
385 MessageParcel &reply, MessageOption &option)
386 {
387 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
388 if (interfaceCode == AbilityManagerInterfaceCode::RELEASE_CALL_ABILITY) {
389 return ReleaseCallInner(data, reply);
390 }
391 if (interfaceCode == AbilityManagerInterfaceCode::START_USER) {
392 return StartUserInner(data, reply);
393 }
394 if (interfaceCode == AbilityManagerInterfaceCode::STOP_USER) {
395 return StopUserInner(data, reply);
396 }
397 if (interfaceCode == AbilityManagerInterfaceCode::LOGOUT_USER) {
398 return LogoutUserInner(data, reply);
399 }
400 if (interfaceCode == AbilityManagerInterfaceCode::GET_ABILITY_RUNNING_INFO) {
401 return GetAbilityRunningInfosInner(data, reply);
402 }
403 if (interfaceCode == AbilityManagerInterfaceCode::GET_EXTENSION_RUNNING_INFO) {
404 return GetExtensionRunningInfosInner(data, reply);
405 }
406 if (interfaceCode == AbilityManagerInterfaceCode::GET_PROCESS_RUNNING_INFO) {
407 return GetProcessRunningInfosInner(data, reply);
408 }
409 if (interfaceCode == AbilityManagerInterfaceCode::SET_ABILITY_CONTROLLER) {
410 return SetAbilityControllerInner(data, reply);
411 }
412 if (interfaceCode == AbilityManagerInterfaceCode::GET_MISSION_SNAPSHOT_INFO) {
413 return GetMissionSnapshotInfoInner(data, reply);
414 }
415 if (interfaceCode == AbilityManagerInterfaceCode::IS_USER_A_STABILITY_TEST) {
416 return IsRunningInStabilityTestInner(data, reply);
417 }
418 return ERR_CODE_NOT_EXIST;
419 }
420
OnRemoteRequestInnerEleventh(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)421 int AbilityManagerStub::OnRemoteRequestInnerEleventh(uint32_t code, MessageParcel &data,
422 MessageParcel &reply, MessageOption &option)
423 {
424 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
425 if (interfaceCode == AbilityManagerInterfaceCode::ACQUIRE_SHARE_DATA) {
426 return AcquireShareDataInner(data, reply);
427 }
428 if (interfaceCode == AbilityManagerInterfaceCode::SHARE_DATA_DONE) {
429 return ShareDataDoneInner(data, reply);
430 }
431 if (interfaceCode == AbilityManagerInterfaceCode::GET_ABILITY_TOKEN) {
432 return GetAbilityTokenByCalleeObjInner(data, reply);
433 }
434 if (interfaceCode == AbilityManagerInterfaceCode::FORCE_EXIT_APP) {
435 return ForceExitAppInner(data, reply);
436 }
437 if (interfaceCode == AbilityManagerInterfaceCode::RECORD_APP_EXIT_REASON) {
438 return RecordAppExitReasonInner(data, reply);
439 }
440 if (interfaceCode == AbilityManagerInterfaceCode::RECORD_PROCESS_EXIT_REASON) {
441 return RecordProcessExitReasonInner(data, reply);
442 }
443 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_SESSION_HANDLER) {
444 return RegisterSessionHandlerInner(data, reply);
445 }
446 return ERR_CODE_NOT_EXIST;
447 }
448
OnRemoteRequestInnerTwelveth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)449 int AbilityManagerStub::OnRemoteRequestInnerTwelveth(uint32_t code, MessageParcel &data,
450 MessageParcel &reply, MessageOption &option)
451 {
452 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
453 if (interfaceCode == AbilityManagerInterfaceCode::START_USER_TEST) {
454 return StartUserTestInner(data, reply);
455 }
456 if (interfaceCode == AbilityManagerInterfaceCode::FINISH_USER_TEST) {
457 return FinishUserTestInner(data, reply);
458 }
459 if (interfaceCode == AbilityManagerInterfaceCode::GET_TOP_ABILITY_TOKEN) {
460 return GetTopAbilityTokenInner(data, reply);
461 }
462 if (interfaceCode == AbilityManagerInterfaceCode::CHECK_UI_EXTENSION_IS_FOCUSED) {
463 return CheckUIExtensionIsFocusedInner(data, reply);
464 }
465 if (interfaceCode == AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_FOREGROUND) {
466 return DelegatorDoAbilityForegroundInner(data, reply);
467 }
468 if (interfaceCode == AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_BACKGROUND) {
469 return DelegatorDoAbilityBackgroundInner(data, reply);
470 }
471 if (interfaceCode == AbilityManagerInterfaceCode::DO_ABILITY_FOREGROUND) {
472 return DoAbilityForegroundInner(data, reply);
473 }
474 if (interfaceCode == AbilityManagerInterfaceCode::DO_ABILITY_BACKGROUND) {
475 return DoAbilityBackgroundInner(data, reply);
476 }
477 if (interfaceCode == AbilityManagerInterfaceCode::GET_MISSION_ID_BY_ABILITY_TOKEN) {
478 return GetMissionIdByTokenInner(data, reply);
479 }
480 if (interfaceCode == AbilityManagerInterfaceCode::GET_TOP_ABILITY) {
481 return GetTopAbilityInner(data, reply);
482 }
483 return ERR_CODE_NOT_EXIST;
484 }
485
OnRemoteRequestInnerThirteenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)486 int AbilityManagerStub::OnRemoteRequestInnerThirteenth(uint32_t code, MessageParcel &data,
487 MessageParcel &reply, MessageOption &option)
488 {
489 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
490 if (interfaceCode == AbilityManagerInterfaceCode::GET_ELEMENT_NAME_BY_TOKEN) {
491 return GetElementNameByTokenInner(data, reply);
492 }
493 if (interfaceCode == AbilityManagerInterfaceCode::DUMP_ABILITY_INFO_DONE) {
494 return DumpAbilityInfoDoneInner(data, reply);
495 }
496 if (interfaceCode == AbilityManagerInterfaceCode::START_EXTENSION_ABILITY) {
497 return StartExtensionAbilityInner(data, reply);
498 }
499 if (interfaceCode == AbilityManagerInterfaceCode::STOP_EXTENSION_ABILITY) {
500 return StopExtensionAbilityInner(data, reply);
501 }
502 if (interfaceCode == AbilityManagerInterfaceCode::UPDATE_MISSION_SNAPSHOT_FROM_WMS) {
503 return UpdateMissionSnapShotFromWMSInner(data, reply);
504 }
505 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_CONNECTION_OBSERVER) {
506 return RegisterConnectionObserverInner(data, reply);
507 }
508 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_CONNECTION_OBSERVER) {
509 return UnregisterConnectionObserverInner(data, reply);
510 }
511 #ifdef WITH_DLP
512 if (interfaceCode == AbilityManagerInterfaceCode::GET_DLP_CONNECTION_INFOS) {
513 return GetDlpConnectionInfosInner(data, reply);
514 }
515 #endif // WITH_DLP
516 if (interfaceCode == AbilityManagerInterfaceCode::MOVE_ABILITY_TO_BACKGROUND) {
517 return MoveAbilityToBackgroundInner(data, reply);
518 }
519 if (interfaceCode == AbilityManagerInterfaceCode::MOVE_UI_ABILITY_TO_BACKGROUND) {
520 return MoveUIAbilityToBackgroundInner(data, reply);
521 }
522 return ERR_CODE_NOT_EXIST;
523 }
524
OnRemoteRequestInnerFourteenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)525 int AbilityManagerStub::OnRemoteRequestInnerFourteenth(uint32_t code, MessageParcel &data,
526 MessageParcel &reply, MessageOption &option)
527 {
528 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
529 if (interfaceCode == AbilityManagerInterfaceCode::SET_MISSION_CONTINUE_STATE) {
530 return SetMissionContinueStateInner(data, reply);
531 }
532 if (interfaceCode == AbilityManagerInterfaceCode::PREPARE_TERMINATE_ABILITY_BY_SCB) {
533 return PrepareTerminateAbilityBySCBInner(data, reply);
534 }
535 if (interfaceCode == AbilityManagerInterfaceCode::REQUESET_MODAL_UIEXTENSION) {
536 return RequestModalUIExtensionInner(data, reply);
537 }
538 if (interfaceCode == AbilityManagerInterfaceCode::GET_UI_EXTENSION_ROOT_HOST_INFO) {
539 return GetUIExtensionRootHostInfoInner(data, reply);
540 }
541 if (interfaceCode == AbilityManagerInterfaceCode::GET_UI_EXTENSION_SESSION_INFO) {
542 return GetUIExtensionSessionInfoInner(data, reply);
543 }
544 if (interfaceCode == AbilityManagerInterfaceCode::PRELOAD_UIEXTENSION_ABILITY) {
545 return PreloadUIExtensionAbilityInner(data, reply);
546 }
547 if (interfaceCode == AbilityManagerInterfaceCode::TERMINATE_UI_SERVICE_EXTENSION_ABILITY) {
548 return TerminateUIServiceExtensionAbilityInner(data, reply);
549 }
550 return ERR_CODE_NOT_EXIST;
551 }
552
OnRemoteRequestInnerFifteenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)553 int AbilityManagerStub::OnRemoteRequestInnerFifteenth(uint32_t code, MessageParcel &data,
554 MessageParcel &reply, MessageOption &option)
555 {
556 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
557 #ifdef SUPPORT_GRAPHICS
558 if (interfaceCode == AbilityManagerInterfaceCode::SET_MISSION_LABEL) {
559 return SetMissionLabelInner(data, reply);
560 }
561 if (interfaceCode == AbilityManagerInterfaceCode::SET_MISSION_ICON) {
562 return SetMissionIconInner(data, reply);
563 }
564 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_WMS_HANDLER) {
565 return RegisterWindowManagerServiceHandlerInner(data, reply);
566 }
567 if (interfaceCode == AbilityManagerInterfaceCode::COMPLETEFIRSTFRAMEDRAWING) {
568 return CompleteFirstFrameDrawingInner(data, reply);
569 }
570 if (interfaceCode == AbilityManagerInterfaceCode::START_UI_EXTENSION_ABILITY) {
571 return StartUIExtensionAbilityInner(data, reply);
572 }
573 if (interfaceCode == AbilityManagerInterfaceCode::MINIMIZE_UI_EXTENSION_ABILITY) {
574 return MinimizeUIExtensionAbilityInner(data, reply);
575 }
576 if (interfaceCode == AbilityManagerInterfaceCode::TERMINATE_UI_EXTENSION_ABILITY) {
577 return TerminateUIExtensionAbilityInner(data, reply);
578 }
579 if (interfaceCode == AbilityManagerInterfaceCode::CONNECT_UI_EXTENSION_ABILITY) {
580 return ConnectUIExtensionAbilityInner(data, reply);
581 }
582 if (interfaceCode == AbilityManagerInterfaceCode::PREPARE_TERMINATE_ABILITY) {
583 return PrepareTerminateAbilityInner(data, reply);
584 }
585 if (interfaceCode == AbilityManagerInterfaceCode::GET_DIALOG_SESSION_INFO) {
586 return GetDialogSessionInfoInner(data, reply);
587 }
588 if (interfaceCode == AbilityManagerInterfaceCode::SEND_DIALOG_RESULT) {
589 return SendDialogResultInner(data, reply);
590 }
591 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_ABILITY_FIRST_FRAME_STATE_OBSERVER) {
592 return RegisterAbilityFirstFrameStateObserverInner(data, reply);
593 }
594 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_ABILITY_FIRST_FRAME_STATE_OBSERVER) {
595 return UnregisterAbilityFirstFrameStateObserverInner(data, reply);
596 }
597 #endif
598 return ERR_CODE_NOT_EXIST;
599 }
600
OnRemoteRequestInnerSixteenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)601 int AbilityManagerStub::OnRemoteRequestInnerSixteenth(uint32_t code, MessageParcel &data,
602 MessageParcel &reply, MessageOption &option)
603 {
604 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
605 #ifdef SUPPORT_GRAPHICS
606 if (interfaceCode == AbilityManagerInterfaceCode::COMPLETE_FIRST_FRAME_DRAWING_BY_SCB) {
607 return CompleteFirstFrameDrawingBySCBInner(data, reply);
608 }
609 if (interfaceCode == AbilityManagerInterfaceCode::START_UI_EXTENSION_ABILITY_EMBEDDED) {
610 return StartUIExtensionAbilityEmbeddedInner(data, reply);
611 }
612 if (interfaceCode == AbilityManagerInterfaceCode::START_UI_EXTENSION_CONSTRAINED_EMBEDDED) {
613 return StartUIExtensionConstrainedEmbeddedInner(data, reply);
614 }
615 #endif
616 if (interfaceCode == AbilityManagerInterfaceCode::REQUEST_DIALOG_SERVICE) {
617 return HandleRequestDialogService(data, reply);
618 };
619 if (interfaceCode == AbilityManagerInterfaceCode::REPORT_DRAWN_COMPLETED) {
620 return HandleReportDrawnCompleted(data, reply);
621 };
622 if (interfaceCode == AbilityManagerInterfaceCode::QUERY_MISSION_VAILD) {
623 return IsValidMissionIdsInner(data, reply);
624 }
625 if (interfaceCode == AbilityManagerInterfaceCode::VERIFY_PERMISSION) {
626 return VerifyPermissionInner(data, reply);
627 }
628 if (interfaceCode == AbilityManagerInterfaceCode::START_UI_ABILITY_BY_SCB) {
629 return StartUIAbilityBySCBInner(data, reply);
630 }
631 if (interfaceCode == AbilityManagerInterfaceCode::SET_ROOT_SCENE_SESSION) {
632 return SetRootSceneSessionInner(data, reply);
633 }
634 if (interfaceCode == AbilityManagerInterfaceCode::CALL_ABILITY_BY_SCB) {
635 return CallUIAbilityBySCBInner(data, reply);
636 }
637 if (interfaceCode == AbilityManagerInterfaceCode::START_SPECIFIED_ABILITY_BY_SCB) {
638 return StartSpecifiedAbilityBySCBInner(data, reply);
639 }
640 return ERR_CODE_NOT_EXIST;
641 }
642
OnRemoteRequestInnerSeventeenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)643 int AbilityManagerStub::OnRemoteRequestInnerSeventeenth(uint32_t code, MessageParcel &data,
644 MessageParcel &reply, MessageOption &option)
645 {
646 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
647 if (interfaceCode == AbilityManagerInterfaceCode::NOTIFY_SAVE_AS_RESULT) {
648 return NotifySaveAsResultInner(data, reply);
649 }
650 if (interfaceCode == AbilityManagerInterfaceCode::SET_SESSIONMANAGERSERVICE) {
651 return SetSessionManagerServiceInner(data, reply);
652 }
653 if (interfaceCode == AbilityManagerInterfaceCode::UPDATE_SESSION_INFO) {
654 return UpdateSessionInfoBySCBInner(data, reply);
655 }
656 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_STATUS_BAR_DELEGATE) {
657 return RegisterStatusBarDelegateInner(data, reply);
658 }
659 if (interfaceCode == AbilityManagerInterfaceCode::KILL_PROCESS_WITH_PREPARE_TERMINATE) {
660 return KillProcessWithPrepareTerminateInner(data, reply);
661 }
662 if (interfaceCode == AbilityManagerInterfaceCode::REGISTER_AUTO_STARTUP_SYSTEM_CALLBACK) {
663 return RegisterAutoStartupSystemCallbackInner(data, reply);
664 }
665 if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_AUTO_STARTUP_SYSTEM_CALLBACK) {
666 return UnregisterAutoStartupSystemCallbackInner(data, reply);
667 }
668 if (interfaceCode == AbilityManagerInterfaceCode::SET_APPLICATION_AUTO_STARTUP) {
669 return SetApplicationAutoStartupInner(data, reply);
670 }
671 if (interfaceCode == AbilityManagerInterfaceCode::CANCEL_APPLICATION_AUTO_STARTUP) {
672 return CancelApplicationAutoStartupInner(data, reply);
673 }
674 if (interfaceCode == AbilityManagerInterfaceCode::QUERY_ALL_AUTO_STARTUP_APPLICATION) {
675 return QueryAllAutoStartupApplicationsInner(data, reply);
676 }
677 return ERR_CODE_NOT_EXIST;
678 }
679
OnRemoteRequestInnerEighteenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)680 int AbilityManagerStub::OnRemoteRequestInnerEighteenth(uint32_t code, MessageParcel &data,
681 MessageParcel &reply, MessageOption &option)
682 {
683 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
684 if (interfaceCode == AbilityManagerInterfaceCode::GET_CONNECTION_DATA) {
685 return GetConnectionDataInner(data, reply);
686 }
687 if (interfaceCode == AbilityManagerInterfaceCode::SET_APPLICATION_AUTO_STARTUP_BY_EDM) {
688 return SetApplicationAutoStartupByEDMInner(data, reply);
689 }
690 if (interfaceCode == AbilityManagerInterfaceCode::CANCEL_APPLICATION_AUTO_STARTUP_BY_EDM) {
691 return CancelApplicationAutoStartupByEDMInner(data, reply);
692 }
693 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_FOR_RESULT_AS_CALLER) {
694 return StartAbilityForResultAsCallerInner(data, reply);
695 }
696 if (interfaceCode == AbilityManagerInterfaceCode::START_ABILITY_FOR_RESULT_AS_CALLER_FOR_OPTIONS) {
697 return StartAbilityForResultAsCallerForOptionsInner(data, reply);
698 }
699 if (interfaceCode == AbilityManagerInterfaceCode::GET_FOREGROUND_UI_ABILITIES) {
700 return GetForegroundUIAbilitiesInner(data, reply);
701 }
702 if (interfaceCode == AbilityManagerInterfaceCode::RESTART_APP) {
703 return RestartAppInner(data, reply);
704 }
705 if (interfaceCode == AbilityManagerInterfaceCode::OPEN_ATOMIC_SERVICE) {
706 return OpenAtomicServiceInner(data, reply);
707 }
708 if (interfaceCode == AbilityManagerInterfaceCode::IS_EMBEDDED_OPEN_ALLOWED) {
709 return IsEmbeddedOpenAllowedInner(data, reply);
710 }
711 if (interfaceCode == AbilityManagerInterfaceCode::REQUEST_ASSERT_FAULT_DIALOG) {
712 return RequestAssertFaultDialogInner(data, reply);
713 }
714 return ERR_CODE_NOT_EXIST;
715 }
716
717
OnRemoteRequestInnerNineteenth(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)718 int AbilityManagerStub::OnRemoteRequestInnerNineteenth(uint32_t code, MessageParcel &data,
719 MessageParcel &reply, MessageOption &option)
720 {
721 AbilityManagerInterfaceCode interfaceCode = static_cast<AbilityManagerInterfaceCode>(code);
722 if (interfaceCode == AbilityManagerInterfaceCode::NOTIFY_DEBUG_ASSERT_RESULT) {
723 return NotifyDebugAssertResultInner(data, reply);
724 }
725 if (interfaceCode == AbilityManagerInterfaceCode::CHANGE_ABILITY_VISIBILITY) {
726 return ChangeAbilityVisibilityInner(data, reply);
727 }
728 if (interfaceCode == AbilityManagerInterfaceCode::CHANGE_UI_ABILITY_VISIBILITY_BY_SCB) {
729 return ChangeUIAbilityVisibilityBySCBInner(data, reply);
730 }
731 if (interfaceCode == AbilityManagerInterfaceCode::START_SHORTCUT) {
732 return StartShortcutInner(data, reply);
733 }
734 if (interfaceCode == AbilityManagerInterfaceCode::SET_RESIDENT_PROCESS_ENABLE) {
735 return SetResidentProcessEnableInner(data, reply);
736 }
737 if (interfaceCode == AbilityManagerInterfaceCode::GET_ABILITY_STATE_BY_PERSISTENT_ID) {
738 return GetAbilityStateByPersistentIdInner(data, reply);
739 }
740 if (interfaceCode == AbilityManagerInterfaceCode::TRANSFER_ABILITY_RESULT) {
741 return TransferAbilityResultForExtensionInner(data, reply);
742 }
743 if (interfaceCode == AbilityManagerInterfaceCode::NOTIFY_FROZEN_PROCESS_BY_RSS) {
744 return NotifyFrozenProcessByRSSInner(data, reply);
745 }
746 if (interfaceCode == AbilityManagerInterfaceCode::PRE_START_MISSION) {
747 return PreStartMissionInner(data, reply);
748 }
749 if (interfaceCode == AbilityManagerInterfaceCode::CLEAN_UI_ABILITY_BY_SCB) {
750 return CleanUIAbilityBySCBInner(data, reply);
751 }
752 if (interfaceCode == AbilityManagerInterfaceCode::OPEN_LINK) {
753 return OpenLinkInner(data, reply);
754 }
755 if (interfaceCode == AbilityManagerInterfaceCode::TERMINATE_MISSION) {
756 return TerminateMissionInner(data, reply);
757 }
758 if (interfaceCode == AbilityManagerInterfaceCode::BLOCK_ALL_APP_START) {
759 return BlockAllAppStartInner(data, reply);
760 }
761 if (interfaceCode == AbilityManagerInterfaceCode::UPDATE_ASSOCIATE_CONFIG_LIST) {
762 return UpdateAssociateConfigListInner(data, reply);
763 }
764 return ERR_CODE_NOT_EXIST;
765 }
766
OnRemoteRequestInner(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)767 int AbilityManagerStub::OnRemoteRequestInner(uint32_t code, MessageParcel &data,
768 MessageParcel &reply, MessageOption &option)
769 {
770 int retCode = ERR_OK;
771 retCode = HandleOnRemoteRequestInnerFirst(code, data, reply, option);
772 if (retCode != ERR_CODE_NOT_EXIST) {
773 return retCode;
774 }
775 retCode = HandleOnRemoteRequestInnerSecond(code, data, reply, option);
776 if (retCode != ERR_CODE_NOT_EXIST) {
777 return retCode;
778 }
779 TAG_LOGW(AAFwkTag::ABILITYMGR, "default case");
780 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
781 }
782
HandleOnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)783 int AbilityManagerStub::HandleOnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data,
784 MessageParcel &reply, MessageOption &option)
785 {
786 int retCode = ERR_OK;
787 retCode = OnRemoteRequestInnerFirst(code, data, reply, option);
788 if (retCode != ERR_CODE_NOT_EXIST) {
789 return retCode;
790 }
791 retCode = OnRemoteRequestInnerSecond(code, data, reply, option);
792 if (retCode != ERR_CODE_NOT_EXIST) {
793 return retCode;
794 }
795 retCode = OnRemoteRequestInnerThird(code, data, reply, option);
796 if (retCode != ERR_CODE_NOT_EXIST) {
797 return retCode;
798 }
799 retCode = OnRemoteRequestInnerFourth(code, data, reply, option);
800 if (retCode != ERR_CODE_NOT_EXIST) {
801 return retCode;
802 }
803 retCode = OnRemoteRequestInnerFifth(code, data, reply, option);
804 if (retCode != ERR_CODE_NOT_EXIST) {
805 return retCode;
806 }
807 retCode = OnRemoteRequestInnerSixth(code, data, reply, option);
808 if (retCode != ERR_CODE_NOT_EXIST) {
809 return retCode;
810 }
811 retCode = OnRemoteRequestInnerSeventh(code, data, reply, option);
812 if (retCode != ERR_CODE_NOT_EXIST) {
813 return retCode;
814 }
815 retCode = OnRemoteRequestInnerEighth(code, data, reply, option);
816 if (retCode != ERR_CODE_NOT_EXIST) {
817 return retCode;
818 }
819 retCode = OnRemoteRequestInnerNinth(code, data, reply, option);
820 if (retCode != ERR_CODE_NOT_EXIST) {
821 return retCode;
822 }
823 retCode = OnRemoteRequestInnerTenth(code, data, reply, option);
824 if (retCode != ERR_CODE_NOT_EXIST) {
825 return retCode;
826 }
827 return ERR_CODE_NOT_EXIST;
828 }
829
HandleOnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)830 int AbilityManagerStub::HandleOnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data,
831 MessageParcel &reply, MessageOption &option)
832 {
833 int retCode = ERR_OK;
834 retCode = OnRemoteRequestInnerEleventh(code, data, reply, option);
835 if (retCode != ERR_CODE_NOT_EXIST) {
836 return retCode;
837 }
838 retCode = OnRemoteRequestInnerTwelveth(code, data, reply, option);
839 if (retCode != ERR_CODE_NOT_EXIST) {
840 return retCode;
841 }
842 retCode = OnRemoteRequestInnerThirteenth(code, data, reply, option);
843 if (retCode != ERR_CODE_NOT_EXIST) {
844 return retCode;
845 }
846 retCode = OnRemoteRequestInnerFourteenth(code, data, reply, option);
847 if (retCode != ERR_CODE_NOT_EXIST) {
848 return retCode;
849 }
850 retCode = OnRemoteRequestInnerFifteenth(code, data, reply, option);
851 if (retCode != ERR_CODE_NOT_EXIST) {
852 return retCode;
853 }
854 retCode = OnRemoteRequestInnerSixteenth(code, data, reply, option);
855 if (retCode != ERR_CODE_NOT_EXIST) {
856 return retCode;
857 }
858 retCode = OnRemoteRequestInnerSeventeenth(code, data, reply, option);
859 if (retCode != ERR_CODE_NOT_EXIST) {
860 return retCode;
861 }
862 retCode = OnRemoteRequestInnerEighteenth(code, data, reply, option);
863 if (retCode != ERR_CODE_NOT_EXIST) {
864 return retCode;
865 }
866 retCode = OnRemoteRequestInnerNineteenth(code, data, reply, option);
867 if (retCode != ERR_CODE_NOT_EXIST) {
868 return retCode;
869 }
870 return ERR_CODE_NOT_EXIST;
871 }
872
OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)873 int AbilityManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
874 {
875 TAG_LOGD(AAFwkTag::ABILITYMGR, "Received code : %{public}d", code);
876 std::u16string abilityDescriptor = AbilityManagerStub::GetDescriptor();
877 std::u16string remoteDescriptor = data.ReadInterfaceToken();
878 if (abilityDescriptor != remoteDescriptor && extensionDescriptor != remoteDescriptor) {
879 TAG_LOGE(AAFwkTag::ABILITYMGR, "local descriptor unequal to remote");
880 return ERR_INVALID_STATE;
881 }
882
883 return OnRemoteRequestInner(code, data, reply, option);
884 }
885
GetTopAbilityInner(MessageParcel &data, MessageParcel &reply)886 int AbilityManagerStub::GetTopAbilityInner(MessageParcel &data, MessageParcel &reply)
887 {
888 bool isNeedLocalDeviceId = data.ReadBool();
889 AppExecFwk::ElementName result = GetTopAbility(isNeedLocalDeviceId);
890 if (result.GetDeviceID().empty()) {
891 TAG_LOGD(AAFwkTag::ABILITYMGR, "GetTopAbilityInner is nullptr");
892 }
893 reply.WriteParcelable(&result);
894 return NO_ERROR;
895 }
896
GetElementNameByTokenInner(MessageParcel &data, MessageParcel &reply)897 int AbilityManagerStub::GetElementNameByTokenInner(MessageParcel &data, MessageParcel &reply)
898 {
899 sptr<IRemoteObject> token = data.ReadRemoteObject();
900 bool isNeedLocalDeviceId = data.ReadBool();
901 AppExecFwk::ElementName result = GetElementNameByToken(token, isNeedLocalDeviceId);
902 if (result.GetDeviceID().empty()) {
903 TAG_LOGD(AAFwkTag::ABILITYMGR, "GetElementNameByTokenInner is nullptr");
904 }
905 reply.WriteParcelable(&result);
906 return NO_ERROR;
907 }
908
MoveAbilityToBackgroundInner(MessageParcel &data, MessageParcel &reply)909 int AbilityManagerStub::MoveAbilityToBackgroundInner(MessageParcel &data, MessageParcel &reply)
910 {
911 sptr<IRemoteObject> token = nullptr;
912 if (data.ReadBool()) {
913 token = data.ReadRemoteObject();
914 }
915 int32_t result = MoveAbilityToBackground(token);
916 if (!reply.WriteInt32(result)) {
917 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result failed");
918 return ERR_INVALID_VALUE;
919 }
920 return NO_ERROR;
921 }
922
MoveUIAbilityToBackgroundInner(MessageParcel &data, MessageParcel &reply)923 int32_t AbilityManagerStub::MoveUIAbilityToBackgroundInner(MessageParcel &data, MessageParcel &reply)
924 {
925 const sptr<IRemoteObject> token = data.ReadRemoteObject();
926 if (!token) {
927 TAG_LOGE(AAFwkTag::ABILITYMGR, "token null");
928 return IPC_STUB_ERR;
929 }
930 int32_t result = MoveUIAbilityToBackground(token);
931 if (!reply.WriteInt32(result)) {
932 TAG_LOGE(AAFwkTag::ABILITYMGR, "write failed");
933 return IPC_STUB_ERR;
934 }
935 return NO_ERROR;
936 }
937
TerminateAbilityInner(MessageParcel &data, MessageParcel &reply)938 int AbilityManagerStub::TerminateAbilityInner(MessageParcel &data, MessageParcel &reply)
939 {
940 sptr<IRemoteObject> token = nullptr;
941 if (data.ReadBool()) {
942 token = data.ReadRemoteObject();
943 }
944 int resultCode = data.ReadInt32();
945 Want *resultWant = data.ReadParcelable<Want>();
946 bool flag = data.ReadBool();
947 int32_t result;
948 if (flag) {
949 result = TerminateAbility(token, resultCode, resultWant);
950 } else {
951 result = CloseAbility(token, resultCode, resultWant);
952 }
953 reply.WriteInt32(result);
954 if (resultWant != nullptr) {
955 delete resultWant;
956 }
957 return NO_ERROR;
958 }
959
BackToCallerInner(MessageParcel &data, MessageParcel &reply)960 int AbilityManagerStub::BackToCallerInner(MessageParcel &data, MessageParcel &reply)
961 {
962 sptr<IRemoteObject> token = nullptr;
963 if (data.ReadBool()) {
964 token = data.ReadRemoteObject();
965 }
966 int resultCode = data.ReadInt32();
967 Want *resultWant = data.ReadParcelable<Want>();
968 int64_t callerRequestCode = data.ReadInt64();
969 int32_t result = BackToCallerAbilityWithResult(token, resultCode, resultWant, callerRequestCode);
970 reply.WriteInt32(result);
971 if (resultWant != nullptr) {
972 delete resultWant;
973 }
974 return NO_ERROR;
975 }
976
TerminateUIServiceExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)977 int32_t AbilityManagerStub::TerminateUIServiceExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
978 {
979 sptr<IRemoteObject> token = nullptr;
980 if (data.ReadBool()) {
981 token = data.ReadRemoteObject();
982 }
983
984 int32_t result = TerminateUIServiceExtensionAbility(token);
985 reply.WriteInt32(result);
986 return NO_ERROR;
987 }
988
TerminateUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)989 int AbilityManagerStub::TerminateUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
990 {
991 sptr<SessionInfo> extensionSessionInfo = nullptr;
992 if (data.ReadBool()) {
993 extensionSessionInfo = data.ReadParcelable<SessionInfo>();
994 }
995 int resultCode = data.ReadInt32();
996 Want *resultWant = data.ReadParcelable<Want>();
997 int32_t result = TerminateUIExtensionAbility(extensionSessionInfo, resultCode, resultWant);
998 reply.WriteInt32(result);
999 if (resultWant != nullptr) {
1000 delete resultWant;
1001 }
1002 return NO_ERROR;
1003 }
1004
SendResultToAbilityInner(MessageParcel &data, MessageParcel &reply)1005 int AbilityManagerStub::SendResultToAbilityInner(MessageParcel &data, MessageParcel &reply)
1006 {
1007 int requestCode = data.ReadInt32();
1008 int resultCode = data.ReadInt32();
1009 Want *resultWant = data.ReadParcelable<Want>();
1010 if (resultWant == nullptr) {
1011 TAG_LOGE(AAFwkTag::ABILITYMGR, "resultWant null");
1012 return ERR_INVALID_VALUE;
1013 }
1014 int32_t result = SendResultToAbility(requestCode, resultCode, *resultWant);
1015 reply.WriteInt32(result);
1016 if (resultWant != nullptr) {
1017 delete resultWant;
1018 }
1019 return NO_ERROR;
1020 }
1021
MinimizeAbilityInner(MessageParcel &data, MessageParcel &reply)1022 int AbilityManagerStub::MinimizeAbilityInner(MessageParcel &data, MessageParcel &reply)
1023 {
1024 auto token = data.ReadRemoteObject();
1025 auto fromUser = data.ReadBool();
1026 int32_t result = MinimizeAbility(token, fromUser);
1027 reply.WriteInt32(result);
1028 return NO_ERROR;
1029 }
1030
MinimizeUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)1031 int AbilityManagerStub::MinimizeUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
1032 {
1033 sptr<SessionInfo> extensionSessionInfo = nullptr;
1034 if (data.ReadBool()) {
1035 extensionSessionInfo = data.ReadParcelable<SessionInfo>();
1036 }
1037 auto fromUser = data.ReadBool();
1038 int32_t result = MinimizeUIExtensionAbility(extensionSessionInfo, fromUser);
1039 reply.WriteInt32(result);
1040 return NO_ERROR;
1041 }
1042
MinimizeUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)1043 int AbilityManagerStub::MinimizeUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)
1044 {
1045 sptr<SessionInfo> sessionInfo = nullptr;
1046 if (data.ReadBool()) {
1047 sessionInfo = data.ReadParcelable<SessionInfo>();
1048 }
1049 bool fromUser = data.ReadBool();
1050 uint32_t sceneFlag = data.ReadUint32();
1051 int32_t result = MinimizeUIAbilityBySCB(sessionInfo, fromUser, sceneFlag);
1052 reply.WriteInt32(result);
1053 return NO_ERROR;
1054 }
1055
AttachAbilityThreadInner(MessageParcel &data, MessageParcel &reply)1056 int AbilityManagerStub::AttachAbilityThreadInner(MessageParcel &data, MessageParcel &reply)
1057 {
1058 auto scheduler = iface_cast<IAbilityScheduler>(data.ReadRemoteObject());
1059 if (scheduler == nullptr) {
1060 TAG_LOGE(AAFwkTag::ABILITYMGR, "scheduler null");
1061 return ERR_INVALID_VALUE;
1062 }
1063 auto token = data.ReadRemoteObject();
1064 int32_t result = AttachAbilityThread(scheduler, token);
1065 reply.WriteInt32(result);
1066 return NO_ERROR;
1067 }
1068
AbilityTransitionDoneInner(MessageParcel &data, MessageParcel &reply)1069 int AbilityManagerStub::AbilityTransitionDoneInner(MessageParcel &data, MessageParcel &reply)
1070 {
1071 auto token = data.ReadRemoteObject();
1072 int targetState = data.ReadInt32();
1073 std::unique_ptr<PacMap> saveData(data.ReadParcelable<PacMap>());
1074 if (!saveData) {
1075 TAG_LOGI(AAFwkTag::ABILITYMGR, "saveData null");
1076 return ERR_INVALID_VALUE;
1077 }
1078 int32_t result = AbilityTransitionDone(token, targetState, *saveData);
1079 reply.WriteInt32(result);
1080 return NO_ERROR;
1081 }
1082
AbilityWindowConfigTransitionDoneInner(MessageParcel &data, MessageParcel &reply)1083 int AbilityManagerStub::AbilityWindowConfigTransitionDoneInner(MessageParcel &data, MessageParcel &reply)
1084 {
1085 auto token = data.ReadRemoteObject();
1086 std::unique_ptr<WindowConfig> windowConfig(data.ReadParcelable<WindowConfig>());
1087 if (!windowConfig) {
1088 TAG_LOGI(AAFwkTag::ABILITYMGR, "windowConfig null");
1089 return ERR_INVALID_VALUE;
1090 }
1091 int32_t result = AbilityWindowConfigTransitionDone(token, *windowConfig);
1092 reply.WriteInt32(result);
1093 return NO_ERROR;
1094 }
1095
ScheduleConnectAbilityDoneInner(MessageParcel &data, MessageParcel &reply)1096 int AbilityManagerStub::ScheduleConnectAbilityDoneInner(MessageParcel &data, MessageParcel &reply)
1097 {
1098 sptr<IRemoteObject> token = nullptr;
1099 sptr<IRemoteObject> remoteObject = nullptr;
1100 if (data.ReadBool()) {
1101 token = data.ReadRemoteObject();
1102 }
1103 if (data.ReadBool()) {
1104 remoteObject = data.ReadRemoteObject();
1105 }
1106 int32_t result = ScheduleConnectAbilityDone(token, remoteObject);
1107 reply.WriteInt32(result);
1108 return NO_ERROR;
1109 }
1110
ScheduleDisconnectAbilityDoneInner(MessageParcel &data, MessageParcel &reply)1111 int AbilityManagerStub::ScheduleDisconnectAbilityDoneInner(MessageParcel &data, MessageParcel &reply)
1112 {
1113 auto token = data.ReadRemoteObject();
1114 int32_t result = ScheduleDisconnectAbilityDone(token);
1115 reply.WriteInt32(result);
1116 return NO_ERROR;
1117 }
1118
ScheduleCommandAbilityDoneInner(MessageParcel &data, MessageParcel &reply)1119 int AbilityManagerStub::ScheduleCommandAbilityDoneInner(MessageParcel &data, MessageParcel &reply)
1120 {
1121 auto token = data.ReadRemoteObject();
1122 int32_t result = ScheduleCommandAbilityDone(token);
1123 reply.WriteInt32(result);
1124 return NO_ERROR;
1125 }
1126
ScheduleCommandAbilityWindowDoneInner(MessageParcel &data, MessageParcel &reply)1127 int AbilityManagerStub::ScheduleCommandAbilityWindowDoneInner(MessageParcel &data, MessageParcel &reply)
1128 {
1129 sptr<IRemoteObject> token = data.ReadRemoteObject();
1130 sptr<SessionInfo> sessionInfo = data.ReadParcelable<SessionInfo>();
1131 int32_t winCmd = data.ReadInt32();
1132 int32_t abilityCmd = data.ReadInt32();
1133 int32_t result = ScheduleCommandAbilityWindowDone(token, sessionInfo,
1134 static_cast<WindowCommand>(winCmd), static_cast<AbilityCommand>(abilityCmd));
1135 reply.WriteInt32(result);
1136 return NO_ERROR;
1137 }
1138
AcquireDataAbilityInner(MessageParcel &data, MessageParcel &reply)1139 int AbilityManagerStub::AcquireDataAbilityInner(MessageParcel &data, MessageParcel &reply)
1140 {
1141 std::unique_ptr<Uri> uri = std::make_unique<Uri>(data.ReadString());
1142 bool tryBind = data.ReadBool();
1143 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
1144 sptr<IAbilityScheduler> result = AcquireDataAbility(*uri, tryBind, callerToken);
1145 TAG_LOGD(AAFwkTag::ABILITYMGR, "acquire data ability %{public}s", result ? "ok" : "failed");
1146 if (result) {
1147 reply.WriteRemoteObject(result->AsObject());
1148 } else {
1149 reply.WriteParcelable(nullptr);
1150 }
1151 return NO_ERROR;
1152 }
1153
ReleaseDataAbilityInner(MessageParcel &data, MessageParcel &reply)1154 int AbilityManagerStub::ReleaseDataAbilityInner(MessageParcel &data, MessageParcel &reply)
1155 {
1156 auto scheduler = iface_cast<IAbilityScheduler>(data.ReadRemoteObject());
1157 if (scheduler == nullptr) {
1158 TAG_LOGE(AAFwkTag::ABILITYMGR, "scheduler null");
1159 return ERR_INVALID_VALUE;
1160 }
1161 auto callerToken = data.ReadRemoteObject();
1162 int32_t result = ReleaseDataAbility(scheduler, callerToken);
1163 TAG_LOGD(AAFwkTag::ABILITYMGR, "release data ability ret = %d", result);
1164 reply.WriteInt32(result);
1165 return NO_ERROR;
1166 }
1167
KillProcessInner(MessageParcel &data, MessageParcel &reply)1168 int AbilityManagerStub::KillProcessInner(MessageParcel &data, MessageParcel &reply)
1169 {
1170 std::string bundleName = Str16ToStr8(data.ReadString16());
1171 bool clearPageStack = data.ReadBool();
1172 int result = KillProcess(bundleName, clearPageStack);
1173 if (!reply.WriteInt32(result)) {
1174 TAG_LOGE(AAFwkTag::ABILITYMGR, "remove stack error");
1175 return ERR_INVALID_VALUE;
1176 }
1177 return NO_ERROR;
1178 }
1179
UninstallAppInner(MessageParcel &data, MessageParcel &reply)1180 int AbilityManagerStub::UninstallAppInner(MessageParcel &data, MessageParcel &reply)
1181 {
1182 std::string bundleName = Str16ToStr8(data.ReadString16());
1183 int32_t uid = data.ReadInt32();
1184 int32_t appIndex = data.ReadInt32();
1185 int32_t result = UninstallApp(bundleName, uid, appIndex);
1186 if (!reply.WriteInt32(result)) {
1187 TAG_LOGE(AAFwkTag::ABILITYMGR, "remove stack error");
1188 return ERR_INVALID_VALUE;
1189 }
1190 return NO_ERROR;
1191 }
1192
UpgradeAppInner(MessageParcel &data, MessageParcel &reply)1193 int32_t AbilityManagerStub::UpgradeAppInner(MessageParcel &data, MessageParcel &reply)
1194 {
1195 std::string bundleName = Str16ToStr8(data.ReadString16());
1196 int32_t uid = data.ReadInt32();
1197 std::string exitMsg = Str16ToStr8(data.ReadString16());
1198 int32_t appIndex = data.ReadInt32();
1199 int32_t result = UpgradeApp(bundleName, uid, exitMsg, appIndex);
1200 if (!reply.WriteInt32(result)) {
1201 TAG_LOGE(AAFwkTag::ABILITYMGR, "UpgradeAppInner error");
1202 return ERR_INVALID_VALUE;
1203 }
1204 return NO_ERROR;
1205 }
1206
StartAbilityInner(MessageParcel &data, MessageParcel &reply)1207 int AbilityManagerStub::StartAbilityInner(MessageParcel &data, MessageParcel &reply)
1208 {
1209 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1210 if (want == nullptr) {
1211 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1212 return ERR_INVALID_VALUE;
1213 }
1214 int32_t userId = data.ReadInt32();
1215 int requestCode = data.ReadInt32();
1216 int32_t result = StartAbility(*want, userId, requestCode);
1217 reply.WriteInt32(result);
1218 return NO_ERROR;
1219 }
1220
StartAbilityInnerSpecifyTokenId(MessageParcel &data, MessageParcel &reply)1221 int AbilityManagerStub::StartAbilityInnerSpecifyTokenId(MessageParcel &data, MessageParcel &reply)
1222 {
1223 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1224 if (want == nullptr) {
1225 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1226 return ERR_INVALID_VALUE;
1227 }
1228
1229 sptr<IRemoteObject> callerToken = nullptr;
1230 if (data.ReadBool()) {
1231 callerToken = data.ReadRemoteObject();
1232 }
1233 int32_t specifyTokenId = data.ReadInt32();
1234 int32_t userId = data.ReadInt32();
1235 int requestCode = data.ReadInt32();
1236 int32_t result = StartAbilityWithSpecifyTokenId(*want, callerToken, specifyTokenId, userId, requestCode);
1237 reply.WriteInt32(result);
1238 return NO_ERROR;
1239 }
1240
StartAbilityByUIContentSessionAddCallerInner(MessageParcel &data, MessageParcel &reply)1241 int AbilityManagerStub::StartAbilityByUIContentSessionAddCallerInner(MessageParcel &data, MessageParcel &reply)
1242 {
1243 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1244 if (want == nullptr) {
1245 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1246 return ERR_INVALID_VALUE;
1247 }
1248
1249 sptr<IRemoteObject> callerToken = nullptr;
1250 if (data.ReadBool()) {
1251 callerToken = data.ReadRemoteObject();
1252 if (callerToken == nullptr) {
1253 TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken null");
1254 return ERR_INVALID_VALUE;
1255 }
1256 }
1257
1258 sptr<SessionInfo> sessionInfo = nullptr;
1259 if (data.ReadBool()) {
1260 sessionInfo = data.ReadParcelable<SessionInfo>();
1261 if (sessionInfo == nullptr) {
1262 TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionInfo null");
1263 return ERR_INVALID_VALUE;
1264 }
1265 }
1266
1267 int32_t userId = data.ReadInt32();
1268 int requestCode = data.ReadInt32();
1269 int32_t result = StartAbilityByUIContentSession(*want, callerToken, sessionInfo, userId, requestCode);
1270 reply.WriteInt32(result);
1271 return NO_ERROR;
1272 }
1273
StartAbilityByUIContentSessionForOptionsInner(MessageParcel &data, MessageParcel &reply)1274 int AbilityManagerStub::StartAbilityByUIContentSessionForOptionsInner(MessageParcel &data, MessageParcel &reply)
1275 {
1276 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
1277 if (want == nullptr) {
1278 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1279 return ERR_INVALID_VALUE;
1280 }
1281 std::unique_ptr<StartOptions> startOptions(data.ReadParcelable<StartOptions>());
1282 if (startOptions == nullptr) {
1283 TAG_LOGE(AAFwkTag::ABILITYMGR, "startOptions null");
1284 return ERR_INVALID_VALUE;
1285 }
1286 startOptions->processOptions = nullptr;
1287 sptr<IRemoteObject> callerToken = nullptr;
1288 if (data.ReadBool()) {
1289 callerToken = data.ReadRemoteObject();
1290 if (callerToken == nullptr) {
1291 TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken null");
1292 return ERR_INVALID_VALUE;
1293 }
1294 }
1295 sptr<SessionInfo> sessionInfo = nullptr;
1296 if (data.ReadBool()) {
1297 sessionInfo = data.ReadParcelable<SessionInfo>();
1298 if (sessionInfo == nullptr) {
1299 TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionInfo null");
1300 return ERR_INVALID_VALUE;
1301 }
1302 }
1303 int32_t userId = data.ReadInt32();
1304 int requestCode = data.ReadInt32();
1305 int32_t result = StartAbilityByUIContentSession(*want, *startOptions,
1306 callerToken, sessionInfo, userId, requestCode);
1307 reply.WriteInt32(result);
1308 return NO_ERROR;
1309 }
1310
StartExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)1311 int AbilityManagerStub::StartExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
1312 {
1313 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1314 if (want == nullptr) {
1315 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1316 return ERR_INVALID_VALUE;
1317 }
1318 sptr<IRemoteObject> callerToken = nullptr;
1319 if (data.ReadBool()) {
1320 callerToken = data.ReadRemoteObject();
1321 }
1322 int32_t userId = data.ReadInt32();
1323 int32_t extensionType = data.ReadInt32();
1324 int32_t result = StartExtensionAbility(*want, callerToken, userId,
1325 static_cast<AppExecFwk::ExtensionAbilityType>(extensionType));
1326 reply.WriteInt32(result);
1327 return NO_ERROR;
1328 }
1329
RequestModalUIExtensionInner(MessageParcel &data, MessageParcel &reply)1330 int AbilityManagerStub::RequestModalUIExtensionInner(MessageParcel &data, MessageParcel &reply)
1331 {
1332 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1333 if (want == nullptr) {
1334 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1335 return ERR_INVALID_VALUE;
1336 }
1337 int32_t result = RequestModalUIExtension(*want);
1338 reply.WriteInt32(result);
1339 return NO_ERROR;
1340 }
1341
PreloadUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)1342 int AbilityManagerStub::PreloadUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
1343 {
1344 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1345 if (want == nullptr) {
1346 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1347 return ERR_INVALID_VALUE;
1348 }
1349 std::string hostBundleName = Str16ToStr8(data.ReadString16());
1350 int32_t userId = data.ReadInt32();
1351 int32_t result = PreloadUIExtensionAbility(*want, hostBundleName, userId);
1352 reply.WriteInt32(result);
1353 return NO_ERROR;
1354 }
1355
ChangeAbilityVisibilityInner(MessageParcel &data, MessageParcel &reply)1356 int AbilityManagerStub::ChangeAbilityVisibilityInner(MessageParcel &data, MessageParcel &reply)
1357 {
1358 sptr<IRemoteObject> token = data.ReadRemoteObject();
1359 if (!token) {
1360 TAG_LOGE(AAFwkTag::ABILITYMGR, "read token fail");
1361 return ERR_NULL_OBJECT;
1362 }
1363
1364 bool isShow = data.ReadBool();
1365 int result = ChangeAbilityVisibility(token, isShow);
1366 if (!reply.WriteInt32(result)) {
1367 TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
1368 return ERR_NATIVE_IPC_PARCEL_FAILED;
1369 }
1370 return NO_ERROR;
1371 }
1372
ChangeUIAbilityVisibilityBySCBInner(MessageParcel &data, MessageParcel &reply)1373 int AbilityManagerStub::ChangeUIAbilityVisibilityBySCBInner(MessageParcel &data, MessageParcel &reply)
1374 {
1375 sptr<SessionInfo> sessionInfo = data.ReadParcelable<SessionInfo>();
1376 if (!sessionInfo) {
1377 TAG_LOGE(AAFwkTag::ABILITYMGR, "read sessionInfo fail");
1378 return ERR_NULL_OBJECT;
1379 }
1380
1381 bool isShow = data.ReadBool();
1382 int result = ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow);
1383 if (!reply.WriteInt32(result)) {
1384 TAG_LOGE(AAFwkTag::ABILITYMGR, "write fail");
1385 return ERR_NATIVE_IPC_PARCEL_FAILED;
1386 }
1387 return NO_ERROR;
1388 }
1389
StartUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)1390 int AbilityManagerStub::StartUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
1391 {
1392 sptr<SessionInfo> extensionSessionInfo = nullptr;
1393 if (data.ReadBool()) {
1394 extensionSessionInfo = data.ReadParcelable<SessionInfo>();
1395 if (extensionSessionInfo == nullptr) {
1396 TAG_LOGE(AAFwkTag::ABILITYMGR, "null extensionSessionInfo");
1397 return ERR_NULL_OBJECT;
1398 }
1399 // To ensure security, this attribute must be rewritten.
1400 extensionSessionInfo->uiExtensionUsage = UIExtensionUsage::MODAL;
1401 }
1402
1403 int32_t userId = data.ReadInt32();
1404
1405 int32_t result = StartUIExtensionAbility(extensionSessionInfo, userId);
1406 reply.WriteInt32(result);
1407 return NO_ERROR;
1408 }
1409
StartUIExtensionAbilityEmbeddedInner(MessageParcel &data, MessageParcel &reply)1410 int AbilityManagerStub::StartUIExtensionAbilityEmbeddedInner(MessageParcel &data, MessageParcel &reply)
1411 {
1412 sptr<SessionInfo> extensionSessionInfo = nullptr;
1413 if (data.ReadBool()) {
1414 extensionSessionInfo = data.ReadParcelable<SessionInfo>();
1415 if (extensionSessionInfo == nullptr) {
1416 TAG_LOGE(AAFwkTag::ABILITYMGR, "null extensionSessionInfo");
1417 return ERR_NULL_OBJECT;
1418 }
1419 // To ensure security, this attribute must be rewritten.
1420 extensionSessionInfo->uiExtensionUsage = UIExtensionUsage::EMBEDDED;
1421 }
1422
1423 int32_t userId = data.ReadInt32();
1424
1425 int32_t result = StartUIExtensionAbility(extensionSessionInfo, userId);
1426 reply.WriteInt32(result);
1427 return NO_ERROR;
1428 }
1429
StartUIExtensionConstrainedEmbeddedInner(MessageParcel &data, MessageParcel &reply)1430 int AbilityManagerStub::StartUIExtensionConstrainedEmbeddedInner(MessageParcel &data, MessageParcel &reply)
1431 {
1432 sptr<SessionInfo> extensionSessionInfo = nullptr;
1433 if (data.ReadBool()) {
1434 extensionSessionInfo = data.ReadParcelable<SessionInfo>();
1435 if (extensionSessionInfo == nullptr) {
1436 TAG_LOGE(AAFwkTag::ABILITYMGR, "null extensionSessionInfo");
1437 return ERR_NULL_OBJECT;
1438 }
1439 // To ensure security, this attribute must be rewritten.
1440 extensionSessionInfo->uiExtensionUsage = UIExtensionUsage::CONSTRAINED_EMBEDDED;
1441 }
1442
1443 int32_t userId = data.ReadInt32();
1444
1445 int32_t result = StartUIExtensionAbility(extensionSessionInfo, userId);
1446 reply.WriteInt32(result);
1447 return NO_ERROR;
1448 }
1449
StopExtensionAbilityInner(MessageParcel& data, MessageParcel& reply)1450 int AbilityManagerStub::StopExtensionAbilityInner(MessageParcel& data, MessageParcel& reply)
1451 {
1452 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1453 if (want == nullptr) {
1454 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
1455 return ERR_INVALID_VALUE;
1456 }
1457 sptr<IRemoteObject> callerToken = nullptr;
1458 if (data.ReadBool()) {
1459 callerToken = data.ReadRemoteObject();
1460 }
1461 int32_t userId = data.ReadInt32();
1462 int32_t extensionType = data.ReadInt32();
1463 int32_t result =
1464 StopExtensionAbility(*want, callerToken, userId, static_cast<AppExecFwk::ExtensionAbilityType>(extensionType));
1465 reply.WriteInt32(result);
1466 return NO_ERROR;
1467 }
1468
StartAbilityAddCallerInner(MessageParcel &data, MessageParcel &reply)1469 int AbilityManagerStub::StartAbilityAddCallerInner(MessageParcel &data, MessageParcel &reply)
1470 {
1471 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1472 if (want == nullptr) {
1473 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
1474 return ERR_INVALID_VALUE;
1475 }
1476
1477 sptr<IRemoteObject> callerToken = nullptr;
1478 if (data.ReadBool()) {
1479 callerToken = data.ReadRemoteObject();
1480 }
1481
1482 int32_t userId = data.ReadInt32();
1483 int requestCode = data.ReadInt32();
1484 int32_t result = StartAbility(*want, callerToken, userId, requestCode);
1485 reply.WriteInt32(result);
1486 return NO_ERROR;
1487 }
1488
StartAbilityAsCallerByTokenInner(MessageParcel &data, MessageParcel &reply)1489 int AbilityManagerStub::StartAbilityAsCallerByTokenInner(MessageParcel &data, MessageParcel &reply)
1490 {
1491 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1492 if (want == nullptr) {
1493 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
1494 return ERR_INVALID_VALUE;
1495 }
1496
1497 sptr<IRemoteObject> callerToken = nullptr;
1498 sptr<IRemoteObject> asCallerSourceToken = nullptr;
1499 if (data.ReadBool()) {
1500 callerToken = data.ReadRemoteObject();
1501 }
1502 if (data.ReadBool()) {
1503 asCallerSourceToken = data.ReadRemoteObject();
1504 }
1505 int32_t userId = data.ReadInt32();
1506 int requestCode = data.ReadInt32();
1507 int32_t result = StartAbilityAsCaller(*want, callerToken, asCallerSourceToken, userId, requestCode);
1508 reply.WriteInt32(result);
1509 return NO_ERROR;
1510 }
1511
StartAbilityAsCallerForOptionInner(MessageParcel &data, MessageParcel &reply)1512 int AbilityManagerStub::StartAbilityAsCallerForOptionInner(MessageParcel &data, MessageParcel &reply)
1513 {
1514 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1515 if (want == nullptr) {
1516 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
1517 return ERR_INVALID_VALUE;
1518 }
1519 StartOptions *startOptions = data.ReadParcelable<StartOptions>();
1520 if (startOptions == nullptr) {
1521 TAG_LOGE(AAFwkTag::ABILITYMGR, "null startOptions");
1522 return ERR_INVALID_VALUE;
1523 }
1524 startOptions->processOptions = nullptr;
1525 sptr<IRemoteObject> callerToken = nullptr;
1526 sptr<IRemoteObject> asCallerSourceToken = nullptr;
1527 if (data.ReadBool()) {
1528 callerToken = data.ReadRemoteObject();
1529 }
1530 if (data.ReadBool()) {
1531 asCallerSourceToken = data.ReadRemoteObject();
1532 }
1533 int32_t userId = data.ReadInt32();
1534 int requestCode = data.ReadInt32();
1535 int32_t result = StartAbilityAsCaller(*want, *startOptions, callerToken, asCallerSourceToken, userId, requestCode);
1536 reply.WriteInt32(result);
1537 delete startOptions;
1538 return NO_ERROR;
1539 }
1540
ConnectAbilityInner(MessageParcel &data, MessageParcel &reply)1541 int AbilityManagerStub::ConnectAbilityInner(MessageParcel &data, MessageParcel &reply)
1542 {
1543 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1544 if (want == nullptr) {
1545 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
1546 return ERR_INVALID_VALUE;
1547 }
1548 sptr<IAbilityConnection> callback = nullptr;
1549 sptr<IRemoteObject> token = nullptr;
1550 if (data.ReadBool()) {
1551 callback = iface_cast<IAbilityConnection>(data.ReadRemoteObject());
1552 }
1553 if (data.ReadBool()) {
1554 token = data.ReadRemoteObject();
1555 }
1556 int32_t userId = data.ReadInt32();
1557 int32_t result = ConnectAbilityCommon(*want, callback, token, AppExecFwk::ExtensionAbilityType::SERVICE, userId);
1558 reply.WriteInt32(result);
1559 return NO_ERROR;
1560 }
1561
ConnectAbilityWithTypeInner(MessageParcel &data, MessageParcel &reply)1562 int AbilityManagerStub::ConnectAbilityWithTypeInner(MessageParcel &data, MessageParcel &reply)
1563 {
1564 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1565 if (want == nullptr) {
1566 TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s, null want", __func__);
1567 return ERR_INVALID_VALUE;
1568 }
1569 sptr<IAbilityConnection> callback = nullptr;
1570 sptr<IRemoteObject> token = nullptr;
1571 if (data.ReadBool()) {
1572 callback = iface_cast<IAbilityConnection>(data.ReadRemoteObject());
1573 }
1574 if (data.ReadBool()) {
1575 token = data.ReadRemoteObject();
1576 }
1577 int32_t userId = data.ReadInt32();
1578 AppExecFwk::ExtensionAbilityType extensionType = static_cast<AppExecFwk::ExtensionAbilityType>(data.ReadInt32());
1579 bool isQueryExtensionOnly = data.ReadBool();
1580 int32_t result = ConnectAbilityCommon(*want, callback, token, extensionType, userId, isQueryExtensionOnly);
1581 reply.WriteInt32(result);
1582 return NO_ERROR;
1583 }
1584
ConnectUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)1585 int AbilityManagerStub::ConnectUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
1586 {
1587 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1588 if (want == nullptr) {
1589 TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s, null want", __func__);
1590 return ERR_INVALID_VALUE;
1591 }
1592 sptr<IAbilityConnection> callback = nullptr;
1593 if (data.ReadBool()) {
1594 callback = iface_cast<IAbilityConnection>(data.ReadRemoteObject());
1595 }
1596 sptr<SessionInfo> sessionInfo = nullptr;
1597 if (data.ReadBool()) {
1598 sessionInfo = data.ReadParcelable<SessionInfo>();
1599 }
1600 int32_t userId = data.ReadInt32();
1601
1602 sptr<UIExtensionAbilityConnectInfo> connectInfo = nullptr;
1603 if (data.ReadBool()) {
1604 connectInfo = data.ReadParcelable<UIExtensionAbilityConnectInfo>();
1605 }
1606
1607 int32_t result = ConnectUIExtensionAbility(*want, callback, sessionInfo, userId, connectInfo);
1608 if (connectInfo != nullptr && !reply.WriteParcelable(connectInfo)) {
1609 TAG_LOGE(AAFwkTag::ABILITYMGR, "connectInfo write fail");
1610 }
1611
1612 reply.WriteInt32(result);
1613 return NO_ERROR;
1614 }
1615
DisconnectAbilityInner(MessageParcel &data, MessageParcel &reply)1616 int AbilityManagerStub::DisconnectAbilityInner(MessageParcel &data, MessageParcel &reply)
1617 {
1618 sptr<IAbilityConnection> callback = iface_cast<IAbilityConnection>(data.ReadRemoteObject());
1619 if (callback == nullptr) {
1620 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
1621 return ERR_INVALID_VALUE;
1622 }
1623 int32_t result = DisconnectAbility(callback);
1624 TAG_LOGD(AAFwkTag::ABILITYMGR, "disconnect ability ret = %d", result);
1625 reply.WriteInt32(result);
1626 return NO_ERROR;
1627 }
1628
StopServiceAbilityInner(MessageParcel &data, MessageParcel &reply)1629 int AbilityManagerStub::StopServiceAbilityInner(MessageParcel &data, MessageParcel &reply)
1630 {
1631 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1632 if (want == nullptr) {
1633 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
1634 return ERR_INVALID_VALUE;
1635 }
1636 int32_t userId = data.ReadInt32();
1637 sptr<IRemoteObject> token = nullptr;
1638 if (data.ReadBool()) {
1639 token = data.ReadRemoteObject();
1640 }
1641 int32_t result = StopServiceAbility(*want, userId, token);
1642 reply.WriteInt32(result);
1643 return NO_ERROR;
1644 }
1645
DumpSysStateInner(MessageParcel &data, MessageParcel &reply)1646 int AbilityManagerStub::DumpSysStateInner(MessageParcel &data, MessageParcel &reply)
1647 {
1648 std::vector<std::string> result;
1649 std::string args = Str16ToStr8(data.ReadString16());
1650 std::vector<std::string> argList;
1651
1652 auto isClient = data.ReadBool();
1653 auto isUserID = data.ReadBool();
1654 auto UserID = data.ReadInt32();
1655 SplitStr(args, " ", argList);
1656 if (argList.empty()) {
1657 return ERR_INVALID_VALUE;
1658 }
1659 DumpSysState(args, result, isClient, isUserID, UserID);
1660 reply.WriteInt32(result.size());
1661 for (auto stack : result) {
1662 reply.WriteString16(Str8ToStr16(stack));
1663 }
1664 return NO_ERROR;
1665 }
1666
DumpStateInner(MessageParcel &data, MessageParcel &reply)1667 int AbilityManagerStub::DumpStateInner(MessageParcel &data, MessageParcel &reply)
1668 {
1669 std::vector<std::string> result;
1670 std::string args = Str16ToStr8(data.ReadString16());
1671 std::vector<std::string> argList;
1672 SplitStr(args, " ", argList);
1673 if (argList.empty()) {
1674 return ERR_INVALID_VALUE;
1675 }
1676 DumpState(args, result);
1677 reply.WriteInt32(result.size());
1678 for (auto stack : result) {
1679 reply.WriteString16(Str8ToStr16(stack));
1680 }
1681 return NO_ERROR;
1682 }
1683
StartAbilityForSettingsInner(MessageParcel &data, MessageParcel &reply)1684 int AbilityManagerStub::StartAbilityForSettingsInner(MessageParcel &data, MessageParcel &reply)
1685 {
1686 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1687 if (want == nullptr) {
1688 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
1689 return ERR_INVALID_VALUE;
1690 }
1691 AbilityStartSetting *abilityStartSetting = data.ReadParcelable<AbilityStartSetting>();
1692 if (abilityStartSetting == nullptr) {
1693 TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityStartSetting null");
1694 return ERR_INVALID_VALUE;
1695 }
1696 sptr<IRemoteObject> callerToken = nullptr;
1697 if (data.ReadBool()) {
1698 callerToken = data.ReadRemoteObject();
1699 }
1700 int32_t userId = data.ReadInt32();
1701 int requestCode = data.ReadInt32();
1702 int32_t result = StartAbility(*want, *abilityStartSetting, callerToken, userId, requestCode);
1703 reply.WriteInt32(result);
1704 delete abilityStartSetting;
1705 return NO_ERROR;
1706 }
1707
StartAbilityForOptionsInner(MessageParcel &data, MessageParcel &reply)1708 int AbilityManagerStub::StartAbilityForOptionsInner(MessageParcel &data, MessageParcel &reply)
1709 {
1710 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1711 if (want == nullptr) {
1712 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
1713 return ERR_INVALID_VALUE;
1714 }
1715 StartOptions *startOptions = data.ReadParcelable<StartOptions>();
1716 if (startOptions == nullptr) {
1717 TAG_LOGE(AAFwkTag::ABILITYMGR, "startOptions null");
1718 return ERR_INVALID_VALUE;
1719 }
1720 sptr<IRemoteObject> callerToken = nullptr;
1721 if (data.ReadBool()) {
1722 callerToken = data.ReadRemoteObject();
1723 }
1724 int32_t userId = data.ReadInt32();
1725 int requestCode = data.ReadInt32();
1726 int32_t result = StartAbility(*want, *startOptions, callerToken, userId, requestCode);
1727 reply.WriteInt32(result);
1728 delete startOptions;
1729 return NO_ERROR;
1730 }
1731
CloseUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)1732 int AbilityManagerStub::CloseUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)
1733 {
1734 sptr<SessionInfo> sessionInfo = nullptr;
1735 if (data.ReadBool()) {
1736 sessionInfo = data.ReadParcelable<SessionInfo>();
1737 }
1738 int32_t result = CloseUIAbilityBySCB(sessionInfo);
1739 reply.WriteInt32(result);
1740 return NO_ERROR;
1741 }
1742
GetWantSenderInner(MessageParcel &data, MessageParcel &reply)1743 int AbilityManagerStub::GetWantSenderInner(MessageParcel &data, MessageParcel &reply)
1744 {
1745 std::unique_ptr<WantSenderInfo> wantSenderInfo(data.ReadParcelable<WantSenderInfo>());
1746 if (wantSenderInfo == nullptr) {
1747 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSenderInfo null");
1748 return ERR_INVALID_VALUE;
1749 }
1750 sptr<IRemoteObject> callerToken = nullptr;
1751 if (data.ReadBool()) {
1752 callerToken = data.ReadRemoteObject();
1753 }
1754
1755 int32_t uid = data.ReadInt32();
1756 sptr<IWantSender> wantSender = GetWantSender(*wantSenderInfo, callerToken, uid);
1757 if (!reply.WriteRemoteObject(((wantSender == nullptr) ? nullptr : wantSender->AsObject()))) {
1758 TAG_LOGE(AAFwkTag::ABILITYMGR, "failed reply wantSender to client, for write parcel error");
1759 return ERR_INVALID_VALUE;
1760 }
1761 return NO_ERROR;
1762 }
1763
SendWantSenderInner(MessageParcel &data, MessageParcel &reply)1764 int AbilityManagerStub::SendWantSenderInner(MessageParcel &data, MessageParcel &reply)
1765 {
1766 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1767 if (wantSender == nullptr) {
1768 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1769 return ERR_INVALID_VALUE;
1770 }
1771 std::unique_ptr<SenderInfo> senderInfo(data.ReadParcelable<SenderInfo>());
1772 if (senderInfo == nullptr) {
1773 TAG_LOGE(AAFwkTag::ABILITYMGR, "senderInfo null");
1774 return ERR_INVALID_VALUE;
1775 }
1776 int32_t result = SendWantSender(wantSender, *senderInfo);
1777 reply.WriteInt32(result);
1778 return NO_ERROR;
1779 }
1780
CancelWantSenderInner(MessageParcel &data, MessageParcel &reply)1781 int AbilityManagerStub::CancelWantSenderInner(MessageParcel &data, MessageParcel &reply)
1782 {
1783 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1784 if (wantSender == nullptr) {
1785 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1786 return ERR_INVALID_VALUE;
1787 }
1788 CancelWantSender(wantSender);
1789 return NO_ERROR;
1790 }
1791
GetPendingWantUidInner(MessageParcel &data, MessageParcel &reply)1792 int AbilityManagerStub::GetPendingWantUidInner(MessageParcel &data, MessageParcel &reply)
1793 {
1794 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1795 if (wantSender == nullptr) {
1796 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1797 return ERR_INVALID_VALUE;
1798 }
1799
1800 int32_t uid = GetPendingWantUid(wantSender);
1801 reply.WriteInt32(uid);
1802 return NO_ERROR;
1803 }
1804
GetPendingWantUserIdInner(MessageParcel &data, MessageParcel &reply)1805 int AbilityManagerStub::GetPendingWantUserIdInner(MessageParcel &data, MessageParcel &reply)
1806 {
1807 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1808 if (wantSender == nullptr) {
1809 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1810 return ERR_INVALID_VALUE;
1811 }
1812
1813 int32_t userId = GetPendingWantUserId(wantSender);
1814 reply.WriteInt32(userId);
1815 return NO_ERROR;
1816 }
1817
GetPendingWantBundleNameInner(MessageParcel &data, MessageParcel &reply)1818 int AbilityManagerStub::GetPendingWantBundleNameInner(MessageParcel &data, MessageParcel &reply)
1819 {
1820 auto remote = data.ReadRemoteObject();
1821 if (remote == nullptr) {
1822 TAG_LOGE(AAFwkTag::ABILITYMGR, "readRemoteObject null");
1823 return ERR_INVALID_VALUE;
1824 }
1825
1826 sptr<IWantSender> wantSender = iface_cast<IWantSender>(remote);
1827 if (wantSender == nullptr) {
1828 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1829 return ERR_INVALID_VALUE;
1830 }
1831
1832 std::string bundleName = GetPendingWantBundleName(wantSender);
1833 reply.WriteString16(Str8ToStr16(bundleName));
1834 return NO_ERROR;
1835 }
1836
GetPendingWantCodeInner(MessageParcel &data, MessageParcel &reply)1837 int AbilityManagerStub::GetPendingWantCodeInner(MessageParcel &data, MessageParcel &reply)
1838 {
1839 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1840 if (wantSender == nullptr) {
1841 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1842 return ERR_INVALID_VALUE;
1843 }
1844
1845 int32_t code = GetPendingWantCode(wantSender);
1846 reply.WriteInt32(code);
1847 return NO_ERROR;
1848 }
1849
GetPendingWantTypeInner(MessageParcel &data, MessageParcel &reply)1850 int AbilityManagerStub::GetPendingWantTypeInner(MessageParcel &data, MessageParcel &reply)
1851 {
1852 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1853 if (wantSender == nullptr) {
1854 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1855 return ERR_INVALID_VALUE;
1856 }
1857
1858 int32_t type = GetPendingWantType(wantSender);
1859 reply.WriteInt32(type);
1860 return NO_ERROR;
1861 }
1862
RegisterCancelListenerInner(MessageParcel &data, MessageParcel &reply)1863 int AbilityManagerStub::RegisterCancelListenerInner(MessageParcel &data, MessageParcel &reply)
1864 {
1865 sptr<IWantSender> sender = iface_cast<IWantSender>(data.ReadRemoteObject());
1866 if (sender == nullptr) {
1867 TAG_LOGE(AAFwkTag::ABILITYMGR, "sender null");
1868 return ERR_INVALID_VALUE;
1869 }
1870 sptr<IWantReceiver> receiver = iface_cast<IWantReceiver>(data.ReadRemoteObject());
1871 if (receiver == nullptr) {
1872 TAG_LOGE(AAFwkTag::ABILITYMGR, "receiver null");
1873 return ERR_INVALID_VALUE;
1874 }
1875 RegisterCancelListener(sender, receiver);
1876 return NO_ERROR;
1877 }
1878
UnregisterCancelListenerInner(MessageParcel &data, MessageParcel &reply)1879 int AbilityManagerStub::UnregisterCancelListenerInner(MessageParcel &data, MessageParcel &reply)
1880 {
1881 sptr<IWantSender> sender = iface_cast<IWantSender>(data.ReadRemoteObject());
1882 if (sender == nullptr) {
1883 TAG_LOGE(AAFwkTag::ABILITYMGR, "sender null");
1884 return ERR_INVALID_VALUE;
1885 }
1886 sptr<IWantReceiver> receiver = iface_cast<IWantReceiver>(data.ReadRemoteObject());
1887 if (receiver == nullptr) {
1888 TAG_LOGE(AAFwkTag::ABILITYMGR, "receiver null");
1889 return ERR_INVALID_VALUE;
1890 }
1891 UnregisterCancelListener(sender, receiver);
1892 return NO_ERROR;
1893 }
1894
GetPendingRequestWantInner(MessageParcel &data, MessageParcel &reply)1895 int AbilityManagerStub::GetPendingRequestWantInner(MessageParcel &data, MessageParcel &reply)
1896 {
1897 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
1898 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1899 if (wantSender == nullptr) {
1900 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1901 return ERR_INVALID_VALUE;
1902 }
1903
1904 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
1905 int32_t result = GetPendingRequestWant(wantSender, want);
1906 if (result != NO_ERROR) {
1907 TAG_LOGE(AAFwkTag::ABILITYMGR, "getPendingRequestWant fail");
1908 return ERR_INVALID_VALUE;
1909 }
1910 reply.WriteParcelable(want.get());
1911 return NO_ERROR;
1912 }
1913
GetWantSenderInfoInner(MessageParcel &data, MessageParcel &reply)1914 int AbilityManagerStub::GetWantSenderInfoInner(MessageParcel &data, MessageParcel &reply)
1915 {
1916 sptr<IWantSender> wantSender = iface_cast<IWantSender>(data.ReadRemoteObject());
1917 if (wantSender == nullptr) {
1918 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantSender null");
1919 return ERR_INVALID_VALUE;
1920 }
1921
1922 std::shared_ptr<WantSenderInfo> info(data.ReadParcelable<WantSenderInfo>());
1923 int32_t result = GetWantSenderInfo(wantSender, info);
1924 if (result != NO_ERROR) {
1925 TAG_LOGE(AAFwkTag::ABILITYMGR, "getWantSenderInfo fail");
1926 return ERR_INVALID_VALUE;
1927 }
1928 reply.WriteParcelable(info.get());
1929 return NO_ERROR;
1930 }
1931
GetAppMemorySizeInner(MessageParcel &data, MessageParcel &reply)1932 int AbilityManagerStub::GetAppMemorySizeInner(MessageParcel &data, MessageParcel &reply)
1933 {
1934 int32_t result = GetAppMemorySize();
1935 TAG_LOGI(AAFwkTag::ABILITYMGR, "result %{public}d", result);
1936 if (!reply.WriteInt32(result)) {
1937 TAG_LOGE(AAFwkTag::ABILITYMGR, "GetAppMemorySize error");
1938 return ERR_INVALID_VALUE;
1939 }
1940 return NO_ERROR;
1941 }
1942
IsRamConstrainedDeviceInner(MessageParcel &data, MessageParcel &reply)1943 int AbilityManagerStub::IsRamConstrainedDeviceInner(MessageParcel &data, MessageParcel &reply)
1944 {
1945 auto result = IsRamConstrainedDevice();
1946 if (!reply.WriteBool(result)) {
1947 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
1948 return ERR_INVALID_VALUE;
1949 }
1950 return NO_ERROR;
1951 }
1952
ContinueMissionInner(MessageParcel &data, MessageParcel &reply)1953 int AbilityManagerStub::ContinueMissionInner(MessageParcel &data, MessageParcel &reply)
1954 {
1955 TAG_LOGI(AAFwkTag::ABILITYMGR, "called");
1956 std::string srcDeviceId = data.ReadString();
1957 std::string dstDeviceId = data.ReadString();
1958 int32_t missionId = data.ReadInt32();
1959 sptr<IRemoteObject> callback = data.ReadRemoteObject();
1960 if (callback == nullptr) {
1961 TAG_LOGE(AAFwkTag::ABILITYMGR, "null callback");
1962 return ERR_NULL_OBJECT;
1963 }
1964 std::unique_ptr<WantParams> wantParams(data.ReadParcelable<WantParams>());
1965 if (wantParams == nullptr) {
1966 TAG_LOGE(AAFwkTag::ABILITYMGR, "null wantParams");
1967 return ERR_NULL_OBJECT;
1968 }
1969 int32_t result = ContinueMission(srcDeviceId, dstDeviceId, missionId, callback, *wantParams);
1970 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
1971 return result;
1972 }
1973
ContinueMissionOfBundleNameInner(MessageParcel &data, MessageParcel &reply)1974 int AbilityManagerStub::ContinueMissionOfBundleNameInner(MessageParcel &data, MessageParcel &reply)
1975 {
1976 TAG_LOGI(AAFwkTag::ABILITYMGR, "amsStub %{public}s call", __func__);
1977 ContinueMissionInfo continueMissionInfo;
1978 continueMissionInfo.srcDeviceId = data.ReadString();
1979 continueMissionInfo.dstDeviceId = data.ReadString();
1980 continueMissionInfo.bundleName = data.ReadString();
1981 sptr<IRemoteObject> callback = data.ReadRemoteObject();
1982 if (callback == nullptr) {
1983 TAG_LOGE(AAFwkTag::ABILITYMGR, "null wantParams");
1984 return ERR_NULL_OBJECT;
1985 }
1986 std::unique_ptr<WantParams> wantParams(data.ReadParcelable<WantParams>());
1987 if (wantParams == nullptr) {
1988 TAG_LOGE(AAFwkTag::ABILITYMGR, "null wantParams");
1989 return ERR_NULL_OBJECT;
1990 }
1991 continueMissionInfo.wantParams = *wantParams;
1992 continueMissionInfo.srcBundleName = data.ReadString();
1993 continueMissionInfo.continueType = data.ReadString();
1994 int32_t result = ContinueMission(continueMissionInfo, callback);
1995 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
1996 return result;
1997 }
1998
ContinueAbilityInner(MessageParcel &data, MessageParcel &reply)1999 int AbilityManagerStub::ContinueAbilityInner(MessageParcel &data, MessageParcel &reply)
2000 {
2001 std::string deviceId = data.ReadString();
2002 int32_t missionId = data.ReadInt32();
2003 uint32_t versionCode = data.ReadUint32();
2004 AAFWK::ContinueRadar::GetInstance().SaveDataContinue("ContinueAbility");
2005 int32_t result = ContinueAbility(deviceId, missionId, versionCode);
2006 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2007 return result;
2008 }
2009
StartContinuationInner(MessageParcel &data, MessageParcel &reply)2010 int AbilityManagerStub::StartContinuationInner(MessageParcel &data, MessageParcel &reply)
2011 {
2012 AAFWK::ContinueRadar::GetInstance().SaveDataRes("GetContentInfo");
2013 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2014 if (want == nullptr) {
2015 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
2016 return ERR_NULL_OBJECT;
2017 }
2018
2019 sptr<IRemoteObject> abilityToken = data.ReadRemoteObject();
2020 if (abilityToken == nullptr) {
2021 TAG_LOGE(AAFwkTag::ABILITYMGR, "null abilityToken");
2022 return ERR_NULL_OBJECT;
2023 }
2024 int32_t status = data.ReadInt32();
2025 int32_t result = StartContinuation(*want, abilityToken, status);
2026 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2027
2028 return result;
2029 }
2030
NotifyCompleteContinuationInner(MessageParcel &data, MessageParcel &reply)2031 int AbilityManagerStub::NotifyCompleteContinuationInner(MessageParcel &data, MessageParcel &reply)
2032 {
2033 std::string devId = data.ReadString();
2034 int32_t sessionId = data.ReadInt32();
2035 bool isSuccess = data.ReadBool();
2036
2037 NotifyCompleteContinuation(devId, sessionId, isSuccess);
2038 TAG_LOGI(AAFwkTag::ABILITYMGR, "end");
2039 return NO_ERROR;
2040 }
2041
NotifyContinuationResultInner(MessageParcel &data, MessageParcel &reply)2042 int AbilityManagerStub::NotifyContinuationResultInner(MessageParcel &data, MessageParcel &reply)
2043 {
2044 int32_t missionId = data.ReadInt32();
2045 int32_t continuationResult = data.ReadInt32();
2046
2047 int32_t result = NotifyContinuationResult(missionId, continuationResult);
2048 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2049 return result;
2050 }
2051
LockMissionForCleanupInner(MessageParcel &data, MessageParcel &reply)2052 int AbilityManagerStub::LockMissionForCleanupInner(MessageParcel &data, MessageParcel &reply)
2053 {
2054 int32_t id = data.ReadInt32();
2055 int result = LockMissionForCleanup(id);
2056 if (!reply.WriteInt32(result)) {
2057 TAG_LOGE(AAFwkTag::ABILITYMGR, "lock mission fail");
2058 return ERR_INVALID_VALUE;
2059 }
2060 return NO_ERROR;
2061 }
2062
UnlockMissionForCleanupInner(MessageParcel &data, MessageParcel &reply)2063 int AbilityManagerStub::UnlockMissionForCleanupInner(MessageParcel &data, MessageParcel &reply)
2064 {
2065 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2066 int32_t id = data.ReadInt32();
2067 int result = UnlockMissionForCleanup(id);
2068 if (!reply.WriteInt32(result)) {
2069 TAG_LOGE(AAFwkTag::ABILITYMGR, "unlock mission fail");
2070 return ERR_INVALID_VALUE;
2071 }
2072 return NO_ERROR;
2073 }
2074
SetLockedStateInner(MessageParcel &data, MessageParcel &reply)2075 int AbilityManagerStub::SetLockedStateInner(MessageParcel &data, MessageParcel &reply)
2076 {
2077 int32_t sessionId = data.ReadInt32();
2078 bool flag = data.ReadBool();
2079 SetLockedState(sessionId, flag);
2080 return NO_ERROR;
2081 }
2082
RegisterMissionListenerInner(MessageParcel &data, MessageParcel &reply)2083 int AbilityManagerStub::RegisterMissionListenerInner(MessageParcel &data, MessageParcel &reply)
2084 {
2085 sptr<IMissionListener> listener = iface_cast<IMissionListener>(data.ReadRemoteObject());
2086 if (listener == nullptr) {
2087 TAG_LOGE(AAFwkTag::ABILITYMGR, "null listener");
2088 return ERR_INVALID_VALUE;
2089 }
2090
2091 int32_t result = RegisterMissionListener(listener);
2092 reply.WriteInt32(result);
2093 return NO_ERROR;
2094 }
2095
UnRegisterMissionListenerInner(MessageParcel &data, MessageParcel &reply)2096 int AbilityManagerStub::UnRegisterMissionListenerInner(MessageParcel &data, MessageParcel &reply)
2097 {
2098 sptr<IMissionListener> listener = iface_cast<IMissionListener>(data.ReadRemoteObject());
2099 if (listener == nullptr) {
2100 TAG_LOGE(AAFwkTag::ABILITYMGR, "null listener");
2101 return ERR_INVALID_VALUE;
2102 }
2103
2104 int32_t result = UnRegisterMissionListener(listener);
2105 reply.WriteInt32(result);
2106 return NO_ERROR;
2107 }
2108
GetMissionInfosInner(MessageParcel &data, MessageParcel &reply)2109 int AbilityManagerStub::GetMissionInfosInner(MessageParcel &data, MessageParcel &reply)
2110 {
2111 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2112 std::string deviceId = Str16ToStr8(data.ReadString16());
2113 int numMax = data.ReadInt32();
2114 std::vector<MissionInfo> missionInfos;
2115 int32_t result = GetMissionInfos(deviceId, numMax, missionInfos);
2116 reply.WriteInt32(missionInfos.size());
2117 for (auto &it : missionInfos) {
2118 if (!reply.WriteParcelable(&it)) {
2119 return ERR_INVALID_VALUE;
2120 }
2121 }
2122 if (!reply.WriteInt32(result)) {
2123 return ERR_INVALID_VALUE;
2124 }
2125 return result;
2126 }
2127
GetMissionInfoInner(MessageParcel &data, MessageParcel &reply)2128 int AbilityManagerStub::GetMissionInfoInner(MessageParcel &data, MessageParcel &reply)
2129 {
2130 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2131 MissionInfo info;
2132 std::string deviceId = Str16ToStr8(data.ReadString16());
2133 int32_t missionId = data.ReadInt32();
2134 int result = GetMissionInfo(deviceId, missionId, info);
2135 if (!reply.WriteParcelable(&info)) {
2136 TAG_LOGE(AAFwkTag::ABILITYMGR, "GetMissionInfo error");
2137 return ERR_INVALID_VALUE;
2138 }
2139
2140 if (!reply.WriteInt32(result)) {
2141 TAG_LOGE(AAFwkTag::ABILITYMGR, "GetMissionInfo result error");
2142 return ERR_INVALID_VALUE;
2143 }
2144 return NO_ERROR;
2145 }
2146
CleanMissionInner(MessageParcel &data, MessageParcel &reply)2147 int AbilityManagerStub::CleanMissionInner(MessageParcel &data, MessageParcel &reply)
2148 {
2149 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2150 int32_t missionId = data.ReadInt32();
2151 int result = CleanMission(missionId);
2152 if (!reply.WriteInt32(result)) {
2153 TAG_LOGE(AAFwkTag::ABILITYMGR, "cleanMission fail");
2154 return ERR_INVALID_VALUE;
2155 }
2156 return NO_ERROR;
2157 }
2158
CleanAllMissionsInner(MessageParcel &data, MessageParcel &reply)2159 int AbilityManagerStub::CleanAllMissionsInner(MessageParcel &data, MessageParcel &reply)
2160 {
2161 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2162 int result = CleanAllMissions();
2163 if (!reply.WriteInt32(result)) {
2164 TAG_LOGE(AAFwkTag::ABILITYMGR, "cleanAllMissions fail");
2165 return ERR_INVALID_VALUE;
2166 }
2167 return NO_ERROR;
2168 }
2169
MoveMissionToFrontInner(MessageParcel &data, MessageParcel &reply)2170 int AbilityManagerStub::MoveMissionToFrontInner(MessageParcel &data, MessageParcel &reply)
2171 {
2172 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2173 int32_t missionId = data.ReadInt32();
2174 int result = MoveMissionToFront(missionId);
2175 if (!reply.WriteInt32(result)) {
2176 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
2177 return ERR_INVALID_VALUE;
2178 }
2179 return NO_ERROR;
2180 }
2181
GetMissionIdByTokenInner(MessageParcel &data, MessageParcel &reply)2182 int AbilityManagerStub::GetMissionIdByTokenInner(MessageParcel &data, MessageParcel &reply)
2183 {
2184 sptr<IRemoteObject> token = data.ReadRemoteObject();
2185 int32_t missionId = GetMissionIdByToken(token);
2186 if (!reply.WriteInt32(missionId)) {
2187 TAG_LOGE(AAFwkTag::ABILITYMGR, "write missionId fail");
2188 return ERR_INVALID_VALUE;
2189 }
2190 return NO_ERROR;
2191 }
2192
MoveMissionToFrontByOptionsInner(MessageParcel &data, MessageParcel &reply)2193 int AbilityManagerStub::MoveMissionToFrontByOptionsInner(MessageParcel &data, MessageParcel &reply)
2194 {
2195 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2196 int32_t missionId = data.ReadInt32();
2197 std::unique_ptr<StartOptions> startOptions(data.ReadParcelable<StartOptions>());
2198 if (startOptions == nullptr) {
2199 TAG_LOGE(AAFwkTag::ABILITYMGR, "startOptions null");
2200 return ERR_INVALID_VALUE;
2201 }
2202 startOptions->processOptions = nullptr;
2203 int result = MoveMissionToFront(missionId, *startOptions);
2204 if (!reply.WriteInt32(result)) {
2205 TAG_LOGE(AAFwkTag::ABILITYMGR, "moveMissionToFront fail");
2206 return ERR_INVALID_VALUE;
2207 }
2208 return NO_ERROR;
2209 }
2210
MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply)2211 int AbilityManagerStub::MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply)
2212 {
2213 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
2214 std::vector<int32_t> missionIds;
2215 data.ReadInt32Vector(&missionIds);
2216 int32_t topMissionId = data.ReadInt32();
2217 int32_t errCode = MoveMissionsToForeground(missionIds, topMissionId);
2218 if (!reply.WriteInt32(errCode)) {
2219 return ERR_INVALID_VALUE;
2220 }
2221 return errCode;
2222 }
2223
MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply)2224 int AbilityManagerStub::MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply)
2225 {
2226 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
2227 std::vector<int32_t> missionIds;
2228 std::vector<int32_t> result;
2229
2230 data.ReadInt32Vector(&missionIds);
2231 int32_t errCode = MoveMissionsToBackground(missionIds, result);
2232 TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called. resultSize: %{public}zu", __func__, result.size());
2233 if (!reply.WriteInt32Vector(result)) {
2234 TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s call writeInt32Vector fail", __func__);
2235 return ERR_INVALID_VALUE;
2236 }
2237 if (!reply.WriteInt32(errCode)) {
2238 return ERR_INVALID_VALUE;
2239 }
2240 return NO_ERROR;
2241 }
2242
StartAbilityByCallInner(MessageParcel &data, MessageParcel &reply)2243 int AbilityManagerStub::StartAbilityByCallInner(MessageParcel &data, MessageParcel &reply)
2244 {
2245 TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityManagerStub::StartAbilityByCallInner begin.");
2246 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
2247 if (want == nullptr) {
2248 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
2249 return ERR_INVALID_VALUE;
2250 }
2251
2252 auto callback = iface_cast<IAbilityConnection>(data.ReadRemoteObject());
2253 if (callback == nullptr) {
2254 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
2255 return ERR_INVALID_VALUE;
2256 }
2257 sptr<IRemoteObject> callerToken = nullptr;
2258 if (data.ReadBool()) {
2259 callerToken = data.ReadRemoteObject();
2260 }
2261
2262 int32_t accountId = data.ReadInt32();
2263 int32_t result = StartAbilityByCall(*want, callback, callerToken, accountId);
2264
2265 TAG_LOGD(AAFwkTag::ABILITYMGR, "resolve call ability ret = %d", result);
2266
2267 reply.WriteInt32(result);
2268
2269 TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityManagerStub::StartAbilityByCallInner end.");
2270
2271 return NO_ERROR;
2272 }
2273
StartUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)2274 int AbilityManagerStub::StartUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)
2275 {
2276 sptr<SessionInfo> sessionInfo = nullptr;
2277 if (data.ReadBool()) {
2278 sessionInfo = data.ReadParcelable<SessionInfo>();
2279 }
2280 uint32_t sceneFlag = data.ReadUint32();
2281 bool isColdStart = false;
2282 int32_t result = StartUIAbilityBySCB(sessionInfo, isColdStart, sceneFlag);
2283 reply.WriteBool(isColdStart);
2284 reply.WriteInt32(result);
2285 return NO_ERROR;
2286 }
2287
CallRequestDoneInner(MessageParcel &data, MessageParcel &reply)2288 int AbilityManagerStub::CallRequestDoneInner(MessageParcel &data, MessageParcel &reply)
2289 {
2290 sptr<IRemoteObject> token = data.ReadRemoteObject();
2291 sptr<IRemoteObject> callStub = data.ReadRemoteObject();
2292 CallRequestDone(token, callStub);
2293 return NO_ERROR;
2294 }
2295
ReleaseCallInner(MessageParcel &data, MessageParcel &reply)2296 int AbilityManagerStub::ReleaseCallInner(MessageParcel &data, MessageParcel &reply)
2297 {
2298 auto callback = iface_cast<IAbilityConnection>(data.ReadRemoteObject());
2299 if (callback == nullptr) {
2300 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
2301 return ERR_INVALID_VALUE;
2302 }
2303
2304 std::unique_ptr<AppExecFwk::ElementName> element(data.ReadParcelable<AppExecFwk::ElementName>());
2305 if (element == nullptr) {
2306 TAG_LOGE(AAFwkTag::ABILITYMGR, "receive null");
2307 return ERR_INVALID_VALUE;
2308 }
2309 int32_t result = ReleaseCall(callback, *element);
2310
2311 TAG_LOGD(AAFwkTag::ABILITYMGR, "release call ability ret = %d", result);
2312
2313 reply.WriteInt32(result);
2314
2315 return NO_ERROR;
2316 }
2317
StartUserInner(MessageParcel &data, MessageParcel &reply)2318 int AbilityManagerStub::StartUserInner(MessageParcel &data, MessageParcel &reply)
2319 {
2320 int32_t userId = data.ReadInt32();
2321 sptr<IUserCallback> callback = nullptr;
2322 if (data.ReadBool()) {
2323 callback = iface_cast<IUserCallback>(data.ReadRemoteObject());
2324 } else {
2325 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback invalid value");
2326 return ERR_INVALID_VALUE;
2327 }
2328 bool isAppRecovery = data.ReadBool();
2329 int result = StartUser(userId, callback, isAppRecovery);
2330 if (!reply.WriteInt32(result)) {
2331 TAG_LOGE(AAFwkTag::ABILITYMGR, "startUser fail");
2332 return ERR_INVALID_VALUE;
2333 }
2334 return NO_ERROR;
2335 }
2336
StopUserInner(MessageParcel &data, MessageParcel &reply)2337 int AbilityManagerStub::StopUserInner(MessageParcel &data, MessageParcel &reply)
2338 {
2339 int32_t userId = data.ReadInt32();
2340 sptr<IUserCallback> callback = nullptr;
2341 if (data.ReadBool()) {
2342 callback = iface_cast<IUserCallback>(data.ReadRemoteObject());
2343 }
2344 int result = StopUser(userId, callback);
2345 if (!reply.WriteInt32(result)) {
2346 TAG_LOGE(AAFwkTag::ABILITYMGR, "stopUser fail");
2347 return ERR_INVALID_VALUE;
2348 }
2349 return NO_ERROR;
2350 }
2351
LogoutUserInner(MessageParcel &data, MessageParcel &reply)2352 int AbilityManagerStub::LogoutUserInner(MessageParcel &data, MessageParcel &reply)
2353 {
2354 int32_t userId = data.ReadInt32();
2355 int result = LogoutUser(userId);
2356 if (!reply.WriteInt32(result)) {
2357 TAG_LOGE(AAFwkTag::ABILITYMGR, "logoutUser fail");
2358 return ERR_INVALID_VALUE;
2359 }
2360 return NO_ERROR;
2361 }
2362
GetAbilityRunningInfosInner(MessageParcel &data, MessageParcel &reply)2363 int AbilityManagerStub::GetAbilityRunningInfosInner(MessageParcel &data, MessageParcel &reply)
2364 {
2365 std::vector<AbilityRunningInfo> abilityRunningInfos;
2366 auto result = GetAbilityRunningInfos(abilityRunningInfos);
2367 reply.WriteInt32(abilityRunningInfos.size());
2368 for (auto &it : abilityRunningInfos) {
2369 if (!reply.WriteParcelable(&it)) {
2370 return ERR_INVALID_VALUE;
2371 }
2372 }
2373 if (!reply.WriteInt32(result)) {
2374 return ERR_INVALID_VALUE;
2375 }
2376 return result;
2377 }
2378
GetExtensionRunningInfosInner(MessageParcel &data, MessageParcel &reply)2379 int AbilityManagerStub::GetExtensionRunningInfosInner(MessageParcel &data, MessageParcel &reply)
2380 {
2381 auto upperLimit = data.ReadInt32();
2382 std::vector<ExtensionRunningInfo> infos;
2383 auto result = GetExtensionRunningInfos(upperLimit, infos);
2384 reply.WriteInt32(infos.size());
2385 for (auto &it : infos) {
2386 if (!reply.WriteParcelable(&it)) {
2387 return ERR_INVALID_VALUE;
2388 }
2389 }
2390 if (!reply.WriteInt32(result)) {
2391 return ERR_INVALID_VALUE;
2392 }
2393 return result;
2394 }
2395
GetProcessRunningInfosInner(MessageParcel &data, MessageParcel &reply)2396 int AbilityManagerStub::GetProcessRunningInfosInner(MessageParcel &data, MessageParcel &reply)
2397 {
2398 std::vector<AppExecFwk::RunningProcessInfo> infos;
2399 auto result = GetProcessRunningInfos(infos);
2400 reply.WriteInt32(infos.size());
2401 for (auto &it : infos) {
2402 if (!reply.WriteParcelable(&it)) {
2403 return ERR_INVALID_VALUE;
2404 }
2405 }
2406 if (!reply.WriteInt32(result)) {
2407 return ERR_INVALID_VALUE;
2408 }
2409 return NO_ERROR;
2410 }
2411
StartSyncRemoteMissionsInner(MessageParcel &data, MessageParcel &reply)2412 int AbilityManagerStub::StartSyncRemoteMissionsInner(MessageParcel &data, MessageParcel &reply)
2413 {
2414 std::string deviceId = data.ReadString();
2415 bool fixConflict = data.ReadBool();
2416 int64_t tag = data.ReadInt64();
2417 int result = StartSyncRemoteMissions(deviceId, fixConflict, tag);
2418 if (!reply.WriteInt32(result)) {
2419 TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
2420 return ERR_INVALID_VALUE;
2421 }
2422 return NO_ERROR;
2423 }
2424
StopSyncRemoteMissionsInner(MessageParcel &data, MessageParcel &reply)2425 int AbilityManagerStub::StopSyncRemoteMissionsInner(MessageParcel &data, MessageParcel &reply)
2426 {
2427 int result = StopSyncRemoteMissions(data.ReadString());
2428 if (!reply.WriteInt32(result)) {
2429 TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
2430 return ERR_INVALID_VALUE;
2431 }
2432 return NO_ERROR;
2433 }
2434
RegisterRemoteMissionListenerInner(MessageParcel &data, MessageParcel &reply)2435 int AbilityManagerStub::RegisterRemoteMissionListenerInner(MessageParcel &data, MessageParcel &reply)
2436 {
2437 std::string deviceId = data.ReadString();
2438 if (deviceId.empty()) {
2439 TAG_LOGE(AAFwkTag::ABILITYMGR, "deviceId empty");
2440 return INVALID_PARAMETERS_ERR;
2441 }
2442 sptr<IRemoteMissionListener> listener = iface_cast<IRemoteMissionListener>(data.ReadRemoteObject());
2443 if (listener == nullptr) {
2444 TAG_LOGE(AAFwkTag::ABILITYMGR, "null listener");
2445 return ERR_NULL_OBJECT;
2446 }
2447 int32_t result = RegisterMissionListener(deviceId, listener);
2448 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d",
2449 result);
2450 return result;
2451 }
2452
RegisterRemoteOnListenerInner(MessageParcel &data, MessageParcel &reply)2453 int AbilityManagerStub::RegisterRemoteOnListenerInner(MessageParcel &data, MessageParcel &reply)
2454 {
2455 std::string type = data.ReadString();
2456 if (type.empty()) {
2457 TAG_LOGE(AAFwkTag::ABILITYMGR, "type empty");
2458 return ERR_NULL_OBJECT;
2459 }
2460 sptr<IRemoteOnListener> listener = iface_cast<IRemoteOnListener>(data.ReadRemoteObject());
2461 if (listener == nullptr) {
2462 TAG_LOGE(AAFwkTag::ABILITYMGR, "null listener");
2463 return ERR_NULL_OBJECT;
2464 }
2465 int32_t result = RegisterOnListener(type, listener);
2466 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2467 return result;
2468 }
2469
RegisterRemoteOffListenerInner(MessageParcel &data, MessageParcel &reply)2470 int AbilityManagerStub::RegisterRemoteOffListenerInner(MessageParcel &data, MessageParcel &reply)
2471 {
2472 std::string type = data.ReadString();
2473 if (type.empty()) {
2474 TAG_LOGE(AAFwkTag::ABILITYMGR, "type empty");
2475 return ERR_NULL_OBJECT;
2476 }
2477 sptr<IRemoteOnListener> listener = iface_cast<IRemoteOnListener>(data.ReadRemoteObject());
2478 if (listener == nullptr) {
2479 TAG_LOGE(AAFwkTag::ABILITYMGR, "null listener");
2480 return ERR_NULL_OBJECT;
2481 }
2482 int32_t result = RegisterOffListener(type, listener);
2483 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2484 return result;
2485 }
2486
UnRegisterRemoteMissionListenerInner(MessageParcel &data, MessageParcel &reply)2487 int AbilityManagerStub::UnRegisterRemoteMissionListenerInner(MessageParcel &data, MessageParcel &reply)
2488 {
2489 std::string deviceId = data.ReadString();
2490 if (deviceId.empty()) {
2491 TAG_LOGE(AAFwkTag::ABILITYMGR, "deviceId empty");
2492 return INVALID_PARAMETERS_ERR;
2493 }
2494 sptr<IRemoteMissionListener> listener = iface_cast<IRemoteMissionListener>(data.ReadRemoteObject());
2495 if (listener == nullptr) {
2496 TAG_LOGE(AAFwkTag::ABILITYMGR, "null listener");
2497 return ERR_NULL_OBJECT;
2498 }
2499 int32_t result = UnRegisterMissionListener(deviceId, listener);
2500 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d",
2501 result);
2502 return result;
2503 }
2504
RegisterSnapshotHandlerInner(MessageParcel &data, MessageParcel &reply)2505 int AbilityManagerStub::RegisterSnapshotHandlerInner(MessageParcel &data, MessageParcel &reply)
2506 {
2507 sptr<ISnapshotHandler> handler = iface_cast<ISnapshotHandler>(data.ReadRemoteObject());
2508 if (handler == nullptr) {
2509 TAG_LOGE(AAFwkTag::ABILITYMGR, "null handler");
2510 return ERR_NULL_OBJECT;
2511 }
2512 int32_t result = RegisterSnapshotHandler(handler);
2513 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d",
2514 result);
2515 return result;
2516 }
2517
GetMissionSnapshotInfoInner(MessageParcel &data, MessageParcel &reply)2518 int AbilityManagerStub::GetMissionSnapshotInfoInner(MessageParcel &data, MessageParcel &reply)
2519 {
2520 std::string deviceId = data.ReadString();
2521 int32_t missionId = data.ReadInt32();
2522 bool isLowResolution = data.ReadBool();
2523 MissionSnapshot missionSnapshot;
2524 int32_t result = GetMissionSnapshot(deviceId, missionId, missionSnapshot, isLowResolution);
2525 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2526 if (!reply.WriteParcelable(&missionSnapshot)) {
2527 TAG_LOGE(AAFwkTag::ABILITYMGR, "GetMissionSnapshot error");
2528 return ERR_INVALID_VALUE;
2529 }
2530 if (!reply.WriteInt32(result)) {
2531 TAG_LOGE(AAFwkTag::ABILITYMGR, "GetMissionSnapshot result error");
2532 return ERR_INVALID_VALUE;
2533 }
2534 return NO_ERROR;
2535 }
2536
SetAbilityControllerInner(MessageParcel &data, MessageParcel &reply)2537 int AbilityManagerStub::SetAbilityControllerInner(MessageParcel &data, MessageParcel &reply)
2538 {
2539 sptr<AppExecFwk::IAbilityController> controller =
2540 iface_cast<AppExecFwk::IAbilityController>(data.ReadRemoteObject());
2541 if (controller == nullptr) {
2542 TAG_LOGE(AAFwkTag::ABILITYMGR, "null controller");
2543 return ERR_NULL_OBJECT;
2544 }
2545 bool imAStabilityTest = data.ReadBool();
2546 int32_t result = SetAbilityController(controller, imAStabilityTest);
2547 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2548 if (!reply.WriteInt32(result)) {
2549 TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
2550 return ERR_INVALID_VALUE;
2551 }
2552 return NO_ERROR;
2553 }
2554
IsRunningInStabilityTestInner(MessageParcel &data, MessageParcel &reply)2555 int AbilityManagerStub::IsRunningInStabilityTestInner(MessageParcel &data, MessageParcel &reply)
2556 {
2557 bool result = IsRunningInStabilityTest();
2558 TAG_LOGI(AAFwkTag::ABILITYMGR, "result=%{public}d", result);
2559 if (!reply.WriteBool(result)) {
2560 TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
2561 return ERR_INVALID_VALUE;
2562 }
2563 return NO_ERROR;
2564 }
2565
StartUserTestInner(MessageParcel &data, MessageParcel &reply)2566 int AbilityManagerStub::StartUserTestInner(MessageParcel &data, MessageParcel &reply)
2567 {
2568 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
2569 if (want == nullptr) {
2570 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
2571 return ERR_INVALID_VALUE;
2572 }
2573 auto observer = data.ReadRemoteObject();
2574 int32_t result = StartUserTest(*want, observer);
2575 reply.WriteInt32(result);
2576 return result;
2577 }
2578
FinishUserTestInner(MessageParcel &data, MessageParcel &reply)2579 int AbilityManagerStub::FinishUserTestInner(MessageParcel &data, MessageParcel &reply)
2580 {
2581 std::string msg = data.ReadString();
2582 int64_t resultCode = data.ReadInt64();
2583 std::string bundleName = data.ReadString();
2584 int32_t result = FinishUserTest(msg, resultCode, bundleName);
2585 reply.WriteInt32(result);
2586 return result;
2587 }
2588
GetTopAbilityTokenInner(MessageParcel &data, MessageParcel &reply)2589 int AbilityManagerStub::GetTopAbilityTokenInner(MessageParcel &data, MessageParcel &reply)
2590 {
2591 sptr<IRemoteObject> token;
2592 auto result = GetTopAbility(token);
2593 if (!reply.WriteRemoteObject(token)) {
2594 TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
2595 return ERR_INVALID_VALUE;
2596 }
2597 reply.WriteInt32(result);
2598
2599 return NO_ERROR;
2600 }
2601
CheckUIExtensionIsFocusedInner(MessageParcel &data, MessageParcel &reply)2602 int AbilityManagerStub::CheckUIExtensionIsFocusedInner(MessageParcel &data, MessageParcel &reply)
2603 {
2604 uint32_t uiExtensionTokenId = data.ReadUint32();
2605 bool isFocused = false;
2606 auto result = CheckUIExtensionIsFocused(uiExtensionTokenId, isFocused);
2607 if (result == ERR_OK) {
2608 if (!reply.WriteBool(isFocused)) {
2609 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2610 return ERR_INVALID_VALUE;
2611 }
2612 }
2613 return result;
2614 }
2615
DelegatorDoAbilityForegroundInner(MessageParcel &data, MessageParcel &reply)2616 int AbilityManagerStub::DelegatorDoAbilityForegroundInner(MessageParcel &data, MessageParcel &reply)
2617 {
2618 sptr<IRemoteObject> token = data.ReadRemoteObject();
2619 auto result = DelegatorDoAbilityForeground(token);
2620 reply.WriteInt32(result);
2621
2622 return NO_ERROR;
2623 }
2624
DelegatorDoAbilityBackgroundInner(MessageParcel &data, MessageParcel &reply)2625 int AbilityManagerStub::DelegatorDoAbilityBackgroundInner(MessageParcel &data, MessageParcel &reply)
2626 {
2627 sptr<IRemoteObject> token = data.ReadRemoteObject();
2628 auto result = DelegatorDoAbilityBackground(token);
2629 reply.WriteInt32(result);
2630 return NO_ERROR;
2631 }
2632
DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag)2633 int AbilityManagerStub::DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag)
2634 {
2635 return 0;
2636 }
2637
DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag)2638 int AbilityManagerStub::DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag)
2639 {
2640 return 0;
2641 }
2642
DoAbilityForegroundInner(MessageParcel &data, MessageParcel &reply)2643 int AbilityManagerStub::DoAbilityForegroundInner(MessageParcel &data, MessageParcel &reply)
2644 {
2645 sptr<IRemoteObject> token = data.ReadRemoteObject();
2646 uint32_t flag = data.ReadUint32();
2647 auto result = DoAbilityForeground(token, flag);
2648 reply.WriteInt32(result);
2649
2650 return NO_ERROR;
2651 }
2652
DoAbilityBackgroundInner(MessageParcel &data, MessageParcel &reply)2653 int AbilityManagerStub::DoAbilityBackgroundInner(MessageParcel &data, MessageParcel &reply)
2654 {
2655 sptr<IRemoteObject> token = data.ReadRemoteObject();
2656 uint32_t flag = data.ReadUint32();
2657 auto result = DoAbilityBackground(token, flag);
2658 reply.WriteInt32(result);
2659 return NO_ERROR;
2660 }
2661
RegisterObserver(const sptr<AbilityRuntime::IConnectionObserver> &observer)2662 int AbilityManagerStub::RegisterObserver(const sptr<AbilityRuntime::IConnectionObserver> &observer)
2663 {
2664 // should implement in child.
2665 return NO_ERROR;
2666 }
2667
UnregisterObserver(const sptr<AbilityRuntime::IConnectionObserver> &observer)2668 int AbilityManagerStub::UnregisterObserver(const sptr<AbilityRuntime::IConnectionObserver> &observer)
2669 {
2670 // should implement in child
2671 return NO_ERROR;
2672 }
2673
2674 #ifdef WITH_DLP
GetDlpConnectionInfos(std::vector<AbilityRuntime::DlpConnectionInfo> &infos)2675 int AbilityManagerStub::GetDlpConnectionInfos(std::vector<AbilityRuntime::DlpConnectionInfo> &infos)
2676 {
2677 // should implement in child
2678 return NO_ERROR;
2679 }
2680 #endif // WITH_DLP
2681
GetConnectionData(std::vector<AbilityRuntime::ConnectionData> &infos)2682 int AbilityManagerStub::GetConnectionData(std::vector<AbilityRuntime::ConnectionData> &infos)
2683 {
2684 // should implement in child
2685 return NO_ERROR;
2686 }
2687
2688 #ifdef ABILITY_COMMAND_FOR_TEST
ForceTimeoutForTestInner(MessageParcel &data, MessageParcel &reply)2689 int AbilityManagerStub::ForceTimeoutForTestInner(MessageParcel &data, MessageParcel &reply)
2690 {
2691 std::string abilityName = Str16ToStr8(data.ReadString16());
2692 std::string state = Str16ToStr8(data.ReadString16());
2693 int result = ForceTimeoutForTest(abilityName, state);
2694 if (!reply.WriteInt32(result)) {
2695 TAG_LOGE(AAFwkTag::ABILITYMGR, "force ability timeout error");
2696 return ERR_INVALID_VALUE;
2697 }
2698 return NO_ERROR;
2699 }
2700 #endif
2701
FreeInstallAbilityFromRemoteInner(MessageParcel &data, MessageParcel &reply)2702 int AbilityManagerStub::FreeInstallAbilityFromRemoteInner(MessageParcel &data, MessageParcel &reply)
2703 {
2704 std::unique_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
2705 if (want == nullptr) {
2706 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
2707 return ERR_INVALID_VALUE;
2708 }
2709 want->SetParam(FROM_REMOTE_KEY, true);
2710
2711 auto callback = data.ReadRemoteObject();
2712 if (callback == nullptr) {
2713 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
2714 return ERR_INVALID_VALUE;
2715 }
2716
2717 int32_t userId = data.ReadInt32();
2718 int32_t requestCode = data.ReadInt32();
2719 int32_t result = FreeInstallAbilityFromRemote(*want, callback, userId, requestCode);
2720 if (!reply.WriteInt32(result)) {
2721 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2722 return ERR_INVALID_VALUE;
2723 }
2724 return NO_ERROR;
2725 }
2726
AddFreeInstallObserverInner(MessageParcel &data, MessageParcel &reply)2727 int AbilityManagerStub::AddFreeInstallObserverInner(MessageParcel &data, MessageParcel &reply)
2728 {
2729 sptr<IRemoteObject> callerToken = nullptr;
2730 if (data.ReadBool()) {
2731 callerToken = data.ReadRemoteObject();
2732 if (callerToken == nullptr) {
2733 TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
2734 return ERR_INVALID_VALUE;
2735 }
2736 }
2737 sptr<AbilityRuntime::IFreeInstallObserver> observer =
2738 iface_cast<AbilityRuntime::IFreeInstallObserver>(data.ReadRemoteObject());
2739 if (observer == nullptr) {
2740 TAG_LOGE(AAFwkTag::ABILITYMGR, "observer null");
2741 return ERR_INVALID_VALUE;
2742 }
2743 int32_t result = AddFreeInstallObserver(callerToken, observer);
2744 if (!reply.WriteInt32(result)) {
2745 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2746 return ERR_INVALID_VALUE;
2747 }
2748 return NO_ERROR;
2749 }
2750
DumpAbilityInfoDoneInner(MessageParcel &data, MessageParcel &reply)2751 int AbilityManagerStub::DumpAbilityInfoDoneInner(MessageParcel &data, MessageParcel &reply)
2752 {
2753 std::vector<std::string> infos;
2754 data.ReadStringVector(&infos);
2755 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
2756 int32_t result = DumpAbilityInfoDone(infos, callerToken);
2757 if (!reply.WriteInt32(result)) {
2758 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2759 return ERR_INVALID_VALUE;
2760 }
2761 return NO_ERROR;
2762 }
2763
UpdateMissionSnapShotFromWMSInner(MessageParcel &data, MessageParcel &reply)2764 int AbilityManagerStub::UpdateMissionSnapShotFromWMSInner(MessageParcel &data, MessageParcel &reply)
2765 {
2766 sptr<IRemoteObject> token = data.ReadRemoteObject();
2767 if (token == nullptr) {
2768 TAG_LOGE(AAFwkTag::ABILITYMGR, "null token");
2769 return ERR_NULL_OBJECT;
2770 }
2771 #ifdef SUPPORT_SCREEN
2772 std::shared_ptr<Media::PixelMap> pixelMap(data.ReadParcelable<Media::PixelMap>());
2773 if (pixelMap == nullptr) {
2774 TAG_LOGE(AAFwkTag::ABILITYMGR, "null pixelMap");
2775 return ERR_NULL_OBJECT;
2776 }
2777 UpdateMissionSnapShot(token, pixelMap);
2778 #endif // SUPPORT_SCREEN
2779 return NO_ERROR;
2780 }
2781
EnableRecoverAbilityInner(MessageParcel &data, MessageParcel &reply)2782 int AbilityManagerStub::EnableRecoverAbilityInner(MessageParcel &data, MessageParcel &reply)
2783 {
2784 sptr<IRemoteObject> token = data.ReadRemoteObject();
2785 if (!token) {
2786 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
2787 return ERR_NULL_OBJECT;
2788 }
2789 EnableRecoverAbility(token);
2790 return NO_ERROR;
2791 }
2792
ScheduleClearRecoveryPageStackInner(MessageParcel &data, MessageParcel &reply)2793 int AbilityManagerStub::ScheduleClearRecoveryPageStackInner(MessageParcel &data, MessageParcel &reply)
2794 {
2795 ScheduleClearRecoveryPageStack();
2796 return NO_ERROR;
2797 }
2798
SubmitSaveRecoveryInfoInner(MessageParcel &data, MessageParcel &reply)2799 int AbilityManagerStub::SubmitSaveRecoveryInfoInner(MessageParcel &data, MessageParcel &reply)
2800 {
2801 sptr<IRemoteObject> token = data.ReadRemoteObject();
2802 if (!token) {
2803 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
2804 return ERR_NULL_OBJECT;
2805 }
2806 SubmitSaveRecoveryInfo(token);
2807 return NO_ERROR;
2808 }
2809
HandleRequestDialogService(MessageParcel &data, MessageParcel &reply)2810 int AbilityManagerStub::HandleRequestDialogService(MessageParcel &data, MessageParcel &reply)
2811 {
2812 std::unique_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
2813 if (want == nullptr) {
2814 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
2815 return ERR_INVALID_VALUE;
2816 }
2817
2818 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
2819 if (!callerToken) {
2820 TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken invalid");
2821 return ERR_INVALID_VALUE;
2822 }
2823
2824 int32_t result = RequestDialogService(*want, callerToken);
2825 if (!reply.WriteInt32(result)) {
2826 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2827 return ERR_INVALID_VALUE;
2828 }
2829 return NO_ERROR;
2830 }
2831
HandleReportDrawnCompleted(MessageParcel &data, MessageParcel &reply)2832 int32_t AbilityManagerStub::HandleReportDrawnCompleted(MessageParcel &data, MessageParcel &reply)
2833 {
2834 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
2835 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
2836 if (callerToken == nullptr) {
2837 TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
2838 return ERR_INVALID_VALUE;
2839 }
2840
2841 auto result = ReportDrawnCompleted(callerToken);
2842 if (!reply.WriteInt32(result)) {
2843 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2844 return ERR_INVALID_VALUE;
2845 }
2846 return NO_ERROR;
2847 }
2848
AcquireShareDataInner(MessageParcel &data, MessageParcel &reply)2849 int AbilityManagerStub::AcquireShareDataInner(MessageParcel &data, MessageParcel &reply)
2850 {
2851 int32_t missionId = data.ReadInt32();
2852 sptr<IAcquireShareDataCallback> shareData = iface_cast<IAcquireShareDataCallback>(data.ReadRemoteObject());
2853 if (!shareData) {
2854 TAG_LOGE(AAFwkTag::ABILITYMGR, "null shareData");
2855 return ERR_INVALID_VALUE;
2856 }
2857 int32_t result = AcquireShareData(missionId, shareData);
2858 if (!reply.WriteInt32(result)) {
2859 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2860 return ERR_INVALID_VALUE;
2861 }
2862 return NO_ERROR;
2863 }
2864
ShareDataDoneInner(MessageParcel &data, MessageParcel &reply)2865 int AbilityManagerStub::ShareDataDoneInner(MessageParcel &data, MessageParcel &reply)
2866 {
2867 sptr<IRemoteObject> token = data.ReadRemoteObject();
2868 if (!token) {
2869 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
2870 return ERR_NULL_OBJECT;
2871 }
2872 int32_t resultCode = data.ReadInt32();
2873 int32_t uniqueId = data.ReadInt32();
2874 std::shared_ptr<WantParams> wantParam(data.ReadParcelable<WantParams>());
2875 if (!wantParam) {
2876 TAG_LOGE(AAFwkTag::ABILITYMGR, "wantParam read fail");
2877 return ERR_INVALID_VALUE;
2878 }
2879 int32_t result = ShareDataDone(token, resultCode, uniqueId, *wantParam);
2880 if (!reply.WriteInt32(result)) {
2881 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
2882 return ERR_INVALID_VALUE;
2883 }
2884 return NO_ERROR;
2885 }
2886
GetAbilityTokenByCalleeObjInner(MessageParcel &data, MessageParcel &reply)2887 int AbilityManagerStub::GetAbilityTokenByCalleeObjInner(MessageParcel &data, MessageParcel &reply)
2888 {
2889 sptr<IRemoteObject> callStub = data.ReadRemoteObject();
2890 if (!callStub) {
2891 TAG_LOGE(AAFwkTag::ABILITYMGR, "read call stub fail");
2892 return ERR_NULL_OBJECT;
2893 }
2894 sptr<IRemoteObject> result;
2895 GetAbilityTokenByCalleeObj(callStub, result);
2896 reply.WriteRemoteObject(result);
2897 return NO_ERROR;
2898 }
2899
ScheduleRecoverAbilityInner(MessageParcel &data, MessageParcel &reply)2900 int AbilityManagerStub::ScheduleRecoverAbilityInner(MessageParcel &data, MessageParcel &reply)
2901 {
2902 sptr<IRemoteObject> token = data.ReadRemoteObject();
2903 if (!token) {
2904 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
2905 return ERR_NULL_OBJECT;
2906 }
2907
2908 int reason = data.ReadInt32();
2909 Want *want = data.ReadParcelable<Want>();
2910 ScheduleRecoverAbility(token, reason, want);
2911 if (want != nullptr) {
2912 delete want;
2913 }
2914 return NO_ERROR;
2915 }
2916
RegisterConnectionObserverInner(MessageParcel &data, MessageParcel &reply)2917 int AbilityManagerStub::RegisterConnectionObserverInner(MessageParcel &data, MessageParcel &reply)
2918 {
2919 sptr<AbilityRuntime::IConnectionObserver> observer = iface_cast<AbilityRuntime::IConnectionObserver>(
2920 data.ReadRemoteObject());
2921 if (!observer) {
2922 TAG_LOGE(AAFwkTag::ABILITYMGR, "read observer fail");
2923 return ERR_NULL_OBJECT;
2924 }
2925
2926 return RegisterObserver(observer);
2927 }
2928
UnregisterConnectionObserverInner(MessageParcel &data, MessageParcel &reply)2929 int AbilityManagerStub::UnregisterConnectionObserverInner(MessageParcel &data, MessageParcel &reply)
2930 {
2931 sptr<AbilityRuntime::IConnectionObserver> observer = iface_cast<AbilityRuntime::IConnectionObserver>(
2932 data.ReadRemoteObject());
2933 if (!observer) {
2934 TAG_LOGE(AAFwkTag::ABILITYMGR, "read observer fail");
2935 return ERR_NULL_OBJECT;
2936 }
2937
2938 return UnregisterObserver(observer);
2939 }
2940
2941 #ifdef WITH_DLP
GetDlpConnectionInfosInner(MessageParcel &data, MessageParcel &reply)2942 int AbilityManagerStub::GetDlpConnectionInfosInner(MessageParcel &data, MessageParcel &reply)
2943 {
2944 std::vector<AbilityRuntime::DlpConnectionInfo> infos;
2945 auto result = GetDlpConnectionInfos(infos);
2946 if (!reply.WriteInt32(result)) {
2947 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
2948 return ERR_INVALID_VALUE;
2949 }
2950
2951 if (!reply.WriteInt32(infos.size())) {
2952 TAG_LOGE(AAFwkTag::ABILITYMGR, "write infos size fail");
2953 return ERR_INVALID_VALUE;
2954 }
2955
2956 for (auto &item : infos) {
2957 if (!reply.WriteParcelable(&item)) {
2958 TAG_LOGE(AAFwkTag::ABILITYMGR, "write info item fail");
2959 return ERR_INVALID_VALUE;
2960 }
2961 }
2962
2963 return ERR_OK;
2964 }
2965 #endif // WITH_DLP
2966
GetConnectionDataInner(MessageParcel &data, MessageParcel &reply)2967 int AbilityManagerStub::GetConnectionDataInner(MessageParcel &data, MessageParcel &reply)
2968 {
2969 std::vector<AbilityRuntime::ConnectionData> connectionData;
2970 auto result = GetConnectionData(connectionData);
2971 if (!reply.WriteInt32(result)) {
2972 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
2973 return ERR_INVALID_VALUE;
2974 }
2975
2976 if (!reply.WriteInt32(connectionData.size())) {
2977 TAG_LOGE(AAFwkTag::ABILITYMGR, "write infos size fail");
2978 return ERR_INVALID_VALUE;
2979 }
2980
2981 for (auto &item : connectionData) {
2982 if (!reply.WriteParcelable(&item)) {
2983 TAG_LOGE(AAFwkTag::ABILITYMGR, "write info item fail");
2984 return ERR_INVALID_VALUE;
2985 }
2986 }
2987
2988 return ERR_OK;
2989 }
2990
SetMissionContinueStateInner(MessageParcel &data, MessageParcel &reply)2991 int AbilityManagerStub::SetMissionContinueStateInner(MessageParcel &data, MessageParcel &reply)
2992 {
2993 sptr<IRemoteObject> token = data.ReadRemoteObject();
2994 if (!token) {
2995 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
2996 return ERR_NULL_OBJECT;
2997 }
2998
2999 int32_t state = data.ReadInt32();
3000 int result = SetMissionContinueState(token, static_cast<AAFwk::ContinueState>(state));
3001 if (!reply.WriteInt32(result)) {
3002 TAG_LOGE(AAFwkTag::ABILITYMGR, "setMissionContinueState fail");
3003 return ERR_INVALID_VALUE;
3004 }
3005 return NO_ERROR;
3006 }
3007
3008 #ifdef SUPPORT_SCREEN
SetMissionLabelInner(MessageParcel &data, MessageParcel &reply)3009 int AbilityManagerStub::SetMissionLabelInner(MessageParcel &data, MessageParcel &reply)
3010 {
3011 sptr<IRemoteObject> token = data.ReadRemoteObject();
3012 if (!token) {
3013 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
3014 return ERR_NULL_OBJECT;
3015 }
3016
3017 std::string label = Str16ToStr8(data.ReadString16());
3018 int result = SetMissionLabel(token, label);
3019 if (!reply.WriteInt32(result)) {
3020 TAG_LOGE(AAFwkTag::ABILITYMGR, "setMissionLabel failed");
3021 return ERR_INVALID_VALUE;
3022 }
3023 return NO_ERROR;
3024 }
3025
SetMissionIconInner(MessageParcel &data, MessageParcel &reply)3026 int AbilityManagerStub::SetMissionIconInner(MessageParcel &data, MessageParcel &reply)
3027 {
3028 sptr<IRemoteObject> token = data.ReadRemoteObject();
3029 if (!token) {
3030 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
3031 return ERR_NULL_OBJECT;
3032 }
3033
3034 std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
3035 if (!icon) {
3036 TAG_LOGE(AAFwkTag::ABILITYMGR, "read icon fail");
3037 return ERR_NULL_OBJECT;
3038 }
3039
3040 int result = SetMissionIcon(token, icon);
3041 if (!reply.WriteInt32(result)) {
3042 TAG_LOGE(AAFwkTag::ABILITYMGR, "setMissionIcon fail");
3043 return ERR_INVALID_VALUE;
3044 }
3045 return NO_ERROR;
3046 }
3047
RegisterWindowManagerServiceHandlerInner(MessageParcel &data, MessageParcel &reply)3048 int AbilityManagerStub::RegisterWindowManagerServiceHandlerInner(MessageParcel &data, MessageParcel &reply)
3049 {
3050 sptr<IWindowManagerServiceHandler> handler = iface_cast<IWindowManagerServiceHandler>(data.ReadRemoteObject());
3051 if (handler == nullptr) {
3052 TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s null handler", __func__);
3053 return ERR_NULL_OBJECT;
3054 }
3055 bool animationEnabled = data.ReadBool();
3056 return RegisterWindowManagerServiceHandler(handler, animationEnabled);
3057 }
3058
CompleteFirstFrameDrawingInner(MessageParcel &data, MessageParcel &reply)3059 int AbilityManagerStub::CompleteFirstFrameDrawingInner(MessageParcel &data, MessageParcel &reply)
3060 {
3061 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3062 sptr<IRemoteObject> abilityToken = data.ReadRemoteObject();
3063 if (abilityToken == nullptr) {
3064 TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s null abilityToken", __func__);
3065 return ERR_NULL_OBJECT;
3066 }
3067 CompleteFirstFrameDrawing(abilityToken);
3068 return NO_ERROR;
3069 }
3070
CompleteFirstFrameDrawingBySCBInner(MessageParcel &data, MessageParcel &reply)3071 int AbilityManagerStub::CompleteFirstFrameDrawingBySCBInner(MessageParcel &data, MessageParcel &reply)
3072 {
3073 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3074 int32_t sessionId = data.ReadInt32();
3075 CompleteFirstFrameDrawing(sessionId);
3076 return NO_ERROR;
3077 }
3078
PrepareTerminateAbilityInner(MessageParcel &data, MessageParcel &reply)3079 int AbilityManagerStub::PrepareTerminateAbilityInner(MessageParcel &data, MessageParcel &reply)
3080 {
3081 TAG_LOGD(AAFwkTag::ABILITYMGR, "call");
3082 sptr<IRemoteObject> token = nullptr;
3083 if (data.ReadBool()) {
3084 token = data.ReadRemoteObject();
3085 }
3086 sptr<IPrepareTerminateCallback> callback = iface_cast<IPrepareTerminateCallback>(data.ReadRemoteObject());
3087 if (callback == nullptr) {
3088 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
3089 return ERR_NULL_OBJECT;
3090 }
3091 int result = PrepareTerminateAbility(token, callback);
3092 if (!reply.WriteInt32(result)) {
3093 TAG_LOGE(AAFwkTag::ABILITYMGR, "end failed err: %{public}d", result);
3094 return ERR_INVALID_VALUE;
3095 }
3096 return NO_ERROR;
3097 }
3098
GetDialogSessionInfoInner(MessageParcel &data, MessageParcel &reply)3099 int AbilityManagerStub::GetDialogSessionInfoInner(MessageParcel &data, MessageParcel &reply)
3100 {
3101 TAG_LOGD(AAFwkTag::ABILITYMGR, "call");
3102 std::string dialogSessionId = data.ReadString();
3103 sptr<DialogSessionInfo> info;
3104 int result = GetDialogSessionInfo(dialogSessionId, info);
3105 if (result != ERR_OK || info == nullptr) {
3106 TAG_LOGE(AAFwkTag::ABILITYMGR, "not find dialogSessionInfo");
3107 return ERR_INVALID_VALUE;
3108 }
3109 if (!reply.WriteParcelable(info)) {
3110 return ERR_INVALID_VALUE;
3111 }
3112 if (!reply.WriteInt32(result)) {
3113 return ERR_INVALID_VALUE;
3114 }
3115 return NO_ERROR;
3116 }
3117
SendDialogResultInner(MessageParcel &data, MessageParcel &reply)3118 int AbilityManagerStub::SendDialogResultInner(MessageParcel &data, MessageParcel &reply)
3119 {
3120 TAG_LOGD(AAFwkTag::ABILITYMGR, "call");
3121 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3122 if (want == nullptr) {
3123 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3124 return ERR_INVALID_VALUE;
3125 }
3126 std::string dialogSessionId = data.ReadString();
3127 bool isAllow = data.ReadBool();
3128 int result = SendDialogResult(*want, dialogSessionId, isAllow);
3129 if (!reply.WriteInt32(result)) {
3130 return ERR_INVALID_VALUE;
3131 }
3132 return NO_ERROR;
3133 }
3134
RegisterAbilityFirstFrameStateObserverInner(MessageParcel &data, MessageParcel &reply)3135 int AbilityManagerStub::RegisterAbilityFirstFrameStateObserverInner(MessageParcel &data, MessageParcel &reply)
3136 {
3137 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3138 auto callback = iface_cast<AppExecFwk::IAbilityFirstFrameStateObserver>(data.ReadRemoteObject());
3139 if (callback == nullptr) {
3140 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
3141 return ERR_INVALID_VALUE;
3142 }
3143
3144 std::string targetBundleName = data.ReadString();
3145 auto ret = RegisterAbilityFirstFrameStateObserver(callback, targetBundleName);
3146 if (!reply.WriteInt32(ret)) {
3147 TAG_LOGE(AAFwkTag::ABILITYMGR, "write ret error");
3148 return IPC_STUB_ERR;
3149 }
3150 return NO_ERROR;
3151 }
3152
UnregisterAbilityFirstFrameStateObserverInner(MessageParcel &data, MessageParcel &reply)3153 int AbilityManagerStub::UnregisterAbilityFirstFrameStateObserverInner(MessageParcel &data, MessageParcel &reply)
3154 {
3155 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3156 auto callback = iface_cast<AppExecFwk::IAbilityFirstFrameStateObserver>(data.ReadRemoteObject());
3157 if (callback == nullptr) {
3158 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
3159 return ERR_INVALID_VALUE;
3160 }
3161 auto ret = UnregisterAbilityFirstFrameStateObserver(callback);
3162 if (!reply.WriteInt32(ret)) {
3163 TAG_LOGE(AAFwkTag::ABILITYMGR, "write ret error");
3164 return IPC_STUB_ERR;
3165 }
3166 return NO_ERROR;
3167 }
3168 #endif
3169
IsValidMissionIdsInner(MessageParcel &data, MessageParcel &reply)3170 int32_t AbilityManagerStub::IsValidMissionIdsInner(MessageParcel &data, MessageParcel &reply)
3171 {
3172 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3173 std::vector<int32_t> missionIds;
3174 std::vector<MissionValidResult> results;
3175
3176 data.ReadInt32Vector(&missionIds);
3177 auto err = IsValidMissionIds(missionIds, results);
3178 if (err != ERR_OK) {
3179 results.clear();
3180 }
3181
3182 if (!reply.WriteInt32(err)) {
3183 return ERR_INVALID_VALUE;
3184 }
3185
3186 reply.WriteInt32(static_cast<int32_t>(results.size()));
3187 for (auto &item : results) {
3188 if (!reply.WriteParcelable(&item)) {
3189 return ERR_INVALID_VALUE;
3190 }
3191 }
3192 return NO_ERROR;
3193 }
3194
VerifyPermissionInner(MessageParcel &data, MessageParcel &reply)3195 int AbilityManagerStub::VerifyPermissionInner(MessageParcel &data, MessageParcel &reply)
3196 {
3197 TAG_LOGD(AAFwkTag::ABILITYMGR, "verifyPermission call");
3198 std::string permission = data.ReadString();
3199 int32_t pid = data.ReadInt32();
3200 int32_t uid = data.ReadInt32();
3201
3202 auto result = VerifyPermission(permission, pid, uid);
3203 if (!reply.WriteInt32(result)) {
3204 TAG_LOGE(AAFwkTag::ABILITYMGR, "verifyPermission fail");
3205 return ERR_INVALID_VALUE;
3206 }
3207 return NO_ERROR;
3208 }
3209
ForceExitAppInner(MessageParcel &data, MessageParcel &reply)3210 int32_t AbilityManagerStub::ForceExitAppInner(MessageParcel &data, MessageParcel &reply)
3211 {
3212 int32_t pid = data.ReadInt32();
3213 std::unique_ptr<ExitReason> exitReason(data.ReadParcelable<ExitReason>());
3214 if (!exitReason) {
3215 TAG_LOGE(AAFwkTag::ABILITYMGR, "exitReason null");
3216 return ERR_INVALID_VALUE;
3217 }
3218 int32_t result = ForceExitApp(pid, *exitReason);
3219 if (!reply.WriteInt32(result)) {
3220 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3221 return ERR_INVALID_VALUE;
3222 }
3223 return NO_ERROR;
3224 }
3225
RecordAppExitReasonInner(MessageParcel &data, MessageParcel &reply)3226 int32_t AbilityManagerStub::RecordAppExitReasonInner(MessageParcel &data, MessageParcel &reply)
3227 {
3228 std::unique_ptr<ExitReason> exitReason(data.ReadParcelable<ExitReason>());
3229 if (!exitReason) {
3230 TAG_LOGE(AAFwkTag::ABILITYMGR, "exitReason null");
3231 return ERR_INVALID_VALUE;
3232 }
3233 int32_t result = RecordAppExitReason(*exitReason);
3234 if (!reply.WriteInt32(result)) {
3235 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3236 return ERR_INVALID_VALUE;
3237 }
3238 return NO_ERROR;
3239 }
3240
RecordProcessExitReasonInner(MessageParcel &data, MessageParcel &reply)3241 int32_t AbilityManagerStub::RecordProcessExitReasonInner(MessageParcel &data, MessageParcel &reply)
3242 {
3243 int32_t pid = data.ReadInt32();
3244 std::unique_ptr<ExitReason> exitReason(data.ReadParcelable<ExitReason>());
3245 if (!exitReason) {
3246 TAG_LOGE(AAFwkTag::ABILITYMGR, "exitReason null");
3247 return ERR_INVALID_VALUE;
3248 }
3249 int32_t result = RecordProcessExitReason(pid, *exitReason);
3250 if (!reply.WriteInt32(result)) {
3251 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3252 return ERR_INVALID_VALUE;
3253 }
3254 return NO_ERROR;
3255 }
3256
SetRootSceneSessionInner(MessageParcel &data, MessageParcel &reply)3257 int AbilityManagerStub::SetRootSceneSessionInner(MessageParcel &data, MessageParcel &reply)
3258 {
3259 TAG_LOGD(AAFwkTag::ABILITYMGR, "Call.");
3260 auto rootSceneSession = data.ReadRemoteObject();
3261 if (rootSceneSession == nullptr) {
3262 TAG_LOGE(AAFwkTag::ABILITYMGR, "null rootSceneSession");
3263 return ERR_INVALID_VALUE;
3264 }
3265 SetRootSceneSession(rootSceneSession);
3266 return NO_ERROR;
3267 }
3268
CallUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)3269 int AbilityManagerStub::CallUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)
3270 {
3271 TAG_LOGD(AAFwkTag::ABILITYMGR, "Call.");
3272 sptr<SessionInfo> sessionInfo = nullptr;
3273 if (data.ReadBool()) {
3274 sessionInfo = data.ReadParcelable<SessionInfo>();
3275 }
3276 bool isColdStart = false;
3277 CallUIAbilityBySCB(sessionInfo, isColdStart);
3278 reply.WriteBool(isColdStart);
3279 return NO_ERROR;
3280 }
3281
StartSpecifiedAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)3282 int32_t AbilityManagerStub::StartSpecifiedAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)
3283 {
3284 TAG_LOGD(AAFwkTag::ABILITYMGR, "Call.");
3285 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3286 if (want == nullptr) {
3287 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3288 return ERR_INVALID_VALUE;
3289 }
3290 StartSpecifiedAbilityBySCB(*want);
3291 return NO_ERROR;
3292 }
3293
NotifySaveAsResultInner(MessageParcel &data, MessageParcel &reply)3294 int AbilityManagerStub::NotifySaveAsResultInner(MessageParcel &data, MessageParcel &reply)
3295 {
3296 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3297 if (!want) {
3298 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3299 return ERR_INVALID_VALUE;
3300 }
3301 int resultCode = data.ReadInt32();
3302 int requestCode = data.ReadInt32();
3303 int32_t result = NotifySaveAsResult(*want, resultCode, requestCode);
3304 reply.WriteInt32(result);
3305 return NO_ERROR;
3306 }
3307
SetSessionManagerServiceInner(MessageParcel &data, MessageParcel &reply)3308 int AbilityManagerStub::SetSessionManagerServiceInner(MessageParcel &data, MessageParcel &reply)
3309 {
3310 sptr<IRemoteObject> sessionManagerService = data.ReadRemoteObject();
3311 if (!sessionManagerService) {
3312 TAG_LOGE(AAFwkTag::ABILITYMGR, "read ability token fail");
3313 return ERR_NULL_OBJECT;
3314 }
3315 SetSessionManagerService(sessionManagerService);
3316 return NO_ERROR;
3317 }
3318
RegisterIAbilityManagerCollaboratorInner(MessageParcel &data, MessageParcel &reply)3319 int32_t AbilityManagerStub::RegisterIAbilityManagerCollaboratorInner(MessageParcel &data, MessageParcel &reply)
3320 {
3321 int32_t type = data.ReadInt32();
3322 sptr<IAbilityManagerCollaborator> collaborator = iface_cast<IAbilityManagerCollaborator>(data.ReadRemoteObject());
3323 if (collaborator == nullptr) {
3324 TAG_LOGE(AAFwkTag::ABILITYMGR, "null collaborator");
3325 return ERR_NULL_OBJECT;
3326 }
3327 int32_t ret = RegisterIAbilityManagerCollaborator(type, collaborator);
3328 reply.WriteInt32(ret);
3329 return NO_ERROR;
3330 }
3331
UnregisterIAbilityManagerCollaboratorInner(MessageParcel &data, MessageParcel &reply)3332 int32_t AbilityManagerStub::UnregisterIAbilityManagerCollaboratorInner(MessageParcel &data, MessageParcel &reply)
3333 {
3334 int32_t type = data.ReadInt32();
3335 int32_t ret = UnregisterIAbilityManagerCollaborator(type);
3336 reply.WriteInt32(ret);
3337 return NO_ERROR;
3338 }
3339
PrepareTerminateAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)3340 int AbilityManagerStub::PrepareTerminateAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)
3341 {
3342 TAG_LOGD(AAFwkTag::ABILITYMGR, "Call.");
3343 sptr<SessionInfo> sessionInfo = nullptr;
3344 if (data.ReadBool()) {
3345 sessionInfo = data.ReadParcelable<SessionInfo>();
3346 }
3347 bool isPrepareTerminate = false;
3348 auto result = PrepareTerminateAbilityBySCB(sessionInfo, isPrepareTerminate);
3349 if (result == ERR_OK) {
3350 if (!reply.WriteBool(isPrepareTerminate)) {
3351 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
3352 return ERR_INVALID_VALUE;
3353 }
3354 }
3355 return result;
3356 }
3357
RegisterStatusBarDelegateInner(MessageParcel &data, MessageParcel &reply)3358 int32_t AbilityManagerStub::RegisterStatusBarDelegateInner(MessageParcel &data, MessageParcel &reply)
3359 {
3360 auto delegate = iface_cast<AbilityRuntime::IStatusBarDelegate>(data.ReadRemoteObject());
3361 if (delegate == nullptr) {
3362 TAG_LOGE(AAFwkTag::ABILITYMGR, "delegate null");
3363 return ERR_NULL_OBJECT;
3364 }
3365 int32_t result = RegisterStatusBarDelegate(delegate);
3366 reply.WriteInt32(result);
3367 return NO_ERROR;
3368 }
3369
KillProcessWithPrepareTerminateInner(MessageParcel &data, MessageParcel &reply)3370 int32_t AbilityManagerStub::KillProcessWithPrepareTerminateInner(MessageParcel &data, MessageParcel &reply)
3371 {
3372 auto size = data.ReadUint32();
3373 if (size == 0 || size > MAX_KILL_PROCESS_PID_COUNT) {
3374 TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid size");
3375 return ERR_INVALID_VALUE;
3376 }
3377 std::vector<int32_t> pids;
3378 for (uint32_t i = 0; i < size; i++) {
3379 pids.emplace_back(data.ReadInt32());
3380 }
3381 int32_t result = KillProcessWithPrepareTerminate(pids);
3382 if (result != ERR_OK) {
3383 TAG_LOGE(AAFwkTag::ABILITYMGR, "kill process fail");
3384 }
3385 return NO_ERROR;
3386 }
3387
RegisterAutoStartupSystemCallbackInner(MessageParcel &data, MessageParcel &reply)3388 int32_t AbilityManagerStub::RegisterAutoStartupSystemCallbackInner(MessageParcel &data, MessageParcel &reply)
3389 {
3390 sptr<IRemoteObject> callback = data.ReadRemoteObject();
3391 if (callback == nullptr) {
3392 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
3393 return ERR_INVALID_VALUE;
3394 }
3395 int32_t result = RegisterAutoStartupSystemCallback(callback);
3396 reply.WriteInt32(result);
3397 return NO_ERROR;
3398 }
3399
UnregisterAutoStartupSystemCallbackInner(MessageParcel &data, MessageParcel &reply)3400 int32_t AbilityManagerStub::UnregisterAutoStartupSystemCallbackInner(MessageParcel &data, MessageParcel &reply)
3401 {
3402 sptr<IRemoteObject> callback = data.ReadRemoteObject();
3403 if (callback == nullptr) {
3404 TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
3405 return ERR_INVALID_VALUE;
3406 }
3407 int32_t result = UnregisterAutoStartupSystemCallback(callback);
3408 reply.WriteInt32(result);
3409 return NO_ERROR;
3410 }
3411
SetApplicationAutoStartupInner(MessageParcel &data, MessageParcel &reply)3412 int32_t AbilityManagerStub::SetApplicationAutoStartupInner(MessageParcel &data, MessageParcel &reply)
3413 {
3414 sptr<AutoStartupInfo> info = data.ReadParcelable<AutoStartupInfo>();
3415 if (info == nullptr) {
3416 TAG_LOGE(AAFwkTag::ABILITYMGR, "info null");
3417 return ERR_INVALID_VALUE;
3418 }
3419 int32_t result = SetApplicationAutoStartup(*info);
3420 reply.WriteInt32(result);
3421 return NO_ERROR;
3422 }
3423
CancelApplicationAutoStartupInner(MessageParcel &data, MessageParcel &reply)3424 int32_t AbilityManagerStub::CancelApplicationAutoStartupInner(MessageParcel &data, MessageParcel &reply)
3425 {
3426 sptr<AutoStartupInfo> info = data.ReadParcelable<AutoStartupInfo>();
3427 if (info == nullptr) {
3428 TAG_LOGE(AAFwkTag::ABILITYMGR, "info null");
3429 return ERR_INVALID_VALUE;
3430 }
3431 int32_t result = CancelApplicationAutoStartup(*info);
3432 reply.WriteInt32(result);
3433 return NO_ERROR;
3434 }
3435
QueryAllAutoStartupApplicationsInner(MessageParcel &data, MessageParcel &reply)3436 int32_t AbilityManagerStub::QueryAllAutoStartupApplicationsInner(MessageParcel &data, MessageParcel &reply)
3437 {
3438 std::vector<AutoStartupInfo> infoList;
3439 auto result = QueryAllAutoStartupApplications(infoList);
3440 if (!reply.WriteInt32(result)) {
3441 return ERR_INVALID_VALUE;
3442 }
3443
3444 reply.WriteInt32(static_cast<int32_t>(infoList.size()));
3445 for (auto &info : infoList) {
3446 if (!reply.WriteParcelable(&info)) {
3447 return ERR_INVALID_VALUE;
3448 }
3449 }
3450 return NO_ERROR;
3451 }
3452
RegisterSessionHandlerInner(MessageParcel &data, MessageParcel &reply)3453 int AbilityManagerStub::RegisterSessionHandlerInner(MessageParcel &data, MessageParcel &reply)
3454 {
3455 sptr<IRemoteObject> handler = data.ReadRemoteObject();
3456 if (handler == nullptr) {
3457 TAG_LOGE(AAFwkTag::ABILITYMGR, "null handler");
3458 return ERR_INVALID_VALUE;
3459 }
3460 int32_t result = RegisterSessionHandler(handler);
3461 reply.WriteInt32(result);
3462 return NO_ERROR;
3463 }
3464
RegisterAppDebugListenerInner(MessageParcel &data, MessageParcel &reply)3465 int32_t AbilityManagerStub::RegisterAppDebugListenerInner(MessageParcel &data, MessageParcel &reply)
3466 {
3467 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3468 auto appDebugLister = iface_cast<AppExecFwk::IAppDebugListener>(data.ReadRemoteObject());
3469 if (appDebugLister == nullptr) {
3470 TAG_LOGE(AAFwkTag::ABILITYMGR, "appDebugLister null");
3471 return ERR_INVALID_VALUE;
3472 }
3473
3474 auto result = RegisterAppDebugListener(appDebugLister);
3475 if (!reply.WriteInt32(result)) {
3476 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3477 return ERR_INVALID_VALUE;
3478 }
3479 return NO_ERROR;
3480 }
3481
UnregisterAppDebugListenerInner(MessageParcel &data, MessageParcel &reply)3482 int32_t AbilityManagerStub::UnregisterAppDebugListenerInner(MessageParcel &data, MessageParcel &reply)
3483 {
3484 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3485 auto appDebugLister = iface_cast<AppExecFwk::IAppDebugListener>(data.ReadRemoteObject());
3486 if (appDebugLister == nullptr) {
3487 TAG_LOGE(AAFwkTag::ABILITYMGR, "appDebugLister null");
3488 return ERR_INVALID_VALUE;
3489 }
3490
3491 auto result = UnregisterAppDebugListener(appDebugLister);
3492 if (!reply.WriteInt32(result)) {
3493 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3494 return ERR_INVALID_VALUE;
3495 }
3496 return NO_ERROR;
3497 }
3498
AttachAppDebugInner(MessageParcel &data, MessageParcel &reply)3499 int32_t AbilityManagerStub::AttachAppDebugInner(MessageParcel &data, MessageParcel &reply)
3500 {
3501 auto bundleName = data.ReadString();
3502 if (bundleName.empty()) {
3503 TAG_LOGE(AAFwkTag::ABILITYMGR, "empty bundleName");
3504 return ERR_INVALID_VALUE;
3505 }
3506
3507 auto result = AttachAppDebug(bundleName);
3508 if (!reply.WriteInt32(result)) {
3509 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3510 return ERR_INVALID_VALUE;
3511 }
3512 return NO_ERROR;
3513 }
3514
DetachAppDebugInner(MessageParcel &data, MessageParcel &reply)3515 int32_t AbilityManagerStub::DetachAppDebugInner(MessageParcel &data, MessageParcel &reply)
3516 {
3517 auto bundleName = data.ReadString();
3518 if (bundleName.empty()) {
3519 TAG_LOGE(AAFwkTag::ABILITYMGR, "empty bundleName");
3520 return ERR_INVALID_VALUE;
3521 }
3522
3523 auto result = DetachAppDebug(bundleName);
3524 if (!reply.WriteInt32(result)) {
3525 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3526 return ERR_INVALID_VALUE;
3527 }
3528 return NO_ERROR;
3529 }
3530
IsAbilityControllerStartInner(MessageParcel &data, MessageParcel &reply)3531 int32_t AbilityManagerStub::IsAbilityControllerStartInner(MessageParcel &data, MessageParcel &reply)
3532 {
3533 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3534 if (want == nullptr) {
3535 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3536 return true;
3537 }
3538 bool result = IsAbilityControllerStart(*want);
3539 reply.WriteBool(result);
3540 return NO_ERROR;
3541 }
3542
ExecuteIntentInner(MessageParcel &data, MessageParcel &reply)3543 int32_t AbilityManagerStub::ExecuteIntentInner(MessageParcel &data, MessageParcel &reply)
3544 {
3545 uint64_t key = data.ReadUint64();
3546 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
3547 if (callerToken == nullptr) {
3548 TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
3549 return ERR_INVALID_VALUE;
3550 }
3551 std::unique_ptr<InsightIntentExecuteParam> param(data.ReadParcelable<InsightIntentExecuteParam>());
3552 if (param == nullptr) {
3553 TAG_LOGE(AAFwkTag::ABILITYMGR, "param null");
3554 return ERR_INVALID_VALUE;
3555 }
3556 auto result = ExecuteIntent(key, callerToken, *param);
3557 if (!reply.WriteInt32(result)) {
3558 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3559 return ERR_INVALID_VALUE;
3560 }
3561 return NO_ERROR;
3562 }
3563
StartAbilityForResultAsCallerInner(MessageParcel &data, MessageParcel &reply)3564 int AbilityManagerStub::StartAbilityForResultAsCallerInner(MessageParcel &data, MessageParcel &reply)
3565 {
3566 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3567 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3568 if (want == nullptr) {
3569 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3570 return ERR_INVALID_VALUE;
3571 }
3572 sptr<IRemoteObject> callerToken = nullptr;
3573 if (data.ReadBool()) {
3574 callerToken = data.ReadRemoteObject();
3575 }
3576 int32_t requestCode = data.ReadInt32();
3577 int32_t userId = data.ReadInt32();
3578 int32_t result = StartAbilityForResultAsCaller(*want, callerToken, requestCode, userId);
3579 reply.WriteInt32(result);
3580 return NO_ERROR;
3581 }
3582
StartAbilityForResultAsCallerForOptionsInner(MessageParcel &data, MessageParcel &reply)3583 int AbilityManagerStub::StartAbilityForResultAsCallerForOptionsInner(MessageParcel &data, MessageParcel &reply)
3584 {
3585 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3586 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3587 if (want == nullptr) {
3588 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3589 return ERR_INVALID_VALUE;
3590 }
3591 std::unique_ptr<StartOptions> startOptions(data.ReadParcelable<StartOptions>());
3592 if (startOptions == nullptr) {
3593 TAG_LOGE(AAFwkTag::ABILITYMGR, "startOptions null");
3594 return ERR_INVALID_VALUE;
3595 }
3596 sptr<IRemoteObject> callerToken = nullptr;
3597 if (data.ReadBool()) {
3598 callerToken = data.ReadRemoteObject();
3599 }
3600 int32_t requestCode = data.ReadInt32();
3601 int32_t userId = data.ReadInt32();
3602 int32_t result = StartAbilityForResultAsCaller(*want, *startOptions, callerToken, requestCode, userId);
3603 reply.WriteInt32(result);
3604 return NO_ERROR;
3605 }
3606
StartAbilityOnlyUIAbilityInner(MessageParcel &data, MessageParcel &reply)3607 int32_t AbilityManagerStub::StartAbilityOnlyUIAbilityInner(MessageParcel &data, MessageParcel &reply)
3608 {
3609 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3610 if (want == nullptr) {
3611 TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
3612 return ERR_INVALID_VALUE;
3613 }
3614
3615 sptr<IRemoteObject> callerToken = nullptr;
3616 if (!data.ReadBool()) {
3617 TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid caller token");
3618 return ERR_INVALID_VALUE;
3619 }
3620 callerToken = data.ReadRemoteObject();
3621 uint32_t specifyTokenId = data.ReadUint32();
3622 int32_t result = StartAbilityOnlyUIAbility(*want, callerToken, specifyTokenId);
3623 reply.WriteInt32(result);
3624 return NO_ERROR;
3625 }
3626
StartAbilityByInsightIntentInner(MessageParcel &data, MessageParcel &reply)3627 int32_t AbilityManagerStub::StartAbilityByInsightIntentInner(MessageParcel &data, MessageParcel &reply)
3628 {
3629 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3630 if (want == nullptr) {
3631 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3632 return ERR_INVALID_VALUE;
3633 }
3634
3635 sptr<IRemoteObject> callerToken = nullptr;
3636 if (!data.ReadBool()) {
3637 TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid caller token");
3638 return ERR_INVALID_VALUE;
3639 }
3640 callerToken = data.ReadRemoteObject();
3641 uint64_t intentId = data.ReadUint64();
3642 int32_t userId = data.ReadInt32();
3643 int32_t result = StartAbilityByInsightIntent(*want, callerToken, intentId, userId);
3644 reply.WriteInt32(result);
3645 return NO_ERROR;
3646 }
3647
ExecuteInsightIntentDoneInner(MessageParcel &data, MessageParcel &reply)3648 int32_t AbilityManagerStub::ExecuteInsightIntentDoneInner(MessageParcel &data, MessageParcel &reply)
3649 {
3650 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3651 auto token = data.ReadRemoteObject();
3652 if (token == nullptr) {
3653 TAG_LOGE(AAFwkTag::ABILITYMGR, "null token");
3654 return ERR_INVALID_VALUE;
3655 }
3656
3657 auto intentId = data.ReadInt64();
3658 std::unique_ptr<InsightIntentExecuteResult> executeResult(data.ReadParcelable<InsightIntentExecuteResult>());
3659 if (!executeResult) {
3660 TAG_LOGE(AAFwkTag::ABILITYMGR, "executeResult null");
3661 return ERR_INVALID_VALUE;
3662 }
3663
3664 int32_t result = ExecuteInsightIntentDone(token, intentId, *executeResult);
3665 reply.WriteInt32(result);
3666 return NO_ERROR;
3667 }
3668
SetApplicationAutoStartupByEDMInner(MessageParcel &data, MessageParcel &reply)3669 int32_t AbilityManagerStub::SetApplicationAutoStartupByEDMInner(MessageParcel &data, MessageParcel &reply)
3670 {
3671 sptr<AutoStartupInfo> info = data.ReadParcelable<AutoStartupInfo>();
3672 if (info == nullptr) {
3673 TAG_LOGE(AAFwkTag::ABILITYMGR, "info null");
3674 return ERR_INVALID_VALUE;
3675 }
3676 auto flag = data.ReadBool();
3677 int32_t result = SetApplicationAutoStartupByEDM(*info, flag);
3678 return reply.WriteInt32(result);
3679 }
3680
CancelApplicationAutoStartupByEDMInner(MessageParcel &data, MessageParcel &reply)3681 int32_t AbilityManagerStub::CancelApplicationAutoStartupByEDMInner(MessageParcel &data, MessageParcel &reply)
3682 {
3683 sptr<AutoStartupInfo> info = data.ReadParcelable<AutoStartupInfo>();
3684 if (info == nullptr) {
3685 TAG_LOGE(AAFwkTag::ABILITYMGR, "info null");
3686 return ERR_INVALID_VALUE;
3687 }
3688 auto flag = data.ReadBool();
3689 int32_t result = CancelApplicationAutoStartupByEDM(*info, flag);
3690 return reply.WriteInt32(result);
3691 }
3692
OpenFileInner(MessageParcel &data, MessageParcel &reply)3693 int32_t AbilityManagerStub::OpenFileInner(MessageParcel &data, MessageParcel &reply)
3694 {
3695 std::unique_ptr<Uri> uri(data.ReadParcelable<Uri>());
3696 if (!uri) {
3697 TAG_LOGE(AAFwkTag::ABILITYMGR, "read uri fail");
3698 return ERR_DEAD_OBJECT;
3699 }
3700 auto flag = data.ReadInt32();
3701 int fd = OpenFile(*uri, flag);
3702 reply.WriteFileDescriptor(fd);
3703 return ERR_OK;
3704 }
3705
RequestAssertFaultDialogInner(MessageParcel &data, MessageParcel &reply)3706 int32_t AbilityManagerStub::RequestAssertFaultDialogInner(MessageParcel &data, MessageParcel &reply)
3707 {
3708 TAG_LOGD(AAFwkTag::ABILITYMGR, "Request to display assert fault dialog.");
3709 sptr<IRemoteObject> callback = data.ReadRemoteObject();
3710 std::unique_ptr<WantParams> wantParams(data.ReadParcelable<WantParams>());
3711 if (wantParams == nullptr) {
3712 TAG_LOGE(AAFwkTag::ABILITYMGR, "null wantParams");
3713 return ERR_NULL_OBJECT;
3714 }
3715 auto result = RequestAssertFaultDialog(callback, *wantParams);
3716 if (!reply.WriteInt32(result)) {
3717 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3718 return ERR_INVALID_VALUE;
3719 }
3720 return NO_ERROR;
3721 }
3722
NotifyDebugAssertResultInner(MessageParcel &data, MessageParcel &reply)3723 int32_t AbilityManagerStub::NotifyDebugAssertResultInner(MessageParcel &data, MessageParcel &reply)
3724 {
3725 TAG_LOGD(AAFwkTag::ABILITYMGR, "Notify user action result to assert fault process.");
3726 uint64_t assertSessionId = data.ReadUint64();
3727 int32_t status = data.ReadInt32();
3728 auto result = NotifyDebugAssertResult(assertSessionId, static_cast<AAFwk::UserStatus>(status));
3729 if (!reply.WriteInt32(result)) {
3730 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3731 return ERR_INVALID_VALUE;
3732 }
3733 return NO_ERROR;
3734 }
3735
GetForegroundUIAbilitiesInner(MessageParcel &data, MessageParcel &reply)3736 int32_t AbilityManagerStub::GetForegroundUIAbilitiesInner(MessageParcel &data, MessageParcel &reply)
3737 {
3738 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3739 std::vector<AppExecFwk::AbilityStateData> abilityStateDatas;
3740 int32_t result = GetForegroundUIAbilities(abilityStateDatas);
3741 if (result != ERR_OK) {
3742 TAG_LOGE(AAFwkTag::ABILITYMGR, "get foreground abilities fail");
3743 return result;
3744 }
3745 auto infoSize = abilityStateDatas.size();
3746 if (infoSize > CYCLE_LIMIT) {
3747 TAG_LOGE(AAFwkTag::ABILITYMGR, "infoSize exceeds limit");
3748 return ERR_INVALID_VALUE;
3749 }
3750 if (!reply.WriteInt32(infoSize)) {
3751 TAG_LOGE(AAFwkTag::ABILITYMGR, "write data size fail");
3752 return ERR_INVALID_VALUE;
3753 }
3754 for (auto &it : abilityStateDatas) {
3755 if (!reply.WriteParcelable(&it)) {
3756 TAG_LOGE(AAFwkTag::ABILITYMGR, "write parcelable fail");
3757 return ERR_INVALID_VALUE;
3758 }
3759 }
3760 if (!reply.WriteInt32(result)) {
3761 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3762 return ERR_INVALID_VALUE;
3763 }
3764 return result;
3765 }
3766
UpdateSessionInfoBySCBInner(MessageParcel &data, MessageParcel &reply)3767 int32_t AbilityManagerStub::UpdateSessionInfoBySCBInner(MessageParcel &data, MessageParcel &reply)
3768 {
3769 auto size = data.ReadInt32();
3770 int32_t threshold = 512;
3771 if (size > threshold) {
3772 TAG_LOGE(AAFwkTag::ABILITYMGR, "vector size too large");
3773 return ERR_ENOUGH_DATA;
3774 }
3775 std::list<SessionInfo> sessionInfos;
3776 for (auto i = 0; i < size; i++) {
3777 std::unique_ptr<SessionInfo> info(data.ReadParcelable<SessionInfo>());
3778 if (info == nullptr) {
3779 TAG_LOGE(AAFwkTag::ABILITYMGR, "null info");
3780 return ERR_NATIVE_IPC_PARCEL_FAILED;
3781 }
3782 sessionInfos.emplace_back(*info);
3783 }
3784 int32_t userId = data.ReadInt32();
3785 std::vector<int32_t> sessionIds;
3786 auto result = UpdateSessionInfoBySCB(sessionInfos, userId, sessionIds);
3787 if (result != ERR_OK) {
3788 return result;
3789 }
3790 size = static_cast<int32_t>(sessionIds.size());
3791 if (size > threshold) {
3792 TAG_LOGE(AAFwkTag::ABILITYMGR, "vector size too large");
3793 return ERR_ENOUGH_DATA;
3794 }
3795 reply.WriteInt32(size);
3796 for (auto index = 0; index < size; index++) {
3797 reply.WriteInt32(sessionIds[index]);
3798 }
3799 return ERR_OK;
3800 }
3801
GetUIExtensionRootHostInfoInner(MessageParcel &data, MessageParcel &reply)3802 int32_t AbilityManagerStub::GetUIExtensionRootHostInfoInner(MessageParcel &data, MessageParcel &reply)
3803 {
3804 sptr<IRemoteObject> callerToken = nullptr;
3805 if (data.ReadBool()) {
3806 callerToken = data.ReadRemoteObject();
3807 if (callerToken == nullptr) {
3808 TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken null");
3809 return ERR_INVALID_VALUE;
3810 }
3811 }
3812
3813 int32_t userId = data.ReadInt32();
3814 UIExtensionHostInfo hostInfo;
3815 auto result = GetUIExtensionRootHostInfo(callerToken, hostInfo, userId);
3816 if (!reply.WriteParcelable(&hostInfo)) {
3817 TAG_LOGE(AAFwkTag::ABILITYMGR, "write host info fail");
3818 return ERR_INVALID_VALUE;
3819 }
3820
3821 if (!reply.WriteInt32(result)) {
3822 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3823 return ERR_INVALID_VALUE;
3824 }
3825
3826 return NO_ERROR;
3827 }
3828
GetUIExtensionSessionInfoInner(MessageParcel &data, MessageParcel &reply)3829 int32_t AbilityManagerStub::GetUIExtensionSessionInfoInner(MessageParcel &data, MessageParcel &reply)
3830 {
3831 sptr<IRemoteObject> callerToken = nullptr;
3832 if (data.ReadBool()) {
3833 callerToken = data.ReadRemoteObject();
3834 if (callerToken == nullptr) {
3835 TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken null");
3836 return ERR_INVALID_VALUE;
3837 }
3838 }
3839
3840 int32_t userId = data.ReadInt32();
3841 UIExtensionSessionInfo uiExtensionSessionInfo;
3842 auto result = GetUIExtensionSessionInfo(callerToken, uiExtensionSessionInfo, userId);
3843 if (!reply.WriteParcelable(&uiExtensionSessionInfo)) {
3844 TAG_LOGE(AAFwkTag::ABILITYMGR, "write ui extension session info fail");
3845 return ERR_INVALID_VALUE;
3846 }
3847
3848 if (!reply.WriteInt32(result)) {
3849 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3850 return ERR_INVALID_VALUE;
3851 }
3852
3853 return NO_ERROR;
3854 }
3855
RestartAppInner(MessageParcel &data, MessageParcel &reply)3856 int32_t AbilityManagerStub::RestartAppInner(MessageParcel &data, MessageParcel &reply)
3857 {
3858 TAG_LOGD(AAFwkTag::ABILITYMGR, "call.");
3859 std::unique_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
3860 if (want == nullptr) {
3861 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3862 return IPC_STUB_ERR;
3863 }
3864 bool isAppRecovery = data.ReadBool();
3865 auto result = RestartApp(*want, isAppRecovery);
3866 if (!reply.WriteInt32(result)) {
3867 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3868 return IPC_STUB_ERR;
3869 }
3870 return ERR_OK;
3871 }
3872
OpenAtomicServiceInner(MessageParcel &data, MessageParcel &reply)3873 int32_t AbilityManagerStub::OpenAtomicServiceInner(MessageParcel &data, MessageParcel &reply)
3874 {
3875 std::unique_ptr<Want> want(data.ReadParcelable<Want>());
3876 if (want == nullptr) {
3877 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3878 return ERR_INVALID_VALUE;
3879 }
3880 std::unique_ptr<StartOptions> options(data.ReadParcelable<StartOptions>());
3881 if (options == nullptr) {
3882 TAG_LOGE(AAFwkTag::ABILITYMGR, "options null");
3883 return ERR_INVALID_VALUE;
3884 }
3885 sptr<IRemoteObject> callerToken = nullptr;
3886 if (data.ReadBool()) {
3887 callerToken = data.ReadRemoteObject();
3888 }
3889 int32_t requestCode = data.ReadInt32();
3890 int32_t userId = data.ReadInt32();
3891 int32_t openRet = OpenAtomicService(*want, *options, callerToken, requestCode, userId);
3892 if (openRet != ERR_OK) {
3893 TAG_LOGE(AAFwkTag::ABILITYMGR, "open atomic service fail");
3894 return openRet;
3895 }
3896 if (!reply.WriteInt32(openRet)) {
3897 TAG_LOGE(AAFwkTag::ABILITYMGR, "write openRet fail");
3898 return ERR_INVALID_VALUE;
3899 }
3900 return ERR_OK;
3901 }
3902
SetResidentProcessEnableInner(MessageParcel &data, MessageParcel &reply)3903 int32_t AbilityManagerStub::SetResidentProcessEnableInner(MessageParcel &data, MessageParcel &reply)
3904 {
3905 std::string bundleName = data.ReadString();
3906 bool enable = data.ReadBool();
3907 auto result = SetResidentProcessEnabled(bundleName, enable);
3908 if (!reply.WriteInt32(result)) {
3909 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3910 return ERR_INVALID_VALUE;
3911 }
3912 return NO_ERROR;
3913 }
3914
IsEmbeddedOpenAllowedInner(MessageParcel &data, MessageParcel &reply)3915 int32_t AbilityManagerStub::IsEmbeddedOpenAllowedInner(MessageParcel &data, MessageParcel &reply)
3916 {
3917 sptr<IRemoteObject> callerToken = nullptr;
3918 if (data.ReadBool()) {
3919 callerToken = data.ReadRemoteObject();
3920 if (callerToken == nullptr) {
3921 TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken null");
3922 return ERR_INVALID_VALUE;
3923 }
3924 }
3925
3926 std::string appId = data.ReadString();
3927 auto result = IsEmbeddedOpenAllowed(callerToken, appId);
3928
3929 if (!reply.WriteInt32(result)) {
3930 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
3931 return ERR_INVALID_VALUE;
3932 }
3933
3934 return NO_ERROR;
3935 }
3936
StartShortcutInner(MessageParcel &data, MessageParcel &reply)3937 int32_t AbilityManagerStub::StartShortcutInner(MessageParcel &data, MessageParcel &reply)
3938 {
3939 std::shared_ptr<Want> want(data.ReadParcelable<Want>());
3940 if (want == nullptr) {
3941 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3942 return ERR_INVALID_VALUE;
3943 }
3944 StartOptions *startOptions = data.ReadParcelable<StartOptions>();
3945 if (startOptions == nullptr) {
3946 TAG_LOGE(AAFwkTag::ABILITYMGR, "startOptions null");
3947 return ERR_INVALID_VALUE;
3948 }
3949 startOptions->processOptions = nullptr;
3950
3951 int32_t result = StartShortcut(*want, *startOptions);
3952 reply.WriteInt32(result);
3953 delete startOptions;
3954 return NO_ERROR;
3955 }
3956
GetAbilityStateByPersistentIdInner(MessageParcel &data, MessageParcel &reply)3957 int32_t AbilityManagerStub::GetAbilityStateByPersistentIdInner(MessageParcel &data, MessageParcel &reply)
3958 {
3959 int32_t persistentId = data.ReadInt32();
3960 bool state = false;
3961 int32_t result = GetAbilityStateByPersistentId(persistentId, state);
3962 if (result == ERR_OK) {
3963 if (!reply.WriteBool(state)) {
3964 TAG_LOGE(AAFwkTag::ABILITYMGR, "reply write fail");
3965 return IPC_STUB_ERR;
3966 }
3967 }
3968 return result;
3969 }
3970
TransferAbilityResultForExtensionInner(MessageParcel &data, MessageParcel &reply)3971 int32_t AbilityManagerStub::TransferAbilityResultForExtensionInner(MessageParcel &data, MessageParcel &reply)
3972 {
3973 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
3974 int32_t resultCode = data.ReadInt32();
3975 sptr<Want> want = data.ReadParcelable<Want>();
3976 if (want == nullptr) {
3977 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
3978 return ERR_INVALID_VALUE;
3979 }
3980 int32_t result = TransferAbilityResultForExtension(callerToken, resultCode, *want);
3981 reply.WriteInt32(result);
3982 return NO_ERROR;
3983 }
3984
NotifyFrozenProcessByRSSInner(MessageParcel &data, MessageParcel &reply)3985 int32_t AbilityManagerStub::NotifyFrozenProcessByRSSInner(MessageParcel &data, MessageParcel &reply)
3986 {
3987 std::vector<int32_t> pidList;
3988 data.ReadInt32Vector(&pidList);
3989 int32_t uid = data.ReadInt32();
3990 NotifyFrozenProcessByRSS(pidList, uid);
3991 return NO_ERROR;
3992 }
3993
PreStartMissionInner(MessageParcel &data, MessageParcel &reply)3994 int32_t AbilityManagerStub::PreStartMissionInner(MessageParcel &data, MessageParcel &reply)
3995 {
3996 std::string bundleName = data.ReadString();
3997 std::string moduleName = data.ReadString();
3998 std::string abilityName = data.ReadString();
3999 std::string startTime = data.ReadString();
4000 int32_t result = PreStartMission(bundleName, moduleName, abilityName, startTime);
4001 reply.WriteInt32(result);
4002 return NO_ERROR;
4003 }
4004
CleanUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)4005 int32_t AbilityManagerStub::CleanUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply)
4006 {
4007 sptr<SessionInfo> sessionInfo = nullptr;
4008 if (data.ReadBool()) {
4009 sessionInfo = data.ReadParcelable<SessionInfo>();
4010 }
4011 int32_t result = CleanUIAbilityBySCB(sessionInfo);
4012 reply.WriteInt32(result);
4013 return NO_ERROR;
4014 }
4015
OpenLinkInner(MessageParcel &data, MessageParcel &reply)4016 int32_t AbilityManagerStub::OpenLinkInner(MessageParcel &data, MessageParcel &reply)
4017 {
4018 sptr<Want> want = data.ReadParcelable<Want>();
4019 if (want == nullptr) {
4020 TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
4021 return ERR_INVALID_VALUE;
4022 }
4023 sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
4024 int32_t userId = data.ReadInt32();
4025 int requestCode = data.ReadInt32();
4026
4027 int32_t result = OpenLink(*want, callerToken, userId, requestCode);
4028 if (result != NO_ERROR && result != ERR_OPEN_LINK_START_ABILITY_DEFAULT_OK) {
4029 TAG_LOGE(AAFwkTag::ABILITYMGR, "openLink fail");
4030 }
4031 reply.WriteInt32(result);
4032 return result;
4033 }
4034
TerminateMissionInner(MessageParcel &data, MessageParcel &reply)4035 int32_t AbilityManagerStub::TerminateMissionInner(MessageParcel &data, MessageParcel &reply)
4036 {
4037 int32_t missionId = data.ReadInt32();
4038 int32_t result = TerminateMission(missionId);
4039 if (result != NO_ERROR && result != ERR_OPEN_LINK_START_ABILITY_DEFAULT_OK) {
4040 TAG_LOGE(AAFwkTag::ABILITYMGR, "openLink fail");
4041 }
4042 reply.WriteInt32(result);
4043 return result;
4044 }
4045
BlockAllAppStartInner(MessageParcel &data, MessageParcel &reply)4046 int32_t AbilityManagerStub::BlockAllAppStartInner(MessageParcel &data, MessageParcel &reply)
4047 {
4048 bool flag = data.ReadBool();
4049 int32_t result = BlockAllAppStart(flag);
4050 if (!reply.WriteInt32(result)) {
4051 TAG_LOGE(AAFwkTag::ABILITYMGR, "write result failed");
4052 return IPC_STUB_ERR;
4053 }
4054 return ERR_OK;
4055 }
4056
UpdateAssociateConfigListInner(MessageParcel &data, MessageParcel &reply)4057 int32_t AbilityManagerStub::UpdateAssociateConfigListInner(MessageParcel &data, MessageParcel &reply)
4058 {
4059 int32_t size = data.ReadInt32();
4060 if (size > MAX_UPDATE_CONFIG_SIZE) {
4061 TAG_LOGE(AAFwkTag::ABILITYMGR, "config size error");
4062 return ERR_INVALID_VALUE;
4063 }
4064 std::map<std::string, std::list<std::string>> configs;
4065 for (int32_t i = 0; i < size; ++i) {
4066 std::string key = data.ReadString();
4067 int32_t itemSize = data.ReadInt32();
4068 if (itemSize > MAX_UPDATE_CONFIG_SIZE) {
4069 TAG_LOGE(AAFwkTag::ABILITYMGR, "config size error");
4070 return ERR_INVALID_VALUE;
4071 }
4072 configs.emplace(key, std::list<std::string>());
4073 for (int32_t j = 0; j < itemSize; ++j) {
4074 configs[key].push_back(data.ReadString());
4075 }
4076 }
4077
4078 std::list<std::string> exportConfigs;
4079 size = data.ReadInt32();
4080 if (size > MAX_UPDATE_CONFIG_SIZE) {
4081 TAG_LOGE(AAFwkTag::ABILITYMGR, "config size error");
4082 return ERR_INVALID_VALUE;
4083 }
4084 for (int32_t i = 0; i < size; ++i) {
4085 exportConfigs.push_back(data.ReadString());
4086 }
4087 int32_t flag = data.ReadInt32();
4088 int32_t result = UpdateAssociateConfigList(configs, exportConfigs, flag);
4089 if (result != NO_ERROR) {
4090 TAG_LOGE(AAFwkTag::ABILITYMGR, "update associate config fail");
4091 }
4092 reply.WriteInt32(result);
4093 return NO_ERROR;
4094 }
4095 } // namespace AAFwk
4096 } // namespace OHOS