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_HOST_LISTEN_TECH_MASK "HOST_LISTEN_TECH_MASK" 31 #define NAME_NFA_DM_CFG "NFA_DM_CFG" 32 #define NAME_SCREEN_OFF_POWER_STATE "SCREEN_OFF_POWER_STATE" 33 #define NAME_NFA_MAX_EE_SUPPORTED "NFA_MAX_EE_SUPPORTED" 34 #define NAME_NFA_DM_DISC_DURATION_POLL "NFA_DM_DISC_DURATION_POLL" 35 #define NAME_POLL_FREQUENCY "POLL_FREQUENCY" 36 #define NAME_NFA_AID_BLOCK_ROUTE "NFA_AID_BLOCK_ROUTE" 37 #define NAME_AID_FOR_EMPTY_SELECT "AID_FOR_EMPTY_SELECT" 38 #define NAME_AID_MATCHING_MODE "AID_MATCHING_MODE" 39 #define NAME_OFFHOST_AID_ROUTE_PWR_STATE "OFFHOST_AID_ROUTE_PWR_STATE" 40 #define NAME_LEGACY_MIFARE_READER "LEGACY_MIFARE_READER" 41 42 /* Configs from vendor interface */ 43 #define NAME_NFA_POLL_BAIL_OUT_MODE "NFA_POLL_BAIL_OUT_MODE" 44 #define NAME_PRESENCE_CHECK_ALGORITHM "PRESENCE_CHECK_ALGORITHM" 45 #define NAME_NFA_PROPRIETARY_CFG "NFA_PROPRIETARY_CFG" 46 #define NAME_DEFAULT_OFFHOST_ROUTE "DEFAULT_OFFHOST_ROUTE" 47 #define NAME_OFFHOST_ROUTE_ESE "OFFHOST_ROUTE_ESE" 48 #define NAME_OFFHOST_ROUTE_UICC "OFFHOST_ROUTE_UICC" 49 #define NAME_DEFAULT_NFCF_ROUTE "DEFAULT_NFCF_ROUTE" 50 #define NAME_DEFAULT_SYS_CODE "DEFAULT_SYS_CODE" 51 #define NAME_DEFAULT_SYS_CODE_ROUTE "DEFAULT_SYS_CODE_ROUTE" 52 #define NAME_DEFAULT_SYS_CODE_PWR_STATE "DEFAULT_SYS_CODE_PWR_STATE" 53 #define NAME_DEFAULT_ROUTE "DEFAULT_ROUTE" 54 #define NAME_OFF_HOST_ESE_PIPE_ID "OFF_HOST_ESE_PIPE_ID" 55 #define NAME_OFF_HOST_SIM_PIPE_ID "OFF_HOST_SIM_PIPE_ID" 56 #define NAME_ISO_DEP_MAX_TRANSCEIVE "ISO_DEP_MAX_TRANSCEIVE" 57 #define NAME_DEVICE_HOST_WHITE_LIST "DEVICE_HOST_WHITE_LIST" 58 #define NAME_DEFAULT_ISODEP_ROUTE "DEFAULT_ISODEP_ROUTE" 59 60 class NfcConfig { 61 public: 62 static bool hasKey(const std::string& key); 63 static std::string getString(const std::string& key); 64 static std::string getString(const std::string& key, 65 std::string default_value); 66 static unsigned getUnsigned(const std::string& key); 67 static unsigned getUnsigned(const std::string& key, unsigned default_value); 68 static std::vector<uint8_t> getBytes(const std::string& key); 69 static void clear(); 70 71 private: 72 void loadConfig(); 73 static NfcConfig& getInstance(); 74 NfcConfig(); 75 76 ConfigFile config_; 77 }; 78