1 /* 2 * Copyright 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 #include <string> 19 #include <vector> 20 21 #include <config.h> 22 23 /* Configs from libnfc-nci.conf */ 24 #define NAME_NFC_DEBUG_ENABLED "NFC_DEBUG_ENABLED" 25 #define NAME_NFA_STORAGE "NFA_STORAGE" 26 #define NAME_PRESERVE_STORAGE "PRESERVE_STORAGE" 27 #define NAME_POLLING_TECH_MASK "POLLING_TECH_MASK" 28 #define NAME_P2P_LISTEN_TECH_MASK "P2P_LISTEN_TECH_MASK" 29 #define NAME_UICC_LISTEN_TECH_MASK "UICC_LISTEN_TECH_MASK" 30 #define NAME_NFA_DM_CFG "NFA_DM_CFG" 31 #define NAME_SCREEN_OFF_POWER_STATE "SCREEN_OFF_POWER_STATE" 32 #define NAME_NFA_MAX_EE_SUPPORTED "NFA_MAX_EE_SUPPORTED" 33 #define NAME_NFA_DM_DISC_DURATION_POLL "NFA_DM_DISC_DURATION_POLL" 34 #define NAME_POLL_FREQUENCY "POLL_FREQUENCY" 35 #define NAME_NFA_AID_BLOCK_ROUTE "NFA_AID_BLOCK_ROUTE" 36 #define NAME_AID_FOR_EMPTY_SELECT "AID_FOR_EMPTY_SELECT" 37 #define NAME_AID_MATCHING_MODE "AID_MATCHING_MODE" 38 #define NAME_OFFHOST_AID_ROUTE_PWR_STATE "OFFHOST_AID_ROUTE_PWR_STATE" 39 40 /* Configs from vendor interface */ 41 #define NAME_NFA_POLL_BAIL_OUT_MODE "NFA_POLL_BAIL_OUT_MODE" 42 #define NAME_PRESENCE_CHECK_ALGORITHM "PRESENCE_CHECK_ALGORITHM" 43 #define NAME_NFA_PROPRIETARY_CFG "NFA_PROPRIETARY_CFG" 44 #define NAME_DEFAULT_OFFHOST_ROUTE "DEFAULT_OFFHOST_ROUTE" 45 #define NAME_DEFAULT_NFCF_ROUTE "DEFAULT_NFCF_ROUTE" 46 #define NAME_DEFAULT_SYS_CODE "DEFAULT_SYS_CODE" 47 #define NAME_DEFAULT_SYS_CODE_ROUTE "DEFAULT_SYS_CODE_ROUTE" 48 #define NAME_DEFAULT_SYS_CODE_PWR_STATE "DEFAULT_SYS_CODE_PWR_STATE" 49 #define NAME_DEFAULT_ROUTE "DEFAULT_ROUTE" 50 #define NAME_OFF_HOST_ESE_PIPE_ID "OFF_HOST_ESE_PIPE_ID" 51 #define NAME_OFF_HOST_SIM_PIPE_ID "OFF_HOST_SIM_PIPE_ID" 52 #define NAME_ISO_DEP_MAX_TRANSCEIVE "ISO_DEP_MAX_TRANSCEIVE" 53 #define NAME_DEVICE_HOST_WHITE_LIST "DEVICE_HOST_WHITE_LIST" 54 55 class NfcConfig { 56 public: 57 static bool hasKey(const std::string& key); 58 static std::string getString(const std::string& key); 59 static std::string getString(const std::string& key, 60 std::string default_value); 61 static unsigned getUnsigned(const std::string& key); 62 static unsigned getUnsigned(const std::string& key, unsigned default_value); 63 static std::vector<uint8_t> getBytes(const std::string& key); 64 static void clear(); 65 66 private: 67 void loadConfig(); 68 static NfcConfig& getInstance(); 69 NfcConfig(); 70 71 ConfigFile config_; 72 }; 73