Read libnfc-nci.conf file after NFC Toggle.

Configs are cleared when Nfc is disabled. This change reads the
configs again if empty.

Test: nfc_test_utils passes
Test: acts test NfcBasicFunctionalityTest:test_nfc_toggle_state_100_iterations
Bug: 73076740
Change-Id: I2e115d399db598b78f0be1a8a20af23a71fc31d0
(cherry picked from commit 8cd001fd8fdef9b6e6c9133b7e922275fc94eb58)
diff --git a/src/adaptation/nfc_config.cc b/src/adaptation/nfc_config.cc
index 96acfe4..f18e450 100644
--- a/src/adaptation/nfc_config.cc
+++ b/src/adaptation/nfc_config.cc
@@ -43,7 +43,7 @@
 
 }  // namespace
 
-NfcConfig::NfcConfig() {
+void NfcConfig::loadConfig() {
   string config_path = findConfigPath();
   CHECK(config_path != "");
   config_.parseFromFile(config_path);
@@ -56,8 +56,13 @@
   }
 }
 
+NfcConfig::NfcConfig() { loadConfig(); }
+
 NfcConfig& NfcConfig::getInstance() {
   static NfcConfig theInstance;
+  if (theInstance.config_.isEmpty()) {
+    theInstance.loadConfig();
+  }
   return theInstance;
 }
 
diff --git a/src/include/nfc_config.h b/src/include/nfc_config.h
index b941ece..890602d 100644
--- a/src/include/nfc_config.h
+++ b/src/include/nfc_config.h
@@ -61,6 +61,7 @@
   static void clear();
 
  private:
+  void loadConfig();
   static NfcConfig& getInstance();
   NfcConfig();
 
diff --git a/utils/config.cc b/utils/config.cc
index 4128098..8850c95 100644
--- a/utils/config.cc
+++ b/utils/config.cc
@@ -161,4 +161,5 @@
   return getValue(key).getBytes();
 }
 
+bool ConfigFile::isEmpty() { return values_.empty(); }
 void ConfigFile::clear() { values_.clear(); }
diff --git a/utils/include/config.h b/utils/include/config.h
index a9a16ec..bb3e0dc 100644
--- a/utils/include/config.h
+++ b/utils/include/config.h
@@ -52,6 +52,7 @@
   unsigned getUnsigned(const std::string& key);
   std::vector<uint8_t> getBytes(const std::string& key);
 
+  bool isEmpty();
   void clear();
 
  private:
diff --git a/utils/test/config_test.cc b/utils/test/config_test.cc
index c31744b..b2fde71 100644
--- a/utils/test/config_test.cc
+++ b/utils/test/config_test.cc
@@ -110,6 +110,15 @@
   EXPECT_DEATH(config.getUnsigned("NUM_VALUE"), "");
 }
 
+TEST(ConfigTestFromString, test_isEmpty) {
+  ConfigFile config;
+  EXPECT_TRUE(config.isEmpty());
+  config.parseFromString(SIMPLE_CONFIG);
+  EXPECT_FALSE(config.isEmpty());
+  config.clear();
+  EXPECT_TRUE(config.isEmpty());
+}
+
 TEST_F(ConfigTestFromFile, test_file_based_config) {
   ConfigFile config;
   config.parseFromFile(SIMPLE_CONFIG_FILE);