1 /* 2 * Copyright (c) 2022 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 APP_INFO_H 17 #define APP_INFO_H 18 19 #include <string> 20 #include <iosfwd> 21 22 namespace OHOS { 23 namespace RME { 24 namespace { 25 constexpr int RT_PRIO = 0; 26 constexpr int RT_NUM = 4; 27 } 28 29 enum class AppState { 30 APP_FOREGROUND, 31 APP_FOREGROUND_WITHOUT_RTG, 32 APP_BACKGROUND, 33 APP_TERMINATED, 34 APP_UNKNOWN, 35 }; 36 37 enum class CgroupPolicy { 38 SP_DEFAULT = 0, 39 SP_BACKGROUND = 1, 40 SP_FOREGROUND = 2, 41 SP_SYSTEM_BACKGROUND = 3, 42 SP_TOP_APP = 4, 43 SP_SYSTEM_DEFAULT = SP_DEFAULT 44 }; 45 46 class AppInfo { 47 public: 48 AppInfo(std::string appName, int pid, int uiTid, int renderTid, int isFocus, AppState state); 49 AppInfo(int pid); 50 ~AppInfo() = default; 51 52 void SetRenderTid(const int tid); 53 int GetRenderTid(); 54 void SetUiTid(const int tid); 55 int GetUiTid(); 56 void SetAppName(const std::string appName); 57 void SetAppState(AppState appState); 58 AppState GetAppState(); 59 void SetFocusState(const int isFocus); 60 int GetFocusState(); 61 void SetAppPid(const int pid); 62 int GetAppPid(); 63 void SetRtgrp(const int grpNum); 64 int GetRtgrp(); 65 private: 66 std::string m_appName; 67 int m_pid; 68 int m_uiTid; 69 int m_renderTid; 70 int m_isFocus; 71 int m_rtGrp; 72 AppState m_appState; 73 }; 74 } // namespace RME 75 } // namespace OHOS 76 #endif 77