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 INTELLI_SENSE_SERVER_H 17 #define INTELLI_SENSE_SERVER_H 18 19 #include <map> 20 #include <list> 21 #include <string> 22 #include <vector> 23 #include <set> 24 #include <cstdint> 25 #include <iosfwd> 26 #include "rme_constants.h" 27 #include "single_instance.h" 28 #include "app_info.h" 29 30 namespace OHOS { 31 namespace RME { 32 using namespace std; 33 34 class IntelliSenseServer { 35 DECLARE_SINGLE_INSTANCE(IntelliSenseServer); 36 public: 37 void Init(); 38 void ReportAppInfo(const int pid, const int uid, const std::string bundleName, ThreadState state); 39 void ReportProcessInfo(const int pid, const int uid, const std::string bundleName, ThreadState state); 40 void ReportCgroupChange(const int pid, const int uid, const int oldGroup, const int newGroup); 41 void ReportWindowFocus(const int pid, const int uid, int isFocus); 42 void ReportRenderThread(const int pid, const int uid, int renderTid); 43 bool ReadXml(); 44 void SetPara(const int32_t currentFps, const int32_t currentRenderType); 45 46 private: 47 void NewForeground(int pid); 48 void NewBackground(int pid); 49 void NewDiedProcess(int pid); 50 void NewAppRecord(int pid); 51 int TryCreateRtgForApp(AppInfo *app); 52 inline CgroupPolicy CheckCgroupState(const CgroupPolicy cgroup); 53 std::list<AppInfo>::iterator GetRecordOfPid(int pid); 54 std::list<AppInfo> m_historyApp = {}; 55 std::set<std::string> m_unsupportApp = {}; 56 std::map<std::string, std::string> m_generalPara {}; 57 std::map<std::string, std::map<std::string, int>> m_subEventPara {}; 58 std::vector<int> m_fpsList {}; 59 std::vector<int> m_renderTypeList {}; 60 bool m_readXmlSuc = false; 61 bool m_needReadXml = true; 62 bool m_switch = false; 63 }; 64 } // namespace RME 65 } // namesapce OHOS 66 #endif 67