13c3173acSopenharmony_ci/*
23c3173acSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
33c3173acSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43c3173acSopenharmony_ci * you may not use this file except in compliance with the License.
53c3173acSopenharmony_ci * You may obtain a copy of the License at
63c3173acSopenharmony_ci *
73c3173acSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
83c3173acSopenharmony_ci *
93c3173acSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103c3173acSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113c3173acSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123c3173acSopenharmony_ci * See the License for the specific language governing permissions and
133c3173acSopenharmony_ci * limitations under the License.
143c3173acSopenharmony_ci */
153c3173acSopenharmony_ci#ifndef CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H
163c3173acSopenharmony_ci#define CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H
173c3173acSopenharmony_ci
183c3173acSopenharmony_ci#include <map>
193c3173acSopenharmony_ci#include <memory>
203c3173acSopenharmony_ci#include <unordered_set>
213c3173acSopenharmony_ci#include "libxml/parser.h"
223c3173acSopenharmony_ci#include "libxml/xpath.h"
233c3173acSopenharmony_ci
243c3173acSopenharmony_cinamespace OHOS {
253c3173acSopenharmony_cinamespace ConcurrentTask {
263c3173acSopenharmony_ciclass ConfigReader {
273c3173acSopenharmony_cipublic:
283c3173acSopenharmony_ci    bool LoadFromConfigFile(const std::string& configFile);
293c3173acSopenharmony_ci    void GetRealConfigPath(const char* configName, std::string& configPath);
303c3173acSopenharmony_ci    bool IsUidAuth(pid_t uid);
313c3173acSopenharmony_ci    bool IsBundleNameAuth(std::string& bundleName);
323c3173acSopenharmony_ci    bool GetPowerModeSchedSwitch();
333c3173acSopenharmony_ci    int GetDegratationFps(int fps);
343c3173acSopenharmony_ciprivate:
353c3173acSopenharmony_ci    bool IsValidNode(const xmlNode* currNode);
363c3173acSopenharmony_ci    bool IsValidFps(const std::string& fps);
373c3173acSopenharmony_ci    bool IsPositiveInt(const std::string& intStr);
383c3173acSopenharmony_ci    bool FillinUidInfo(const xmlNode* currNode);
393c3173acSopenharmony_ci    bool FillinBundleNameInfo(const xmlNode* currNode);
403c3173acSopenharmony_ci    void ParseAuth(const xmlNode* currNode);
413c3173acSopenharmony_ci    void ParsePowerMode(const xmlNode* currNode);
423c3173acSopenharmony_ci    void ConfigHilog();
433c3173acSopenharmony_ci    bool powerModeSchedSwitch_ = false;
443c3173acSopenharmony_ci    std::unordered_set<pid_t> authProcUidConfigs_;
453c3173acSopenharmony_ci    std::unordered_set<std::string> authProcBundleNameConfigs_;
463c3173acSopenharmony_ci    std::map<int, int> degradationFpsMap_;
473c3173acSopenharmony_ci};
483c3173acSopenharmony_ci} // namespace ConcurrentTask
493c3173acSopenharmony_ci} // namespace OHOS
503c3173acSopenharmony_ci#endif // CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H
51