/* * Copyright (C) 2013-2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef PERKILL_H #define PERKILL_H #include #include #include #include "tinyxml2.h" #include #include #define PREKILL_CONFIG_PATH "/vendor/etc/camera/prekill_size_config.xml" // ============ 配置项结构 ============ struct ConfigItem { std::string name; // 配置名称 std::string property; // 属性名 int defaultValue; // 默认值 }; // ============ 配置管理器 ============ class PrekillConfigManager { public: static PrekillConfigManager& getInstance(); bool init(); int getValue(const std::string& configName, int defaultValue = -1); private: PrekillConfigManager() = default; ~PrekillConfigManager() = default; PrekillConfigManager(const PrekillConfigManager&) = delete; PrekillConfigManager& operator=(const PrekillConfigManager&) = delete; bool loadConfigDefs(); void applyAllProperties(); int getXmlValue(const std::string& configName, int defaultValue); tinyxml2::XMLElement* findElement(tinyxml2::XMLElement* root, const std::vector& path); void setProperty(const char* key, int value); std::vector mConfigItems; std::shared_ptr mXmlDoc; std::string mRamSize; std::string mProjectName; bool mInitialized = false; }; // ============ 初始化函数 ============ bool prekillInitInternal(); // ============ 便捷查询函数 ============ int getConfigValue(const std::string& name, int defaultValue = -1); int getCameraPrekillSizeByProject(); int getThirdPrekillSizeByProject(); int getAnonCompressThresholdByProject(); // ============ 辅助函数 ============ std::string getProperty(const char* key, const char* defaultValue); std::string getRamSize(); std::string getProjectName(); #endif