1 /* 2 * Copyright (c) 2021 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 FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_LIFECYCLE_DEAL_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_LIFECYCLE_DEAL_H 18 19 #include "app_scheduler_proxy.h" 20 #include "app_launch_data.h" 21 #include "ability_running_record.h" 22 #include "hap_module_info.h" 23 #include "want.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class AppLifeCycleDeal { 28 public: 29 AppLifeCycleDeal(); 30 virtual ~AppLifeCycleDeal(); 31 32 /** 33 * LaunchApplication, call ScheduleLaunchApplication() through proxy project, 34 * Notify application to launch application. 35 * 36 * @param The app data value. 37 * 38 * @return 39 */ 40 void LaunchApplication(const AppLaunchData &launchData_, const Configuration &config); 41 42 /** 43 * AddAbilityStageInfo, call ScheduleAbilityStageInfo() through proxy project, 44 * Notify application to launch application. 45 * 46 * @param The app data value. 47 * 48 * @return 49 */ 50 void AddAbilityStage(const HapModuleInfo &abilityStage); 51 52 /** 53 * LaunchAbility, call ScheduleLaunchAbility() through proxy project, 54 * Notify application to launch ability. 55 * 56 * @param The ability info. 57 * @return 58 */ 59 void LaunchAbility(const std::shared_ptr<AbilityRunningRecord> &ability); 60 61 /** 62 * ScheduleTerminate, call ScheduleTerminateApplication() through proxy project, 63 * Notify application to terminate. 64 * 65 * @return 66 */ 67 void ScheduleTerminate(); 68 69 /** 70 * ScheduleForegroundRunning, call ScheduleForegroundApplication() through proxy project, 71 * Notify application to switch to foreground. 72 * 73 * @return 74 */ 75 void ScheduleForegroundRunning(); 76 77 /** 78 * ScheduleBackgroundRunning, call ScheduleBackgroundApplication() through proxy project, 79 * Notify application to switch to background. 80 * 81 * @return 82 */ 83 void ScheduleBackgroundRunning(); 84 85 /** 86 * ScheduleTrimMemory, call ScheduleShrinkMemory() through proxy project, 87 * Notifies the application of the memory seen. 88 * 89 * @param The memory value. 90 * 91 * @return 92 */ 93 void ScheduleTrimMemory(int32_t timeLevel); 94 95 /** 96 * LowMemoryWarning, call ScheduleLowMemory() through proxy project, 97 * Notify application to low memory. 98 * 99 * @return 100 */ 101 void LowMemoryWarning(); 102 103 /** 104 * ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project, 105 * Notify application to clean ability. 106 * 107 * @param token, The ability token. 108 * @return 109 */ 110 void ScheduleCleanAbility(const sptr<IRemoteObject> &token); 111 112 /** 113 * ScheduleProcessSecurityExit, call ScheduleTerminateApplication() through proxy project, 114 * Notify application process exit safely. 115 * 116 * @return 117 */ 118 void ScheduleProcessSecurityExit(); 119 120 /** 121 * @brief Setting client for application record. 122 * 123 * @param thread, the application client. 124 */ 125 void SetApplicationClient(const sptr<IAppScheduler> &thread); 126 127 /** 128 * @brief Obtains the client of the application record. 129 * 130 * @return Returns the application client. 131 */ 132 sptr<IAppScheduler> GetApplicationClient() const; 133 134 void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName); 135 136 /** 137 * UpdateConfiguration, ANotify application update system environment changes. 138 * 139 * @param config, System environment change parameters. 140 */ 141 void UpdateConfiguration(const Configuration &config); 142 143 private: 144 sptr<IAppScheduler> appThread_ = nullptr; 145 }; 146 } // namespace AppExecFwk 147 } // namespace OHOS 148 149 #endif // FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_LIFECYCLE_DEAL_H