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