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