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 #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 "hap_module_info.h" 24 #include "iquick_fix_callback.h" 25 #include "want.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 class IAppScheduler : public IRemoteBroker { 30 public: 31 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppScheduler"); 32 33 /** 34 * ScheduleForegroundApplication, call ScheduleForegroundApplication() through proxy project, 35 * Notify application to switch to foreground. 36 * 37 * @return 38 */ 39 virtual void ScheduleForegroundApplication() = 0; 40 41 /** 42 * ScheduleBackgroundApplication, call ScheduleBackgroundApplication() through proxy project, 43 * Notify application to switch to background. 44 * 45 * @return 46 */ 47 virtual void ScheduleBackgroundApplication() = 0; 48 49 /** 50 * ScheduleTerminateApplication, call ScheduleTerminateApplication() through proxy project, 51 * Notify application to terminate. 52 * 53 * @return 54 */ 55 virtual void ScheduleTerminateApplication() = 0; 56 57 /** 58 * ScheduleShrinkMemory, call ScheduleShrinkMemory() through proxy project, 59 * Notifies the application of the memory seen. 60 * 61 * @param The memory value. 62 * 63 * @return 64 */ 65 virtual void ScheduleShrinkMemory(const int) = 0; 66 67 /** 68 * ScheduleLowMemory, call ScheduleLowMemory() through proxy project, 69 * Notify application to low memory. 70 * 71 * @return 72 */ 73 virtual void ScheduleLowMemory() = 0; 74 75 /** 76 * ScheduleMemoryLevel, call ScheduleMemoryLevel() through proxy project, 77 * Notify applications background the current memory level. 78 * 79 * @return 80 */ 81 virtual void ScheduleMemoryLevel(int32_t level) = 0; 82 83 /** 84 * ScheduleLaunchApplication, call ScheduleLaunchApplication() through proxy project, 85 * Notify application to launch application. 86 * 87 * @param The app data value. 88 * 89 * @return 90 */ 91 virtual void ScheduleLaunchApplication(const AppLaunchData &, const Configuration &) = 0; 92 93 /** 94 * ScheduleUpdateApplicationInfoInstalled, call ScheduleUpdateApplicationInfoInstalled() through proxy object, 95 * update the application info after new module installed. 96 * 97 * @param appInfo The latest application info obtained from bms for update abilityRuntimeContext. 98 * 99 * @return 100 */ 101 virtual void ScheduleUpdateApplicationInfoInstalled(const ApplicationInfo &) = 0; 102 103 /** 104 * ScheduleAbilityStageInfo, call ScheduleAbilityStageInfo() through proxy project, 105 * Notify application to launch application. 106 * 107 * @param The app data value. 108 * 109 * @return 110 */ 111 virtual void ScheduleAbilityStage(const HapModuleInfo &) = 0; 112 113 virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &, 114 const std::shared_ptr<AAFwk::Want> &want) = 0; 115 116 /** 117 * ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project, 118 * Notify application to clean ability. 119 * 120 * @param The ability token. 121 * @return 122 */ 123 virtual void ScheduleCleanAbility(const sptr<IRemoteObject> &) = 0; 124 125 /** 126 * ScheduleProfileChanged, call ScheduleProfileChanged() through proxy project, 127 * Notify application to profile update. 128 * 129 * @param The profile data. 130 * @return 131 */ 132 virtual void ScheduleProfileChanged(const Profile &) = 0; 133 134 /** 135 * ScheduleConfigurationUpdated, call ScheduleConfigurationUpdated() through proxy project, 136 * Notify application to configuration update. 137 * 138 * @param The configuration data. 139 * @return 140 */ 141 virtual void ScheduleConfigurationUpdated(const Configuration &config) = 0; 142 143 /** 144 * ScheduleProcessSecurityExit, call ScheduleProcessSecurityExit() through proxy project, 145 * Notify application process exit safely. 146 * 147 * @return 148 */ 149 virtual void ScheduleProcessSecurityExit() = 0; 150 151 virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) = 0; 152 153 /** 154 * @brief Notify application load patch. 155 * 156 * @param bundleName Bundle name 157 * @param callback called when LoadPatch finished. 158 * @return Returns 0 on success, error code on failure. 159 */ 160 virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName, 161 const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0; 162 163 /** 164 * @brief Notify application reload page. 165 * 166 * @param callback called when HotReload finished. 167 * @return Returns 0 on success, error code on failure. 168 */ 169 virtual int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0; 170 171 /** 172 * @brief Notify application unload patch. 173 * 174 * @param bundleName Bundle name 175 * @param callback called when UnloadPatch finished. 176 * @return Returns 0 on success, error code on failure. 177 */ 178 virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName, 179 const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0; 180 181 enum class Message { 182 SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0, 183 SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION, 184 SCHEDULE_TERMINATE_APPLICATION_TRANSACTION, 185 SCHEDULE_LOWMEMORY_APPLICATION_TRANSACTION, 186 SCHEDULE_SHRINK_MEMORY_APPLICATION_TRANSACTION, 187 SCHEDULE_LAUNCH_ABILITY_TRANSACTION, 188 SCHEDULE_CLEAN_ABILITY_TRANSACTION, 189 SCHEDULE_LAUNCH_APPLICATION_TRANSACTION, 190 SCHEDULE_PROFILE_CHANGED_TRANSACTION, 191 SCHEDULE_CONFIGURATION_UPDATED, 192 SCHEDULE_PROCESS_SECURITY_EXIT_TRANSACTION, 193 SCHEDULE_ABILITY_STAGE_INFO, 194 SCHEDULE_ACCEPT_WANT, 195 SCHEDULE_MEMORYLEVEL_APPLICATION_TRANSACTION, 196 SCHEDULE_NOTIFY_LOAD_REPAIR_PATCH, 197 SCHEDULE_NOTIFY_HOT_RELOAD_PAGE, 198 SCHEDULE_NOTIFY_UNLOAD_REPAIR_PATCH, 199 SCHEDULE_UPDATE_APPLICATION_INFO_INSTALLED, 200 }; 201 }; 202 } // namespace AppExecFwk 203 } // namespace OHOS 204 #endif // OHOS_ABILITY_RUNTIME_APP_SCHEDULER_INTERFACE_H 205