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