• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 OHOS_ABILITY_RUNTIME_APP_SCHEDULER_INTERFACE_H
17 #define OHOS_ABILITY_RUNTIME_APP_SCHEDULER_INTERFACE_H
18 
19 #include "iremote_broker.h"
20 #include "ability_info.h"
21 #include "app_launch_data.h"
22 #include "configuration.h"
23 #include "fault_data.h"
24 #include "hap_module_info.h"
25 #include "iquick_fix_callback.h"
26 #include "want.h"
27 #include "app_malloc_info.h"
28 
29 namespace OHOS {
30 namespace AppExecFwk {
31 class IAppScheduler : public IRemoteBroker {
32 public:
33     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppScheduler");
34 
35     /**
36      * ScheduleForegroundApplication, call ScheduleForegroundApplication() through proxy project,
37      * Notify application to switch to foreground.
38      *
39      * @return
40      */
41     virtual void ScheduleForegroundApplication() = 0;
42 
43     /**
44      * ScheduleBackgroundApplication, call ScheduleBackgroundApplication() through proxy project,
45      * Notify application to switch to background.
46      *
47      * @return
48      */
49     virtual void ScheduleBackgroundApplication() = 0;
50 
51     /**
52      * ScheduleTerminateApplication, call ScheduleTerminateApplication() through proxy project,
53      * Notify application to terminate.
54      *
55      * @param isLastProcess When it is the last application process, pass in true.
56      */
57     virtual void ScheduleTerminateApplication(bool isLastProcess = false) = 0;
58 
59     /**
60      * ScheduleShrinkMemory, call ScheduleShrinkMemory() through proxy project,
61      * Notifies the application of the memory seen.
62      *
63      * @param The memory value.
64      *
65      * @return
66      */
67     virtual void ScheduleShrinkMemory(const int) = 0;
68 
69     /**
70      * ScheduleLowMemory, call ScheduleLowMemory() through proxy project,
71      * Notify application to low memory.
72      *
73      * @return
74      */
75     virtual void ScheduleLowMemory() = 0;
76 
77     /**
78      * ScheduleMemoryLevel, call ScheduleMemoryLevel() through proxy project,
79      * Notify applications background the current memory level.
80      *
81      * @return
82      */
83     virtual void ScheduleMemoryLevel(int32_t level) = 0;
84 
85     /**
86      * ScheduleHeapMemory, call ScheduleHeapMemory() through proxy project,
87      * Get the application's memory allocation info.
88      *
89      * @param pid, pid input.
90      * @param mallocInfo, dynamic storage information output.
91      *
92      * @return
93      */
94     virtual void ScheduleHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo) = 0;
95 
96     /**
97      * ScheduleLaunchApplication, call ScheduleLaunchApplication() through proxy project,
98      * Notify application to launch application.
99      *
100      * @param The app data value.
101      *
102      * @return
103      */
104     virtual void ScheduleLaunchApplication(const AppLaunchData &, const Configuration &) = 0;
105 
106     /**
107      * ScheduleUpdateApplicationInfoInstalled, call ScheduleUpdateApplicationInfoInstalled() through proxy object,
108      * update the application info after new module installed.
109      *
110      * @param appInfo The latest application info obtained from bms for update abilityRuntimeContext.
111      *
112      * @return
113      */
114     virtual void ScheduleUpdateApplicationInfoInstalled(const ApplicationInfo &) = 0;
115 
116     /**
117      * ScheduleAbilityStageInfo, call ScheduleAbilityStageInfo() through proxy project,
118      * Notify application to launch application.
119      *
120      * @param The app data value.
121      *
122      * @return
123      */
124     virtual void ScheduleAbilityStage(const HapModuleInfo &) = 0;
125 
126     virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &,
127         const std::shared_ptr<AAFwk::Want> &want) = 0;
128 
129     /**
130      * ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project,
131      * Notify application to clean ability.
132      *
133      * @param The ability token.
134      * @return
135      */
136     virtual void ScheduleCleanAbility(const sptr<IRemoteObject> &) = 0;
137 
138     /**
139      * ScheduleProfileChanged, call ScheduleProfileChanged() through proxy project,
140      * Notify application to profile update.
141      *
142      * @param The profile data.
143      * @return
144      */
145     virtual void ScheduleProfileChanged(const Profile &) = 0;
146 
147     /**
148      * ScheduleConfigurationUpdated, call ScheduleConfigurationUpdated() through proxy project,
149      * Notify application to configuration update.
150      *
151      * @param The configuration data.
152      * @return
153      */
154     virtual void ScheduleConfigurationUpdated(const Configuration &config) = 0;
155 
156     /**
157      * ScheduleProcessSecurityExit, call ScheduleProcessSecurityExit() through proxy project,
158      * Notify application process exit safely.
159      *
160      * @return
161      */
162     virtual void ScheduleProcessSecurityExit() = 0;
163 
164     virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) = 0;
165 
166     virtual void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) = 0;
167 
168     /**
169      * @brief Notify application load patch.
170      *
171      * @param bundleName Bundle name
172      * @param callback called when LoadPatch finished.
173      * @return Returns 0 on success, error code on failure.
174      */
175     virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
176         const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0;
177 
178     /**
179      * @brief Notify application reload page.
180      *
181      * @param callback called when HotReload finished.
182      * @return Returns 0 on success, error code on failure.
183      */
184     virtual int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0;
185 
186     /**
187      * @brief Notify application unload patch.
188      *
189      * @param bundleName Bundle name
190      * @param callback called when UnloadPatch finished.
191      * @return Returns 0 on success, error code on failure.
192      */
193     virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
194         const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0;
195 
196     /**
197      * @brief Schedule Notify App Fault Data.
198      *
199      * @param faultData fault data
200      * @return Returns ERR_OK on success, error code on failure.
201      */
202     virtual int32_t ScheduleNotifyAppFault(const FaultData &faultData) = 0;
203 
204     /**
205      * @brief Notify NativeEngine GC of status change.
206      *
207      * @param state GC state
208      * @param pid pid
209      *
210      * @return Is the status change completed.
211      */
212     virtual int32_t ScheduleChangeAppGcState(int32_t state) = 0;
213 
214     /**
215      * @brief Attach app debug.
216      */
217     virtual void AttachAppDebug() = 0;
218 
219     /**
220      * @brief Detach app debug.
221      */
222     virtual void DetachAppDebug() = 0;
223 
224     enum class Message {
225         SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0,
226         SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION,
227         SCHEDULE_TERMINATE_APPLICATION_TRANSACTION,
228         SCHEDULE_LOWMEMORY_APPLICATION_TRANSACTION,
229         SCHEDULE_SHRINK_MEMORY_APPLICATION_TRANSACTION,
230         SCHEDULE_LAUNCH_ABILITY_TRANSACTION,
231         SCHEDULE_CLEAN_ABILITY_TRANSACTION,
232         SCHEDULE_LAUNCH_APPLICATION_TRANSACTION,
233         SCHEDULE_PROFILE_CHANGED_TRANSACTION,
234         SCHEDULE_CONFIGURATION_UPDATED,
235         SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION,
236         SCHEDULE_ABILITY_STAGE_INFO,
237         SCHEDULE_ACCEPT_WANT,
238         SCHEDULE_MEMORYLEVEL_APPLICATION_TRANSACTION,
239         SCHEDULE_NOTIFY_LOAD_REPAIR_PATCH,
240         SCHEDULE_NOTIFY_HOT_RELOAD_PAGE,
241         SCHEDULE_NOTIFY_UNLOAD_REPAIR_PATCH,
242         SCHEDULE_UPDATE_APPLICATION_INFO_INSTALLED,
243         SCHEDULE_HEAPMEMORY_APPLICATION_TRANSACTION,
244         SCHEDULE_NOTIFY_FAULT,
245         APP_GC_STATE_CHANGE,
246         SCHEDULE_ATTACH_APP_DEBUG,
247         SCHEDULE_DETACH_APP_DEBUG,
248         SCHEDULE_NEW_PROCESS_REQUEST,
249     };
250 };
251 }  // namespace AppExecFwk
252 }  // namespace OHOS
253 #endif  // OHOS_ABILITY_RUNTIME_APP_SCHEDULER_INTERFACE_H
254