• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 MOCK_OHOS_ABILITY_RUNTIME_APP_SCHEDULER_H
17 #define MOCK_OHOS_ABILITY_RUNTIME_APP_SCHEDULER_H
18 
19 #include <memory>
20 #include <unordered_set>
21 
22 #include "ability_info.h"
23 #include "app_debug_listener_interface.h"
24 #include "application_info.h"
25 #include "app_mgr_client.h"
26 #include "bundle_info.h"
27 #include "configuration.h"
28 #include "iremote_object.h"
29 #include "last_exit_detail_info.h"
30 #include "refbase.h"
31 #include "running_process_info.h"
32 #include "singleton.h"
33 #include "user_callback.h"
34 #include "want.h"
35 
36 namespace OHOS {
37 namespace AbilityRuntime {
38 struct LoadParam;
39 }
40 namespace AAFwk {
41 enum class AppState {
42     BEGIN = 0,
43     READY,
44     FOREGROUND,
45     FOCUS,
46     BACKGROUND,
47     TERMINATED,
48     END,
49     SUSPENDED,
50     COLD_START = 99,
51 };
52 
53 struct AppData {
54     std::string appName;
55     int32_t uid;
56 };
57 
58 struct AppInfo {
59     std::vector<AppData> appData;
60     std::string processName;
61     AppState state;
62     pid_t pid = 0;
63     int32_t appIndex = 0;
64     std::string instanceKey = "";
65     std::string bundleName = "";
66 };
67 
68 class AppStateCallback {};
69 
70 class AppScheduler : virtual RefBase {
DECLARE_DELAYED_SINGLETON(AppScheduler)71     DECLARE_DELAYED_SINGLETON(AppScheduler)
72 public:
73     bool Init(const std::weak_ptr<AppStateCallback> &callback)
74     {
75         return false;
76     }
77 
UpdateConfiguration(const AppExecFwk::Configuration & config)78     int UpdateConfiguration(const AppExecFwk::Configuration &config)
79     {
80         return 0;
81     }
82 
GetConfiguration(AppExecFwk::Configuration & config)83     int GetConfiguration(AppExecFwk::Configuration &config)
84     {
85         return 0;
86     }
87 
GetApplicationInfoByProcessID(const int pid,AppExecFwk::ApplicationInfo & application,bool & debug)88     int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug)
89     {
90         return 0;
91     }
92 
GetBundleNameByPid(const int pid,std::string & bundleName,int32_t & uid)93     int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid)
94     {
95         return 0;
96     }
97 
RegisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> & listener)98     int32_t RegisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> &listener)
99     {
100         return 0;
101     }
102 
UnregisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> & listener)103     int32_t UnregisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> &listener)
104     {
105         return 0;
106     }
107 
AttachAppDebug(const std::string & bundleName,bool isDebugFromLocal)108     int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal)
109     {
110         return 0;
111     }
112 
DetachAppDebug(const std::string & bundleName)113     int32_t DetachAppDebug(const std::string &bundleName)
114     {
115         return 0;
116     }
117 
IsMemorySizeSufficent()118     virtual bool IsMemorySizeSufficent() const
119     {
120         return false;
121     }
122 
IsProcessContainsOnlyUIAbility(const pid_t pid)123     bool IsProcessContainsOnlyUIAbility(const pid_t pid)
124     {
125         return false;
126     }
127 
SetEnableStartProcessFlagByUserId(int32_t userId,bool enableStartProcess)128     void SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) {}
129 
130     void KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg = false,
131         sptr<AAFwk::IUserCallback> callback = nullptr) {}
132 
SetCurrentUserId(int32_t userId)133     void SetCurrentUserId(int32_t userId) {}
134 };
135 }  // namespace AAFwk
136 }  // namespace OHOS
137 #endif