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