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_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_APP_SCHEDULER_PROXY_H 18 19 #include "iremote_proxy.h" 20 #include "app_scheduler_interface.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 class AppSchedulerProxy : public IRemoteProxy<IAppScheduler> { 25 public: 26 explicit AppSchedulerProxy(const sptr<IRemoteObject> &impl); 27 virtual ~AppSchedulerProxy() = default; 28 29 /** 30 * ScheduleForegroundApplication, call ScheduleForegroundApplication() through proxy project, 31 * Notify application to switch to foreground. 32 * 33 * @return 34 */ 35 virtual void ScheduleForegroundApplication() override; 36 37 /** 38 * ScheduleBackgroundApplication, call ScheduleBackgroundApplication() through proxy project, 39 * Notify application to switch to background. 40 * 41 * @return 42 */ 43 virtual void ScheduleBackgroundApplication() override; 44 45 /** 46 * ScheduleTerminateApplication, call ScheduleTerminateApplication() through proxy project, 47 * Notify application to terminate. 48 * 49 * @return 50 */ 51 virtual void ScheduleTerminateApplication() override; 52 53 /** 54 * ScheduleShrinkMemory, call ScheduleShrinkMemory() through proxy project, 55 * Notifies the application of the memory seen. 56 * 57 * @param The memory value. 58 * 59 * @return 60 */ 61 virtual void ScheduleShrinkMemory(const int32_t level) override; 62 63 /** 64 * ScheduleLowMemory, call ScheduleLowMemory() through proxy project, 65 * Notify application to low memory. 66 * 67 * @return 68 */ 69 virtual void ScheduleLowMemory() override; 70 71 /** 72 * ScheduleMemoryLevel, call ScheduleMemoryLevel() through proxy project, 73 * Notify applications background the current memory level. 74 * 75 * @return 76 */ 77 virtual void ScheduleMemoryLevel(int32_t level) override; 78 79 /** 80 * ScheduleLaunchApplication, call ScheduleLaunchApplication() through proxy project, 81 * Notify application to launch application. 82 * 83 * @param The app data value. 84 * 85 * @return 86 */ 87 virtual void ScheduleLaunchApplication(const AppLaunchData &launchData, const Configuration &config) override; 88 89 /** 90 * ScheduleUpdateApplicationInfoInstalled, call ScheduleUpdateApplicationInfoInstalled() through proxy object, 91 * update the application info after new module installed. 92 * 93 * @param appInfo The latest application info obtained from bms for update abilityRuntimeContext. 94 * 95 * @return 96 */ 97 virtual void ScheduleUpdateApplicationInfoInstalled(const ApplicationInfo &) override; 98 99 /** 100 * Notify application to launch ability stage. 101 * 102 * @param The resident process data value. 103 */ 104 virtual void ScheduleAbilityStage(const HapModuleInfo &abilityStage) override; 105 106 /** 107 * ScheduleLaunchAbility, call ScheduleLaunchAbility() through proxy project, 108 * Notify application to launch ability. 109 * 110 * @param The ability info. 111 * @param The ability token. 112 * @param The ability want. 113 * @return 114 */ 115 virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &, 116 const std::shared_ptr<AAFwk::Want> &want) override; 117 118 /** 119 * ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project, 120 * Notify application to clean ability. 121 * 122 * @param The ability token. 123 * @return 124 */ 125 virtual void ScheduleCleanAbility(const sptr<IRemoteObject> &token) override; 126 127 /** 128 * ScheduleProfileChanged, call ScheduleProfileChanged() through proxy project, 129 * Notify application to profile update. 130 * 131 * @param The profile data. 132 * @return 133 */ 134 virtual void ScheduleProfileChanged(const Profile &profile) override; 135 136 /** 137 * ScheduleConfigurationUpdated, call ScheduleConfigurationUpdated() through proxy project, 138 * Notify application to configuration update. 139 * 140 * @param The configuration data. 141 * @return 142 */ 143 virtual void ScheduleConfigurationUpdated(const Configuration &config) override; 144 145 /** 146 * ScheduleProcessSecurityExit, call ScheduleProcessSecurityExit() through proxy project, 147 * Notify application process exit safely. 148 * 149 * @return 150 */ 151 virtual void ScheduleProcessSecurityExit() override; 152 153 virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override; 154 155 int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName, 156 const sptr<IQuickFixCallback> &callback, const int32_t recordId) override; 157 158 int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) override; 159 160 int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName, 161 const sptr<IQuickFixCallback> &callback, const int32_t recordId) override; 162 163 private: 164 bool WriteInterfaceToken(MessageParcel &data); 165 void ScheduleMemoryCommon(const int32_t level, const uint32_t operation); 166 static inline BrokerDelegator<AppSchedulerProxy> delegator_; 167 }; 168 } // namespace AppExecFwk 169 } // namespace OHOS 170 #endif // OHOS_ABILITY_RUNTIME_APP_SCHEDULER_PROXY_H 171