1 /* 2 * Copyright (c) 2024 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_STATE_UTILS_H 17 #define OHOS_ABILITY_RUNTIME_STATE_UTILS_H 18 19 #include <string> 20 21 #include "ability_state.h" 22 #include "app_scheduler.h" 23 24 namespace OHOS { 25 namespace AAFwk { 26 /** 27 * @class StateUtils 28 * provides state utilities. 29 */ 30 class StateUtils final { 31 public: 32 /** 33 * StateToStrMap, convert ability state to string. 34 * 35 * @param state The ability state. 36 * @return The string ability state. 37 */ 38 static std::string StateToStrMap(const AbilityState &state); 39 40 /** 41 * AppStateToStrMap, convert app state to string. 42 * 43 * @param state The app state. 44 * @return The string app state. 45 */ 46 static std::string AppStateToStrMap(const AppState &state); 47 48 /** 49 * ConvertStateMap, convert ability lifecycle state to string. 50 * 51 * @param state The ability lifecycle state. 52 * @return The string ability lifecycle state. 53 */ 54 static int ConvertStateMap(const AbilityLifeCycleState &state); 55 }; 56 } // namespace AAFwk 57 } // namespace OHOS 58 #endif //OHOS_ABILITY_RUNTIME_STATE_UTILS_H 59