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