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