• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_AAFWK_ABILITY_MANAGER_CLIENT_H
17 #define OHOS_AAFWK_ABILITY_MANAGER_CLIENT_H
18 
19 #include <mutex>
20 
21 #include "ability_connect_callback_interface.h"
22 #include "ability_manager_errors.h"
23 #include "ability_scheduler_interface.h"
24 #include "ability_manager_interface.h"
25 #include "snapshot.h"
26 #include "want.h"
27 
28 #include "iremote_object.h"
29 #include "system_memory_attr.h"
30 
31 namespace OHOS {
32 namespace AAFwk {
33 /**
34  * @class AbilityManagerClient
35  * AbilityManagerClient is used to access ability manager services.
36  */
37 class AbilityManagerClient {
38 public:
39     AbilityManagerClient();
40     virtual ~AbilityManagerClient();
41     static std::shared_ptr<AbilityManagerClient> GetInstance();
42 
43     /**
44      * AttachAbilityThread, ability call this interface after loaded.
45      *
46      * @param scheduler,.the interface handler of kit ability.
47      * @param token,.ability's token.
48      * @return Returns ERR_OK on success, others on failure.
49      */
50     ErrCode AttachAbilityThread(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token);
51 
52     /**
53      * AbilityTransitionDone, ability call this interface after lift cycle was changed.
54      *
55      * @param token,.ability's token.
56      * @param state,.the state of ability lift cycle.
57      * @return Returns ERR_OK on success, others on failure.
58      */
59     ErrCode AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData);
60 
61     /**
62      * ScheduleConnectAbilityDone, service ability call this interface while session was connected.
63      *
64      * @param token,.service ability's token.
65      * @param remoteObject,.the session proxy of service ability.
66      * @return Returns ERR_OK on success, others on failure.
67      */
68     ErrCode ScheduleConnectAbilityDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject);
69 
70     /**
71      * ScheduleDisconnectAbilityDone, service ability call this interface while session was disconnected.
72      *
73      * @param token,.service ability's token.
74      * @return Returns ERR_OK on success, others on failure.
75      */
76     ErrCode ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token);
77 
78     /**
79      * ScheduleCommandAbilityDone, service ability call this interface while session was commanded.
80      *
81      * @param token,.service ability's token.
82      * @return Returns ERR_OK on success, others on failure.
83      */
84     ErrCode ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token);
85 
86     /**
87      * Get top ability.
88      *
89      * @return Returns front desk focus ability elementName.
90      */
91     AppExecFwk::ElementName GetTopAbility();
92 
93     /**
94      * AddWindowInfo, add windowToken to AbilityRecord.
95      *
96      * @param token, the token of the ability.
97      * @param windowToken, window id of the ability.
98      */
99     void AddWindowInfo(const sptr<IRemoteObject> &token, int32_t windowToken);
100 
101     /**
102      * StartAbility with want, send want to ability manager service.
103      *
104      * @param want Ability want.
105      * @param requestCode Ability request code.
106      * @return Returns ERR_OK on success, others on failure.
107      */
108     ErrCode StartAbility(const Want &want, int requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE);
109 
110     /**
111      * StartAbility with want, send want to ability manager service.
112      *
113      * @param want Ability want.
114      * @param callerToken, caller ability token.
115      * @param requestCode Ability request code.
116      * @return Returns ERR_OK on success, others on failure.
117      */
118     ErrCode StartAbility(
119         const Want &want,
120         const sptr<IRemoteObject> &callerToken,
121         int requestCode = DEFAULT_INVAL_VALUE,
122         int32_t userId = DEFAULT_INVAL_VALUE);
123 
124     /**
125      * Starts a new ability with specific start settings.
126      *
127      * @param want Indicates the ability to start.
128      * @param requestCode the resultCode of the ability to start.
129      * @param abilityStartSetting Indicates the setting ability used to start.
130      * @return Returns ERR_OK on success, others on failure.
131      */
132     ErrCode StartAbility(
133         const Want &want,
134         const AbilityStartSetting &abilityStartSetting,
135         const sptr<IRemoteObject> &callerToken,
136         int requestCode = DEFAULT_INVAL_VALUE,
137         int32_t userId = DEFAULT_INVAL_VALUE);
138 
139     /**
140      * Starts a new ability with specific start options.
141      *
142      * @param want, the want of the ability to start.
143      * @param startOptions Indicates the options used to start.
144      * @param callerToken, caller ability token.
145      * @param requestCode the resultCode of the ability to start.
146      * @return Returns ERR_OK on success, others on failure.
147      */
148     ErrCode StartAbility(
149         const Want &want,
150         const StartOptions &startOptions,
151         const sptr<IRemoteObject> &callerToken,
152         int requestCode = DEFAULT_INVAL_VALUE,
153         int32_t userId = DEFAULT_INVAL_VALUE);
154 
155     /**
156      * TerminateAbility with want, return want from ability manager service.
157      *
158      * @param token Ability token.
159      * @param resultCode resultCode.
160      * @param Want Ability want returned.
161      * @return Returns ERR_OK on success, others on failure.
162      */
163     ErrCode TerminateAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant);
164 
165     /**
166      * CloseAbility with want, return want from ability manager service.
167      *
168      * @param token Ability token.
169      * @param resultCode resultCode.
170      * @param Want Ability want returned.
171      * @return Returns ERR_OK on success, others on failure.
172      */
173     ErrCode CloseAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE,
174         const Want *resultWant = nullptr);
175 
176     /**
177      * TerminateAbility, terminate the special ability.
178      *
179      * @param callerToken, caller ability token.
180      * @param requestCode Ability request code.
181      * @return Returns ERR_OK on success, others on failure.
182      */
183     ErrCode TerminateAbility(const sptr<IRemoteObject> &callerToken, int requestCode);
184 
185     /**
186      * Destroys this Service ability if the number of times it
187      * has been started equals the number represented by
188      * the given startId.
189      *
190      * @param token ability's token.
191      * @param startId is incremented by 1 every time this ability is started.
192      * @return Returns true if the startId matches the number of startup times
193      * and this Service ability will be destroyed; returns false otherwise.
194      */
195     ErrCode TerminateAbilityResult(const sptr<IRemoteObject> &token, int startId);
196 
197     /**
198      * MinimizeAbility, minimize the special ability.
199      *
200      * @param token, ability token.
201      * @param fromUser mark the minimize operation source.
202      * @return Returns ERR_OK on success, others on failure.
203      */
204     ErrCode MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser = false);
205 
206     /**
207      * ConnectAbility, connect session with service ability.
208      *
209      * @param want, Special want for service type's ability.
210      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
211      * @param callerToken, caller ability token.
212      * @return Returns ERR_OK on success, others on failure.
213      */
214     ErrCode ConnectAbility(
215         const Want &want,
216         const sptr<IAbilityConnection> &connect,
217         const sptr<IRemoteObject> &callerToken,
218         int32_t userId = DEFAULT_INVAL_VALUE);
219 
220     /**
221      * DisconnectAbility, disconnect session with service ability.
222      *
223      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
224      * @return Returns ERR_OK on success, others on failure.
225      */
226     ErrCode DisconnectAbility(const sptr<IAbilityConnection> &connect);
227 
228     /**
229      * AcquireDataAbility, acquire a data ability by its authority, if it not existed,
230      * AMS loads it synchronously.
231      *
232      * @param uri, data ability uri.
233      * @param tryBind, true: when a data ability is died, ams will kill this client, or do nothing.
234      * @param callerToken, specifies the caller ability token.
235      * @return returns the data ability ipc object, or nullptr for failed.
236      */
237     sptr<IAbilityScheduler> AcquireDataAbility(const Uri &uri, bool tryBind, const sptr<IRemoteObject> &callerToken);
238 
239     /**
240      * ReleaseDataAbility, release the data ability that referenced by 'dataAbilityToken'.
241      *
242      * @param dataAbilityToken, specifies the data ability that will be released.
243      * @param callerToken, specifies the caller ability token.
244      * @return returns ERR_OK if succeeded, or error codes for failed.
245      */
246     ErrCode ReleaseDataAbility(sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken);
247 
248     /**
249      * dump ability stack info, about userID, mission stack info,
250      * mission record info and ability info.
251      *
252      * @param state Ability stack info.
253      * @return Returns ERR_OK on success, others on failure.
254      */
255     ErrCode DumpState(const std::string &args, std::vector<std::string> &state);
256     ErrCode DumpSysState(
257         const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int UserID);
258     /**
259      * Connect ability manager service.
260      *
261      * @return Returns ERR_OK on success, others on failure.
262      */
263     ErrCode Connect();
264 
265     /**
266      * Get all stack info from ability manager service.
267      *
268      * @return Returns ERR_OK on success, others on failure.
269      */
270     ErrCode GetAllStackInfo(StackInfo &stackInfo);
271 
272     /**
273      * Destroys this Service ability by Want.
274      *
275      * @param want, Special want for service type's ability.
276      * @return Returns true if this Service ability will be destroyed; returns false otherwise.
277      */
278     ErrCode StopServiceAbility(const Want &want);
279 
280     /**
281      * Get the list of the missions that the user has recently launched,
282      * with the most recent being first and older ones after in order.
283      *
284      * @param recentList recent mission info
285      * @param numMax The maximum number of entries to return in the list. The
286      * actual number returned may be smaller, depending on how many tasks the
287      * user has started and the maximum number the system can remember.
288      * @param flags Information about what to return.  May be any combination
289      * of {@link #RECENT_WITH_EXCLUDED} and {@link #RECENT_IGNORE_UNAVAILABLE}.
290      * @return Returns ERR_OK on success, others on failure.
291      */
292     ErrCode GetRecentMissions(const int32_t numMax, const int32_t flags, std::vector<AbilityMissionInfo> &recentList);
293 
294     /**
295      * Get mission snapshot by mission id
296      *
297      * @param missionId the id of the mission to retrieve the sAutoapshots
298      * @return Returns ERR_OK on success, others on failure.
299      */
300     ErrCode GetMissionSnapshot(const int32_t missionId, MissionSnapshot &missionSnapshot);
301 
302     /**
303      * Ask that the mission associated with a given mission ID be moved to the
304      * front of the stack, so it is now visible to the user.
305      *
306      * @param missionId.
307      * @return Returns ERR_OK on success, others on failure.
308      */
309     ErrCode MoveMissionToTop(int32_t missionId);
310 
311     /**
312      * Requires that tasks associated with a given capability token be moved to the background
313      *
314      * @param token ability token
315      * @param nonFirst If nonfirst is false and not the lowest ability of the mission, you cannot move mission to end
316      * @return Returns ERR_OK on success, others on failure.
317      */
318     ErrCode MoveMissionToEnd(const sptr<IRemoteObject> &token, const bool nonFirst);
319 
320     /**
321      * Remove the specified mission from the stack by missionid
322      *
323      * @param id.
324      * @return Returns ERR_OK on success, others on failure.
325      */
326     ErrCode RemoveMissions(std::vector<int> missionId);
327     ErrCode RemoveStack(int id);
328 
329     /**
330      * Kill the process immediately.
331      *
332      * @param bundleName.
333      * @return Returns ERR_OK on success, others on failure.
334      */
335     ErrCode KillProcess(const std::string &bundleName);
336 
337     /**
338      * Force ability timeout.
339      *
340      * @param abilityName.
341      * @param state. ability lifecycle state.
342      * @return Returns ERR_OK on success, others on failure.
343      */
344     ErrCode ForceTimeoutForTest(const std::string &abilityName, const std::string &state);
345 
346     /**
347      * ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
348      * clear the application data.
349      *
350      * @param bundleName, bundle name in Application record.
351      * @return
352      */
353     ErrCode ClearUpApplicationData(const std::string &bundleName);
354 
355     /**
356      * @brief Checks whether this ability is the first ability in a mission.
357      *
358      * @return Returns true is first in Mission.
359      */
360     ErrCode IsFirstInMission(const sptr<IRemoteObject> &token);
361 
362     /**
363      * Save the top ability States and move them to the background
364      * @return Returns ERR_OK on success, others on failure.
365      */
366     ErrCode PowerOff();
367 
368     /**
369      * Restore the state before top ability poweroff
370      * @return Returns ERR_OK on success, others on failure.
371      */
372     ErrCode PowerOn();
373 
374     /**
375      * Sets the application to start its ability in lock mission mode.
376      * @param missionId luck mission id
377      * @return Returns ERR_OK on success, others on failure.
378      */
379     ErrCode LockMission(int missionId);
380 
381     /**
382      * Unlocks this ability by exiting the lock mission mode.
383      * @param missionId unluck mission id
384      * @return Returns ERR_OK on success, others on failure.
385      */
386     ErrCode UnlockMission(int missionId);
387 
388     /**
389      * Sets description information about the mission containing this ability.
390      *
391      * @param description Indicates the object containing information about the
392      *                    mission. This parameter cannot be null.
393      * @return Returns ERR_OK on success, others on failure.
394      */
395     ErrCode SetMissionDescriptionInfo(const sptr<IRemoteObject> &token, const MissionDescriptionInfo &description);
396 
397     /**
398      * get current system mission lock mode state.
399      *
400      * @return Returns 0: LOCK_MISSION_STATE_NONE, 1: LOCK_MISSION_STATE_LOCKED
401      */
402     int GetMissionLockModeState();
403 
404     int UpdateConfiguration(const AppExecFwk::Configuration &config);
405 
406     sptr<IWantSender> GetWantSender(const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken);
407 
408     ErrCode SendWantSender(const sptr<IWantSender> &target, const SenderInfo &senderInfo);
409 
410     void CancelWantSender(const sptr<IWantSender> &sender);
411 
412     ErrCode GetPendingWantUid(const sptr<IWantSender> &target, int32_t &uid);
413 
414     ErrCode GetPendingWantUserId(const sptr<IWantSender> &target, int32_t &userId);
415 
416     ErrCode GetPendingWantBundleName(const sptr<IWantSender> &target, std::string &bundleName);
417 
418     ErrCode GetPendingWantCode(const sptr<IWantSender> &target, int32_t &code);
419 
420     ErrCode GetPendingWantType(const sptr<IWantSender> &target, int32_t &type);
421 
422     void RegisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &recevier);
423 
424     void UnregisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &recevier);
425 
426     ErrCode GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want);
427 
428     ErrCode GetWantSenderInfo(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info);
429 
430     /**
431      * Moving mission to the specified stack by mission option(Enter floating window mode).
432      * @param missionOption, target mission option
433      * @return Returns ERR_OK on success, others on failure.
434      */
435     ErrCode MoveMissionToFloatingStack(const MissionOption &missionOption);
436 
437     /**
438      * Moving mission to the specified stack by mission option(Enter floating window mode).
439      * @param primary, display primary mission option
440      * @param secondary, display secondary mission option
441      * @return Returns ERR_OK on success, others on failure.
442      */
443     ErrCode MoveMissionToSplitScreenStack(const MissionOption &primary, const MissionOption &secondary);
444 
445     /**
446      * minimize multiwindow by mission id.
447      * @param missionId, the id of target mission
448      * @return Returns ERR_OK on success, others on failure.
449      */
450     ErrCode MinimizeMultiWindow(int missionId);
451 
452     /**
453      * maximize multiwindow by mission id.
454      * @param missionId, the id of target mission
455      * @return Returns ERR_OK on success, others on failure.
456      */
457     ErrCode MaximizeMultiWindow(int missionId);
458 
459     /**
460      * Change the focus of ability in the mission stack.
461      * @param lostToken, the token of lost focus ability
462      * @param getToken, the token of get focus ability
463      * @return Returns ERR_OK on success, others on failure.
464      */
465     ErrCode ChangeFocusAbility(const sptr<IRemoteObject> &lostFocusToken, const sptr<IRemoteObject> &getFocusToken);
466 
467     /**
468      * get missions info of floating mission stack.
469      * @param list, mission info.
470      * @return Returns ERR_OK on success, others on failure.
471      */
472     ErrCode GetFloatingMissions(std::vector<AbilityMissionInfo> &list);
473 
474     /**
475      * close multiwindow by mission id.
476      * @param missionId, the id of target mission.
477      * @return Returns ERR_OK on success, others on failure.
478      */
479     ErrCode CloseMultiWindow(int missionId);
480 
481     /**
482      * set special mission stack default settings.
483      * @param stackSetting, mission stack default settings.
484      * @return Returns ERR_OK on success, others on failure.
485      */
486     ErrCode SetMissionStackSetting(const StackSetting &stackSetting);
487 
488     /**
489      * set lock screen Permit list
490      *
491      * @param isAllow whether to allow startup on lock screen.
492      * @return Returns ERR_OK on success, others on failure.
493      */
494     ErrCode SetShowOnLockScreen(bool isAllow);
495 
496     /**
497      * Get system memory information.
498      * @param SystemMemoryAttr, memory information.
499      */
500     void GetSystemMemoryAttr(AppExecFwk::SystemMemoryAttr &memoryInfo);
501 
502     /**
503      * ContinueMission, continue ability from mission center.
504      *
505      * @param srcDeviceId, origin deviceId.
506      * @param dstDeviceId, target deviceId.
507      * @param missionId, indicates which ability to continue.
508      * @param callBack, notify result back.
509      * @param wantParams, extended params.
510      * @return Returns ERR_OK on success, others on failure.
511      */
512     ErrCode ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId, int32_t missionId,
513         const sptr<IRemoteObject> &callback, AAFwk::WantParams &wantParams);
514 
515     /**
516      * start continuation.
517      * @param want, used to start a ability.
518      * @param abilityToken, ability token.
519      * @param status, continue status.
520      * @return Returns ERR_OK on success, others on failure.
521      */
522     ErrCode StartContinuation(const Want &want, const sptr<IRemoteObject> &abilityToken, int32_t status);
523 
524     /**
525      * notify continuation complete to dms.
526      * @param deviceId, source device which start a continuation.
527      * @param sessionId, represent a continuaion.
528      * @param isSuccess, continuation result.
529      * @return
530      */
531     void NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess);
532 
533     /**
534      * @brief Lock specified mission.
535      * @param missionId The id of target mission.
536      *
537      * @return Returns ERR_OK on success, others on failure.
538      */
539     ErrCode LockMissionForCleanup(int32_t missionId);
540 
541     /**
542      * @brief Unlock specified mission.
543      * @param missionId The id of target mission.
544      *
545      * @return Returns ERR_OK on success, others on failure.
546      */
547     ErrCode UnlockMissionForCleanup(int32_t missionId);
548 
549     /**
550      * @brief Register mission listener to ams.
551      * @param listener The handler of listener.
552      *
553      * @return Returns ERR_OK on success, others on failure.
554      */
555     ErrCode RegisterMissionListener(const sptr<IMissionListener> &listener);
556 
557     /**
558      * @brief UnRegister mission listener from ams.
559      * @param listener The handler of listener.
560      *
561      * @return Returns ERR_OK on success, others on failure.
562      */
563     ErrCode UnRegisterMissionListener(const sptr<IMissionListener> &listener);
564 
565     /**
566      * @brief Register mission listener to ability manager service.
567      * @param deviceId The remote device Id.
568      * @param listener The handler of listener.
569      *
570      * @return Returns ERR_OK on success, others on failure.
571      */
572     ErrCode RegisterMissionListener(const std::string &deviceId, const sptr<IRemoteMissionListener> &listener);
573 
574     /**
575      * @brief UnRegister mission listener from ability manager service.
576      * @param deviceId The remote device Id.
577      * @param listener The handler of listener.
578      *
579      * @return Returns ERR_OK on success, others on failure.
580      */
581     ErrCode UnRegisterMissionListener(const std::string &deviceId, const sptr<IRemoteMissionListener> &listener);
582 
583     /**
584      * @brief Get mission infos from ams.
585      * @param deviceId local or remote deviceid.
586      * @param numMax max number of missions.
587      * @param missionInfos mission info result.
588      *
589      * @return Returns ERR_OK on success, others on failure.
590      */
591     ErrCode GetMissionInfos(const std::string &deviceId, int32_t numMax, std::vector<MissionInfo> &missionInfos);
592 
593     /**
594      * @brief Get mission info by id.
595      * @param deviceId local or remote deviceid.
596      * @param missionId Id of target mission.
597      * @param missionInfo mision info of target mission.
598      *
599      * @return Returns ERR_OK on success, others on failure.
600      */
601     ErrCode GetMissionInfo(const std::string &deviceId, int32_t missionId, MissionInfo &missionInfo);
602 
603     /**
604      * @brief Get the Mission Snapshot Info object
605      * @param deviceId local or remote deviceid.
606      * @param missionId Id of target mission.
607      * @param snapshot snapshot of target mission
608      * @return Returns ERR_OK on success, others on failure.
609      */
610     ErrCode GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot);
611 
612     /**
613      * @brief Clean mission by id.
614      * @param missionId Id of target mission.
615      *
616      * @return Returns ERR_OK on success, others on failure.
617      */
618     ErrCode CleanMission(int32_t missionId);
619 
620     /**
621      * @brief Clean all missions in system.
622      *
623      * @return Returns ERR_OK on success, others on failure.
624      */
625     ErrCode CleanAllMissions();
626 
627     /**
628      * @brief Move a mission to front.
629      * @param missionId Id of target mission.
630      * @param startOptions Special startOptions for target mission.
631      *
632      * @return Returns ERR_OK on success, others on failure.
633      */
634     ErrCode MoveMissionToFront(int32_t missionId);
635     ErrCode MoveMissionToFront(int32_t missionId, const StartOptions &startOptions);
636 
637     /**
638      * @brief Get mission id by ability token.
639      *
640      * @param token ability token.
641      * @param missionId output mission id.
642      * @return Returns ERR_OK on success, others on failure.
643      */
644     ErrCode GetMissionIdByToken(const sptr<IRemoteObject> &token, int32_t &missionId);
645 
646 	/**
647      * Start Ability, connect session with common ability.
648      *
649      * @param want, Special want for service type's ability.
650      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
651      * @return Returns ERR_OK on success, others on failure.
652      */
653     ErrCode StartAbilityByCall(
654         const Want &want, const sptr<IAbilityConnection> &connect, const sptr<IRemoteObject> &callToken);
655 
656     /**
657      * Release Ability, disconnect session with common ability.
658      *
659      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
660      * @return Returns ERR_OK on success, others on failure.
661      */
662     ErrCode ReleaseAbility(const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element);
663 
664     ErrCode GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info);
665 
666     ErrCode GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info);
667 
668     ErrCode GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info);
669 
670     /**
671      * Start synchronizing remote device mission
672      * @param devId, deviceId.
673      * @param fixConflict, resolve synchronizing conflicts flag.
674      * @param tag, call tag.
675      * @return Returns ERR_OK on success, others on failure.
676      */
677     ErrCode StartSyncRemoteMissions(const std::string &devId, bool fixConflict, int64_t tag);
678 
679     /**
680      * Stop synchronizing remote device mission
681      * @param devId, deviceId.
682      * @return Returns ERR_OK on success, others on failure.
683      */
684     ErrCode StopSyncRemoteMissions(const std::string &devId);
685 
686     /**
687      * @brief start user.
688      * @param accountId accountId.
689      *
690      * @return Returns ERR_OK on success, others on failure.
691      */
692     ErrCode StartUser(int accountId);
693 
694     /**
695      * @brief stop user.
696      * @param accountId accountId.
697      * @param callback callback.
698      *
699      * @return Returns ERR_OK on success, others on failure.
700      */
701     ErrCode StopUser(int accountId, const sptr<IStopUserCallback> &callback);
702 
703     /**
704      * @brief Register the snapshot handler
705      * @param handler snapshot handler
706      * @return ErrCode Returns ERR_OK on success, others on failure.
707      */
708     ErrCode RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler);
709 
710     /**
711      * Set mission label of this ability.
712      *
713      * @param abilityToken Indidate token of ability.
714      * @param label Indidate the label showed of the ability in recent missions.
715      * @return Returns ERR_OK on success, others on failure.
716      */
717     ErrCode SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label);
718 
719 #ifdef SUPPORT_GRAPHICS
720     /**
721      * Set mission icon of this ability.
722      *
723      * @param abilityToken Indidate token of ability.
724      * @param icon Indidate the icon showed of the ability in recent missions.
725      * @return Returns ERR_OK on success, others on failure.
726      */
727     ErrCode SetMissionIcon(const sptr<IRemoteObject> &abilityToken,
728         const std::shared_ptr<OHOS::Media::PixelMap> &icon);
729 #endif
730 
731     /**
732      * @brief start user test.
733      * @param want the want of the ability user test to start.
734      * @param observer test observer callback.
735      *
736      * @return Returns ERR_OK on success, others on failure.
737      */
738     ErrCode StartUserTest(const Want &want, const sptr<IRemoteObject> &observer);
739 
740     /**
741      * @brief Finish user test.
742      * @param msg user test message.
743      * @param resultCode user test result Code.
744      * @param bundleName user test bundleName.
745      *
746      * @return Returns ERR_OK on success, others on failure.
747      */
748     ErrCode FinishUserTest(const std::string &msg, const int &resultCode, const std::string &bundleName);
749 
750     /**
751      * GetCurrentTopAbility, get the token of current top ability.
752      *
753      * @param token, the token of current top ability.
754      * @return Returns ERR_OK on success, others on failure.
755      */
756     ErrCode GetCurrentTopAbility(sptr<IRemoteObject> &token);
757 
758     /**
759      * DelegatorDoAbilityForeground, the delegator calls this interface to move the ability to the foreground.
760      *
761      * @param token, ability's token.
762      * @return Returns ERR_OK on success, others on failure.
763      */
764     ErrCode DelegatorDoAbilityForeground(const sptr<IRemoteObject> &token);
765 
766     /**
767      * DelegatorDoAbilityBackground, the delegator calls this interface to move the ability to the background.
768      *
769      * @param token, ability's token.
770      * @return Returns ERR_OK on success, others on failure.
771      */
772     ErrCode DelegatorDoAbilityBackground(const sptr<IRemoteObject> &token);
773 
774    /**
775      * Calls this interface to move the ability to the foreground.
776      *
777      * @param token, ability's token.
778      * @param flag, use for lock or unlock flag and so on.
779      * @return Returns ERR_OK on success, others on failure.
780      */
781     ErrCode DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag);
782 
783     /**
784      * Calls this interface to move the ability to the background.
785      *
786      * @param token, ability's token.
787      * @param flag, use for lock or unlock flag and so on.
788      * @return Returns ERR_OK on success, others on failure.
789      */
790     ErrCode DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag);
791 
792     /**
793      * Set ability controller.
794      *
795      * @param abilityController, The ability controller.
796      * @return Returns ERR_OK on success, others on failure.
797      */
798     virtual int SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController,
799         bool imAStabilityTest);
800 
801     /**
802      * Send not response process ID to ability manager service.
803      *
804      * @param pid The not response process ID.
805      * @return Returns ERR_OK on success, others on failure.
806      */
807     ErrCode SendANRProcessID(int pid);
808 
809     /**
810      * Called when client complete dump.
811      *
812      * @param infos The dump info.
813      * @param callerToken The caller ability token.
814      * @return Returns ERR_OK on success, others on failure.
815      */
816     ErrCode DumpAbilityInfoDone(std::vector<std::string> &infos, const sptr<IRemoteObject> &callerToken);
817 
818 private:
819     static std::mutex mutex_;
820     static std::shared_ptr<AbilityManagerClient> instance_;
821     sptr<IRemoteObject> remoteObject_;
822 };
823 }  // namespace AAFwk
824 }  // namespace OHOS
825 #endif  // OHOS_AAFWK_ABILITY_MANAGER_H
826