• 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_RECORD_H
17 #define OHOS_AAFWK_ABILITY_RECORD_H
18 
19 #include <ctime>
20 #include <functional>
21 #include <list>
22 #include <memory>
23 #include <vector>
24 
25 #include "ability_connect_callback_interface.h"
26 #include "ability_info.h"
27 #include "ability_start_setting.h"
28 #include "ability_token_stub.h"
29 #ifdef SUPPORT_GRAPHICS
30 #include "ability_window_configuration.h"
31 #endif
32 #include "app_scheduler.h"
33 #include "application_info.h"
34 #include "ability_record_info.h"
35 #include "bundlemgr/bundle_mgr_interface.h"
36 #include "call_container.h"
37 #include "lifecycle_deal.h"
38 #include "lifecycle_state_info.h"
39 #include "want.h"
40 #include "window_info.h"
41 #include "uri.h"
42 
43 namespace OHOS {
44 namespace AAFwk {
45 using Closure = std::function<void()>;
46 
47 class AbilityRecord;
48 class MissionRecord;
49 class ConnectionRecord;
50 class Mission;
51 class MissionList;
52 class CallContainer;
53 
54 const std::string ABILITY_TOKEN_NAME = "AbilityToken";
55 const std::string LINE_SEPARATOR = "\n";
56 constexpr int32_t API_VERSION_7 = 7;
57 
58 /**
59  * @class Token
60  * Token is identification of ability and used to interact with kit and wms.
61  */
62 class Token : public AbilityTokenStub {
63 public:
64     explicit Token(std::weak_ptr<AbilityRecord> abilityRecord);
65     virtual ~Token();
66 
67     std::shared_ptr<AbilityRecord> GetAbilityRecord() const;
68     static std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token);
69 
70 private:
71     std::weak_ptr<AbilityRecord> abilityRecord_;  // ability of this token
72 };
73 
74 /**
75  * @class AbilityResult
76  * Record requestCode of for-result start mode and result.
77  */
78 class AbilityResult {
79 public:
80     AbilityResult() = default;
AbilityResult(int requestCode,int resultCode,const Want & resultWant)81     AbilityResult(int requestCode, int resultCode, const Want &resultWant)
82         : requestCode_(requestCode), resultCode_(resultCode), resultWant_(resultWant)
83     {}
~AbilityResult()84     virtual ~AbilityResult()
85     {}
86 
87     int requestCode_ = -1;  // requestCode of for-result start mode
88     int resultCode_ = -1;   // resultCode of for-result start mode
89     Want resultWant_;       // for-result start mode ability will send the result to caller
90 };
91 
92 /**
93  * @class CallerRecord
94  * Record caller ability of for-result start mode and result.
95  */
96 class CallerRecord {
97 public:
98     CallerRecord() = default;
CallerRecord(int requestCode,std::weak_ptr<AbilityRecord> caller)99     CallerRecord(int requestCode, std::weak_ptr<AbilityRecord> caller) : requestCode_(requestCode), caller_(caller)
100     {}
~CallerRecord()101     virtual ~CallerRecord()
102     {}
103 
GetRequestCode()104     int GetRequestCode()
105     {
106         return requestCode_;
107     }
GetCaller()108     std::shared_ptr<AbilityRecord> GetCaller()
109     {
110         return caller_.lock();
111     }
112 
113 private:
114     int requestCode_ = -1;  // requestCode of for-result start mode
115     std::weak_ptr<AbilityRecord> caller_;
116 };
117 
118 /**
119  * @class AbilityRequest
120  * Wrap parameters of starting ability.
121  */
122 enum AbilityCallType {
123     INVALID_TYPE = 0,
124     CALL_REQUEST_TYPE,
125 };
126 struct AbilityRequest {
127     Want want;
128     AppExecFwk::AbilityInfo abilityInfo;
129     AppExecFwk::ApplicationInfo appInfo;
130     int32_t uid = 0;
131     int requestCode = -1;
132     bool restart = false;
133     int32_t restartCount = -1;
134 
135     // call ability
136     int callerUid = -1;
137     AbilityCallType callType = AbilityCallType::INVALID_TYPE;
138     sptr<IRemoteObject> callerToken = nullptr;
139     sptr<IAbilityConnection> connect = nullptr;
140 
141     std::shared_ptr<AbilityStartSetting> startSetting = nullptr;
142     int32_t compatibleVersion = 0;
143     std::string specifiedFlag;
144 
IsNewVersionAbilityRequest145     bool IsNewVersion() const
146     {
147         return compatibleVersion > API_VERSION_7;
148     }
149 
IsContinuationAbilityRequest150     bool IsContinuation() const
151     {
152         auto flags = want.GetFlags();
153         if ((flags & Want::FLAG_ABILITY_CONTINUATION) == Want::FLAG_ABILITY_CONTINUATION) {
154             return true;
155         }
156         return false;
157     }
158 
IsCallTypeAbilityRequest159     bool IsCallType(const AbilityCallType & type) const
160     {
161         return (callType == type);
162     }
163 
DumpAbilityRequest164     void Dump(std::vector<std::string> &state)
165     {
166         std::string dumpInfo = "      want [" + want.ToUri() + "]";
167         state.push_back(dumpInfo);
168         dumpInfo = "      app name [" + abilityInfo.applicationName + "]";
169         state.push_back(dumpInfo);
170         dumpInfo = "      main name [" + abilityInfo.name + "]";
171         state.push_back(dumpInfo);
172         dumpInfo = "      request code [" + std::to_string(requestCode) + "]";
173         state.push_back(dumpInfo);
174     }
175 };
176 
177 // new version
178 enum ResolveResultType {
179     OK_NO_REMOTE_OBJ = 0,
180     OK_HAS_REMOTE_OBJ,
181     NG_INNER_ERROR,
182 };
183 /**
184  * @class AbilityRecord
185  * AbilityRecord records ability info and states and used to schedule ability life.
186  */
187 class AbilityRecord : public std::enable_shared_from_this<AbilityRecord> {
188 public:
189     AbilityRecord(const Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
190         const AppExecFwk::ApplicationInfo &applicationInfo, int requestCode = -1, int32_t apiVersion = 1);
191 
192     virtual ~AbilityRecord();
193 
194     /**
195      * CreateAbilityRecord.
196      *
197      * @param abilityRequest,create ability record.
198      * @return Returns ability record ptr.
199      */
200     static std::shared_ptr<AbilityRecord> CreateAbilityRecord(const AbilityRequest &abilityRequest);
201 
202     /**
203      * Init ability record.
204      *
205      * @return Returns true on success, others on failure.
206      */
207     bool Init();
208 
209     /**
210      * load ability.
211      *
212      * @return Returns ERR_OK on success, others on failure.
213      */
214     int LoadAbility();
215 
216     /**
217      * foreground the ability.
218      *
219      */
220     void ForegroundAbility(uint32_t sceneFlag = 0);
221 
222     /**
223      * process request of foregrounding the ability.
224      *
225      */
226     void ProcessForegroundAbility(uint32_t sceneFlag = 0);
227 
228     /**
229      * move the ability to back ground.
230      *
231      * @param task timeout task.
232      */
233     void BackgroundAbility(const Closure &task);
234 
235     /**
236      * terminate ability.
237      *
238      * @return Returns ERR_OK on success, others on failure.
239      */
240     int TerminateAbility();
241 
242     /**
243      * set ability's mission record.
244      *
245      * @param missionRecord, mission record.
246      */
247     void SetMissionRecord(const std::shared_ptr<MissionRecord> &missionRecord);
248 
249     /**
250      * set ability's mission stack.
251      *
252      * @param missionStack, mission stack.
253      */
254     void SetMissionStackId(const int stackId);
255 
256     /**
257      * Get ability's mission stack id.
258      */
259     int GetMissionStackId() const;
260 
261     /**
262      * get ability's mission record.
263      *
264      * @return missionRecord, mission record.
265      */
266     std::shared_ptr<MissionRecord> GetMissionRecord() const;
267 
268     int GetMissionRecordId() const;
269 
270     /**
271      * get ability's info.
272      *
273      * @return ability info.
274      */
275     const AppExecFwk::AbilityInfo &GetAbilityInfo() const;
276 
277     /**
278      * get application's info.
279      *
280      * @return application info.
281      */
282     const AppExecFwk::ApplicationInfo &GetApplicationInfo() const;
283 
284     /**
285      * set ability's state.
286      *
287      * @param state, ability's state.
288      */
289     void SetAbilityState(AbilityState state);
290 
291     /**
292      * get ability's state.
293      *
294      * @return ability state.
295      */
296     AbilityState GetAbilityState() const;
297 
298     bool IsForeground() const;
299 
300     /**
301      * set ability scheduler for accessing ability thread.
302      *
303      * @param scheduler , ability scheduler.
304      */
305     void SetScheduler(const sptr<IAbilityScheduler> &scheduler);
306 
307     /**
308      * get ability's token.
309      *
310      * @return ability's token.
311      */
312     sptr<Token> GetToken() const;
313 
314     /**
315      * set ability's previous ability record.
316      *
317      * @param abilityRecord , previous ability record
318      */
319     void SetPreAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord);
320 
321     /**
322      * get ability's previous ability record.
323      *
324      * @return previous ability record
325      */
326     std::shared_ptr<AbilityRecord> GetPreAbilityRecord() const;
327 
328     /**
329      * set ability's next ability record.
330      *
331      * @param abilityRecord , next ability record
332      */
333     void SetNextAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord);
334 
335     /**
336      * get ability's previous ability record.
337      *
338      * @return previous ability record
339      */
340     std::shared_ptr<AbilityRecord> GetNextAbilityRecord() const;
341 
342     /**
343      * set ability's back ability record.
344      *
345      * @param abilityRecord , back ability record
346      */
347     void SetBackAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord);
348 
349     /**
350      * get ability's back ability record.
351      *
352      * @return back ability record
353      */
354     std::shared_ptr<AbilityRecord> GetBackAbilityRecord() const;
355 
356     /**
357      * set event id.
358      *
359      * @param eventId
360      */
361     void SetEventId(int64_t eventId);
362 
363     /**
364      * get event id.
365      *
366      * @return eventId
367      */
368     int64_t GetEventId() const;
369 
370     /**
371      * check whether the ability is ready.
372      *
373      * @return true : ready ,false: not ready
374      */
375     bool IsReady() const;
376 
377 #ifdef SUPPORT_GRAPHICS
378     /**
379      * check whether the ability 's window is attached.
380      *
381      * @return true : attached ,false: not attached
382      */
383     bool IsWindowAttached() const;
384 #endif
385 
386     /**
387      * check whether the ability is launcher.
388      *
389      * @return true : lanucher ,false: not lanucher
390      */
391     bool IsLauncherAbility() const;
392 
393     /**
394      * check whether the ability is terminating.
395      *
396      * @return true : yes ,false: not
397      */
398     bool IsTerminating() const;
399 
400     /**
401      * check whether the ability force to terminate.
402      *
403      * @return true : yes ,false: not
404      */
405     bool IsForceTerminate() const;
406     void SetForceTerminate(bool flag);
407 
408     /**
409      * set the ability is terminating.
410      *
411      */
412     void SetTerminatingState();
413 
414     /**
415      * set the ability is new want flag.
416      *
417      * @return isNewWant
418      */
419     void SetIsNewWant(bool isNewWant);
420 
421     /**
422      * check whether the ability is new want flag.
423      *
424      * @return true : yes ,false: not
425      */
426     bool IsNewWant() const;
427 
428     /**
429      * check whether the ability is created by connect ability mode.
430      *
431      * @return true : yes ,false: not
432      */
433     bool IsCreateByConnect() const;
434 
435     /**
436      * set the ability is created by connect ability mode.
437      *
438      */
439     void SetCreateByConnectMode();
440 
441     /**
442      * active the ability.
443      *
444      */
445     virtual void Activate();
446 
447     /**
448      * process request of activing the ability.
449      *
450      */
451     void ProcessActivate();
452 
453     /**
454      * process request of activing the ability in moving.
455      *
456      */
457     void ProcessActivateInMoving();
458 
459     /**
460      * process request of inactiving the ability.
461      *
462      */
463     void ProcessInactivate();
464 
465     /**
466      * process request of inactiving the ability in moving.
467      *
468      */
469     void ProcessInactivateInMoving();
470 
471     /**
472      * inactive the ability.
473      *
474      */
475     virtual void Inactivate();
476 
477     /**
478      * move the ability to back ground.
479      *
480      */
481     virtual void MoveToBackground(const Closure &task);
482 
483     /**
484      * terminate the ability.
485      *
486      */
487     void Terminate(const Closure &task);
488 
489     /**
490      * connect the ability.
491      *
492      */
493     void ConnectAbility();
494 
495     /**
496      * disconnect the ability.
497      *
498      */
499     void DisconnectAbility();
500 
501     /**
502      * Command the ability.
503      *
504      */
505     void CommandAbility();
506 
507     /**
508      * save ability state.
509      *
510      */
511     void SaveAbilityState();
512     void SaveAbilityState(const PacMap &inState);
513 
514     /**
515      * restore ability state.
516      *
517      */
518     void RestoreAbilityState();
519 
520     /**
521      * notify top active ability updated.
522      *
523      */
524     void TopActiveAbilityChanged(bool flag);
525 
526     /**
527      * set the want for start ability.
528      *
529      */
530     void SetWant(const Want &want);
531 
532     /**
533      * get the want for start ability.
534      *
535      */
536     const Want &GetWant() const;
537 
538     /**
539      * get request code of the ability to start.
540      *
541      */
542     int GetRequestCode() const;
543 
544     /**
545      * set the result object of the ability which one need to be terminated.
546      *
547      */
548     void SetResult(const std::shared_ptr<AbilityResult> &result);
549 
550     /**
551      * get the result object of the ability which one need to be terminated.
552      *
553      */
554     std::shared_ptr<AbilityResult> GetResult() const;
555 
556     /**
557      * send result object to caller ability thread.
558      *
559      */
560     void SendResult();
561 
562     /**
563      * send result object to caller ability.
564      *
565      */
566     void SendResultToCallers();
567 
568     /**
569      * save result object to caller ability.
570      *
571      */
572     void SaveResultToCallers(const int resultCode, const Want *resultWant);
573 
574     /**
575      * add connect record to the list.
576      *
577      */
578     void AddConnectRecordToList(const std::shared_ptr<ConnectionRecord> &connRecord);
579 
580     /**
581      * get the list of connect record.
582      *
583      */
584     std::list<std::shared_ptr<ConnectionRecord>> GetConnectRecordList() const;
585 
586     /**
587      * get the list of connect record.
588      *
589      */
590     std::list<std::shared_ptr<ConnectionRecord>> GetConnectingRecordList();
591 
592     /**
593      * remove the connect record from list.
594      *
595      */
596     void RemoveConnectRecordFromList(const std::shared_ptr<ConnectionRecord> &connRecord);
597 
598     /**
599      * check whether connect list is empty.
600      *
601      */
602     bool IsConnectListEmpty();
603 
604 #ifdef SUPPORT_GRAPHICS
605     /**
606      * add ability's window info to record.
607      *
608      */
609     void AddWindowInfo(int windowToken);
610 
611     /**
612      * remove ability's window info from record.
613      *
614      */
615     void RemoveWindowInfo();
616 
617     /**
618      * get ability's window info from record.
619      *
620      */
621     std::shared_ptr<WindowInfo> GetWindowInfo() const;
622 #endif
623 
624     /**
625      * add caller record
626      *
627      */
628     void AddCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode);
629 
630     /**
631      * get caller record to list.
632      *
633      */
634     std::list<std::shared_ptr<CallerRecord>> GetCallerRecordList() const;
635     std::shared_ptr<AbilityRecord> GetCallerRecord() const;
636 
637     /**
638      * get connecting record from list.
639      *
640      */
641     std::shared_ptr<ConnectionRecord> GetConnectingRecord() const;
642 
643     /**
644      * get disconnecting record from list.
645      *
646      */
647     std::shared_ptr<ConnectionRecord> GetDisconnectingRecord() const;
648 
649     /**
650      * convert ability state (enum type to string type).
651      *
652      */
653     static std::string ConvertAbilityState(const AbilityState &state);
654 
655     static std::string ConvertAppState(const AppState &state);
656 
657     /**
658      * convert life cycle state to ability state .
659      *
660      */
661     static int ConvertLifeCycleToAbilityState(const AbilityLifeCycleState &state);
662 
663     /**
664      * get the ability record id.
665      *
666      */
GetRecordId()667     inline int GetRecordId() const
668     {
669         return recordId_;
670     }
671 
672     /**
673      * dump ability info.
674      *
675      */
676     void Dump(std::vector<std::string> &info);
677 
678     void DumpSys(std::vector<std::string> &info, bool isClient = false);
679 
680     void DumpClientInfo(std::vector<std::string> &info, const std::vector<std::string> &params,
681         bool isClient = false, bool dumpConfig = true) const;
682 
683     /**
684      * Called when client complete dump.
685      *
686      * @param infos The dump info.
687      */
688     void DumpAbilityInfoDone(std::vector<std::string> &infos);
689 
690     /**
691      * dump ability state info.
692      *
693      */
694     void DumpAbilityState(std::vector<std::string> &info, bool isClient, const std::vector<std::string> &params);
695 
696     void SetStartTime();
697 
698     int64_t GetStartTime() const;
699 
700     /**
701      * dump service info.
702      *
703      */
704     void DumpService(std::vector<std::string> &info, bool isClient = false) const;
705 
706     /**
707      * get ability record info.
708      *
709      */
710     void GetAbilityRecordInfo(AbilityRecordInfo &recordInfo);
711 
712     /**
713      * set aconnect remote object.
714      *
715      */
716     void SetConnRemoteObject(const sptr<IRemoteObject> &remoteObject);
717 
718     /**
719      * get connect remote object.
720      *
721      */
722     sptr<IRemoteObject> GetConnRemoteObject() const;
723 
724     void AddStartId();
725     int GetStartId() const;
726 
727     void SetIsUninstallAbility();
728     /**
729      * Determine whether ability is uninstalled
730      *
731      * @return true: uninstalled false: installed
732      */
733     bool IsUninstallAbility() const;
734 
735     void SetKernalSystemAbility();
736     bool IsKernalSystemAbility() const;
737 
738     void SetLauncherRoot();
739     bool IsLauncherRoot() const;
740 
741     bool IsAbilityState(const AbilityState &state) const;
742     bool IsActiveState() const;
743 
744 #ifdef SUPPORT_GRAPHICS
745     bool SupportMultWindow() const;
746     void NotifyMultiWinModeChanged(const AbilityWindowConfiguration &winModeKey, bool flag);
747 #endif
748     void SetInMovingState(bool isMoving);
749     bool GetInMovingState() const;
750 
751     bool IsToEnd() const;
752     void SetToEnd(bool isToEnd);
753 
754     void SetStartSetting(const std::shared_ptr<AbilityStartSetting> &setting);
755     std::shared_ptr<AbilityStartSetting> GetStartSetting() const;
756 
757     void SetPowerState(const bool isPower);
758     bool GetPowerState() const;
759 
760     void SetRestarting(const bool isRestart);
761     void SetRestarting(const bool isRestart, int32_t canReStartCount);
762     int32_t GetRestartCount() const;
763     bool IsRestarting() const;
764     void SetAppState(const AppState &state);
765     AppState GetAppState() const;
766 
767     void ClearFlag();
768 
769     void SetLockScreenState(const bool isLock);
770     bool GetLockScreenState() const;
771     void SetMovingBackgroundFlag(bool isMoving);
772     bool IsMovingBackground() const;
773 
774     void SetLockScreenRoot();
775     bool IsLockScreenRoot() const;
776     void SetPowerStateLockScreen(const bool isPower);
777     bool GetPowerStateLockScreen() const;
778 
779     bool IsNewVersion();
780     void SetLaunchReason(const LaunchReason &reason);
781     void SetLastExitReason(const LastExitReason &reason);
782     void ContinueAbility(const std::string& deviceId);
783     void NotifyContinuationResult(int32_t result);
784     std::shared_ptr<MissionList> GetOwnedMissionList() const;
785 
786     void SetUseNewMission();
787     void SetMission(const std::shared_ptr<Mission> &mission);
788     void SetMissionList(const std::shared_ptr<MissionList> &missionList);
789     std::shared_ptr<Mission> GetMission() const;
790     int32_t GetMissionId() const;
791 
792     void SetUid(int32_t uid);
793     int32_t GetUid();
794     void SetSwitchingPause(bool state);
795     bool IsSwitchingPause();
796     void SetOwnerMissionUserId(int32_t userId);
797     int32_t GetOwnerMissionUserId();
798 
799     // new version
800     ResolveResultType Resolve(const AbilityRequest &abilityRequest);
801     bool Release(const sptr<IAbilityConnection> & connect);
802     bool IsNeedToCallRequest() const;
803     bool IsStartedByCall() const;
804     void SetStartedByCall(const bool isFlag);
805     bool CallRequest();
806     bool IsStartToBackground() const;
807     void SetStartToBackground(const bool flag);
808     void SetMinimizeReason(bool fromUser);
809     bool IsMinimizeFromUser() const;
810 
811     void SetSpecifiedFlag(const std::string &flag);
812     std::string GetSpecifiedFlag() const;
813     void SetWindowMode(int32_t windowMode);
814     void RemoveWindowMode();
815     LifeCycleStateInfo lifeCycleStateInfo_;                // target life state info
816 
817     bool CanRestartRootLauncher();
818 
819 protected:
820     void SendEvent(uint32_t msg, uint32_t timeOut);
821 
822     sptr<Token> token_ = {};                               // used to interact with kit and wms
823     std::unique_ptr<LifecycleDeal> lifecycleDeal_ = {};    // life manager used to schedule life
824     AbilityState currentState_ = AbilityState::INITIAL;    // current life state
825     Want want_ = {};                                       // want to start this ability
826     static int64_t g_abilityRecordEventId_;
827     int64_t eventId_ = 0;                                  // post event id
828 
829 private:
830     /**
831      * get the type of ability.
832      *
833      */
834     void GetAbilityTypeString(std::string &typeStr);
835     void OnSchedulerDied(const wptr<IRemoteObject> &remote);
836     void GrantUriPermission(const Want &want);
837     int GetCurrentAccountId();
838 
839     static int64_t abilityRecordId;
840     int recordId_ = 0;                                // record id
841     AppExecFwk::AbilityInfo abilityInfo_ = {};             // the ability info get from BMS
842     AppExecFwk::ApplicationInfo applicationInfo_ = {};     // the ability info get from BMS
843     std::weak_ptr<MissionRecord> missionRecord_ = {};      // mission of this ability
844     std::weak_ptr<AbilityRecord> preAbilityRecord_ = {};   // who starts this ability record
845     std::weak_ptr<AbilityRecord> nextAbilityRecord_ = {};  // ability that started by this ability
846     std::weak_ptr<AbilityRecord> backAbilityRecord_ = {};  // who back to this ability record
847     int64_t startTime_ = 0;                           // records first time of ability start
848     bool isReady_ = false;                            // is ability thread attached?
849     bool isWindowAttached_ = false;                   // Is window of this ability attached?
850     bool isLauncherAbility_ = false;                  // is launcher?
851 
852     sptr<IAbilityScheduler> scheduler_ = {};       // kit scheduler
853     bool isTerminating_ = false;              // is terminating ?
854     std::shared_ptr<WindowInfo> windowInfo_;  // add window info
855     bool isCreateByConnect_ = false;          // is created by connect ability mode?
856     bool isToEnd_ = false;                    // is to end ?
857 
858     int requestCode_ = -1;  // requestCode_: >= 0 for-result start mode; <0 for normal start mode in default.
859     sptr<IRemoteObject::DeathRecipient> schedulerDeathRecipient_ = {};  // scheduler binderDied Recipient
860     sptr<AppExecFwk::IBundleMgr> iBundleManager_;
861 
862     /**
863      * result_: ability starts with for-result mode will send result before being terminated.
864      * Its caller will receive results before active.
865      * Now we assume only one result generate when terminate.
866      */
867     std::shared_ptr<AbilityResult> result_ = {};
868 
869     // service(ability) can be connected by multi-pages(abilites), so need to store this service's connections
870     std::list<std::shared_ptr<ConnectionRecord>> connRecordList_ = {};
871     // service(ability) onConnect() return proxy of service ability
872     sptr<IRemoteObject> connRemoteObject_ = {};
873     int startId_ = 0;  // service(ability) start id
874 
875     // page(ability) can be started by multi-pages(abilites), so need to store this ability's caller
876     std::list<std::shared_ptr<CallerRecord>> callerList_ = {};
877 
878     bool isUninstall_ = false;
879     bool isForceTerminate_ = false;
880     const static std::map<AbilityState, std::string> stateToStrMap;
881     const static std::map<AbilityLifeCycleState, AbilityState> convertStateMap;
882     const static std::map<AppState, std::string> appStateToStrMap_;
883 
884     bool isKernalSystemAbility_ = false;
885     bool isLauncherRoot_ = false;
886     bool isPowerState_ = false;  // ability to change state when poweroff and poweron.
887     bool isLockScreenState_ = false; // ability to change state when lockscreen.
888 
889     PacMap stateDatas_;             // ability saved ability state data
890     bool isRestarting_ = false;     // is restarting ?
891     bool isInMovingState_ = false;  // whether complete multi window moving state.
892     bool isMovingBackground_ = false;
893     bool isLockScreenRoot_ = false;
894     bool isPowerStateLockScreen_ = false;
895     AppState appState_ = AppState::BEGIN;
896 
897     int32_t compatibleVersion_ = 0; // > 7 new version, <= 7 old version.
898     int32_t uid_ = 0;
899     std::weak_ptr<MissionList> missionList_;
900     std::weak_ptr<Mission> mission_;
901     int32_t missionId_ = -1;
902     int32_t ownerMissionUserId_ = -1;
903     bool isSwitchingPause_ = false;
904 
905 	// new version
906     std::shared_ptr<CallContainer> callContainer_ = nullptr;
907     bool isStartedByCall_ = false;
908     bool isStartToBackground_ = false;
909     bool minimizeReason_ = false;
910 
911     int32_t restartCount_ = -1;
912     int32_t restratMax_ = -1;
913     std::string specifiedFlag_;
914     std::mutex lock_;
915     mutable std::mutex dumpInfoLock_;
916     mutable std::mutex dumpLock_;
917     mutable std::condition_variable dumpCondition_;
918     mutable bool isDumpTimeout_ = false;
919     std::vector<std::string> dumpInfos_;
920 };
921 
922 class AbilityRecordNew : public AbilityRecord {
923 public:
924     AbilityRecordNew(const Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
925         const AppExecFwk::ApplicationInfo &applicationInfo, int requestCode = -1, int32_t apiVersion = 1);
926 
927     ~AbilityRecordNew();
928 
929     void Activate() override;
930     void Inactivate() override;
931     void MoveToBackground(const Closure &task) override;
932 
933     void ForegroundNew();
934     void BackgroundNew(const Closure &task);
935 };
936 }  // namespace AAFwk
937 }  // namespace OHOS
938 #endif  // OHOS_AAFWK_ABILITY_RECORD_H
939