• 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      * @return
56      */
57     virtual void ScheduleTerminateApplication() = 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     /**
167      * @brief Notify application load patch.
168      *
169      * @param bundleName Bundle name
170      * @param callback called when LoadPatch finished.
171      * @return Returns 0 on success, error code on failure.
172      */
173     virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
174         const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0;
175 
176     /**
177      * @brief Notify application reload page.
178      *
179      * @param callback called when HotReload finished.
180      * @return Returns 0 on success, error code on failure.
181      */
182     virtual int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0;
183 
184     /**
185      * @brief Notify application unload patch.
186      *
187      * @param bundleName Bundle name
188      * @param callback called when UnloadPatch finished.
189      * @return Returns 0 on success, error code on failure.
190      */
191     virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
192         const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0;
193 
194     /**
195      * @brief Schedule Notify App Fault Data.
196      *
197      * @param faultData fault data
198      * @return Returns ERR_OK on success, error code on failure.
199      */
200     virtual int32_t ScheduleNotifyAppFault(const FaultData &faultData) = 0;
201 
202     enum class Message {
203         SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0,
204         SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION,
205         SCHEDULE_TERMINATE_APPLICATION_TRANSACTION,
206         SCHEDULE_LOWMEMORY_APPLICATION_TRANSACTION,
207         SCHEDULE_SHRINK_MEMORY_APPLICATION_TRANSACTION,
208         SCHEDULE_LAUNCH_ABILITY_TRANSACTION,
209         SCHEDULE_CLEAN_ABILITY_TRANSACTION,
210         SCHEDULE_LAUNCH_APPLICATION_TRANSACTION,
211         SCHEDULE_PROFILE_CHANGED_TRANSACTION,
212         SCHEDULE_CONFIGURATION_UPDATED,
213         SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION,
214         SCHEDULE_ABILITY_STAGE_INFO,
215         SCHEDULE_ACCEPT_WANT,
216         SCHEDULE_MEMORYLEVEL_APPLICATION_TRANSACTION,
217         SCHEDULE_NOTIFY_LOAD_REPAIR_PATCH,
218         SCHEDULE_NOTIFY_HOT_RELOAD_PAGE,
219         SCHEDULE_NOTIFY_UNLOAD_REPAIR_PATCH,
220         SCHEDULE_UPDATE_APPLICATION_INFO_INSTALLED,
221         SCHEDULE_HEAPMEMORY_APPLICATION_TRANSACTION,
222         SCHEDULE_NOTIFY_FAULT
223     };
224 };
225 }  // namespace AppExecFwk
226 }  // namespace OHOS
227 #endif  // OHOS_ABILITY_RUNTIME_APP_SCHEDULER_INTERFACE_H
228