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_ABILITY_RUNTIME_ABILITY_LIFECYCLE_EXECUTOR_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_LIFECYCLE_EXECUTOR_H 18 19 namespace OHOS { 20 namespace AppExecFwk { 21 class AbilityLifecycleExecutor { 22 public: 23 AbilityLifecycleExecutor() = default; 24 virtual ~AbilityLifecycleExecutor() = default; 25 enum LifecycleState { 26 ACTIVE, 27 BACKGROUND, 28 INACTIVE, 29 INITIAL, 30 UNINITIALIZED, 31 STARTED_NEW, 32 FOREGROUND_NEW, 33 BACKGROUND_NEW, 34 STOPED_NEW 35 }; 36 37 /** 38 * @brief While Ability's lifecycle changes, dispatch lifecycle state. 39 * 40 * @param state Lifecycle state. 41 */ 42 void DispatchLifecycleState(const AbilityLifecycleExecutor::LifecycleState &state); 43 44 /** 45 * @brief Obtains the int value of the ability lifecycle state represented by the 46 * AbilityLifecycleExecutor.LifecycleState enum constant. 47 * 48 * @return return Returns the int value of the ability lifecycle state represented 49 * by the AbilityLifecycleExecutor.LifecycleState enum constant. 50 */ 51 int GetState() const; 52 53 private: 54 AbilityLifecycleExecutor::LifecycleState state_ = UNINITIALIZED; 55 }; 56 } // namespace AppExecFwk 57 } // namespace OHOS 58 #endif // OHOS_ABILITY_RUNTIME_ABILITY_LIFECYCLE_EXECUTOR_H 59