• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_APP_RUNNING_RECORD_H
17 #define OHOS_ABILITY_RUNTIME_APP_RUNNING_RECORD_H
18 
19 #include <list>
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <unordered_set>
24 
25 #include "cpp/mutex.h"
26 #include "iremote_object.h"
27 #include "irender_scheduler.h"
28 #include "ability_running_record.h"
29 #include "ability_state_data.h"
30 #include "application_info.h"
31 #include "task_handler_wrap.h"
32 #include "app_mgr_service_event_handler.h"
33 #include "app_death_recipient.h"
34 #include "app_launch_data.h"
35 #include "app_mgr_constants.h"
36 #include "app_scheduler_proxy.h"
37 #include "app_record_id.h"
38 #include "child_process_record.h"
39 #include "fault_data.h"
40 #include "profile.h"
41 #include "priority_object.h"
42 #include "app_lifecycle_deal.h"
43 #include "module_running_record.h"
44 #include "app_spawn_msg_wrapper.h"
45 #include "app_malloc_info.h"
46 #include "window_visibility_changed_listener.h"
47 
48 namespace OHOS {
49 namespace AppExecFwk {
50 class AbilityRunningRecord;
51 class AppMgrServiceInner;
52 class AppRunningRecord;
53 
54 /**
55  * @class RenderRecord
56  * Record nweb render process info.
57  */
58 class RenderRecord {
59 public:
60     RenderRecord(pid_t hostPid, const std::string &renderParam, int32_t ipcFd,
61                  int32_t sharedFd, int32_t crashFd,
62                  const std::shared_ptr<AppRunningRecord> &host);
63 
64     virtual ~RenderRecord();
65 
66     static std::shared_ptr<RenderRecord>
67     CreateRenderRecord(pid_t hostPid, const std::string &renderParam,
68                        int32_t ipcFd, int32_t sharedFd, int32_t crashFd,
69                        const std::shared_ptr<AppRunningRecord> &host);
70 
71     void SetPid(pid_t pid);
72     pid_t GetPid() const ;
73     pid_t GetHostPid() const;
74     void SetUid(int32_t uid);
75     int32_t GetUid() const;
76     int32_t GetHostUid() const;
77     std::string GetHostBundleName() const;
78     std::string GetRenderParam() const;
79     std::string GetProcessName() const;
80     int32_t GetIpcFd() const;
81     int32_t GetSharedFd() const;
82     int32_t GetCrashFd() const;
83     ProcessType GetProcessType() const;
84     std::shared_ptr<AppRunningRecord> GetHostRecord() const;
85     sptr<IRenderScheduler> GetScheduler() const;
86     void SetScheduler(const sptr<IRenderScheduler> &scheduler);
87     void SetDeathRecipient(const sptr<AppDeathRecipient> recipient);
88     void RegisterDeathRecipient();
89 
90 private:
91     void SetHostUid(const int32_t hostUid);
92     void SetHostBundleName(const std::string &hostBundleName);
93     void SetProcessName(const std::string &hostProcessName);
94 
95     pid_t pid_ = 0;
96     pid_t hostPid_ = 0;
97     int32_t uid_ = 0;
98     int32_t hostUid_ = 0;
99     std::string hostBundleName_;
100     std::string renderParam_;
101     std::string processName_;
102     int32_t ipcFd_ = 0;
103     int32_t sharedFd_ = 0;
104     int32_t crashFd_ = 0;
105     ProcessType processType_ = ProcessType::RENDER;
106     std::weak_ptr<AppRunningRecord> host_; // nweb host
107     sptr<IRenderScheduler> renderScheduler_ = nullptr;
108     sptr<AppDeathRecipient> deathRecipient_ = nullptr;
109 };
110 
111 class AppRunningRecord : public std::enable_shared_from_this<AppRunningRecord> {
112 public:
113     static int64_t appEventId_;
114 public:
115     AppRunningRecord(
116         const std::shared_ptr<ApplicationInfo> &info, const int32_t recordId, const std::string &processName);
117     virtual ~AppRunningRecord() = default;
118 
119     /**
120      * @brief Obtains the app record bundleName.
121      *
122      * @return Returns app record bundleName.
123      */
124     const std::string &GetBundleName() const;
125 
126     /**
127      * @brief Obtains the app record CallerPid.
128      *
129      * @return Returns app record CallerPid.
130      */
131     int32_t GetCallerPid() const;
132 
133     /**
134      * @brief Setting the Caller pid.
135      *
136      * @param CallerUid, the Caller pid.
137      */
138     void SetCallerPid(int32_t pid);
139 
140     /**
141      * @brief Obtains the app record CallerUid.
142      *
143      * @return Returns app record CallerUid.
144      */
145     int32_t GetCallerUid() const;
146 
147     /**
148      * @brief Setting the Caller uid.
149      *
150      * @param CallerUid, the Caller uid.
151      */
152     void SetCallerUid(int32_t uid);
153 
154     /**
155      * @brief Obtains the app record CallerTokenId.
156      *
157      * @return Returns app record CallerTokenId.
158      */
159     int32_t GetCallerTokenId() const;
160 
161     /**
162      * @brief Setting the Caller tokenId.
163      *
164      * @param CallerToken, the Caller tokenId.
165      */
166     void SetCallerTokenId(int32_t tokenId);
167 
168     /**
169      * @brief Obtains the app record isLauncherApp flag.
170      *
171      * @return Returns app record isLauncherApp flag.
172      */
173     bool IsLauncherApp() const;
174 
175     /**
176      * @brief Obtains the app record id.
177      *
178      * @return Returns app record id.
179      */
180     int32_t GetRecordId() const;
181 
182     /**
183      * @brief Obtains the app name.
184      *
185      * @return Returns the app name.
186      */
187     const std::string &GetName() const;
188 
189     /**
190      * @brief Obtains the process name.
191      *
192      * @return Returns the process name.
193      */
194     const std::string &GetProcessName() const;
195 
196     /**
197      * @brief Obtains the the flag of specified process.
198      *
199      * @return Returns the the flag of specified process.
200      */
201     const std::string &GetSpecifiedProcessFlag() const;
202 
203     /**
204      * @brief Setting the the flag of specified process.
205      *
206      * @param flag, the the flag of specified process.
207      */
208     void SetSpecifiedProcessFlag(const std::string &flag);
209 
210     /**
211      * @brief Obtains the sign code.
212      *
213      * @return Returns the sign code.
214      */
215     const std::string &GetSignCode() const;
216 
217     /**
218      * @brief Setting the sign code.
219      *
220      * @param code, the sign code.
221      */
222     void SetSignCode(const std::string &signCode);
223 
224     /**
225      * @brief Obtains the jointUserId.
226      *
227      * @return Returns the jointUserId.
228      */
229     const std::string &GetJointUserId() const;
230 
231     /**
232      * @brief Setting the jointUserId.
233      *
234      * @param jointUserId, the jointUserId.
235      */
236     void SetJointUserId(const std::string &jointUserId);
237 
238     /**
239      * @brief Obtains the application uid.
240      *
241      * @return Returns the application uid.
242      */
243     int32_t GetUid() const;
244 
245     /**
246      * @brief Setting the application uid.
247      *
248      * @param state, the application uid.
249      */
250     void SetUid(const int32_t uid);
251 
252     // Get current state for this process
253 
254     /**
255      * @brief Obtains the application state.
256      *
257      * @return Returns the application state.
258      */
259     ApplicationState GetState() const;
260 
261     // Set current state for this process
262 
263     /**
264      * @brief Setting the application state.
265      *
266      * @param state, the application state.
267      */
268     void SetState(const ApplicationState state);
269 
270     // Get abilities_ for this process
271     /**
272      * @brief Obtains the abilities info for the application record.
273      *
274      * @return Returns the abilities info for the application record.
275      */
276     const std::map<const sptr<IRemoteObject>, std::shared_ptr<AbilityRunningRecord>> GetAbilities();
277     // Update appThread with appThread
278 
279     /**
280      * @brief Setting the application client.
281      *
282      * @param thread, the application client.
283      */
284     void SetApplicationClient(const sptr<IAppScheduler> &thread);
285 
286     /**
287      * @brief Obtains the application client.
288      *
289      * @return Returns the application client.
290      */
291     sptr<IAppScheduler> GetApplicationClient() const;
292 
293     void AddModule(const std::shared_ptr<ApplicationInfo> &appInfo, const std::shared_ptr<AbilityInfo> &abilityInfo,
294         const sptr<IRemoteObject> &token, const HapModuleInfo &hapModuleInfo,
295         const std::shared_ptr<AAFwk::Want> &want);
296 
297     void AddModules(const std::shared_ptr<ApplicationInfo> &appInfo, const std::vector<HapModuleInfo> &moduleInfos);
298 
299     std::shared_ptr<ModuleRunningRecord> GetModuleRecordByModuleName(
300         const std::string bundleName, const std::string &moduleName);
301 
302     std::shared_ptr<ModuleRunningRecord> GetModuleRunningRecordByToken(const sptr<IRemoteObject> &token) const;
303 
304     std::shared_ptr<ModuleRunningRecord> GetModuleRunningRecordByTerminateLists(const sptr<IRemoteObject> &token) const;
305 
306     std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(const int64_t eventId) const;
307 
308     /**
309      * @brief Setting the Trim Memory Level.
310      *
311      * @param level, the Memory Level.
312      */
313     void SetTrimMemoryLevel(int32_t level);
314 
315     // Kill this process with a given reason
316     /**
317      * ForceKillApp, Kill this process with a given reason.
318      *
319      * @param reason, The reason to kill the process.
320      *
321      * @return
322      */
323     void ForceKillApp(const std::string &reason) const;
324 
325     // Schedule to crash this app with a given description
326     /**
327      * ScheduleAppCrash, Schedule to crash this app with a given description.
328      *
329      * @param description, the given description.
330      *
331      * @return
332      */
333     void ScheduleAppCrash(const std::string &description) const;
334 
335     /**
336      * LaunchApplication, Notify application to launch application.
337      *
338      * @return
339      */
340     void LaunchApplication(const Configuration &config);
341 
342     /**
343      * AddAbilityStage, Notify application to ability stage.
344      *
345      * @return
346      */
347     void AddAbilityStage();
348 
349     void AddAbilityStageBySpecifiedAbility(const std::string &bundleName);
350 
351     void AddAbilityStageBySpecifiedProcess(const std::string &bundleName);
352 
353     /**
354      * AddAbilityStage Result returned.
355      *
356      * @return
357      */
358     void AddAbilityStageDone();
359 
360     /**
361      * update the application info after new module installed.
362      *
363      * @param appInfo The latest application info obtained from bms for update abilityRuntimeContext.
364      *
365      * @return
366      */
367     void UpdateApplicationInfoInstalled(const ApplicationInfo &appInfo);
368 
369     /**
370      * LaunchAbility, Notify application to launch ability.
371      *
372      * @param ability, the ability record.
373      *
374      * @return
375      */
376     void LaunchAbility(const std::shared_ptr<AbilityRunningRecord> &ability);
377 
378     /**
379      * LaunchPendingAbilities, Launch Pending Abilities.
380      *
381      * @return
382      */
383     void LaunchPendingAbilities();
384 
385     /**
386      * LowMemoryWarning, Low memory warning.
387      *
388      * @return
389      */
390     void LowMemoryWarning();
391 
392     /**
393      * ScheduleTerminate, Notify application to terminate.
394      *
395      * @return
396      */
397     void ScheduleTerminate();
398 
399     /**
400      * ScheduleTerminate, Notify application process exit safely.
401      *
402      * @return
403      */
404     void ScheduleProcessSecurityExit();
405 
406     /**
407      * ScheduleTrimMemory, Notifies the application of the memory seen.
408      *
409      * @return
410      */
411     void ScheduleTrimMemory();
412 
413     /**
414      * ScheduleMemoryLevel, Notifies the application of the current memory.
415      *
416      * @return
417      */
418     void ScheduleMemoryLevel(int32_t level);
419 
420     /**
421      * ScheduleHeapMemory, Get the application's memory allocation info.
422      *
423      * @param pid, pid input.
424      * @param mallocInfo, dynamic storage information output.
425      *
426      * @return
427      */
428     void ScheduleHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo);
429 
430     /**
431      * GetAbilityRunningRecordByToken, Obtaining the ability record through token.
432      *
433      * @param token, the unique identification to the ability.
434      *
435      * @return
436      */
437     std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecordByToken(const sptr<IRemoteObject> &token) const;
438 
439     std::shared_ptr<AbilityRunningRecord> GetAbilityByTerminateLists(const sptr<IRemoteObject> &token) const;
440 
441     /**
442      * UpdateAbilityState, update the ability status.
443      *
444      * @param token, the unique identification to update the ability.
445      * @param state, ability status that needs to be updated.
446      *
447      * @return
448      */
449     void UpdateAbilityState(const sptr<IRemoteObject> &token, const AbilityState state);
450 
451     /**
452      * PopForegroundingAbilityTokens, Extract the token record from the foreground tokens list.
453      *
454      * @return
455      */
456     void PopForegroundingAbilityTokens();
457 
458     /**
459      * TerminateAbility, terminate the token ability.
460      *
461      * @param token, he unique identification to terminate the ability.
462      *
463      * @return
464      */
465     void TerminateAbility(const sptr<IRemoteObject> &token, const bool isForce);
466 
467     /**
468      * AbilityTerminated, terminate the ability.
469      *
470      * @param token, the unique identification to terminated the ability.
471      *
472      * @return
473      */
474     void AbilityTerminated(const sptr<IRemoteObject> &token);
475 
476     /**
477      * @brief Setting application service internal handler instance.
478      *
479      * @param serviceInner, application service internal handler instance.
480      */
481     void SetAppMgrServiceInner(const std::weak_ptr<AppMgrServiceInner> &inner);
482 
483     /**
484      * @brief Setting application death recipient.
485      *
486      * @param appDeathRecipient, application death recipient instance.
487      */
488     void SetAppDeathRecipient(const sptr<AppDeathRecipient> &appDeathRecipient);
489 
490     /**
491      * @brief Obtains application priority info.
492      *
493      * @return Returns the application priority info.
494      */
495     std::shared_ptr<PriorityObject> GetPriorityObject();
496 
497     /**
498      * Remove application death recipient record.
499      *
500      * @return
501      */
502     void RemoveAppDeathRecipient() const;
503 
504     /**
505     *  Notify application update system environment changes.
506     *
507     * @param config System environment change parameters.
508     * @return Returns ERR_OK on success, others on failure.
509     */
510     int32_t UpdateConfiguration(const Configuration &config);
511 
512     void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler);
513     void SetEventHandler(const std::shared_ptr<AMSEventHandler> &handler);
514 
515     int64_t GetEventId() const;
516 
517     bool IsLastAbilityRecord(const sptr<IRemoteObject> &token);
518 
519     bool IsLastPageAbilityRecord(const sptr<IRemoteObject> &token);
520 
521     void SetTerminating();
522 
523     bool IsTerminating();
524 
525     bool IsKeepAliveApp() const;
526 
527     bool IsEmptyKeepAliveApp() const;
528 
529     void SetKeepAliveAppState(bool isKeepAlive, bool isEmptyKeepAliveApp);
530 
531     void SetEmptyKeepAliveAppState(bool isEmptyKeepAlive);
532 
533     void SetStageModelState(bool isStageBasedModel);
534 
535     std::list<std::shared_ptr<ModuleRunningRecord>> GetAllModuleRecord() const;
536 
537     const std::list<std::shared_ptr<ApplicationInfo>> GetAppInfoList();
538 
GetApplicationInfo()539     inline const std::shared_ptr<ApplicationInfo> GetApplicationInfo()
540     {
541         return appInfo_;
542     }
543 
544     void SetRestartResidentProcCount(int count);
545     void DecRestartResidentProcCount();
546     int GetRestartResidentProcCount() const;
547     bool CanRestartResidentProc();
548 
549     /**
550      * Notify observers when state change.
551      *
552      * @param ability, ability or extension record.
553      * @param state, ability or extension state.
554      */
555     void StateChangedNotifyObserver(
556         const std::shared_ptr<AbilityRunningRecord> &ability,
557         int32_t state,
558         bool isAbility,
559         bool isFromWindowFocusChanged);
560 
561     void insertAbilityStageInfo(std::vector<HapModuleInfo> moduleInfos);
562 
563     void GetBundleNames(std::vector<std::string> &bundleNames);
564 
565     void SetUserTestInfo(const std::shared_ptr<UserTestRecord> &record);
566     std::shared_ptr<UserTestRecord> GetUserTestInfo();
567 
568     void SetProcessAndExtensionType(const std::shared_ptr<AbilityInfo> &abilityInfo);
569     void SetSpecifiedAbilityFlagAndWant(const bool flag, const AAFwk::Want &want, const std::string &moduleName);
570     void SetScheduleNewProcessRequestState(const bool isNewProcessRequest, const AAFwk::Want &want,
571         const std::string &moduleName);
572     bool IsNewProcessRequest() const;
573     bool IsStartSpecifiedAbility() const;
574     void ScheduleAcceptWant(const std::string &moduleName);
575     void ScheduleAcceptWantDone();
576     void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName);
577     void ScheduleNewProcessRequestDone();
578     void ApplicationTerminated();
579     const AAFwk::Want &GetSpecifiedWant() const;
580     const AAFwk::Want &GetNewProcessRequestWant() const;
581     void SetDebugApp(bool isDebugApp);
582     bool IsDebugApp();
583     void SetNativeDebug(bool isNativeDebug);
584     void SetPerfCmd(const std::string &perfCmd);
585     void AddRenderRecord(const std::shared_ptr<RenderRecord> &record);
586     void RemoveRenderRecord(const std::shared_ptr<RenderRecord> &record);
587     std::shared_ptr<RenderRecord> GetRenderRecordByPid(const pid_t pid);
588     std::map<int32_t, std::shared_ptr<RenderRecord>> GetRenderRecordMap();
589     void SetStartMsg(const AppSpawnStartMsg &msg);
590     AppSpawnStartMsg GetStartMsg();
591 
592     void SendEventForSpecifiedAbility(uint32_t msg, int64_t timeOut);
593 
594     void SendAppStartupTypeEvent(const std::shared_ptr<AbilityRunningRecord> &ability, const AppStartType startType);
595     void SetKilling();
596     bool IsKilling() const;
597     void SetAppIndex(const int32_t appIndex);
598     int32_t GetAppIndex() const;
599     void SetSecurityFlag(bool securityFlag);
600     bool GetSecurityFlag() const;
601 
602     using Closure = std::function<void()>;
603     void PostTask(std::string msg, int64_t timeOut, const Closure &task);
604     void RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObject>& token) const;
605 
606     int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback,
607         const int32_t recordId);
608 
609     int32_t NotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId);
610 
611     int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback,
612         const int32_t recordId);
613 
614     bool IsContinuousTask();
615 
616     void SetContinuousTaskAppState(bool isContinuousTask);
617 
618     /**
619      * Update target ability focus state.
620      *
621      * @param token the token of target ability.
622      * @param isFocus focus state.
623      *
624      * @return true if process focus state changed, false otherwise.
625      */
626     bool UpdateAbilityFocusState(const sptr<IRemoteObject> &token, bool isFocus);
627 
628     bool GetFocusFlag() const;
629 
630     int64_t GetAppStartTime() const;
631 
632     void SetRestartTimeMillis(const int64_t restartTimeMillis);
633     void SetRequestProcCode(int32_t requestProcCode);
634 
635     int32_t GetRequestProcCode() const;
636 
637     void SetProcessChangeReason(ProcessChangeReason reason);
638 
639     ProcessChangeReason GetProcessChangeReason() const;
640 
641     bool IsUpdateStateFromService();
642 
643     void SetUpdateStateFromService(bool isUpdateStateFromService);
644 
645     ExtensionAbilityType GetExtensionType() const;
646     ProcessType GetProcessType() const;
647 
648     int32_t NotifyAppFault(const FaultData &faultData);
649 
650     void OnWindowVisibilityChanged(const std::vector<sptr<OHOS::Rosen::WindowVisibilityInfo>> &windowVisibilityInfos);
651 
652     bool IsAbilitytiesBackground();
653 
SetAbilityForegroundingFlag()654     inline void SetAbilityForegroundingFlag()
655     {
656         isAbilityForegrounding_.store(true);
657     }
658 
GetAbilityForegroundingFlag()659     inline bool GetAbilityForegroundingFlag()
660     {
661         return isAbilityForegrounding_.load();
662     }
663 
SetSpawned()664     inline void SetSpawned()
665     {
666         isSpawned_.store(true);
667     }
668 
GetSpawned()669     inline bool GetSpawned() const
670     {
671         return isSpawned_.load();
672     }
673 
674     /**
675      * @brief Notify NativeEngine GC of status change.
676      *
677      * @param state GC state
678      *
679      * @return Is the status change completed.
680      */
681     int32_t ChangeAppGcState(const int32_t state);
682 
683     void SetAttachDebug(const bool &isAttachDebug);
684     bool isAttachDebug() const;
685 
686     void SetApplicationPendingState(ApplicationPendingState pendingState);
687     ApplicationPendingState GetApplicationPendingState() const;
688 
689     void GetSplitModeAndFloatingMode(bool &isSplitScreenMode, bool &isFloatingWindowMode);
690 
691     void AddChildProcessRecord(pid_t pid, const std::shared_ptr<ChildProcessRecord> record);
692     void RemoveChildProcessRecord(const std::shared_ptr<ChildProcessRecord> record);
693     std::shared_ptr<ChildProcessRecord> GetChildProcessRecordByPid(const pid_t pid);
694     std::map<pid_t, std::shared_ptr<ChildProcessRecord>> GetChildProcessRecordMap();
695 private:
696     /**
697      * SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data.
698      *
699      * @return If an uninitialized data is found return true,Otherwise return false.
700      */
701     bool GetTheModuleInfoNeedToUpdated(const std::string bundleName, HapModuleInfo &info);
702 
703     // drive application state changes when ability state changes.
704     /**
705      * ScheduleForegroundRunning, Notify application to switch to foreground.
706      *
707      * @return
708      */
709     void ScheduleForegroundRunning();
710 
711     /**
712      * ScheduleBackgroundRunning, Notify application to switch to background.
713      *
714      * @return
715      */
716     void ScheduleBackgroundRunning();
717 
718     /**
719      * AbilityForeground, Handling the ability process when switching to the foreground.
720      *
721      * @param ability, the ability info.
722      *
723      * @return
724      */
725     void AbilityForeground(const std::shared_ptr<AbilityRunningRecord> &ability);
726 
727     /**
728      * AbilityBackground, Handling the ability process when switching to the background.
729      *
730      * @param ability, the ability info.
731      *
732      * @return
733      */
734     void AbilityBackground(const std::shared_ptr<AbilityRunningRecord> &ability);
735     // drive application state changes when ability state changes.
736 
737     bool AbilityFocused(const std::shared_ptr<AbilityRunningRecord> &ability);
738 
739     bool AbilityUnfocused(const std::shared_ptr<AbilityRunningRecord> &ability);
740 
741     void SendEvent(uint32_t msg, int64_t timeOut);
742 
743     void SendClearTask(uint32_t msg, int64_t timeOut);
744 
745     void RemoveModuleRecord(const std::shared_ptr<ModuleRunningRecord> &record, bool isExtensionDebug = false);
746 
747 private:
748     class RemoteObjHash {
749     public:
operator()750         size_t operator() (const sptr<IRemoteObject> remoteObj) const
751         {
752             return reinterpret_cast<size_t>(remoteObj.GetRefPtr());
753         }
754     };
755 
756     bool isKeepAliveApp_ = false;  // Only resident processes can be set to true, please choose carefully
757     bool isEmptyKeepAliveApp_ = false;  // Only empty resident processes can be set to true, please choose carefully
758     bool isStageBasedModel_ = false;
759     ApplicationState curState_ = ApplicationState::APP_STATE_CREATE;  // current state of this process
760     ApplicationPendingState pendingState_ = ApplicationPendingState::READY;
761     bool isFocused_ = false; // if process is focused.
762     /**
763      * If there is an ability is foregrounding, this flag will be true,
764      * and this flag will remain true until this application is background.
765      */
766     std::atomic_bool isAbilityForegrounding_ = false;
767 
768     std::shared_ptr<ApplicationInfo> appInfo_ = nullptr;  // the application's info of this process
769     int32_t appRecordId_ = 0;
770     std::string appName_;
771     std::string processName_;  // the name of this process
772     std::string specifiedProcessFlag_; // the flag of specified Process
773     int64_t eventId_ = 0;
774     int64_t startProcessSpecifiedAbilityEventId_ = 0;
775     int64_t addAbilityStageInfoEventId_ = 0;
776     std::unordered_set<sptr<IRemoteObject>, RemoteObjHash> foregroundingAbilityTokens_;
777     std::weak_ptr<AppMgrServiceInner> appMgrServiceInner_;
778     sptr<AppDeathRecipient> appDeathRecipient_ = nullptr;
779     std::shared_ptr<PriorityObject> priorityObject_ = nullptr;
780     std::shared_ptr<AppLifeCycleDeal> appLifeCycleDeal_ = nullptr;
781     std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler_;
782     std::shared_ptr<AMSEventHandler> eventHandler_;
783     bool isTerminating = false;
784     std::string signCode_;  // the sign of this hap
785     std::string jointUserId_;
786     std::map<std::string, std::shared_ptr<ApplicationInfo>> appInfos_;
787     ffrt::mutex appInfosLock_;
788     std::map<std::string, std::vector<std::shared_ptr<ModuleRunningRecord>>> hapModules_;
789     mutable ffrt::mutex hapModulesLock_;
790     int32_t mainUid_;
791     std::string mainBundleName_;
792     bool isLauncherApp_;
793     std::string mainAppName_;
794     int restartResidentProcCount_ = 0;
795     bool isSpecifiedAbility_ = false;
796     AAFwk::Want SpecifiedWant_;
797     std::string moduleName_;
798     bool isNewProcessRequest_;
799     AAFwk::Want newProcessRequestWant_;
800     bool isDebugApp_ = false;
801     bool isNativeDebug_ = false;
802     bool isAttachDebug_ = false;
803     std::string perfCmd_;
804     int64_t startTimeMillis_ = 0;   // The time of app start(CLOCK_MONOTONIC)
805     int64_t restartTimeMillis_ = 0; // The time of last trying app restart
806 
807     std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr;
808 
809     bool isKilling_ = false;
810     bool isContinuousTask_ = false;    // Only continuesTask processes can be set to true, please choose carefully
811     std::atomic_bool isSpawned_ = false;
812 
813     // render record
814     std::map<int32_t, std::shared_ptr<RenderRecord>> renderRecordMap_;
815     ffrt::mutex renderRecordMapLock_;
816     AppSpawnStartMsg startMsg_;
817     int32_t appIndex_ = 0;
818     bool securityFlag_ = false;
819     int32_t requestProcCode_ = 0;
820     ProcessChangeReason processChangeReason_ = ProcessChangeReason::REASON_NONE;
821 
822     bool isUpdateStateFromService_ = false;
823     int32_t callerPid_ = -1;
824     int32_t callerUid_ = -1;
825     int32_t callerTokenId_ = -1;
826     ProcessType processType_ = ProcessType::NORMAL;
827     ExtensionAbilityType extensionType_ = ExtensionAbilityType::UNSPECIFIED;
828 
829     std::set<uint32_t> windowIds_;
830     std::map<pid_t, std::shared_ptr<ChildProcessRecord>> childProcessRecordMap_;
831     ffrt::mutex childProcessRecordMapLock_;
832 };
833 }  // namespace AppExecFwk
834 }  // namespace OHOS
835 #endif  // OHOS_ABILITY_RUNTIME_APP_RUNNING_RECORD_H
836