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