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 #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
AbilityBehaviorAnalysis(const sptr<IRemoteObject> & token,const sptr<IRemoteObject> & preToken,const int32_t visibility,const int32_t perceptibility,const int32_t connectionState)70 void AppScheduler::AbilityBehaviorAnalysis(const sptr<IRemoteObject>& token, const sptr<IRemoteObject>& preToken,
71 const int32_t visibility, const int32_t perceptibility, const int32_t connectionState)
72 {
73 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::AbilityBehaviorAnalysis()");
74 }
75
KillProcessByAbilityToken(const sptr<IRemoteObject> & token)76 void AppScheduler::KillProcessByAbilityToken(const sptr<IRemoteObject>& token)
77 {
78 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::KillProcessByAbilityToken()");
79 }
80
KillProcessesByUserId(int32_t userId)81 void AppScheduler::KillProcessesByUserId(int32_t userId)
82 {
83 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::KillProcessesByUserId()");
84 }
85
ConvertToAppAbilityState(const int32_t state)86 AppAbilityState AppScheduler::ConvertToAppAbilityState(const int32_t state)
87 {
88 AppExecFwk::AbilityState abilityState = static_cast<AppExecFwk::AbilityState>(state);
89 switch (abilityState) {
90 case AppExecFwk::AbilityState::ABILITY_STATE_FOREGROUND: {
91 return AppAbilityState::ABILITY_STATE_FOREGROUND;
92 }
93 case AppExecFwk::AbilityState::ABILITY_STATE_BACKGROUND: {
94 return AppAbilityState::ABILITY_STATE_BACKGROUND;
95 }
96 default:
97 return AppAbilityState::ABILITY_STATE_UNDEFINED;
98 }
99 }
100
GetAbilityState() const101 AppAbilityState AppScheduler::GetAbilityState() const
102 {
103 return appAbilityState_;
104 }
105
OnAbilityRequestDone(const sptr<IRemoteObject> & token,const AppExecFwk::AbilityState state)106 void AppScheduler::OnAbilityRequestDone(const sptr<IRemoteObject>& token, const AppExecFwk::AbilityState state)
107 {
108 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAbilityRequestDone()");
109 }
110
KillApplication(const std::string & bundleName,const bool clearPageStack)111 int AppScheduler::KillApplication(const std::string& bundleName, const bool clearPageStack)
112 {
113 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::KillApplication()");
114 return ERR_OK;
115 }
116
AttachTimeOut(const sptr<IRemoteObject> & token)117 void AppScheduler::AttachTimeOut(const sptr<IRemoteObject>& token)
118 {
119 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::AttachTimeOut()");
120 }
121
PrepareTerminate(const sptr<IRemoteObject> & token,bool clearMissionFlag)122 void AppScheduler::PrepareTerminate(const sptr<IRemoteObject>& token, bool clearMissionFlag)
123 {
124 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::PrepareTerminate()");
125 }
126
OnAppStateChanged(const AppExecFwk::AppProcessData & appData)127 void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData)
128 {
129 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppStateChanged()");
130 }
131
NotifyConfigurationChange(const AppExecFwk::Configuration & config,int32_t userId)132 void AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId)
133 {
134 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyConfigurationChange()");
135 }
136
NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> & bundleInfos)137 void AppScheduler::NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos)
138 {
139 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartResidentProcess()");
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
NotifyAppPreCache(int32_t pid,int32_t userId)147 void AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId)
148 {
149 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyAppPreCache()");
150 }
151
UpdateAbilityState(const sptr<IRemoteObject> & token,const AppExecFwk::AbilityState state)152 void AppScheduler::UpdateAbilityState(const sptr<IRemoteObject>& token, const AppExecFwk::AbilityState state)
153 {
154 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::UpdateAbilityState()");
155 }
156
UpdateExtensionState(const sptr<IRemoteObject> & token,const AppExecFwk::ExtensionState state)157 void AppScheduler::UpdateExtensionState(const sptr<IRemoteObject>& token, const AppExecFwk::ExtensionState state)
158 {
159 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::UpdateExtensionState()");
160 }
161
StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> & bundleInfos)162 void AppScheduler::StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo>& bundleInfos)
163 {
164 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::StartupResidentProcess()");
165 }
166
GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> & info)167 int AppScheduler::GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo>& info)
168 {
169 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::GetProcessRunningInfos()");
170 return 0;
171 }
172
GetRunningProcessInfoByToken(const sptr<IRemoteObject> & token,AppExecFwk::RunningProcessInfo & info)173 void AppScheduler::GetRunningProcessInfoByToken(const sptr<IRemoteObject>& token, AppExecFwk::RunningProcessInfo& info)
174 {
175 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::GetRunningProcessInfoByToken()");
176 }
177
GetRunningProcessInfoByPid(const pid_t pid,OHOS::AppExecFwk::RunningProcessInfo & info) const178 void AppScheduler::GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo& info) const
179 {
180 TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::GetRunningProcessInfoByPid()");
181 }
182
IsMemorySizeSufficent() const183 bool AppScheduler::IsMemorySizeSufficent() const
184 {
185 return true;
186 }
187
StartSpecifiedAbility(const AAFwk::Want &,const AppExecFwk::AbilityInfo &,int32_t)188 void AppScheduler::StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t)
189 {}
190
StartUserTest(const Want & want,const sptr<IRemoteObject> & observer,const AppExecFwk::BundleInfo & bundleInfo,int32_t userId)191 int AppScheduler::StartUserTest(
192 const Want& want, const sptr<IRemoteObject>& observer, const AppExecFwk::BundleInfo& bundleInfo, int32_t userId)
193 {
194 return 0;
195 }
196
GetApplicationInfoByProcessID(const int pid,AppExecFwk::ApplicationInfo & application,bool & debug)197 int AppScheduler::GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo& application, bool& debug)
198 {
199 if (pid < 0) {
200 return -1;
201 }
202
203 return 0;
204 }
205
NotifyAppMgrRecordExitReason(int32_t pid,int32_t reason,const std::string & exitMsg)206 int32_t AppScheduler::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg)
207 {
208 return 0;
209 }
210
GetAbilityRecordsByProcessID(const int pid,std::vector<sptr<IRemoteObject>> & tokens)211 int AppScheduler::GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>>& tokens)
212 {
213 return 0;
214 }
215
RegisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> & listener)216 int32_t AppScheduler::RegisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> &listener)
217 {
218 return 0;
219 }
220
UnregisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> & listener)221 int32_t AppScheduler::UnregisterAppDebugListener(const sptr<AppExecFwk::IAppDebugListener> &listener)
222 {
223 return 0;
224 }
225
AttachAppDebug(const std::string & bundleName)226 int32_t AppScheduler::AttachAppDebug(const std::string &bundleName)
227 {
228 return 0;
229 }
230
DetachAppDebug(const std::string & bundleName)231 int32_t AppScheduler::DetachAppDebug(const std::string &bundleName)
232 {
233 return 0;
234 }
235
RegisterAbilityDebugResponse(const sptr<AppExecFwk::IAbilityDebugResponse> & response)236 int32_t AppScheduler::RegisterAbilityDebugResponse(const sptr<AppExecFwk::IAbilityDebugResponse> &response)
237 {
238 return 0;
239 }
240 } // namespace AAFwk
241 } // namespace OHOS
242