• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #include "app_scheduler.h"
17 
18 #include "hilog_tag_wrapper.h"
19 #include "ability_util.h"
20 #include "ability_manager_errors.h"
21 #include "appmgr/app_mgr_constants.h"
22 
23 namespace OHOS {
24 namespace AAFwk {
AppScheduler()25 AppScheduler::AppScheduler()
26 {
27     TAG_LOGI(AAFwkTag::TEST, " Test AppScheduler::AppScheduler()");
28 }
29 
~AppScheduler()30 AppScheduler::~AppScheduler()
31 {
32     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::~AppScheduler()");
33 }
34 
Init(const std::weak_ptr<AppStateCallback> & callback)35 bool AppScheduler::Init(const std::weak_ptr<AppStateCallback>& callback)
36 {
37     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::Init()");
38     if (!callback.lock()) {
39         return false;
40     }
41     return true;
42 }
43 
LoadAbility(const AbilityRuntime::LoadParam & loadParam,const AppExecFwk::AbilityInfo & abilityInfo,const AppExecFwk::ApplicationInfo & applicationInfo,const AAFwk::Want & want)44 int AppScheduler::LoadAbility(const AbilityRuntime::LoadParam &loadParam, const AppExecFwk::AbilityInfo& abilityInfo,
45     const AppExecFwk::ApplicationInfo& applicationInfo, const AAFwk::Want& want)
46 {
47     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::LoadAbility()");
48     if (applicationInfo.bundleName.find("com.ix.First.Test") != std::string::npos) {
49         return INNER_ERR;
50     }
51     return ERR_OK;
52 }
53 
TerminateAbility(const sptr<IRemoteObject> & token,bool isClearMissionFlag)54 int AppScheduler::TerminateAbility(const sptr<IRemoteObject>& token, bool isClearMissionFlag)
55 {
56     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::TerminateAbility()");
57     return ERR_OK;
58 }
59 
MoveToForeground(const sptr<IRemoteObject> & token)60 void AppScheduler::MoveToForeground(const sptr<IRemoteObject>& token)
61 {
62     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::MoveToForeground()");
63 }
64 
MoveToBackground(const sptr<IRemoteObject> & token)65 void AppScheduler::MoveToBackground(const sptr<IRemoteObject>& token)
66 {
67     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::MoveToBackground()");
68 }
69 
KillProcessByAbilityToken(const sptr<IRemoteObject> & token)70 void AppScheduler::KillProcessByAbilityToken(const sptr<IRemoteObject>& token)
71 {
72     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::KillProcessByAbilityToken()");
73 }
74 
KillProcessesByUserId(int32_t userId,bool isNeedSendAppSpawnMsg,sptr<AAFwk::IUserCallback> callback)75 void AppScheduler::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg,
76     sptr<AAFwk::IUserCallback> callback)
77 {
78     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::KillProcessesByUserId()");
79 }
80 
ConvertToAppAbilityState(const int32_t state)81 AppAbilityState AppScheduler::ConvertToAppAbilityState(const int32_t state)
82 {
83     AppExecFwk::AbilityState abilityState = static_cast<AppExecFwk::AbilityState>(state);
84     switch (abilityState) {
85         case AppExecFwk::AbilityState::ABILITY_STATE_FOREGROUND: {
86             return AppAbilityState::ABILITY_STATE_FOREGROUND;
87         }
88         case AppExecFwk::AbilityState::ABILITY_STATE_BACKGROUND: {
89             return AppAbilityState::ABILITY_STATE_BACKGROUND;
90         }
91         default:
92             return AppAbilityState::ABILITY_STATE_UNDEFINED;
93     }
94 }
95 
GetAbilityState() const96 AppAbilityState AppScheduler::GetAbilityState() const
97 {
98     return appAbilityState_;
99 }
100 
OnAbilityRequestDone(const sptr<IRemoteObject> & token,const AppExecFwk::AbilityState state)101 void AppScheduler::OnAbilityRequestDone(const sptr<IRemoteObject>& token, const AppExecFwk::AbilityState state)
102 {
103     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAbilityRequestDone()");
104 }
105 
KillApplication(const std::string & bundleName,bool clearPageStack,int32_t appIndex)106 int AppScheduler::KillApplication(const std::string& bundleName, bool clearPageStack, int32_t appIndex)
107 {
108     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::KillApplication()");
109     return ERR_OK;
110 }
111 
AttachTimeOut(const sptr<IRemoteObject> & token)112 void AppScheduler::AttachTimeOut(const sptr<IRemoteObject>& token)
113 {
114     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::AttachTimeOut()");
115 }
116 
PrepareTerminate(const sptr<IRemoteObject> & token,bool clearMissionFlag)117 void AppScheduler::PrepareTerminate(const sptr<IRemoteObject>& token, bool clearMissionFlag)
118 {
119     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::PrepareTerminate()");
120 }
121 
OnAppStateChanged(const AppExecFwk::AppProcessData & appData)122 void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData)
123 {
124     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppStateChanged()");
125 }
126 
NotifyConfigurationChange(const AppExecFwk::Configuration & config,int32_t userId)127 void AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId)
128 {
129     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyConfigurationChange()");
130 }
131 
NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> & bundleInfos)132 void AppScheduler::NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos)
133 {
134     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartResidentProcess()");
135 }
136 
NotifyStartKeepAliveProcess(std::vector<AppExecFwk::BundleInfo> & bundleInfos)137 void AppScheduler::NotifyStartKeepAliveProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos)
138 {
139     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartKeepAliveProcess()");
140 }
141 
OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> & abilityTokens)142 void AppScheduler::OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens)
143 {
144     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppRemoteDied()");
145 }
146 
OnStartProcessFailed(const std::vector<sptr<IRemoteObject>> & abilityTokens)147 void AppScheduler::OnStartProcessFailed(const std::vector<sptr<IRemoteObject>> &abilityTokens)
148 {
149     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnStartProcessFailed()");
150 }
151 
NotifyAppPreCache(int32_t pid,int32_t userId)152 void AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId)
153 {
154     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyAppPreCache()");
155 }
156 
UpdateAbilityState(const sptr<IRemoteObject> & token,const AppExecFwk::AbilityState state)157 void AppScheduler::UpdateAbilityState(const sptr<IRemoteObject>& token, const AppExecFwk::AbilityState state)
158 {
159     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::UpdateAbilityState()");
160 }
161 
UpdateExtensionState(const sptr<IRemoteObject> & token,const AppExecFwk::ExtensionState state)162 void AppScheduler::UpdateExtensionState(const sptr<IRemoteObject>& token, const AppExecFwk::ExtensionState state)
163 {
164     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::UpdateExtensionState()");
165 }
166 
StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> & bundleInfos)167 void AppScheduler::StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo>& bundleInfos)
168 {
169     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::StartupResidentProcess()");
170 }
171 
GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> & info)172 int AppScheduler::GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo>& info)
173 {
174     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::GetProcessRunningInfos()");
175     return 0;
176 }
177 
GetRunningProcessInfoByToken(const sptr<IRemoteObject> & token,AppExecFwk::RunningProcessInfo & info)178 void AppScheduler::GetRunningProcessInfoByToken(const sptr<IRemoteObject>& token, AppExecFwk::RunningProcessInfo& info)
179 {
180     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::GetRunningProcessInfoByToken()");
181 }
182 
GetRunningProcessInfoByPid(const pid_t pid,OHOS::AppExecFwk::RunningProcessInfo & info) const183 void AppScheduler::GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo& info) const
184 {
185     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::GetRunningProcessInfoByPid()");
186 }
187 
IsMemorySizeSufficent() const188 bool AppScheduler::IsMemorySizeSufficent() const
189 {
190     return true;
191 }
192 
VerifyKillProcessPermission(const std::string & bundleName) const193 int32_t AppScheduler::VerifyKillProcessPermission(const std::string &bundleName) const
194 {
195     TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::VerifyKillProcessPermission()");
196     return ERR_OK;
197 }
198 
StartSpecifiedAbility(const AAFwk::Want &,const AppExecFwk::AbilityInfo &,int32_t)199 void AppScheduler::StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t)
200 {}
201 
StartUserTest(const Want & want,const sptr<IRemoteObject> & observer,const AppExecFwk::BundleInfo & bundleInfo,int32_t userId)202 int AppScheduler::StartUserTest(
203     const Want& want, const sptr<IRemoteObject>& observer, const AppExecFwk::BundleInfo& bundleInfo, int32_t userId)
204 {
205     return 0;
206 }
207 
GetApplicationInfoByProcessID(const int pid,AppExecFwk::ApplicationInfo & application,bool & debug)208 int AppScheduler::GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo& application, bool& debug)
209 {
210     if (pid < 0) {
211         return -1;
212     }
213 
214     return 0;
215 }
216 
NotifyAppMgrRecordExitReason(int32_t pid,int32_t reason,const std::string & exitMsg)217 int32_t AppScheduler::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg)
218 {
219     return 0;
220 }
221 
GetAbilityRecordsByProcessID(const int pid,std::vector<sptr<IRemoteObject>> & tokens)222 int AppScheduler::GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>>& tokens)
223 {
224     return 0;
225 }
226 
RegisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> & listener)227 int32_t AppScheduler::RegisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> &listener)
228 {
229     return 0;
230 }
231 
UnregisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> & listener)232 int32_t AppScheduler::UnregisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> &listener)
233 {
234     return 0;
235 }
236 
AttachAppDebug(const std::string & bundleName,bool isDebugFromLocal)237 int32_t AppScheduler::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal)
238 {
239     return 0;
240 }
241 
DetachAppDebug(const std::string & bundleName)242 int32_t AppScheduler::DetachAppDebug(const std::string &bundleName)
243 {
244     return 0;
245 }
246 
RegisterAbilityDebugResponse(const sptr<AppExecFwk::IAbilityDebugResponse> & response)247 int32_t AppScheduler::RegisterAbilityDebugResponse(const sptr<AppExecFwk::IAbilityDebugResponse> &response)
248 {
249     return 0;
250 }
251 }  // namespace AAFwk
252 }  // namespace OHOS
253