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_wrapper.h"
19 #include "ability_util.h"
20 #include "ability_manager_errors.h"
21 #include "ability_record.h"
22 #include "appmgr/app_mgr_constants.h"
23
24 namespace OHOS {
25 namespace AAFwk {
AppScheduler()26 AppScheduler::AppScheduler()
27 {
28 HILOG_INFO(" Test AppScheduler::AppScheduler()");
29 }
30
~AppScheduler()31 AppScheduler::~AppScheduler()
32 {
33 HILOG_INFO("Test AppScheduler::~AppScheduler()");
34 }
35
Init(const std::weak_ptr<AppStateCallback> & callback)36 bool AppScheduler::Init(const std::weak_ptr<AppStateCallback> &callback)
37 {
38 HILOG_INFO("Test AppScheduler::Init()");
39 if (!callback.lock()) {
40 return false;
41 }
42 return true;
43 }
44
LoadAbility(const sptr<IRemoteObject> & token,const sptr<IRemoteObject> & preToken,const AppExecFwk::AbilityInfo & abilityInfo,const AppExecFwk::ApplicationInfo & applicationInfo,const AAFwk::Want & want)45 int AppScheduler::LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
46 const AppExecFwk::AbilityInfo &abilityInfo, const AppExecFwk::ApplicationInfo &applicationInfo,
47 const AAFwk::Want &want)
48 {
49 HILOG_INFO("Test AppScheduler::LoadAbility()");
50 if (applicationInfo.bundleName.find("com.ix.First.Test") != std::string::npos) {
51 return INNER_ERR;
52 }
53 return ERR_OK;
54 }
55
TerminateAbility(const sptr<IRemoteObject> & token,bool isClearMissionFlag)56 int AppScheduler::TerminateAbility(const sptr<IRemoteObject> &token, bool isClearMissionFlag)
57 {
58 HILOG_INFO("Test AppScheduler::TerminateAbility()");
59 return ERR_OK;
60 }
61
MoveToForeground(const sptr<IRemoteObject> & token)62 void AppScheduler::MoveToForeground(const sptr<IRemoteObject> &token)
63 {
64 HILOG_INFO("Test AppScheduler::MoveToForeground()");
65 }
66
MoveToBackground(const sptr<IRemoteObject> & token)67 void AppScheduler::MoveToBackground(const sptr<IRemoteObject> &token)
68 {
69 HILOG_INFO("Test AppScheduler::MoveToBackground()");
70 }
71
AbilityBehaviorAnalysis(const sptr<IRemoteObject> & token,const sptr<IRemoteObject> & preToken,const int32_t visibility,const int32_t perceptibility,const int32_t connectionState)72 void AppScheduler::AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &preToken,
73 const int32_t visibility, const int32_t perceptibility, const int32_t connectionState)
74 {
75 HILOG_INFO("Test AppScheduler::AbilityBehaviorAnalysis()");
76 }
77
KillProcessByAbilityToken(const sptr<IRemoteObject> & token)78 void AppScheduler::KillProcessByAbilityToken(const sptr<IRemoteObject> &token)
79 {
80 HILOG_INFO("Test AppScheduler::KillProcessByAbilityToken()");
81 }
82
KillProcessesByUserId(int32_t userId)83 void AppScheduler::KillProcessesByUserId(int32_t userId)
84 {
85 HILOG_INFO("Test AppScheduler::KillProcessesByUserId()");
86 }
87
ConvertToAppAbilityState(const int32_t state)88 AppAbilityState AppScheduler::ConvertToAppAbilityState(const int32_t state)
89 {
90 AppExecFwk::AbilityState abilityState = static_cast<AppExecFwk::AbilityState>(state);
91 switch (abilityState) {
92 case AppExecFwk::AbilityState::ABILITY_STATE_FOREGROUND: {
93 return AppAbilityState::ABILITY_STATE_FOREGROUND;
94 }
95 case AppExecFwk::AbilityState::ABILITY_STATE_BACKGROUND: {
96 return AppAbilityState::ABILITY_STATE_BACKGROUND;
97 }
98 default:
99 return AppAbilityState::ABILITY_STATE_UNDEFINED;
100 }
101 }
102
GetAbilityState() const103 AppAbilityState AppScheduler::GetAbilityState() const
104 {
105 return appAbilityState_;
106 }
107
OnAbilityRequestDone(const sptr<IRemoteObject> & token,const AppExecFwk::AbilityState state)108 void AppScheduler::OnAbilityRequestDone(const sptr<IRemoteObject> &token, const AppExecFwk::AbilityState state)
109 {
110 HILOG_INFO("Test AppScheduler::OnAbilityRequestDone()");
111 }
112
KillApplication(const std::string & bundleName)113 int AppScheduler::KillApplication(const std::string &bundleName)
114 {
115 HILOG_INFO("Test AppScheduler::KillApplication()");
116 return ERR_OK;
117 }
118
AttachTimeOut(const sptr<IRemoteObject> & token)119 void AppScheduler::AttachTimeOut(const sptr<IRemoteObject> &token)
120 {
121 HILOG_INFO("Test AppScheduler::AttachTimeOut()");
122 }
123
PrepareTerminate(const sptr<IRemoteObject> & token)124 void AppScheduler::PrepareTerminate(const sptr<IRemoteObject> &token)
125 {
126 HILOG_INFO("Test AppScheduler::PrepareTerminate()");
127 }
128
OnAppStateChanged(const AppExecFwk::AppProcessData & appData)129 void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData &appData)
130 {
131 HILOG_INFO("Test AppScheduler::OnAppStateChanged()");
132 }
133
ClearUpApplicationData(const std::string & bundleName)134 int AppScheduler::ClearUpApplicationData(const std::string &bundleName)
135 {
136 HILOG_INFO("Test AppScheduler::ClearUpApplicationData()");
137 return ERR_OK;
138 }
139
UpdateAbilityState(const sptr<IRemoteObject> & token,const AppExecFwk::AbilityState state)140 void AppScheduler::UpdateAbilityState(const sptr<IRemoteObject> &token, const AppExecFwk::AbilityState state)
141 {
142 HILOG_INFO("Test AppScheduler::UpdateAbilityState()");
143 }
144
UpdateExtensionState(const sptr<IRemoteObject> & token,const AppExecFwk::ExtensionState state)145 void AppScheduler::UpdateExtensionState(const sptr<IRemoteObject> &token, const AppExecFwk::ExtensionState state)
146 {
147 HILOG_INFO("Test AppScheduler::UpdateExtensionState()");
148 }
149
StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> & bundleInfos)150 void AppScheduler::StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> &bundleInfos)
151 {
152 HILOG_INFO("Test AppScheduler::StartupResidentProcess()");
153 }
154
GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> & info)155 int AppScheduler::GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info)
156 {
157 HILOG_INFO("Test AppScheduler::GetProcessRunningInfos()");
158 return 0;
159 }
160
GetRunningProcessInfoByToken(const sptr<IRemoteObject> & token,AppExecFwk::RunningProcessInfo & info)161 void AppScheduler::GetRunningProcessInfoByToken(const sptr<IRemoteObject> &token, AppExecFwk::RunningProcessInfo &info)
162 {
163 HILOG_INFO("Test AppScheduler::GetRunningProcessInfoByToken()");
164 }
165
GetRunningProcessInfoByPid(const pid_t pid,OHOS::AppExecFwk::RunningProcessInfo & info) const166 void AppScheduler::GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) const
167 {
168 HILOG_INFO("Test AppScheduler::GetRunningProcessInfoByPid()");
169 }
170
StartSpecifiedAbility(const AAFwk::Want & want,const AppExecFwk::AbilityInfo & abilityInfo)171 void AppScheduler::StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo)
172 {}
173
StartUserTest(const Want & want,const sptr<IRemoteObject> & observer,const AppExecFwk::BundleInfo & bundleInfo,int32_t userId)174 int AppScheduler::StartUserTest(
175 const Want &want, const sptr<IRemoteObject> &observer, const AppExecFwk::BundleInfo &bundleInfo, int32_t userId)
176 {
177 return 0;
178 }
179
GetApplicationInfoByProcessID(const int pid,AppExecFwk::ApplicationInfo & application,bool & debug)180 int AppScheduler::GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug)
181 {
182 if (pid < 0) {
183 return -1;
184 }
185
186 return 0;
187 }
188
GetAbilityRecordsByProcessID(const int pid,std::vector<sptr<IRemoteObject>> & tokens)189 int AppScheduler::GetAbilityRecordsByProcessID(const int pid, std::vector<sptr<IRemoteObject>> &tokens)
190 {
191 return 0;
192 }
193 } // namespace AAFwk
194 } // namespace OHOS
195