• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "hilog_wrapper.h"
22 #include "iremote_proxy.h"
23 #include "mission_info.h"
24 
25 namespace OHOS {
26 namespace AAFwk {
27 using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
28 /**
29  * @class AbilityManagerProxy
30  * AbilityManagerProxy.
31  */
32 class AbilityManagerProxy : public IRemoteProxy<IAbilityManager> {
33 public:
AbilityManagerProxy(const sptr<IRemoteObject> & impl)34     explicit AbilityManagerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAbilityManager>(impl)
35     {}
36 
~AbilityManagerProxy()37     virtual ~AbilityManagerProxy()
38     {}
39 
40     /**
41      * StartAbility with want, send want to ability manager service.
42      *
43      * @param want, the want of the ability to start.
44      * @param requestCode, Ability request code.
45      * @param userId, Designation User ID.
46      * @return Returns ERR_OK on success, others on failure.
47      */
48     virtual int StartAbility(
49         const Want &want,
50         int32_t userId = DEFAULT_INVAL_VALUE,
51         int requestCode = DEFAULT_INVAL_VALUE) override;
52 
53     /**
54      * StartAbility with want, send want to ability manager service.
55      *
56      * @param want, the want of the ability to start.
57      * @param callerToken, caller ability token.
58      * @param requestCode the resultCode of the ability to start.
59      * @param userId, Designation User ID.
60      * @return Returns ERR_OK on success, others on failure.
61      */
62     virtual int StartAbility(
63         const Want &want,
64         const sptr<IRemoteObject> &callerToken,
65         int32_t userId = DEFAULT_INVAL_VALUE,
66         int requestCode = DEFAULT_INVAL_VALUE) override;
67 
68     /**
69      * StartAbility by insight intent, send want to ability manager service.
70      *
71      * @param want Ability want.
72      * @param callerToken caller ability token.
73      * @param intentId insight intent id.
74      * @param userId userId of target ability.
75      * @return Returns ERR_OK on success, others on failure.
76      */
77     int32_t StartAbilityByInsightIntent(
78         const Want &want,
79         const sptr<IRemoteObject> &callerToken,
80         uint64_t intentId,
81         int32_t userId = DEFAULT_INVAL_VALUE) override;
82 
83     /**
84      * Starts a new ability with specific start settings.
85      *
86      * @param want Indicates the ability to start.
87      * @param callerToken caller ability token.
88      * @param abilityStartSetting Indicates the setting ability used to start.
89      * @param userId, Designation User ID.
90      * @return Returns ERR_OK on success, others on failure.
91      */
92     virtual int StartAbility(
93         const Want &want,
94         const AbilityStartSetting &abilityStartSetting,
95         const sptr<IRemoteObject> &callerToken,
96         int32_t userId = DEFAULT_INVAL_VALUE,
97         int requestCode = DEFAULT_INVAL_VALUE) override;
98 
99     /**
100      * Starts a new ability with specific start options.
101      *
102      * @param want, the want of the ability to start.
103      * @param startOptions Indicates the options used to start.
104      * @param callerToken, caller ability token.
105      * @param userId, Designation User ID.
106      * @param requestCode the resultCode of the ability to start.
107      * @return Returns ERR_OK on success, others on failure.
108      */
109     virtual int StartAbility(
110         const Want &want,
111         const StartOptions &startOptions,
112         const sptr<IRemoteObject> &callerToken,
113         int32_t userId = DEFAULT_INVAL_VALUE,
114         int requestCode = DEFAULT_INVAL_VALUE) override;
115 
116     /**
117      * Starts a new ability using the original caller information.
118      *
119      * @param want the want of the ability to start.
120      * @param callerToken current caller ability token.
121      * @param asCallerSourceToken source caller ability token.
122      * @param userId Designation User ID.
123      * @param requestCode the resultCode of the ability to start.
124      * @return Returns ERR_OK on success, others on failure.
125      */
126     virtual int StartAbilityAsCaller(
127         const Want &want,
128         const sptr<IRemoteObject> &callerToken,
129         sptr<IRemoteObject> asCallerSourceToken,
130         int32_t userId = DEFAULT_INVAL_VALUE,
131         int requestCode = DEFAULT_INVAL_VALUE,
132         bool isSendDialogResult = false) override;
133 
134     /**
135      * Starts a new ability using the original caller information.
136      *
137      * @param want the want of the ability to start.
138      * @param startOptions Indicates the options used to start.
139      * @param callerToken current caller ability token.
140      * @param asCallerSourceToken source caller ability token.
141      * @param userId Designation User ID.
142      * @param requestCode the resultCode of the ability to start.
143      * @return Returns ERR_OK on success, others on failure.
144      */
145     virtual int StartAbilityAsCaller(
146         const Want &want,
147         const StartOptions &startOptions,
148         const sptr<IRemoteObject> &callerToken,
149         sptr<IRemoteObject> asCallerSourceToken,
150         int32_t userId = DEFAULT_INVAL_VALUE,
151         int requestCode = DEFAULT_INVAL_VALUE) override;
152 
153     /**
154      * Start ui session ability with extension session info, send session info to ability manager service.
155      *
156      * @param want, the want of the ability to start.
157      * @param callerToken, caller ability token.
158      * @param sessionInfo the information of UIExtensionContentSession.
159      * @param userId, Designation User ID.
160      * @param requestCode, Ability request code.
161      * @return Returns ERR_OK on success, others on failure.
162      */
163     virtual int StartAbilityByUIContentSession(
164         const Want &want,
165         const sptr<IRemoteObject> &callerToken,
166         const sptr<SessionInfo> &sessionInfo,
167         int32_t userId = DEFAULT_INVAL_VALUE,
168         int requestCode = DEFAULT_INVAL_VALUE) override;
169 
170     /**
171      * Start ui session ability with extension session info, send session info to ability manager service.
172      *
173      * @param want, the want of the ability to start.
174      * @param startOptions Indicates the options used to start.
175      * @param callerToken, caller ability token.
176      * @param sessionInfo the information of UIExtensionContentSession.
177      * @param userId, Designation User ID.
178      * @param requestCode the resultCode of the ability to start.
179      * @return Returns ERR_OK on success, others on failure.
180      */
181     virtual int StartAbilityByUIContentSession(
182         const Want &want,
183         const StartOptions &startOptions,
184         const sptr<IRemoteObject> &callerToken,
185         const sptr<SessionInfo> &sessionInfo,
186         int32_t userId = DEFAULT_INVAL_VALUE,
187         int requestCode = DEFAULT_INVAL_VALUE) override;
188 
189     /**
190      * Start extension ability with want, send want to ability manager service.
191      *
192      * @param want, the want of the ability to start.
193      * @param callerToken, caller ability token.
194      * @param userId, Designation User ID.
195      * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
196      * @return Returns ERR_OK on success, others on failure.
197      */
198     virtual int StartExtensionAbility(
199         const Want &want,
200         const sptr<IRemoteObject> &callerToken,
201         int32_t userId = DEFAULT_INVAL_VALUE,
202         AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
203 
204     /**
205      * Create UIExtension with want, send want to ability manager service.
206      *
207      * @param want, the want of the ability to start.
208      * @return Returns ERR_OK on success, others on failure.
209      */
210     int RequestModalUIExtension(const Want &want) override;
211 
212     /**
213      * Start ui extension ability with extension session info, send extension session info to ability manager service.
214      *
215      * @param extensionSessionInfo the extension session info of the ability to start.
216      * @param userId, Designation User ID.
217      * @return Returns ERR_OK on success, others on failure.
218      */
219     virtual int StartUIExtensionAbility(
220         const sptr<SessionInfo> &extensionSessionInfo,
221         int32_t userId = DEFAULT_INVAL_VALUE) override;
222 
223     /**
224      * Start ui ability with want, send want to ability manager service.
225      *
226      * @param sessionInfo the session info of the ability to start.
227      * @return Returns ERR_OK on success, others on failure.
228      */
229     virtual int StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo) override;
230 
231     /**
232      * Stop extension ability with want, send want to ability manager service.
233      *
234      * @param want, the want of the ability to stop.
235      * @param callerToken, caller ability token.
236      * @param userId, Designation User ID.
237      * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be stopped.
238      * @return Returns ERR_OK on success, others on failure.
239      */
240     virtual int StopExtensionAbility(
241         const Want& want,
242         const sptr<IRemoteObject>& callerToken,
243         int32_t userId = DEFAULT_INVAL_VALUE,
244         AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
245     /**
246      * TerminateAbility, terminate the special ability.
247      *
248      * @param token, the token of the ability to terminate.
249      * @param resultCode, the resultCode of the ability to terminate.
250      * @param resultWant, the Want of the ability to return.
251      * @return Returns ERR_OK on success, others on failure.
252      */
253     virtual int TerminateAbility(
254         const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override;
255 
256     /**
257      * TerminateUIExtensionAbility, terminate the special ui extension ability.
258      *
259      * @param extensionSessionInfo the extension session info of the ability to terminate.
260      * @param resultCode resultCode.
261      * @param Want Ability want returned.
262      * @return Returns ERR_OK on success, others on failure.
263      */
264     virtual int TerminateUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int resultCode,
265         const Want *resultWant) override;
266 
267     /**
268      * CloseUIAbilityBySCB, close the special ability by scb.
269      *
270      * @param sessionInfo the session info of the ability to terminate.
271      * @return Returns ERR_OK on success, others on failure.
272      */
273     virtual int CloseUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo) override;
274 
275     /**
276      * SendResultToAbility with want, return want from ability manager service.(Only used for dms)
277      *
278      * @param requestCode, request code.
279      * @param resultCode, resultCode to return.
280      * @param resultWant, the Want of the ability to return.
281      * @return Returns ERR_OK on success, others on failure.
282      */
283     virtual int SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant) override;
284 
285     /**
286      * MoveAbilityToBackground.
287      *
288      * @param token, the token of the ability to move.
289      * @return Returns ERR_OK on success, others on failure.
290      */
291     virtual int MoveAbilityToBackground(const sptr<IRemoteObject> &token) override;
292 
293     /**
294      * CloseAbility, close the special ability.
295      *
296      * @param token, the token of the ability to terminate.
297      * @param resultCode, the resultCode of the ability to terminate.
298      * @param resultWant, the Want of the ability to return.
299      * @return Returns ERR_OK on success, others on failure.
300      */
301     virtual int CloseAbility(
302         const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override;
303 
304     /**
305      * MinimizeAbility, minimize the special ability.
306      *
307      * @param token, ability token.
308      * @param fromUser mark the minimize operation source.
309      * @return Returns ERR_OK on success, others on failure.
310      */
311     virtual int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser = false) override;
312 
313     /**
314      * MinimizeUIExtensionAbility, minimize the special ui extension ability.
315      *
316      * @param extensionSessionInfo the extension session info of the ability to minimize.
317      * @param fromUser mark the minimize operation source.
318      * @return Returns ERR_OK on success, others on failure.
319      */
320     virtual int MinimizeUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo,
321         bool fromUser = false) override;
322 
323     /**
324      * MinimizeUIAbilityBySCB, minimize the special ability by scb.
325      *
326      * @param sessionInfo the session info of the ability to minimize.
327      * @param fromUser, Whether form user.
328      * @return Returns ERR_OK on success, others on failure.
329      */
330     virtual int MinimizeUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool fromUser = false) override;
331 
332     /**
333      * ConnectAbility, connect session with service ability.
334      *
335      * @param want, Special want for service type's ability.
336      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
337      * @param callerToken, caller ability token.
338      * @param userId, Designation User ID.
339      * @return Returns ERR_OK on success, others on failure.
340      */
341     virtual int ConnectAbility(
342         const Want &want,
343         const sptr<IAbilityConnection> &connect,
344         const sptr<IRemoteObject> &callerToken,
345         int32_t userId = DEFAULT_INVAL_VALUE) override;
346 
347     virtual int ConnectAbilityCommon(
348         const Want &want,
349         const sptr<IAbilityConnection> &connect,
350         const sptr<IRemoteObject> &callerToken,
351         AppExecFwk::ExtensionAbilityType extensionType,
352         int32_t userId = DEFAULT_INVAL_VALUE,
353         bool isQueryExtensionOnly = false) override;
354 
355     virtual int ConnectUIExtensionAbility(
356         const Want &want,
357         const sptr<IAbilityConnection> &connect,
358         const sptr<SessionInfo> &sessionInfo,
359         int32_t userId = DEFAULT_INVAL_VALUE,
360         sptr<UIExtensionAbilityConnectInfo> connectInfo = nullptr) override;
361 
362     /**
363      * DisconnectAbility, connect session with service ability.
364      *
365      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
366      * @return Returns ERR_OK on success, others on failure.
367      */
368     virtual int DisconnectAbility(sptr<IAbilityConnection> connect) override;
369 
370     /**
371      * AcquireDataAbility, acquire a data ability by its authority, if it not existed,
372      * AMS loads it synchronously.
373      *
374      * @param uri, data ability uri.
375      * @param isKill, true: when a data ability is died, ams will kill this client, or do nothing.
376      * @param callerToken, specifies the caller ability token.
377      * @return returns the data ability ipc object, or nullptr for failed.
378      */
379     virtual sptr<IAbilityScheduler> AcquireDataAbility(
380         const Uri &uri, bool isKill, const sptr<IRemoteObject> &callerToken) override;
381 
382     /**
383      * ReleaseDataAbility, release the data ability that referenced by 'dataAbilityToken'.
384      *
385      * @param dataAbilityScheduler, specifies the data ability that will be released.
386      * @param callerToken, specifies the caller ability token.
387      * @return returns ERR_OK if succeeded, or error codes for failed.
388      */
389     virtual int ReleaseDataAbility(
390         sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken) override;
391 
392     /**
393      * AttachAbilityThread, ability call this interface after loaded.
394      *
395      * @param scheduler,.the interface handler of kit ability.
396      * @param token,.ability's token.
397      * @return Returns ERR_OK on success, others on failure.
398      */
399     virtual int AttachAbilityThread(
400         const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override;
401 
402     /**
403      * AbilityTransitionDone, ability call this interface after lift cycle was changed.
404      *
405      * @param token,.ability's token.
406      * @param state,.the state of ability lift cycle.
407      * @return Returns ERR_OK on success, others on failure.
408      */
409     virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
410 
411     /**
412      * ScheduleConnectAbilityDone, service ability call this interface while session was connected.
413      *
414      * @param token,.service ability's token.
415      * @param remoteObject,.the session proxy of service ability.
416      * @return Returns ERR_OK on success, others on failure.
417      */
418     virtual int ScheduleConnectAbilityDone(
419         const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override;
420 
421     /**
422      * ScheduleDisconnectAbilityDone, service ability call this interface while session was disconnected.
423      *
424      * @param token,.service ability's token.
425      * @return Returns ERR_OK on success, others on failure.
426      */
427     virtual int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override;
428 
429     /**
430      * ScheduleCommandAbilityDone, service ability call this interface while session was commanded.
431      *
432      * @param token,.service ability's token.
433      * @return Returns ERR_OK on success, others on failure.
434      */
435     virtual int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override;
436 
437     virtual int ScheduleCommandAbilityWindowDone(
438         const sptr<IRemoteObject> &token,
439         const sptr<SessionInfo> &sessionInfo,
440         WindowCommand winCmd,
441         AbilityCommand abilityCmd) override;
442 
443     /**
444      * dump ability stack info, about userID, mission stack info,
445      * mission record info and ability info.
446      *
447      * @param state Ability stack info.
448      * @return Returns ERR_OK on success, others on failure.
449      */
450     virtual void DumpState(const std::string &args, std::vector<std::string> &state) override;
451     virtual void DumpSysState(
452         const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int UserID) override;
453 
454     /**
455      * Destroys this Service ability by Want.
456      *
457      * @param want, Special want for service type's ability.
458      * @param token ability's token.
459      * @return Returns true if this Service ability will be destroyed; returns false otherwise.
460      */
461     virtual int StopServiceAbility(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE,
462         const sptr<IRemoteObject> &token = nullptr) override;
463 
464     /**
465      * Get top ability.
466      *
467      * @param isNeedLocalDeviceId is need local device id.
468      * @return Returns front desk focus ability elementName.
469      */
470     virtual AppExecFwk::ElementName GetTopAbility(bool isNeedLocalDeviceId = true) override;
471 
472     /**
473      * Get element name by token.
474      *
475      * @param token ability's token.
476      * @param isNeedLocalDeviceId is need local device id.
477      * @return Returns front desk focus ability elementName by token.
478      */
479     virtual AppExecFwk::ElementName GetElementNameByToken(sptr<IRemoteObject> token,
480         bool isNeedLocalDeviceId = true) override;
481 
482     /**
483      * Kill the process immediately.
484      *
485      * @param bundleName.
486      * @return Returns ERR_OK on success, others on failure.
487      */
488     virtual int KillProcess(const std::string &bundleName) override;
489 
490     #ifdef ABILITY_COMMAND_FOR_TEST
491     /**
492      * force timeout ability.
493      *
494      * @param abilityName.
495      * @param state.
496      * @return Returns ERR_OK on success, others on failure.
497      */
498     virtual int ForceTimeoutForTest(const std::string &abilityName, const std::string &state) override;
499     #endif
500 
501     /**
502      * ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
503      * clear the application data.
504      *
505      * @param bundleName, bundle name in Application record.
506      * @return
507      */
508     virtual int ClearUpApplicationData(const std::string &bundleName,
509         const int32_t userId = -1) override;
510 
511     /**
512      * Uninstall app
513      *
514      * @param bundleName bundle name of uninstalling app.
515      * @param uid uid of bundle.
516      * @return Returns ERR_OK on success, others on failure.
517      */
518     virtual int UninstallApp(const std::string &bundleName, int32_t uid) override;
519 
520     virtual sptr<IWantSender> GetWantSender(
521         const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken) override;
522 
523     virtual int SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo) override;
524 
525     virtual void CancelWantSender(const sptr<IWantSender> &sender) override;
526 
527     virtual int GetPendingWantUid(const sptr<IWantSender> &target) override;
528 
529     virtual int GetPendingWantUserId(const sptr<IWantSender> &target) override;
530 
531     virtual std::string GetPendingWantBundleName(const sptr<IWantSender> &target) override;
532 
533     virtual int GetPendingWantCode(const sptr<IWantSender> &target) override;
534 
535     virtual int GetPendingWantType(const sptr<IWantSender> &target) override;
536 
537     virtual void RegisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override;
538 
539     virtual void UnregisterCancelListener(
540         const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver) override;
541 
542     virtual int GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want) override;
543 
544     virtual int GetWantSenderInfo(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info) override;
545 
546     virtual int GetAppMemorySize() override;
547 
548     virtual bool IsRamConstrainedDevice() override;
549     virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId,
550         int32_t missionId, const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams) override;
551 
552     virtual int ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId,
553         const std::string &bundleName, const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams) override;
554 
555     virtual int ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode) override;
556 
557     virtual int StartContinuation(const Want &want, const sptr<IRemoteObject> &abilityToken, int32_t status) override;
558 
559     virtual void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess) override;
560 
561     virtual int NotifyContinuationResult(int32_t missionId, int32_t result) override;
562 
563     virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
564 
565     virtual int StopSyncRemoteMissions(const std::string& devId) override;
566 
567     virtual int LockMissionForCleanup(int32_t missionId) override;
568 
569     virtual int UnlockMissionForCleanup(int32_t missionId) override;
570 
571     virtual void SetLockedState(int32_t sessionId, bool lockedState) override;
572 
573     virtual int RegisterMissionListener(const sptr<IMissionListener> &listener) override;
574 
575     virtual int UnRegisterMissionListener(const sptr<IMissionListener> &listener) override;
576 
577     virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax,
578         std::vector<MissionInfo> &missionInfos) override;
579 
580     virtual int GetMissionInfo(const std::string& deviceId, int32_t missionId,
581         MissionInfo &missionInfos) override;
582 
583     virtual int CleanMission(int32_t missionId) override;
584 
585     virtual int CleanAllMissions() override;
586 
587     virtual int MoveMissionToFront(int32_t missionId) override;
588 
589     virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override;
590 
591     virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override;
592 
593     virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
594         std::vector<int32_t>& result) override;
595 
596     /**
597      * Start Ability, connect session with common ability.
598      *
599      * @param want, Special want for service type's ability.
600      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
601      * @param accountId Indicates the account to start.
602      * @return Returns ERR_OK on success, others on failure.
603      */
604     virtual int StartAbilityByCall(const Want &want, const sptr<IAbilityConnection> &connect,
605         const sptr<IRemoteObject> &callerToken, int32_t accountId = DEFAULT_INVAL_VALUE) override;
606 
607     /**
608      * CallRequestDone, after invoke callRequest, ability will call this interface to return callee.
609      *
610      * @param token, ability's token.
611      * @param callStub, ability's callee.
612      */
613     void CallRequestDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callStub) override;
614 
615     /**
616      * Release the call between Ability, disconnect session with common ability.
617      *
618      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
619      * @param element, the element of target service.
620      * @return Returns ERR_OK on success, others on failure.
621      */
622     virtual int ReleaseCall(
623         const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) override;
624 
625     virtual int StartUser(int userId) override;
626 
627     virtual int StopUser(int userId, const sptr<IStopUserCallback> &callback) override;
628 
629     virtual int LogoutUser(int32_t userId) override;
630 
631     virtual int SetMissionContinueState(const sptr<IRemoteObject> &token, const AAFwk::ContinueState &state) override;
632 
633 #ifdef SUPPORT_GRAPHICS
634     virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override;
635 
636     virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
637         const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
638 
639     virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override;
640 
641     virtual void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) override;
642 
643     virtual int PrepareTerminateAbility(
644         const sptr<IRemoteObject> &token, sptr<IPrepareTerminateCallback> &callback) override;
645 
646     virtual int GetDialogSessionInfo(const std::string dialogSessionId, sptr<DialogSessionInfo> &info) override;
647 
648     virtual int SendDialogResult(const Want &want, const std::string dialogSessionId, bool isAllow) override;
649 #endif
650 
651     virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) override;
652 
653     virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) override;
654 
655     virtual int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) override;
656 
657     virtual int RegisterMissionListener(const std::string &deviceId,
658         const sptr<IRemoteMissionListener> &listener) override;
659 
660     virtual int RegisterOnListener(const std::string &type,
661         const sptr<IRemoteOnListener> &listener) override;
662 
663     virtual int RegisterOffListener(const std::string &deviceId,
664         const sptr<IRemoteOnListener> &listener) override;
665 
666     virtual int UnRegisterMissionListener(const std::string &deviceId,
667         const sptr<IRemoteMissionListener> &listener) override;
668 
669     /**
670      * Set ability controller.
671      *
672      * @param abilityController, The ability controller.
673      * @return Returns ERR_OK on success, others on failure.
674      */
675     virtual int SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController,
676         bool imAStabilityTest) override;
677 
678     /**
679      * Is user a stability test.
680      *
681      * @return Returns true if user is a stability test.
682      */
683     virtual bool IsRunningInStabilityTest() override;
684 
685     virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
686 
687     virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
688         MissionSnapshot& snapshot, bool isLowResolution) override;
689 
690     virtual int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) override;
691 
692     virtual int FinishUserTest(
693         const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override;
694 
695      /**
696      * GetTopAbility, get the token of top ability.
697      *
698      * @param token, the token of top ability.
699      * @return Returns ERR_OK on success, others on failure.
700      */
701     virtual int GetTopAbility(sptr<IRemoteObject> &token) override;
702 
703     virtual int CheckUIExtensionIsFocused(uint32_t uiExtensionTokenId, bool& isFocused) override;
704 
705     /**
706      * The delegator calls this interface to move the ability to the foreground.
707      *
708      * @param token, ability's token.
709      * @return Returns ERR_OK on success, others on failure.
710      */
711     virtual int DelegatorDoAbilityForeground(const sptr<IRemoteObject> &token) override;
712 
713     /**
714      * The delegator calls this interface to move the ability to the background.
715      *
716      * @param token, ability's token.
717      * @return Returns ERR_OK on success, others on failure.
718      */
719     virtual int DelegatorDoAbilityBackground(const sptr<IRemoteObject> &token) override;
720 
721     /**
722      * Calls this interface to move the ability to the foreground.
723      *
724      * @param token, ability's token.
725      * @param flag, use for lock or unlock flag and so on.
726      * @return Returns ERR_OK on success, others on failure.
727      */
728     virtual int DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag) override;
729 
730     /**
731      * Calls this interface to move the ability to the background.
732      *
733      * @param token, ability's token.
734      * @param flag, use for lock or unlock flag and so on.
735      * @return Returns ERR_OK on success, others on failure.
736      */
737     virtual int DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag) override;
738 
739     /**
740      * Send not response process ID to ability manager service.
741      *
742      * @param pid The not response process ID.
743      * @return Returns ERR_OK on success, others on failure.
744      */
745     virtual int SendANRProcessID(int pid) override;
746 
747     /**
748      * Get mission id by ability token.
749      *
750      * @param token The token of ability.
751      * @return Returns -1 if do not find mission, otherwise return mission id.
752      */
753     virtual int32_t GetMissionIdByToken(const sptr<IRemoteObject> &token) override;
754 
755     /**
756      * Get ability token by connect.
757      *
758      * @param token The token of ability.
759      * @param callStub The callee object.
760      */
761     void GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token) override;
762 
763     #ifdef ABILITY_COMMAND_FOR_TEST
764     /**
765      * Block ability manager service.
766      *
767      * @return Returns ERR_OK on success, others on failure.
768      */
769     virtual int BlockAmsService() override;
770 
771     /**
772      * Block ability.
773      *
774      * @param abilityRecordId The Ability Record Id.
775      * @return Returns ERR_OK on success, others on failure.
776      */
777     virtual int BlockAbility(int32_t abilityRecordId) override;
778 
779     /**
780      * Block app service.
781      *
782      * @return Returns ERR_OK on success, others on failure.
783      */
784     virtual int BlockAppService() override;
785     #endif
786 
787     /**
788      * Call free install from remote.
789      *
790      * @param want, the want of the ability to start.
791      * @param userId, Designation User ID.
792      * @param requestCode, Ability request code.
793      * @param callback, Callback from remote.
794      * @return Returns ERR_OK on success, others on failure.
795      */
796     virtual int FreeInstallAbilityFromRemote(const Want &want, const sptr<IRemoteObject> &callback,
797         int32_t userId, int requestCode = DEFAULT_INVAL_VALUE) override;
798 
799     /**
800      * Add FreeInstall Observer
801      *
802      * @param observer the observer of ability free install start.
803      * @return Returns ERR_OK on success, others on failure.
804      */
805     virtual int AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer) override;
806 
807     /**
808      * Called when client complete dump.
809      *
810      * @param infos The dump info.
811      * @return Returns ERR_OK on success, others on failure.
812      */
813     virtual int DumpAbilityInfoDone(std::vector<std::string> &infos, const sptr<IRemoteObject> &callerToken) override;
814 
815     /**
816      * Called to update mission snapshot.
817      * @param token The target ability.
818      * @param pixelMap The snapshot.
819      */
820     virtual void UpdateMissionSnapShot(const sptr<IRemoteObject> &token,
821         const std::shared_ptr<Media::PixelMap> &pixelMap) override;
822 
823     virtual void EnableRecoverAbility(const sptr<IRemoteObject>& token) override;
824     virtual void ScheduleRecoverAbility(const sptr<IRemoteObject> &token, int32_t reason,
825         const Want *want = nullptr) override;
826 
827     /**
828      * Called to verify that the MissionId is valid.
829      * @param missionIds Query mission list.
830      * @param results Output parameters, return results up to 20 query results.
831      * @return Returns ERR_OK on success, others on failure.
832      */
833     int32_t IsValidMissionIds(
834         const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results) override;
835 
836     /**
837      * Query whether the application of the specified PID and UID has been granted a certain permission
838      * @param permission
839      * @param pid Process id
840      * @param uid
841      * @return Returns ERR_OK if the current process has the permission, others on failure.
842      */
843     virtual int VerifyPermission(const std::string &permission, int pid, int uid) override;
844 
845     /**
846      * Request dialog service with want, send want to ability manager service.
847      *
848      * @param want, the want of the dialog service to start.
849      * @param callerToken, caller ability token.
850      * @return Returns ERR_OK on success, others on failure.
851      */
852     virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override;
853 
854     int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) override;
855 
856     virtual int32_t AcquireShareData(
857         const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override;
858     virtual int32_t ShareDataDone(const sptr<IRemoteObject> &token,
859         const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam) override;
860 
861     /**
862      * Force app exit and record exit reason.
863      * @param pid Process id .
864      * @param exitReason The reason of app exit.
865      * @return Returns ERR_OK on success, others on failure.
866      */
867     virtual int32_t ForceExitApp(const int32_t pid, Reason exitReason) override;
868 
869     /**
870      * Record app exit reason.
871      * @param exitReason The reason of app exit.
872      * @return Returns ERR_OK on success, others on failure.
873      */
874     virtual int32_t RecordAppExitReason(Reason exitReason) override;
875 
876     /**
877      * Set rootSceneSession by SCB.
878      *
879      * @param rootSceneSession Indicates root scene session of SCB.
880      */
881     virtual void SetRootSceneSession(const sptr<IRemoteObject> &rootSceneSession) override;
882 
883     /**
884      * Call UIAbility by SCB.
885      *
886      * @param sessionInfo the session info of the ability to be called.
887      */
888     virtual void CallUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo) override;
889 
890     /**
891      * Start specified ability by SCB.
892      *
893      * @param want Want information.
894      */
895     void StartSpecifiedAbilityBySCB(const Want &want) override;
896 
897     /**
898      * Notify sandbox app the result of saving file.
899      * @param want Result of saving file, which contains the file's uri if success.
900      * @param resultCode Indicates the action's result.
901      * @param requestCode Pass the requestCode to match request.
902      * @return Returns ERR_OK on success, others on failure.
903      */
904     virtual int32_t NotifySaveAsResult(const Want &want, int resultCode, int requestCode) override;
905 
906     /**
907      * Set sessionManagerService
908      * @param sessionManagerService the point of sessionManagerService.
909      *
910      * @return Returns ERR_OK on success, others on failure.
911      */
912     virtual int32_t SetSessionManagerService(const sptr<IRemoteObject> &sessionManagerService) override;
913 
914     /**
915      * @brief Register collaborator.
916      * @param type collaborator type.
917      * @param impl collaborator.
918      * @return 0 or else.
919     */
920     virtual int32_t RegisterIAbilityManagerCollaborator(
921         int32_t type, const sptr<IAbilityManagerCollaborator> &impl) override;
922 
923     /**
924      * @brief Unregister collaborator.
925      * @param type collaborator type.
926      * @return 0 or else.
927     */
928     virtual int32_t UnregisterIAbilityManagerCollaborator(int32_t type) override;
929 
930     /**
931      * @brief Register auto start up callback for system api.
932      * @param callback The point of JsAbilityAutoStartupCallBack.
933      * @return Returns ERR_OK on success, others on failure.
934      */
935     virtual int32_t RegisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback) override;
936 
937     /**
938      * @brief Unregister auto start up callback for system api.
939      * @param callback The point of JsAbilityAutoStartupCallBack.
940      * @return Returns ERR_OK on success, others on failure.
941      */
942     virtual int32_t UnregisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback) override;
943 
944     /**
945      * @brief Set every application auto start up state.
946      * @param info The auto startup info,include bundle name, module name, ability name.
947      * @return Returns ERR_OK on success, others on failure.
948      */
949     virtual int32_t SetApplicationAutoStartup(const AutoStartupInfo &info) override;
950 
951     /**
952      * @brief Cancel every application auto start up .
953      * @param info The auto startup info,include bundle name, module name, ability name.
954      * @return Returns ERR_OK on success, others on failure.
955      */
956     virtual int32_t CancelApplicationAutoStartup(const AutoStartupInfo &info) override;
957 
958     /**
959      * @brief Query auto startup state all application.
960      * @param infoList Output parameters, return auto startup info list.
961      * @return Returns ERR_OK on success, others on failure.
962      */
963     virtual int32_t QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList) override;
964 
965     /**
966      * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb.
967      *
968      * @param sessionInfo the session info of the ability to start.
969      * @param isPrepareTerminate the result of ability onPrepareToTermiante.
970      * @return Returns ERR_OK on success, others on failure.
971      */
972     virtual int PrepareTerminateAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isPrepareTerminate) override;
973     virtual int RegisterSessionHandler(const sptr<IRemoteObject> &object) override;
974 
975     /**
976      * @brief Register app debug listener.
977      * @param listener App debug listener.
978      * @return Returns ERR_OK on success, others on failure.
979      */
980     int32_t RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override;
981 
982     /**
983      * @brief Unregister app debug listener.
984      * @param listener App debug listener.
985      * @return Returns ERR_OK on success, others on failure.
986      */
987     int32_t UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener) override;
988 
989     /**
990      * @brief Attach app debug.
991      * @param bundleName The application bundle name.
992      * @return Returns ERR_OK on success, others on failure.
993      */
994     int32_t AttachAppDebug(const std::string &bundleName) override;
995 
996     /**
997      * @brief Detach app debug.
998      * @param bundleName The application bundle name.
999      * @return Returns ERR_OK on success, others on failure.
1000      */
1001     int32_t DetachAppDebug(const std::string &bundleName) override;
1002 
1003     /**
1004      * @brief Execute intent.
1005      * @param key The key of intent executing client.
1006      * @param callerToken Caller ability token.
1007      * @param param The Intent execute param.
1008      * @return Returns ERR_OK on success, others on failure.
1009      */
1010     int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken,
1011         const InsightIntentExecuteParam &param) override;
1012 
1013     /**
1014      * @brief Check if ability controller can start.
1015      * @param want The want of ability to start.
1016      * @return Return true to allow ability to start, or false to reject.
1017      */
1018     virtual bool IsAbilityControllerStart(const Want &want) override;
1019 
1020     /**
1021      * @brief Called when insight intent execute finished.
1022      *
1023      * @param token ability's token.
1024      * @param intentId insight intent id.
1025      * @param result insight intent execute result.
1026      * @return Returns ERR_OK on success, others on failure.
1027      */
1028     int32_t ExecuteInsightIntentDone(const sptr<IRemoteObject> &token, uint64_t intentId,
1029         const InsightIntentExecuteResult &result) override;
1030 
1031     /**
1032      * @brief Set application auto start up state by EDM.
1033      * @param info The auto startup info, include bundle name, module name, ability name.
1034      * @param flag Indicate whether to allow the application to change the auto start up state.
1035      * @return Returns ERR_OK on success, others on failure.
1036      */
1037     int32_t SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override;
1038 
1039     /**
1040      * @brief Cancel application auto start up state by EDM.
1041      * @param info The auto startup info, include bundle name, module name, ability name.
1042      * @param flag Indicate whether to allow the application to change the auto start up state.
1043      * @return Returns ERR_OK on success, others on failure.
1044      */
1045     int32_t CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag) override;
1046 
1047     /**
1048      * @brief Get foreground ui abilities.
1049      * @param list Foreground ui abilities.
1050      * @return Returns ERR_OK on success, others on failure.
1051      */
1052     int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list) override;
1053 
1054     /**
1055      * @brief Open file by uri.
1056      * @param uri The file uri.
1057      * @param flag Want::FLAG_AUTH_READ_URI_PERMISSION or Want::FLAG_AUTH_WRITE_URI_PERMISSION.
1058      * @return int The file descriptor.
1059      */
1060     virtual int32_t OpenFile(const Uri& uri, uint32_t flag) override;
1061 
1062     /**
1063      * @brief Update session info.
1064      * @param sessionInfos The vector of session info.
1065      */
1066     virtual void UpdateSessionInfoBySCB(const std::vector<SessionInfo> &sessionInfos, int32_t userId) override;
1067 private:
1068     template <typename T>
1069     int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
1070     bool WriteInterfaceToken(MessageParcel &data);
1071     // flag = true : terminate; flag = false : close
1072     int TerminateAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant, bool flag);
1073     ErrCode SendRequest(AbilityManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply,
1074         MessageOption& option);
1075     int CheckUISessionParams(MessageParcel &data, const sptr<IRemoteObject> &callerToken,
1076         const sptr<SessionInfo> &sessionInfo, int32_t userId, int requestCode);
1077 
1078 private:
1079     static inline BrokerDelegator<AbilityManagerProxy> delegator_;
1080 };
1081 }  // namespace AAFwk
1082 }  // namespace OHOS
1083 #endif
1084