1 /* 2 * Copyright (c) 2021-2024 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 #include "app_jsheap_mem_info.h" 29 30 namespace OHOS { 31 namespace AppExecFwk { 32 class IAppScheduler : public IRemoteBroker { 33 public: 34 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppScheduler"); 35 36 /** 37 * ScheduleForegroundApplication, call ScheduleForegroundApplication() through proxy project, 38 * Notify application to switch to foreground. 39 * 40 * @return 41 */ 42 virtual bool ScheduleForegroundApplication() = 0; 43 44 /** 45 * ScheduleBackgroundApplication, call ScheduleBackgroundApplication() through proxy project, 46 * Notify application to switch to background. 47 * 48 * @return 49 */ 50 virtual void ScheduleBackgroundApplication() = 0; 51 52 /** 53 * ScheduleTerminateApplication, call ScheduleTerminateApplication() through proxy project, 54 * Notify application to terminate. 55 * 56 * @param isLastProcess When it is the last application process, pass in true. 57 */ 58 virtual void ScheduleTerminateApplication(bool isLastProcess = false) = 0; 59 60 /** 61 * ScheduleShrinkMemory, call ScheduleShrinkMemory() through proxy project, 62 * Notifies the application of the memory seen. 63 * 64 * @param The memory value. 65 * 66 * @return 67 */ 68 virtual void ScheduleShrinkMemory(const int) = 0; 69 70 /** 71 * ScheduleLowMemory, call ScheduleLowMemory() through proxy project, 72 * Notify application to low memory. 73 * 74 * @return 75 */ 76 virtual void ScheduleLowMemory() = 0; 77 78 /** 79 * ScheduleMemoryLevel, call ScheduleMemoryLevel() through proxy project, 80 * Notify applications background the current memory level. 81 * 82 * @return 83 */ 84 virtual void ScheduleMemoryLevel(int32_t level) = 0; 85 86 /** 87 * ScheduleHeapMemory, call ScheduleHeapMemory() through proxy project, 88 * Get the application's memory allocation info. 89 * 90 * @param pid, pid input. 91 * @param mallocInfo, dynamic storage information output. 92 * 93 * @return 94 */ 95 virtual void ScheduleHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo) = 0; 96 97 /** 98 * ScheduleJsHeapMemory, call ScheduleJsHeapMemory() through proxy project, 99 * triggerGC and dump the application's jsheap memory info. 100 * 101 * @param info, pid, tid, needGc, needSnapshot 102 * 103 * @return 104 */ 105 virtual void ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) = 0; 106 107 /** 108 * ScheduleLaunchApplication, call ScheduleLaunchApplication() through proxy project, 109 * Notify application to launch application. 110 * 111 * @param The app data value. 112 * 113 * @return 114 */ 115 virtual void ScheduleLaunchApplication(const AppLaunchData &, const Configuration &) = 0; 116 117 /** 118 * ScheduleUpdateApplicationInfoInstalled, call ScheduleUpdateApplicationInfoInstalled() through proxy object, 119 * update the application info after new module installed. 120 * 121 * @param appInfo The latest application info obtained from bms for update abilityRuntimeContext. 122 * 123 * @return 124 */ 125 virtual void ScheduleUpdateApplicationInfoInstalled(const ApplicationInfo &) = 0; 126 127 /** 128 * ScheduleAbilityStageInfo, call ScheduleAbilityStageInfo() through proxy project, 129 * Notify application to launch application. 130 * 131 * @param The app data value. 132 * 133 * @return 134 */ 135 virtual void ScheduleAbilityStage(const HapModuleInfo &) = 0; 136 137 virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &, 138 const std::shared_ptr<AAFwk::Want> &want, int32_t abilityRecordId) = 0; 139 140 /** 141 * ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project, 142 * Notify application to clean ability. 143 * 144 * @param The ability token. 145 * @return 146 */ 147 virtual void ScheduleCleanAbility(const sptr<IRemoteObject> &, bool isCacheProcess = false) = 0; 148 149 /** 150 * ScheduleProfileChanged, call ScheduleProfileChanged() through proxy project, 151 * Notify application to profile update. 152 * 153 * @param The profile data. 154 * @return 155 */ 156 virtual void ScheduleProfileChanged(const Profile &) = 0; 157 158 /** 159 * ScheduleConfigurationUpdated, call ScheduleConfigurationUpdated() through proxy project, 160 * Notify application to configuration update. 161 * 162 * @param The configuration data. 163 * @return 164 */ 165 virtual void ScheduleConfigurationUpdated(const Configuration &config) = 0; 166 167 /** 168 * ScheduleProcessSecurityExit, call ScheduleProcessSecurityExit() through proxy project, 169 * Notify application process exit safely. 170 * 171 * @return 172 */ 173 virtual void ScheduleProcessSecurityExit() = 0; 174 175 virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) = 0; 176 177 virtual void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) = 0; 178 179 /** 180 * @brief Notify application load patch. 181 * 182 * @param bundleName Bundle name 183 * @param callback called when LoadPatch finished. 184 * @return Returns 0 on success, error code on failure. 185 */ 186 virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName, 187 const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0; 188 189 /** 190 * @brief Notify application reload page. 191 * 192 * @param callback called when HotReload finished. 193 * @return Returns 0 on success, error code on failure. 194 */ 195 virtual int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0; 196 197 /** 198 * @brief Notify application unload patch. 199 * 200 * @param bundleName Bundle name 201 * @param callback called when UnloadPatch finished. 202 * @return Returns 0 on success, error code on failure. 203 */ 204 virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName, 205 const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0; 206 207 /** 208 * @brief Schedule Notify App Fault Data. 209 * 210 * @param faultData fault data 211 * @return Returns ERR_OK on success, error code on failure. 212 */ 213 virtual int32_t ScheduleNotifyAppFault(const FaultData &faultData) = 0; 214 215 /** 216 * @brief Notify NativeEngine GC of status change. 217 * 218 * @param state GC state 219 * @param pid pid 220 * 221 * @return Is the status change completed. 222 */ 223 virtual int32_t ScheduleChangeAppGcState(int32_t state) = 0; 224 225 /** 226 * @brief Attach app debug. 227 */ 228 virtual void AttachAppDebug() = 0; 229 230 /** 231 * @brief Detach app debug. 232 */ 233 virtual void DetachAppDebug() = 0; 234 235 /** 236 * ScheduleDumpIpcStart, call ScheduleDumpIpcStart(std::string& result) through proxy project, 237 * Start querying the application's IPC payload info. 238 * 239 * @param result, start IPC dump result output. 240 * 241 * @return Returns 0 on success, error code on failure. 242 */ 243 virtual int32_t ScheduleDumpIpcStart(std::string& result) = 0; 244 245 /** 246 * ScheduleDumpIpcStop, call ScheduleDumpIpcStop(std::string& result) through proxy project, 247 * Stop querying the application's IPC payload info. 248 * 249 * @param result, stop IPC dump result output. 250 * 251 * @return Returns 0 on success, error code on failure. 252 */ 253 virtual int32_t ScheduleDumpIpcStop(std::string& result) = 0; 254 255 /** 256 * ScheduleDumpIpcStat, call ScheduleDumpIpcStat(std::string& result) through proxy project, 257 * Collect the application's IPC payload info. 258 * 259 * @param result, IPC payload result output. 260 * 261 * @return Returns 0 on success, error code on failure. 262 */ 263 virtual int32_t ScheduleDumpIpcStat(std::string& result) = 0; 264 265 virtual void ScheduleCacheProcess() = 0; 266 267 /** 268 * ScheduleDumpFfrt, call ScheduleDumpFfrt(std::string& result) through proxy project, 269 * Start querying the application's ffrt usage. 270 * 271 * @param result, ffrt dump result output. 272 * 273 * @return Returns 0 on success, error code on failure. 274 */ 275 virtual int32_t ScheduleDumpFfrt(std::string& result) = 0; 276 277 enum class Message { 278 SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0, 279 SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION, 280 SCHEDULE_TERMINATE_APPLICATION_TRANSACTION, 281 SCHEDULE_LOWMEMORY_APPLICATION_TRANSACTION, 282 SCHEDULE_SHRINK_MEMORY_APPLICATION_TRANSACTION, 283 SCHEDULE_LAUNCH_ABILITY_TRANSACTION, 284 SCHEDULE_CLEAN_ABILITY_TRANSACTION, 285 SCHEDULE_LAUNCH_APPLICATION_TRANSACTION, 286 SCHEDULE_PROFILE_CHANGED_TRANSACTION, 287 SCHEDULE_CONFIGURATION_UPDATED, 288 SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION, 289 SCHEDULE_ABILITY_STAGE_INFO, 290 SCHEDULE_ACCEPT_WANT, 291 SCHEDULE_MEMORYLEVEL_APPLICATION_TRANSACTION, 292 SCHEDULE_NOTIFY_LOAD_REPAIR_PATCH, 293 SCHEDULE_NOTIFY_HOT_RELOAD_PAGE, 294 SCHEDULE_NOTIFY_UNLOAD_REPAIR_PATCH, 295 SCHEDULE_UPDATE_APPLICATION_INFO_INSTALLED, 296 SCHEDULE_HEAPMEMORY_APPLICATION_TRANSACTION, 297 SCHEDULE_NOTIFY_FAULT, 298 APP_GC_STATE_CHANGE, 299 SCHEDULE_ATTACH_APP_DEBUG, 300 SCHEDULE_DETACH_APP_DEBUG, 301 SCHEDULE_NEW_PROCESS_REQUEST, 302 SCHEDULE_JSHEAP_MEMORY_APPLICATION_TRANSACTION, 303 SCHEDULE_DUMP_IPC_START, 304 SCHEDULE_DUMP_IPC_STOP, 305 SCHEDULE_DUMP_IPC_STAT, 306 SCHEDULE_DUMP_FFRT, 307 SCHEDULE_CACHE_PROCESS, 308 }; 309 }; 310 } // namespace AppExecFwk 311 } // namespace OHOS 312 #endif // OHOS_ABILITY_RUNTIME_APP_SCHEDULER_INTERFACE_H 313