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, int uid); 48 void NewBackground(int pid); 49 void NewDiedProcess(int pid); 50 void NewAppRecord(int pid, int uid); 51 void AuthAppKilled(int uid); 52 void AuthForeground(int uid); 53 void AuthBackground(int uid); 54 int TryCreateRtgForApp(AppInfo *app); 55 inline CgroupPolicy CheckCgroupState(const CgroupPolicy cgroup); 56 std::list<AppInfo>::iterator GetRecordOfPid(int pid); 57 std::list<AppInfo> m_historyApp = {}; 58 std::set<std::string> m_unsupportApp = {}; 59 std::map<std::string, std::string> m_generalPara {}; 60 std::map<std::string, std::map<std::string, int>> m_subEventPara {}; 61 std::vector<int> m_fpsList {}; 62 std::vector<int> m_renderTypeList {}; 63 bool m_readXmlSuc = false; 64 bool m_needReadXml = true; 65 bool m_switch = false; 66 }; 67 } // namespace RME 68 } // namesapce OHOS 69 #endif 70