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 #ifndef OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_PROXY_H
17 #define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_PROXY_H
18 
19 #include "ability_manager_interface.h"
20 #include "auto_startup_info.h"
21 #include "iremote_proxy.h"
22 #include "mission_info.h"
23 
24 namespace OHOS {
25 namespace AAFwk {
26 using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
27 /**
28  * @class AbilityManagerProxy
29  * AbilityManagerProxy.
30  */
31 class AbilityManagerProxy : public IRemoteProxy<IAbilityManager> {
32 public:
AbilityManagerProxy(const sptr<IRemoteObject> &impl)33     explicit AbilityManagerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAbilityManager>(impl)
34     {}
35 
~AbilityManagerProxy()36     virtual ~AbilityManagerProxy()
37     {}
38 
39     /**
40      * StartAbility with want, send want to ability manager service.
41      *
42      * @param want, the want of the ability to start.
43      * @param requestCode, Ability request code.
44      * @param userId, Designation User ID.
45      * @return Returns ERR_OK on success, others on failure.
46      */
47     virtual int StartAbility(
48         const Want &want,
49         int32_t userId = DEFAULT_INVAL_VALUE,
50         int requestCode = DEFAULT_INVAL_VALUE) override;
51 
52     /**
53      * StartAbility with want, send want to ability manager service.
54      *
55      * @param want, the want of the ability to start.
56      * @param callerToken, caller ability token.
57      * @param requestCode the resultCode of the ability to start.
58      * @param userId, Designation User ID.
59      * @return Returns ERR_OK on success, others on failure.
60      */
61     virtual int StartAbility(
62         const Want &want,
63         const sptr<IRemoteObject> &callerToken,
64         int32_t userId = DEFAULT_INVAL_VALUE,
65         int requestCode = DEFAULT_INVAL_VALUE) override;
66 
67     /**
68      * StartAbilityWithSpecifyTokenId with want and specialId, send want to ability manager service.
69      *
70      * @param want, the want of the ability to start.
71      * @param callerToken, caller ability token.
72      * @param specialId the caller Id.
73      * @param userId, Designation User ID.
74      * @param requestCode the resultCode of the ability to start.
75      * @return Returns ERR_OK on success, others on failure.
76      */
77     virtual int StartAbilityWithSpecifyTokenId(
78         const Want &want,
79         const sptr<IRemoteObject> &callerToken,
80         uint32_t specifyTokenId,
81         int32_t userId = DEFAULT_INVAL_VALUE,
82         int requestCode = DEFAULT_INVAL_VALUE) override;
83 
84     /**
85      * StartAbility by insight intent, send want to ability manager service.
86      *
87      * @param want Ability want.
88      * @param callerToken caller ability token.
89      * @param intentId insight intent id.
90      * @param userId userId of target ability.
91      * @return Returns ERR_OK on success, others on failure.
92      */
93     int32_t StartAbilityByInsightIntent(
94         const Want &want,
95         const sptr<IRemoteObject> &callerToken,
96         uint64_t intentId,
97         int32_t userId = DEFAULT_INVAL_VALUE) override;
98 
99     /**
100      * Starts a new ability with specific start settings.
101      *
102      * @param want Indicates the ability to start.
103      * @param callerToken caller ability token.
104      * @param abilityStartSetting Indicates the setting ability used to start.
105      * @param userId, Designation User ID.
106      * @return Returns ERR_OK on success, others on failure.
107      */
108     virtual int StartAbility(
109         const Want &want,
110         const AbilityStartSetting &abilityStartSetting,
111         const sptr<IRemoteObject> &callerToken,
112         int32_t userId = DEFAULT_INVAL_VALUE,
113         int requestCode = DEFAULT_INVAL_VALUE) override;
114 
115     /**
116      * Starts a new ability with specific start options.
117      *
118      * @param want, the want of the ability to start.
119      * @param startOptions Indicates the options used to start.
120      * @param callerToken, caller ability token.
121      * @param userId, Designation User ID.
122      * @param requestCode the resultCode of the ability to start.
123      * @return Returns ERR_OK on success, others on failure.
124      */
125     virtual int StartAbility(
126         const Want &want,
127         const StartOptions &startOptions,
128         const sptr<IRemoteObject> &callerToken,
129         int32_t userId = DEFAULT_INVAL_VALUE,
130         int requestCode = DEFAULT_INVAL_VALUE) override;
131 
132     /**
133      * Starts a new ability using the original caller information.
134      *
135      * @param want the want of the ability to start.
136      * @param callerToken current caller ability token.
137      * @param asCallerSourceToken source caller ability token.
138      * @param userId Designation User ID.
139      * @param requestCode the resultCode of the ability to start.
140      * @return Returns ERR_OK on success, others on failure.
141      */
142     virtual int StartAbilityAsCaller(
143         const Want &want,
144         const sptr<IRemoteObject> &callerToken,
145         sptr<IRemoteObject> asCallerSourceToken,
146         int32_t userId = DEFAULT_INVAL_VALUE,
147         int requestCode = DEFAULT_INVAL_VALUE) override;
148 
149     /**
150      * Starts a new ability using the original caller information.
151      *
152      * @param want the want of the ability to start.
153      * @param startOptions Indicates the options used to start.
154      * @param callerToken current caller ability token.
155      * @param asCallerSourceToken source caller ability token.
156      * @param userId Designation User ID.
157      * @param requestCode the resultCode of the ability to start.
158      * @return Returns ERR_OK on success, others on failure.
159      */
160     virtual int StartAbilityAsCaller(
161         const Want &want,
162         const StartOptions &startOptions,
163         const sptr<IRemoteObject> &callerToken,
164         sptr<IRemoteObject> asCallerSourceToken,
165         int32_t userId = DEFAULT_INVAL_VALUE,
166         int requestCode = DEFAULT_INVAL_VALUE) override;
167 
168     /**
169      * Starts a new ability for result using the original caller information.
170      *
171      * @param want the want of the ability to start.
172      * @param callerToken current caller ability token.
173      * @param requestCode the resultCode of the ability to start.
174      * @param userId Designation User ID.
175      * @return Returns ERR_OK on success, others on failure.
176      */
177     int StartAbilityForResultAsCaller(
178         const Want &want,
179         const sptr<IRemoteObject> &callerToken,
180         int requestCode = DEFAULT_INVAL_VALUE,
181         int32_t userId = DEFAULT_INVAL_VALUE) override;
182 
183     /**
184      * Starts a new ability for result using the original caller information.
185      *
186      * @param want the want of the ability to start.
187      * @param startOptions Indicates the options used to start.
188      * @param callerToken current caller ability token.
189      * @param requestCode the resultCode of the ability to start.
190      * @param userId Designation User ID.
191      * @return Returns ERR_OK on success, others on failure.
192      */
193     int StartAbilityForResultAsCaller(
194         const Want &want,
195         const StartOptions &startOptions,
196         const sptr<IRemoteObject> &callerToken,
197         int requestCode = DEFAULT_INVAL_VALUE,
198         int32_t userId = DEFAULT_INVAL_VALUE) override;
199 
200     /**
201      * Start ui session ability with extension session info, send session info to ability manager service.
202      *
203      * @param want, the want of the ability to start.
204      * @param callerToken, caller ability token.
205      * @param sessionInfo the information of UIExtensionContentSession.
206      * @param userId, Designation User ID.
207      * @param requestCode, Ability request code.
208      * @return Returns ERR_OK on success, others on failure.
209      */
210     virtual int StartAbilityByUIContentSession(
211         const Want &want,
212         const sptr<IRemoteObject> &callerToken,
213         const sptr<SessionInfo> &sessionInfo,
214         int32_t userId = DEFAULT_INVAL_VALUE,
215         int requestCode = DEFAULT_INVAL_VALUE) override;
216 
217     /**
218      * Start ui session ability with extension session info, send session info to ability manager service.
219      *
220      * @param want, the want of the ability to start.
221      * @param startOptions Indicates the options used to start.
222      * @param callerToken, caller ability token.
223      * @param sessionInfo the information of UIExtensionContentSession.
224      * @param userId, Designation User ID.
225      * @param requestCode the resultCode of the ability to start.
226      * @return Returns ERR_OK on success, others on failure.
227      */
228     virtual int StartAbilityByUIContentSession(
229         const Want &want,
230         const StartOptions &startOptions,
231         const sptr<IRemoteObject> &callerToken,
232         const sptr<SessionInfo> &sessionInfo,
233         int32_t userId = DEFAULT_INVAL_VALUE,
234         int requestCode = DEFAULT_INVAL_VALUE) override;
235 
236     /**
237      * Start ui ability
238      *
239      * @param want the want of the ability to start.
240      * @param callerToken caller ability token.
241      * @param specifyTokenId The Caller ID.
242      * @return Returns ERR_OK on success, others on failure.
243      */
244     virtual int StartAbilityOnlyUIAbility(
245         const Want &want,
246         const sptr<IRemoteObject> &callerToken,
247         uint32_t specifyTokenId) override;
248 
249     /**
250      * Start extension ability with want, send want to ability manager service.
251      *
252      * @param want, the want of the ability to start.
253      * @param callerToken, caller ability token.
254      * @param userId, Designation User ID.
255      * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
256      * @return Returns ERR_OK on success, others on failure.
257      */
258     virtual int32_t StartExtensionAbility(
259         const Want &want,
260         const sptr<IRemoteObject> &callerToken,
261         int32_t userId = DEFAULT_INVAL_VALUE,
262         AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
263 
264     /**
265      * Create UIExtension with want, send want to ability manager service.
266      *
267      * @param want, the want of the ability to start.
268      * @return Returns ERR_OK on success, others on failure.
269      */
270     int RequestModalUIExtension(const Want &want) override;
271 
272     /**
273      * Preload UIExtension with want, send want to ability manager service.
274      *
275      * @param want, the want of the ability to start.
276      * @param hostBundleName, the caller application bundle name.
277      * @param userId, the extension runs in.
278      * @return Returns ERR_OK on success, others on failure.
279      */
280     int PreloadUIExtensionAbility(const Want &want, std::string &hostBundleName,
281         int32_t userId = DEFAULT_INVAL_VALUE) override;
282 
283     int ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow) override;
284 
285     int ChangeUIAbilityVisibilityBySCB(sptr<SessionInfo> sessionInfo, bool isShow) override;
286     /**
287      * Start ui extension ability with extension session info, send extension session info to ability manager service.
288      *
289      * @param extensionSessionInfo the extension session info of the ability to start.
290      * @param userId, Designation User ID.
291      * @return Returns ERR_OK on success, others on failure.
292      */
293     virtual int StartUIExtensionAbility(
294         const sptr<SessionInfo> &extensionSessionInfo,
295         int32_t userId = DEFAULT_INVAL_VALUE) override;
296 
297     /**
298      * Start ui ability with want, send want to ability manager service.
299      *
300      * @param sessionInfo the session info of the ability to start.
301      * @param isColdStart the session info of the ability is or not cold start.
302      * @return Returns ERR_OK on success, others on failure.
303      */
304     virtual int StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isColdStart, uint32_t sceneFlag = 0) override;
305 
306     /**
307      * Stop extension ability with want, send want to ability manager service.
308      *
309      * @param want, the want of the ability to stop.
310      * @param callerToken, caller ability token.
311      * @param userId, Designation User ID.
312      * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be stopped.
313      * @return Returns ERR_OK on success, others on failure.
314      */
315     virtual int StopExtensionAbility(
316         const Want& want,
317         const sptr<IRemoteObject>& callerToken,
318         int32_t userId = DEFAULT_INVAL_VALUE,
319         AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
320     /**
321      * TerminateAbility, terminate the special ability.
322      *
323      * @param token, the token of the ability to terminate.
324      * @param resultCode, the resultCode of the ability to terminate.
325      * @param resultWant, the Want of the ability to return.
326      * @return Returns ERR_OK on success, others on failure.
327      */
328     virtual int TerminateAbility(
329         const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override;
330 
331     /**
332      * BackToCallerAbilityWithResult, return to the caller ability.
333      *
334      * @param token, the token of the ability to terminate.
335      * @param resultCode, the resultCode of the ability to terminate.
336      * @param resultWant, the Want of the ability to return.
337      * @param callerRequestCode, the requestCode of caller ability.
338      * @return Returns ERR_OK on success, others on failure.
339      */
340     virtual int BackToCallerAbilityWithResult(const sptr<IRemoteObject> &token, int resultCode,
341         const Want *resultWant, int64_t callerRequestCode) override;
342 
343     /**
344      * TerminateUIServiceExtensionAbility, terminate UIServiceExtensionAbility.
345      *
346      * @param token, the token of the UIServiceExtensionAbility to terminate.
347      * @return Returns ERR_OK on success, others on failure.
348      */
349     virtual int32_t TerminateUIServiceExtensionAbility(const sptr<IRemoteObject> &token) override;
350 
351     /**
352      * TerminateUIExtensionAbility, terminate the special ui extension ability.
353      *
354      * @param extensionSessionInfo the extension session info of the ability to terminate.
355      * @param resultCode resultCode.
356      * @param Want Ability want returned.
357      * @return Returns ERR_OK on success, others on failure.
358      */
359     virtual int TerminateUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int resultCode,
360         const Want *resultWant) override;
361 
362     /**
363      * CloseUIAbilityBySCB, close the special ability by scb.
364      *
365      * @param sessionInfo the session info of the ability to terminate.
366      * @return Returns ERR_OK on success, others on failure.
367      */
368     virtual int CloseUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo) override;
369 
370     /**
371      * SendResultToAbility with want, return want from ability manager service.(Only used for dms)
372      *
373      * @param requestCode, request code.
374      * @param resultCode, resultCode to return.
375      * @param resultWant, the Want of the ability to return.
376      * @return Returns ERR_OK on success, others on failure.
377      */
378     virtual int SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant) override;
379 
380     /**
381      * MoveAbilityToBackground.
382      *
383      * @param token, the token of the ability to move.
384      * @return Returns ERR_OK on success, others on failure.
385      */
386     virtual int MoveAbilityToBackground(const sptr<IRemoteObject> &token) override;
387 
388     /**
389      * Move the UIAbility to background, called by app self.
390      *
391      * @param token the token of the ability to move.
392      * @return Returns ERR_OK on success, others on failure.
393      */
394     virtual int32_t MoveUIAbilityToBackground(const sptr<IRemoteObject> token) override;
395 
396     /**
397      * CloseAbility, close the special ability.
398      *
399      * @param token, the token of the ability to terminate.
400      * @param resultCode, the resultCode of the ability to terminate.
401      * @param resultWant, the Want of the ability to return.
402      * @return Returns ERR_OK on success, others on failure.
403      */
404     virtual int CloseAbility(
405         const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override;
406 
407     /**
408      * MinimizeAbility, minimize the special ability.
409      *
410      * @param token, ability token.
411      * @param fromUser mark the minimize operation source.
412      * @return Returns ERR_OK on success, others on failure.
413      */
414     virtual int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser = false) override;
415 
416     /**
417      * MinimizeUIExtensionAbility, minimize the special ui extension ability.
418      *
419      * @param extensionSessionInfo the extension session info of the ability to minimize.
420      * @param fromUser mark the minimize operation source.
421      * @return Returns ERR_OK on success, others on failure.
422      */
423     virtual int MinimizeUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo,
424         bool fromUser = false) override;
425 
426     /**
427      * MinimizeUIAbilityBySCB, minimize the special ability by scb.
428      *
429      * @param sessionInfo the session info of the ability to minimize.
430      * @param fromUser, Whether form user.
431      * @return Returns ERR_OK on success, others on failure.
432      */
433     virtual int MinimizeUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool fromUser = false,
434         uint32_t sceneFlag = 0) override;
435 
436     /**
437      * ConnectAbility, connect session with service ability.
438      *
439      * @param want, Special want for service type's ability.
440      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
441      * @param callerToken, caller ability token.
442      * @param userId, Designation User ID.
443      * @return Returns ERR_OK on success, others on failure.
444      */
445     virtual int ConnectAbility(
446         const Want &want,
447         const sptr<IAbilityConnection> &connect,
448         const sptr<IRemoteObject> &callerToken,
449         int32_t userId = DEFAULT_INVAL_VALUE) override;
450 
451     virtual int ConnectAbilityCommon(
452         const Want &want,
453         const sptr<IAbilityConnection> &connect,
454         const sptr<IRemoteObject> &callerToken,
455         AppExecFwk::ExtensionAbilityType extensionType,
456         int32_t userId = DEFAULT_INVAL_VALUE,
457         bool isQueryExtensionOnly = false) override;
458 
459     virtual int ConnectUIExtensionAbility(
460         const Want &want,
461         const sptr<IAbilityConnection> &connect,
462         const sptr<SessionInfo> &sessionInfo,
463         int32_t userId = DEFAULT_INVAL_VALUE,
464         sptr<UIExtensionAbilityConnectInfo> connectInfo = nullptr) override;
465 
466     /**
467      * DisconnectAbility, connect session with service ability.
468      *
469      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
470      * @return Returns ERR_OK on success, others on failure.
471      */
472     virtual int DisconnectAbility(sptr<IAbilityConnection> connect) override;
473 
474     /**
475      * AcquireDataAbility, acquire a data ability by its authority, if it not existed,
476      * AMS loads it synchronously.
477      *
478      * @param uri, data ability uri.
479      * @param isKill, true: when a data ability is died, ams will kill this client, or do nothing.
480      * @param callerToken, specifies the caller ability token.
481      * @return returns the data ability ipc object, or nullptr for failed.
482      */
483     virtual sptr<IAbilityScheduler> AcquireDataAbility(
484         const Uri &uri, bool isKill, const sptr<IRemoteObject> &callerToken) override;
485 
486     /**
487      * ReleaseDataAbility, release the data ability that referenced by 'dataAbilityToken'.
488      *
489      * @param dataAbilityScheduler, specifies the data ability that will be released.
490      * @param callerToken, specifies the caller ability token.
491      * @return returns ERR_OK if succeeded, or error codes for failed.
492      */
493     virtual int ReleaseDataAbility(
494         sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken) override;
495 
496     /**
497      * AttachAbilityThread, ability call this interface after loaded.
498      *
499      * @param scheduler,.the interface handler of kit ability.
500      * @param token,.ability's token.
501      * @return Returns ERR_OK on success, others on failure.
502      */
503     virtual int AttachAbilityThread(
504         const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override;
505 
506     /**
507      * AbilityTransitionDone, ability call this interface after lift cycle was changed.
508      *
509      * @param token,.ability's token.
510      * @param state,.the state of ability lift cycle.
511      * @return Returns ERR_OK on success, others on failure.
512      */
513     virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
514 
515     /**
516      * AbilityWindowConfigTransitionDone, ability call this interface after lift cycle was changed.
517      *
518      * @param token,.ability's token.
519      * @return Returns ERR_OK on success, others on failure.
520      */
521     virtual int AbilityWindowConfigTransitionDone(
522         const sptr<IRemoteObject> &token, const WindowConfig &windowConfig) override;
523 
524     /**
525      * ScheduleConnectAbilityDone, service ability call this interface while session was connected.
526      *
527      * @param token,.service ability's token.
528      * @param remoteObject,.the session proxy of service ability.
529      * @return Returns ERR_OK on success, others on failure.
530      */
531     virtual int ScheduleConnectAbilityDone(
532         const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override;
533 
534     /**
535      * ScheduleDisconnectAbilityDone, service ability call this interface while session was disconnected.
536      *
537      * @param token,.service ability's token.
538      * @return Returns ERR_OK on success, others on failure.
539      */
540     virtual int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override;
541 
542     /**
543      * ScheduleCommandAbilityDone, service ability call this interface while session was commanded.
544      *
545      * @param token,.service ability's token.
546      * @return Returns ERR_OK on success, others on failure.
547      */
548     virtual int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override;
549 
550     virtual int ScheduleCommandAbilityWindowDone(
551         const sptr<IRemoteObject> &token,
552         const sptr<SessionInfo> &sessionInfo,
553         WindowCommand winCmd,
554         AbilityCommand abilityCmd) override;
555 
556     /**
557      * dump ability stack info, about userID, mission stack info,
558      * mission record info and ability info.
559      *
560      * @param state Ability stack info.
561      * @return Returns ERR_OK on success, others on failure.
562      */
563     virtual void DumpState(const std::string &args, std::vector<std::string> &state) override;
564     virtual void DumpSysState(
565         const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int UserID) override;
566 
567     /**
568      * Destroys this Service ability by Want.
569      *
570      * @param want, Special want for service type's ability.
571      * @param token ability's token.
572      * @return Returns true if this Service ability will be destroyed; returns false otherwise.
573      */
574     virtual int StopServiceAbility(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE,
575         const sptr<IRemoteObject> &token = nullptr) override;
576 
577     /**
578      * Get top ability.
579      *
580      * @param isNeedLocalDeviceId is need local device id.
581      * @return Returns front desk focus ability elementName.
582      */
583     virtual AppExecFwk::ElementName GetTopAbility(bool isNeedLocalDeviceId = true) override;
584 
585     /**
586      * Get element name by token.
587      *
588      * @param token ability's token.
589      * @param isNeedLocalDeviceId is need local device id.
590      * @return Returns front desk focus ability elementName by token.
591      */
592     virtual AppExecFwk::ElementName GetElementNameByToken(sptr<IRemoteObject> token,
593         bool isNeedLocalDeviceId = true) override;
594 
595     /**
596      * Kill the process immediately.
597      *
598      * @param bundleName.
599      * @return Returns ERR_OK on success, others on failure.
600      */
601     virtual int KillProcess(const std::string &bundleName, const bool clearPageStack = false) override;
602 
603     #ifdef ABILITY_COMMAND_FOR_TEST
604     /**
605      * force timeout ability.
606      *
607      * @param abilityName.
608      * @param state.
609      * @return Returns ERR_OK on success, others on failure.
610      */
611     virtual int ForceTimeoutForTest(const std::string &abilityName, const std::string &state) override;
612     #endif
613 
614     /**
615      * Uninstall app
616      *
617      * @param bundleName bundle name of uninstalling app.
618      * @param uid uid of bundle.
619      * @return Returns ERR_OK on success, others on failure.
620      */
621     virtual int UninstallApp(const std::string &bundleName, int32_t uid) override;
622 
623     /**
624      * Uninstall app
625      *
626      * @param bundleName bundle name of uninstalling app.
627      * @param uid uid of bundle.
628      * @param appIndex the app index of app clone.
629      * @return Returns ERR_OK on success, others on failure.
630      */
631     virtual int32_t UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex) override;
632 
633     /**
634      * Upgrade app, record exit reason and kill application
635      *
636      * @param bundleName bundle name of upgrading app.
637      * @param uid uid of bundle.
638      * @param exitMsg the exit reason message.
639      * @param appIndex the app index of app clone.
640      * @return Returns ERR_OK on success, others on failure.
641      */
642     virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg,
643         int32_t appIndex = 0) override;
644 
645     virtual sptr<IWantSender> GetWantSender(
646         const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override;
647 
648     virtual int SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo) override;
649 
650     virtual void CancelWantSender(const sptr<IWantSender> &sender) override;
651 
652     virtual int GetPendingWantUid(const sptr<IWantSender> &target) override;
653 
654     virtual int GetPendingWantUserId(const sptr<IWantSender> &target) override;
655 
656     virtual std::string GetPendingWantBundleName(const sptr<IWantSender> &target) override;
657 
658     virtual int GetPendingWantCode(const sptr<IWantSender> &target) override;
659 
660     virtual int GetPendingWantType(const sptr<IWantSender> &target) override;
661 
662     virtual void RegisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override;
663 
664     virtual void UnregisterCancelListener(
665         const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override;
666 
667     virtual int GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want) override;
668 
669     virtual int GetWantSenderInfo(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info) override;
670 
671     virtual int GetAppMemorySize() override;
672 
673     virtual bool IsRamConstrainedDevice() override;
674     virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId,
675         int32_t missionId, const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams) override;
676 
677     virtual int ContinueMission(AAFwk::ContinueMissionInfo continueMissionInfo,
678         const sptr<IRemoteObject> &callback) override;
679 
680     virtual int ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode) override;
681 
682     virtual int StartContinuation(const Want &want, const sptr<IRemoteObject> &abilityToken, int32_t status) override;
683 
684     virtual void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess) override;
685 
686     virtual int NotifyContinuationResult(int32_t missionId, int32_t result) override;
687 
688     virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
689 
690     virtual int StopSyncRemoteMissions(const std::string& devId) override;
691 
692     virtual int LockMissionForCleanup(int32_t missionId) override;
693 
694     virtual int UnlockMissionForCleanup(int32_t missionId) override;
695 
696     virtual void SetLockedState(int32_t sessionId, bool lockedState) override;
697 
698     /**
699      * @brief Register mission listener to ability mgr.
700      * @param listener The handler of listener.
701      *
702      * @return Returns ERR_OK on success, others on failure.
703      */
704     virtual int RegisterMissionListener(const sptr<IMissionListener> &listener) override;
705 
706     /**
707      * @brief UnRegister mission listener from ability mgr.
708      * @param listener The handler of listener.
709      *
710      * @return Returns ERR_OK on success, others on failure.
711      */
712     virtual int UnRegisterMissionListener(const sptr<IMissionListener> &listener) override;
713 
714     /**
715      * @brief Get mission infos from ability mgr.
716      * @param deviceId local or remote deviceId.
717      * @param numMax max number of missions.
718      * @param missionInfos mission info result.
719      *
720      * @return Returns ERR_OK on success, others on failure.
721      */
722     virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax,
723         std::vector<MissionInfo> &missionInfos) override;
724 
725     /**
726      * @brief Get mission info by id.
727      * @param deviceId local or remote deviceId.
728      * @param missionId Id of target mission.
729      * @param missionInfo mission info of target mission.
730      *
731      * @return Returns ERR_OK on success, others on failure.
732      */
733     virtual int GetMissionInfo(const std::string& deviceId, int32_t missionId,
734         MissionInfo &missionInfos) override;
735 
736     /**
737      * @brief Clean mission by id.
738      * @param missionId Id of target mission.
739      *
740      * @return Returns ERR_OK on success, others on failure.
741      */
742     virtual int CleanMission(int32_t missionId) override;
743 
744     /**
745      * @brief Clean all missions in system.
746      *
747      * @return Returns ERR_OK on success, others on failure.
748      */
749     virtual int CleanAllMissions() override;
750 
751     virtual int MoveMissionToFront(int32_t missionId) override;
752 
753     /**
754      * @brief Move a mission to front.
755      * @param missionId Id of target mission.
756      * @param startOptions Special startOptions for target mission.
757      *
758      * @return Returns ERR_OK on success, others on failure.
759      */
760     virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override;
761 
762     /**
763      * Move missions to front
764      * @param missionIds Ids of target missions
765      * @param topMissionId Indicate which mission will be moved to top, if set to -1, missions' order won't change
766      * @return Returns ERR_OK on success, others on failure.
767      */
768     virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override;
769 
770     /**
771      * Move missions to background
772      * @param missionIds Ids of target missions
773      * @param result The result of move missions to background, and the array is sorted by zOrder
774      * @return Returns ERR_OK on success, others on failure.
775      */
776     virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
777         std::vector<int32_t>& result) override;
778 
779     /**
780      * Start Ability, connect session with common ability.
781      *
782      * @param want, Special want for service type's ability.
783      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
784      * @param accountId Indicates the account to start.
785      * @return Returns ERR_OK on success, others on failure.
786      */
787     virtual int StartAbilityByCall(const Want &want, const sptr<IAbilityConnection> &connect,
788         const sptr<IRemoteObject> &callerToken, int32_t accountId = DEFAULT_INVAL_VALUE) override;
789 
790     /**
791      * CallRequestDone, after invoke callRequest, ability will call this interface to return callee.
792      *
793      * @param token, ability's token.
794      * @param callStub, ability's callee.
795      */
796     void CallRequestDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callStub) override;
797 
798     /**
799      * Release the call between Ability, disconnect session with common ability.
800      *
801      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
802      * @param element, the element of target service.
803      * @return Returns ERR_OK on success, others on failure.
804      */
805     virtual int ReleaseCall(
806         const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) override;
807 
808     /**
809      * @brief start user.
810      * @param accountId accountId.
811      * @param isAppRecovery is appRecovery or not.
812      * @return Returns ERR_OK on success, others on failure.
813      */
814     virtual int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery = false) override;
815 
816     /**
817      * @brief stop user.
818      * @param accountId accountId.
819      * @param callback callback.
820      *
821      * @return Returns ERR_OK on success, others on failure.
822      */
823     virtual int StopUser(int userId, const sptr<IUserCallback> &callback) override;
824 
825     /**
826      * @brief logout user.
827      * @param accountId accountId.
828      *
829      * @return Returns ERR_OK on success, others on failure.
830      */
831     virtual int LogoutUser(int32_t userId) override;
832 
833     virtual int SetMissionContinueState(const sptr<IRemoteObject> &token, const AAFwk::ContinueState &state) override;
834 
835 #ifdef SUPPORT_SCREEN
836     virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override;
837 
838     virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
839         const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
840 
841     virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler,
842         bool animationEnabled) override;
843 
844     virtual void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) override;
845 
846     virtual void CompleteFirstFrameDrawing(int32_t sessionId) override;
847 
848     virtual int PrepareTerminateAbility(
849         const sptr<IRemoteObject> &token, sptr<IPrepareTerminateCallback> &callback) override;
850 
851     virtual int GetDialogSessionInfo(const std::string &dialogSessionId, sptr<DialogSessionInfo> &info) override;
852 
853     virtual int SendDialogResult(const Want &want, const std::string &dialogSessionId, bool isAllow) override;
854 
855     virtual int RegisterAbilityFirstFrameStateObserver(const sptr<IAbilityFirstFrameStateObserver> &observer,
856         const std::string &targetBundleName) override;
857 
858     virtual int UnregisterAbilityFirstFrameStateObserver(
859         const sptr<IAbilityFirstFrameStateObserver> &observer) override;
860 #endif
861     /**
862      * @brief Get the ability running information.
863      *
864      * @param info Ability running information.
865      * @return Returns ERR_OK on success, others on failure.
866      */
867     virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) override;
868 
869     /**
870      * @brief Get the extension running information.
871      *
872      * @param upperLimit The maximum limit of information wish to get.
873      * @param info Extension running information.
874      * @return Returns ERR_OK on success, others on failure.
875      */
876     virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) override;
877 
878     /**
879      * @brief Get running process information.
880      *
881      * @param info Running process information.
882      * @return Returns ERR_OK on success, others on failure.
883      */
884     virtual int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) override;
885 
886     /**
887      * @brief Register mission listener to ability manager service.
888      * @param deviceId The remote device Id.
889      * @param listener The handler of listener.
890      *
891      * @return Returns ERR_OK on success, others on failure.
892      */
893     virtual int RegisterMissionListener(const std::string &deviceId,
894         const sptr<IRemoteMissionListener> &listener) override;
895 
896     virtual int RegisterOnListener(const std::string &type,
897         const sptr<IRemoteOnListener> &listener) override;
898 
899     virtual int RegisterOffListener(const std::string &deviceId,
900         const sptr<IRemoteOnListener> &listener) override;
901 
902     virtual int UnRegisterMissionListener(const std::string &deviceId,
903         const sptr<IRemoteMissionListener> &listener) override;
904 
905     /**
906      * Set ability controller.
907      *
908      * @param abilityController, The ability controller.
909      * @return Returns ERR_OK on success, others on failure.
910      */
911     virtual int SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController,
912         bool imAStabilityTest) override;
913 
914     /**
915      * Is user a stability test.
916      *
917      * @return Returns true if user is a stability test.
918      */
919     virtual bool IsRunningInStabilityTest() override;
920 
921     /**
922      * @brief Register the snapshot handler
923      * @param handler snapshot handler
924      * @return ErrCode Returns ERR_OK on success, others on failure.
925      */
926     virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
927 
928     /**
929      * @brief Get the Mission Snapshot Info object
930      * @param deviceId local or remote deviceId.
931      * @param missionId Id of target mission.
932      * @param snapshot snapshot of target mission.
933      * @param isLowResolution get low resolution snapshot.
934      * @return Returns ERR_OK on success, others on failure.
935      */
936     virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
937         MissionSnapshot& snapshot, bool isLowResolution) override;
938 
939     /**
940      * @brief start user test.
941      * @param want the want of the ability user test to start.
942      * @param observer test observer callback.
943      *
944      * @return Returns ERR_OK on success, others on failure.
945      */
946     virtual int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) override;
947 
948     /**
949      * @brief Finish user test.
950      * @param msg user test message.
951      * @param resultCode user test result Code.
952      * @param bundleName user test bundleName.
953      *
954      * @return Returns ERR_OK on success, others on failure.
955      */
956     virtual int FinishUserTest(
957         const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override;
958 
959      /**
960      * GetTopAbility, get the token of top ability.
961      *
962      * @param token, the token of top ability.
963      * @return Returns ERR_OK on success, others on failure.
964      */
965     virtual int GetTopAbility(sptr<IRemoteObject> &token) override;
966 
967     virtual int CheckUIExtensionIsFocused(uint32_t uiExtensionTokenId, bool& isFocused) override;
968 
969     /**
970      * The delegator calls this interface to move the ability to the foreground.
971      *
972      * @param token, ability's token.
973      * @return Returns ERR_OK on success, others on failure.
974      */
975     virtual int DelegatorDoAbilityForeground(const sptr<IRemoteObject> &token) override;
976 
977     /**
978      * The delegator calls this interface to move the ability to the background.
979      *
980      * @param token, ability's token.
981      * @return Returns ERR_OK on success, others on failure.
982      */
983     virtual int DelegatorDoAbilityBackground(const sptr<IRemoteObject> &token) override;
984 
985     /**
986      * Calls this interface to move the ability to the foreground.
987      *
988      * @param token, ability's token.
989      * @param flag, use for lock or unlock flag and so on.
990      * @return Returns ERR_OK on success, others on failure.
991      */
992     virtual int DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag) override;
993 
994     /**
995      * Calls this interface to move the ability to the background.
996      *
997      * @param token, ability's token.
998      * @param flag, use for lock or unlock flag and so on.
999      * @return Returns ERR_OK on success, others on failure.
1000      */
1001     virtual int DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag) override;
1002 
1003     /**
1004      * Get mission id by ability token.
1005      *
1006      * @param token The token of ability.
1007      * @return Returns -1 if do not find mission, otherwise return mission id.
1008      */
1009     virtual int32_t GetMissionIdByToken(const sptr<IRemoteObject> &token) override;
1010 
1011     /**
1012      * Get ability token by connect.
1013      *
1014      * @param token The token of ability.
1015      * @param callStub The callee object.
1016      */
1017     void GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token) override;
1018 
1019     /**
1020      * Call free install from remote.
1021      *
1022      * @param want, the want of the ability to start.
1023      * @param userId, Designation User ID.
1024      * @param requestCode, Ability request code.
1025      * @param callback, Callback from remote.
1026      * @return Returns ERR_OK on success, others on failure.
1027      */
1028     virtual int FreeInstallAbilityFromRemote(const Want &want, const sptr<IRemoteObject> &callback,
1029         int32_t userId, int requestCode = DEFAULT_INVAL_VALUE) override;
1030 
1031     /**
1032      * Add FreeInstall Observer
1033      *
1034      * @param observer the observer of ability free install start.
1035      * @return Returns ERR_OK on success, others on failure.
1036      */
1037     virtual int AddFreeInstallObserver(const sptr<IRemoteObject> &callerToken,
1038         const sptr<AbilityRuntime::IFreeInstallObserver> &observer) override;
1039 
1040     /**
1041      * Called when client complete dump.
1042      *
1043      * @param infos The dump info.
1044      * @return Returns ERR_OK on success, others on failure.
1045      */
1046     virtual int DumpAbilityInfoDone(std::vector<std::string> &infos, const sptr<IRemoteObject> &callerToken) override;
1047 
1048     /**
1049      * Called to update mission snapshot.
1050      * @param token The target ability.
1051      * @param pixelMap The snapshot.
1052      */
1053 #ifdef SUPPORT_SCREEN
1054     virtual void UpdateMissionSnapShot(const sptr<IRemoteObject> &token,
1055         const std::shared_ptr<Media::PixelMap> &pixelMap) override;
1056 #endif // SUPPORT_SCREEN
1057     virtual void EnableRecoverAbility(const sptr<IRemoteObject>& token) override;
1058     virtual void SubmitSaveRecoveryInfo(const sptr<IRemoteObject>& token) override;
1059     virtual void ScheduleRecoverAbility(const sptr<IRemoteObject> &token, int32_t reason,
1060         const Want *want = nullptr) override;
1061 
1062     /**
1063      * @brief Schedule clear recovery page stack.
1064      *
1065      * @param bundleName application bundleName.
1066      */
1067     virtual void ScheduleClearRecoveryPageStack() override;
1068 
1069     /**
1070      * Called to verify that the MissionId is valid.
1071      * @param missionIds Query mission list.
1072      * @param results Output parameters, return results up to 20 query results.
1073      * @return Returns ERR_OK on success, others on failure.
1074      */
1075     int32_t IsValidMissionIds(
1076         const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results) override;
1077 
1078     /**
1079      * Query whether the application of the specified PID and UID has been granted a certain permission
1080      * @param permission
1081      * @param pid Process id
1082      * @param uid
1083      * @return Returns ERR_OK if the current process has the permission, others on failure.
1084      */
1085     virtual int VerifyPermission(const std::string &permission, int pid, int uid) override;
1086 
1087     /**
1088      * Request dialog service with want, send want to ability manager service.
1089      *
1090      * @param want, the want of the dialog service to start.
1091      * @param callerToken, caller ability token.
1092      * @return Returns ERR_OK on success, others on failure.
1093      */
1094     virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override;
1095 
1096     int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) override;
1097 
1098     virtual int32_t AcquireShareData(
1099         const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override;
1100     virtual int32_t ShareDataDone(const sptr<IRemoteObject> &token,
1101         const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam) override;
1102 
1103     /**
1104      * Force app exit and record exit reason.
1105      * @param pid Process id .
1106      * @param exitReason The reason of app exit.
1107      * @return Returns ERR_OK on success, others on failure.
1108      */
1109     virtual int32_t ForceExitApp(const int32_t pid, const ExitReason &exitReason) override;
1110 
1111     /**
1112      * Record app exit reason.
1113      * @param exitReason The reason of app exit.
1114      * @return Returns ERR_OK on success, others on failure.
1115      */
1116     virtual int32_t RecordAppExitReason(const ExitReason &exitReason) override;
1117 
1118     /**
1119      * Record the process exit reason before the process being killed.
1120      * @param pid The process id.
1121      * @param exitReason The reason of process exit.
1122      * @return Returns ERR_OK on success, others on failure.
1123      */
1124     virtual int32_t RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason) override;
1125 
1126     /**
1127      * Set rootSceneSession by SCB.
1128      *
1129      * @param rootSceneSession Indicates root scene session of SCB.
1130      */
1131     virtual void SetRootSceneSession(const sptr<IRemoteObject> &rootSceneSession) override;
1132 
1133     /**
1134      * Call UIAbility by SCB.
1135      *
1136      * @param sessionInfo the session info of the ability to be called.
1137      * @param isColdStart the session of the ability is or not cold start.
1138      */
1139     virtual void CallUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isColdStart) override;
1140 
1141     /**
1142      * Start specified ability by SCB.
1143      *
1144      * @param want Want information.
1145      */
1146     void StartSpecifiedAbilityBySCB(const Want &want) override;
1147 
1148     /**
1149      * Notify sandbox app the result of saving file.
1150      * @param want Result of saving file, which contains the file's uri if success.
1151      * @param resultCode Indicates the action's result.
1152      * @param requestCode Pass the requestCode to match request.
1153      * @return Returns ERR_OK on success, others on failure.
1154      */
1155     virtual int32_t NotifySaveAsResult(const Want &want, int resultCode, int requestCode) override;
1156 
1157     /**
1158      * Set sessionManagerService
1159      * @param sessionManagerService the point of sessionManagerService.
1160      *
1161      * @return Returns ERR_OK on success, others on failure.
1162      */
1163     virtual int32_t SetSessionManagerService(const sptr<IRemoteObject> &sessionManagerService) override;
1164 
1165     /**
1166      * @brief Register collaborator.
1167      * @param type collaborator type.
1168      * @param impl collaborator.
1169      * @return 0 or else.
1170     */
1171     virtual int32_t RegisterIAbilityManagerCollaborator(
1172         int32_t type, const sptr<IAbilityManagerCollaborator> &impl) override;
1173 
1174     /**
1175      * @brief Unregister collaborator.
1176      * @param type collaborator type.
1177      * @return 0 or else.
1178     */
1179     virtual int32_t UnregisterIAbilityManagerCollaborator(int32_t type) override;
1180 
1181     virtual int32_t RegisterStatusBarDelegate(sptr<AbilityRuntime::IStatusBarDelegate> delegate) override;
1182 
1183     virtual int32_t KillProcessWithPrepareTerminate(const std::vector<int32_t>& pids) override;
1184 
1185     /**
1186      * @brief Register auto start up callback for system api.
1187      * @param callback The point of JsAbilityAutoStartupCallBack.
1188      * @return Returns ERR_OK on success, others on failure.
1189      */
1190     virtual int32_t RegisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback) override;
1191 
1192     /**
1193      * @brief Unregister auto start up callback for system api.
1194      * @param callback The point of JsAbilityAutoStartupCallBack.
1195      * @return Returns ERR_OK on success, others on failure.
1196      */
1197     virtual int32_t UnregisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback) override;
1198 
1199     /**
1200      * @brief Set every application auto start up state.
1201      * @param info The auto startup info,include bundle name, module name, ability name.
1202      * @return Returns ERR_OK on success, others on failure.
1203      */
1204     virtual int32_t SetApplicationAutoStartup(const AutoStartupInfo &info) override;
1205 
1206     /**
1207      * @brief Cancel every application auto start up .
1208      * @param info The auto startup info,include bundle name, module name, ability name.
1209      * @return Returns ERR_OK on success, others on failure.
1210      */
1211     virtual int32_t CancelApplicationAutoStartup(const AutoStartupInfo &info) override;
1212 
1213     /**
1214      * @brief Query auto startup state all application.
1215      * @param infoList Output parameters, return auto startup info list.
1216      * @return Returns ERR_OK on success, others on failure.
1217      */
1218     virtual int32_t QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList) override;
1219 
1220     /**
1221      * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb.
1222      *
1223      * @param sessionInfo the session info of the ability to start.
1224      * @param isPrepareTerminate the result of ability onPrepareToTerminate.
1225      * @return Returns ERR_OK on success, others on failure.
1226      */
1227     virtual int PrepareTerminateAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isPrepareTerminate) override;
1228 
1229     /**
1230      * @brief Register session handler.
1231      * @param object The handler.
1232      *
1233      * @return Returns ERR_OK on success, others on failure.
1234     */
1235     virtual int RegisterSessionHandler(const sptr<IRemoteObject> &object) override;
1236 
1237     /**
1238      * @brief Register app debug listener.
1239      * @param listener App debug listener.
1240      * @return Returns ERR_OK on success, others on failure.
1241      */
1242     int32_t RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override;
1243 
1244     /**
1245      * @brief Unregister app debug listener.
1246      * @param listener App debug listener.
1247      * @return Returns ERR_OK on success, others on failure.
1248      */
1249     int32_t UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override;
1250 
1251     /**
1252      * @brief Attach app debug.
1253      * @param bundleName The application bundle name.
1254      * @return Returns ERR_OK on success, others on failure.
1255      */
1256     int32_t AttachAppDebug(const std::string &bundleName) override;
1257 
1258     /**
1259      * @brief Detach app debug.
1260      * @param bundleName The application bundle name.
1261      * @return Returns ERR_OK on success, others on failure.
1262      */
1263     int32_t DetachAppDebug(const std::string &bundleName) override;
1264 
1265     /**
1266      * @brief Execute intent.
1267      * @param key The key of intent executing client.
1268      * @param callerToken Caller ability token.
1269      * @param param The Intent execute param.
1270      * @return Returns ERR_OK on success, others on failure.
1271      */
1272     int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken,
1273         const InsightIntentExecuteParam &param) override;
1274 
1275     /**
1276      * @brief Check if ability controller can start.
1277      * @param want The want of ability to start.
1278      * @return Return true to allow ability to start, or false to reject.
1279      */
1280     virtual bool IsAbilityControllerStart(const Want &want) override;
1281 
1282     /**
1283      * @brief Called when insight intent execute finished.
1284      *
1285      * @param token ability's token.
1286      * @param intentId insight intent id.
1287      * @param result insight intent execute result.
1288      * @return Returns ERR_OK on success, others on failure.
1289      */
1290     int32_t ExecuteInsightIntentDone(const sptr<IRemoteObject> &token, uint64_t intentId,
1291         const InsightIntentExecuteResult &result) override;
1292 
1293     /**
1294      * @brief Set application auto start up state by EDM.
1295      * @param info The auto startup info, include bundle name, module name, ability name.
1296      * @param flag Indicate whether to allow the application to change the auto start up state.
1297      * @return Returns ERR_OK on success, others on failure.
1298      */
1299     int32_t SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override;
1300 
1301     /**
1302      * @brief Cancel application auto start up state by EDM.
1303      * @param info The auto startup info, include bundle name, module name, ability name.
1304      * @param flag Indicate whether to allow the application to change the auto start up state.
1305      * @return Returns ERR_OK on success, others on failure.
1306      */
1307     int32_t CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override;
1308 
1309     /**
1310      * @brief Get foreground ui abilities.
1311      * @param list Foreground ui abilities.
1312      * @return Returns ERR_OK on success, others on failure.
1313      */
1314     int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list) override;
1315 
1316     /**
1317      * @brief Open file by uri.
1318      * @param uri The file uri.
1319      * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION.
1320      * @return int The file descriptor.
1321      */
1322     virtual int32_t OpenFile(const Uri& uri, uint32_t flag) override;
1323 
1324     /**
1325      * @brief Update session info.
1326      * @param sessionInfos The vector of session info.
1327      */
1328     virtual int32_t UpdateSessionInfoBySCB(std::list<SessionInfo> &sessionInfos, int32_t userId,
1329         std::vector<int32_t> &sessionIds) override;
1330 
1331     /**
1332      * @brief Restart app self.
1333      * @param want The ability type must be UIAbility.
1334      * @param isAppRecovery True indicates that the app is restarted because of recovery.
1335      * @return Returns ERR_OK on success, others on failure.
1336      */
1337     int32_t RestartApp(const AAFwk::Want &want, bool isAppRecovery = false) override;
1338 
1339     /**
1340      * @brief Get host info of root caller.
1341      *
1342      * @param token The ability token.
1343      * @param hostInfo The host info of root caller.
1344      * @param userId The user id.
1345      * @return int32_t Returns 0 on success, others on failure.
1346      */
1347     int32_t GetUIExtensionRootHostInfo(const sptr<IRemoteObject> token, UIExtensionHostInfo &hostInfo,
1348         int32_t userId = DEFAULT_INVAL_VALUE) override;
1349 
1350     /**
1351      * @brief Get ui extension session info
1352      *
1353      * @param token The ability token.
1354      * @param uiExtensionSessionInfo The ui extension session info.
1355      * @param userId The user id.
1356      * @return int32_t Returns ERR_OK on success, others on failure.
1357      */
1358     int32_t GetUIExtensionSessionInfo(const sptr<IRemoteObject> token, UIExtensionSessionInfo &uiExtensionSessionInfo,
1359         int32_t userId = DEFAULT_INVAL_VALUE) override;
1360 
1361     /**
1362      * @brief Pop-up launch of full-screen atomic service.
1363      * @param want The want with parameters.
1364      * @param callerToken caller ability token.
1365      * @param requestCode Ability request code.
1366      * @param userId The User ID.
1367      * @return Returns ERR_OK on success, others on failure.
1368      */
1369     virtual int32_t OpenAtomicService(Want& want, const StartOptions &options, sptr<IRemoteObject> callerToken,
1370         int32_t requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE) override;
1371 
1372     /**
1373      * @brief Querying whether to allow embedded startup of atomic service.
1374      *
1375      * @param token The caller UIAbility token.
1376      * @param appId The ID of the application to which this bundle belongs.
1377      * @return Returns true to allow ability to start, or false to reject.
1378      */
1379     virtual bool IsEmbeddedOpenAllowed(sptr<IRemoteObject> callerToken, const std::string &appId) override;
1380 
1381     /**
1382      * Set the enable status for starting and stopping resident processes.
1383      * The caller application can only set the resident status of the configured process.
1384      * @param bundleName The bundle name of the resident process.
1385      * @param enable Set resident process enable status.
1386      * @return Returns ERR_OK on success, others on failure.
1387      */
1388     int32_t SetResidentProcessEnabled(const std::string &bundleName, bool enable) override;
1389 
1390     /**
1391      * @brief Request to display assert fault dialog.
1392      * @param callback Listen for user operation callbacks.
1393      * @param wantParams Assert dialog box display information.
1394      * @return Returns ERR_OK on success, others on failure.
1395      */
1396     virtual int32_t RequestAssertFaultDialog(
1397         const sptr<IRemoteObject> &callback, const AAFwk::WantParams &wantParams) override;
1398 
1399     /**
1400      * @brief Notify the operation status of the user.
1401      * @param assertFaultSessionId Indicates the request ID of AssertFault.
1402      * @param userStatus Operation status of the user.
1403      * @return Returns ERR_OK on success, others on failure.
1404      */
1405     virtual int32_t NotifyDebugAssertResult(uint64_t assertFaultSessionId, AAFwk::UserStatus userStatus) override;
1406 
1407     /**
1408      * Starts a new ability with specific start options.
1409      *
1410      * @param want, the want of the ability to start.
1411      * @param startOptions Indicates the options used to start.
1412      * @return Returns ERR_OK on success, others on failure.
1413      */
1414     virtual int32_t StartShortcut(const Want &want, const StartOptions &startOptions) override;
1415 
1416     /**
1417      * Get ability state by persistent id.
1418      *
1419      * @param persistentId, the persistentId of the session.
1420      * @param state Indicates the ability state.
1421      * @return Returns ERR_OK on success, others on failure.
1422      */
1423     virtual int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state) override;
1424 
1425     /**
1426      * Transfer resultCode & want to ability manager service.
1427      *
1428      * @param callerToken caller ability token.
1429      * @param requestCode the resultCode of the ability to start.
1430      * @param want Indicates the ability to start.
1431      * @return Returns ERR_OK on success, others on failure.
1432      */
1433     virtual int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode,
1434         const Want &want) override;
1435 
1436     /**
1437      * Notify ability manager service frozen process.
1438      *
1439      * @param pidList, the pid list of the frozen process.
1440      * @param uid, the uid of the frozen process.
1441      */
1442     virtual void NotifyFrozenProcessByRSS(const std::vector<int32_t> &pidList, int32_t uid) override;
1443 
1444     /**
1445      * Open atomic service window prior to finishing free install.
1446      *
1447      * @param bundleName, the bundle name of the atomic service.
1448      * @param moduleName, the module name of the atomic service.
1449      * @param abilityName, the ability name of the atomic service.
1450      * @param startTime, the starting time of the free install task.
1451      * @return Returns ERR_OK on success, others on failure.
1452      */
1453     virtual int32_t PreStartMission(const std::string& bundleName, const std::string& moduleName,
1454         const std::string& abilityName, const std::string& startTime) override;
1455 
1456     /**
1457      *  Request to clean UIAbility from user.
1458      *
1459      * @param sessionInfo the session info of the ability to clean.
1460      * @return Returns ERR_OK on success, others on failure.
1461      */
1462     virtual int32_t CleanUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo) override;
1463 
1464     /**
1465      * Open link of ability and atomic service.
1466      *
1467      * @param want Ability want.
1468      * @param callerToken Caller ability token.
1469      * @param userId User ID.
1470      * @param requestCode Ability request code.
1471      * @return Returns ERR_OK on success, others on failure.
1472     */
1473     virtual int32_t OpenLink(const Want& want, sptr<IRemoteObject> callerToken,
1474         int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE) override;
1475 
1476     /**
1477      * Terminate the mission.
1478      *
1479      * @param missionId, The mission id of the UIAbility need to be terminated.
1480      * @return Returns ERR_OK on success, others on failure.
1481      */
1482     virtual int32_t TerminateMission(int32_t missionId) override;
1483 
1484     /**
1485      * Notify ability manager to set the flag to block all apps from starting.
1486      * Needs to apply for ohos.permission.BLOCK_ALL_APP_START.
1487      * @param flag, The flag to block all apps from starting
1488      * @return Returns ERR_OK on success, others on failure.
1489      */
1490     virtual int32_t BlockAllAppStart(bool flag) override;
1491 
1492     /**
1493      * update associate config list by rss.
1494      *
1495      * @param configs The rss config info.
1496      * @param exportConfigs The rss export config info.
1497      * @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config.
1498      */
1499     virtual int32_t UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
1500         const std::list<std::string>& exportConfigs, int32_t flag) override;
1501 
1502 private:
1503     template <typename T>
1504     int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
1505     bool WriteInterfaceToken(MessageParcel &data);
1506     // flag = true : terminate; flag = false : close
1507     int TerminateAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant, bool flag);
1508     ErrCode SendRequest(AbilityManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply,
1509         MessageOption& option);
1510     int CheckUISessionParams(MessageParcel &data, const sptr<IRemoteObject> &callerToken,
1511         const sptr<SessionInfo> &sessionInfo, int32_t userId, int requestCode);
1512     bool UpdateAssociateConfigInner(const std::map<std::string, std::list<std::string>>& configs,
1513         MessageParcel& data);
1514 
1515 private:
1516     static inline BrokerDelegator<AbilityManagerProxy> delegator_;
1517 };
1518 }  // namespace AAFwk
1519 }  // namespace OHOS
1520 #endif
1521