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