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