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 OHOS_AAFWK_LIFECYCLE_DEAL_H 17 #define OHOS_AAFWK_LIFECYCLE_DEAL_H 18 19 #include <memory> 20 21 #include "ability_scheduler_interface.h" 22 #include "want.h" 23 #include "nocopyable.h" 24 25 namespace OHOS { 26 namespace AAFwk { 27 /** 28 * @class LifecycleDeal 29 * LifecycleDeal schedule ability life. 30 */ 31 class LifecycleDeal { 32 public: 33 LifecycleDeal(); 34 virtual ~LifecycleDeal(); 35 36 /** 37 * set scheduler for accessing ability 38 * 39 * @param scheduler, ability thread ipc proxy. 40 */ 41 void SetScheduler(const sptr<IAbilityScheduler> &scheduler); 42 43 /** 44 * schedule ability life 45 * 46 */ 47 void Activate(const Want &want, LifeCycleStateInfo &stateInfo); 48 void Inactivate(const Want &want, LifeCycleStateInfo &stateInfo); 49 void MoveToBackground(const Want &want, LifeCycleStateInfo &stateInfo); 50 void ConnectAbility(const Want &want); 51 void DisconnectAbility(const Want &want); 52 void Terminate(const Want &want, LifeCycleStateInfo &stateInfo); 53 void CommandAbility(const Want &want, bool reStart, int startId); 54 void SaveAbilityState(PacMap &outState); 55 void RestoreAbilityState(const PacMap &inState); 56 void UpdateConfiguration(const DummyConfiguration &config); 57 58 private: 59 sptr<IAbilityScheduler> abilityScheduler_; // kit interface used to schedule ability life 60 61 DISALLOW_COPY_AND_MOVE(LifecycleDeal); 62 }; 63 } // namespace AAFwk 64 } // namespace OHOS 65 #endif // OHOS_AAFWK_LIFECYCLE_DEAL_H