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 #ifndef CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H 16 #define CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H 17 18 #include <map> 19 #include <memory> 20 #include <unordered_set> 21 #include "libxml/parser.h" 22 #include "libxml/xpath.h" 23 24 namespace OHOS { 25 namespace ConcurrentTask { 26 class ConfigReader { 27 public: 28 bool LoadFromConfigFile(const std::string& configFile); 29 void GetRealConfigPath(const char* configName, std::string& configPath); 30 bool IsUidAuth(pid_t uid); 31 bool IsBundleNameAuth(std::string& bundleName); 32 bool GetPowerModeSchedSwitch(); 33 int GetDegratationFps(int fps); 34 private: 35 bool IsValidNode(const xmlNode* currNode); 36 bool IsValidFps(const std::string& fps); 37 bool IsPositiveInt(const std::string& intStr); 38 bool FillinUidInfo(const xmlNode* currNode); 39 bool FillinBundleNameInfo(const xmlNode* currNode); 40 void ParseAuth(const xmlNode* currNode); 41 void ParsePowerMode(const xmlNode* currNode); 42 void ConfigHilog(); 43 bool powerModeSchedSwitch_ = false; 44 std::unordered_set<pid_t> authProcUidConfigs_; 45 std::unordered_set<std::string> authProcBundleNameConfigs_; 46 std::map<int, int> degradationFpsMap_; 47 }; 48 } // namespace ConcurrentTask 49 } // namespace OHOS 50 #endif // CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H 51