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 #include "app_lifecycle_deal.h" 17 #include "app_log_wrapper.h" 18 19 namespace OHOS { 20 namespace AppExecFwk { AppLifeCycleDeal()21AppLifeCycleDeal::AppLifeCycleDeal() 22 {} 23 ~AppLifeCycleDeal()24AppLifeCycleDeal::~AppLifeCycleDeal() 25 {} 26 LaunchApplication(const AppLaunchData & launchData_)27void AppLifeCycleDeal::LaunchApplication(const AppLaunchData &launchData_) 28 { 29 appThread_->ScheduleLaunchApplication(launchData_); 30 } 31 LaunchAbility(const std::shared_ptr<AbilityRunningRecord> & ability)32void AppLifeCycleDeal::LaunchAbility(const std::shared_ptr<AbilityRunningRecord> &ability) 33 { 34 appThread_->ScheduleLaunchAbility(*(ability->GetAbilityInfo()), ability->GetToken()); 35 } 36 ScheduleTerminate()37void AppLifeCycleDeal::ScheduleTerminate() 38 { 39 if (appThread_) { 40 appThread_->ScheduleTerminateApplication(); 41 } 42 } 43 ScheduleForegroundRunning()44void AppLifeCycleDeal::ScheduleForegroundRunning() 45 { 46 if (appThread_) { 47 appThread_->ScheduleForegroundApplication(); 48 } 49 } 50 ScheduleBackgroundRunning()51void AppLifeCycleDeal::ScheduleBackgroundRunning() 52 { 53 if (appThread_) { 54 appThread_->ScheduleBackgroundApplication(); 55 } 56 } 57 ScheduleTrimMemory(int32_t timeLevel)58void AppLifeCycleDeal::ScheduleTrimMemory(int32_t timeLevel) 59 { 60 if (appThread_) { 61 appThread_->ScheduleShrinkMemory(timeLevel); 62 } 63 } 64 LowMemoryWarning()65void AppLifeCycleDeal::LowMemoryWarning() 66 { 67 if (appThread_) { 68 appThread_->ScheduleLowMemory(); 69 } 70 } 71 ScheduleCleanAbility(const sptr<IRemoteObject> & token)72void AppLifeCycleDeal::ScheduleCleanAbility(const sptr<IRemoteObject> &token) 73 { 74 if (appThread_) { 75 appThread_->ScheduleCleanAbility(token); 76 } 77 } 78 ScheduleProcessSecurityExit()79void AppLifeCycleDeal::ScheduleProcessSecurityExit() 80 { 81 if (appThread_) { 82 appThread_->ScheduleProcessSecurityExit(); 83 } 84 } 85 SetApplicationClient(const sptr<IAppScheduler> & thread)86void AppLifeCycleDeal::SetApplicationClient(const sptr<IAppScheduler> &thread) 87 { 88 appThread_ = thread; 89 } 90 GetApplicationClient() const91sptr<IAppScheduler> AppLifeCycleDeal::GetApplicationClient() const 92 { 93 return appThread_; 94 } 95 } // namespace AppExecFwk 96 } // namespace OHOS