• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_AMS_MGR_PROCESS_MANAGER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_AMS_MGR_PROCESS_MANAGER_H
18 
19 #include <list>
20 
21 #include "iremote_object.h"
22 #include "refbase.h"
23 
24 #include "app_task_info.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 class AppProcessManager {
29 public:
30     AppProcessManager();
31     virtual ~AppProcessManager();
32 
33     /**
34      * RemoveAppFromRecentList, Remove the corresponding latest application list data.
35      *
36      * @param appTaskInfo, the application task information.
37      *
38      * @return
39      */
40     void RemoveAppFromRecentList(const std::shared_ptr<AppTaskInfo> &appTaskInfo);
41 
42     /**
43      * GetRecentAppList, Clear recent application list.
44      *
45      * @return
46      */
47     void ClearRecentAppList();
48 
49     /**
50      * AddAppToRecentList, Add application to recent list.
51      *
52      * @param appName, the app name.
53      * @param processName, the process name.
54      * @param pid, the app pid.
55      * @param recordId, the app record id.
56      *
57      * @return
58      */
59     void AddAppToRecentList(
60         const std::string &appName, const std::string &processName, const pid_t pid, const int32_t recordId);
61 
62     /**
63      * GetRecentAppList, Get a list of recent applications.
64      *
65      * @return a list of recent applications.
66      */
67     const std::list<const std::shared_ptr<AppTaskInfo>> &GetRecentAppList() const;
68 
69     /**
70      * PushAppFront, Adjust the latest application record to the top level.
71      *
72      * @param recordId, the app record id.
73      *
74      * @return
75      */
76     void PushAppFront(const int32_t recordId);
77 
78     /**
79      * RemoveAppFromRecentListById, Remove the specified recent application record by application record id.
80      *
81      * @param recordId, the app record id.
82      *
83      * @return
84      */
85     void RemoveAppFromRecentListById(const int32_t recordId);
86 
87     /**
88      * AddAppToRecentList, Get application task information through ID.
89      *
90      * @param recordId, the app record id.
91      *
92      * @return application task information.
93      */
94     const std::shared_ptr<AppTaskInfo> GetAppTaskInfoById(const int32_t recordId) const;
95 
96     /**
97      * GetAppTaskInfoByProcessName, Get application task information through process name.
98      *
99      * @param appName, the application name.
100      * @param processName, the process name.
101      *
102      * @return application task information.
103      */
104     std::shared_ptr<AppTaskInfo> GetAppTaskInfoByProcessName(
105         const std::string &appName, const std::string &processName) const;
106 
107 private:
108     std::list<const std::shared_ptr<AppTaskInfo>> recentAppList_;
109 };
110 }  // namespace AppExecFwk
111 }  // namespace OHOS
112 
113 #endif  // FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_AMS_MGR_PROCESS_MANAGER_H