NFC: Fix compilation issues

Modified code to fix build errors and
enabled 2.0 HIDL service for NFC.

Change-Id: Ib1b7a8e4a239dbcb8429cd105a3b66dda9e2494e
diff --git a/Android.bp b/Android.bp
index 957b8b3..c5a2b37 100644
--- a/Android.bp
+++ b/Android.bp
@@ -116,10 +116,6 @@
         "halimpl/utils/*.cpp",
         "halimpl/configs/*.cpp",
         "halimpl/mifare/*.cc",
-        "halimpl/ese-clients/src/DwpEseUpdater.cc",
-        "halimpl/ese-clients/src/DwpSeChannelCallback.cc",
-        "halimpl/ese-clients/src/DwpSeEvtCallback.cc",
-        "halimpl/ese-clients/src/HalLibnfcInteface.cc",
     ],
     shared_libs: [
         "libbase",
@@ -134,6 +130,7 @@
         "android.hardware.nfc@1.2",
         "vendor.nxp.hardware.nfc@1.0",
         "vendor.nxp.hardware.nfc@1.1",
+        "vendor.nxp.hardware.nfc@2.0",
         "android.hardware.secure_element@1.0",
         "vendor.nxp.nxpnfclegacy@1.0",
         "hal_libnfc"
@@ -149,12 +146,15 @@
         "jcos_client/inc",
     ],
     export_include_dirs: [
-        "extns/impl",
+        "extns/impl/nxpnfc/2.0/",
         "halimpl/inc",
         "halimpl/common",
         "halimpl/utils",
+        "halimpl/hal",
         "halimpl/mifare",
         "halimpl/ese-clients/inc",
+        "halimpl/configs",
+        "halimpl/tml",
     ],
     cflags: [
         "-DBUILDCFG=1",
diff --git a/extns/intf/nxpnfc/2.0/Android.bp b/extns/intf/nxpnfc/2.0/Android.bp
deleted file mode 100644
index 59ab821..0000000
--- a/extns/intf/nxpnfc/2.0/Android.bp
+++ /dev/null
@@ -1,16 +0,0 @@
-// This file is autogenerated by hidl-gen -Landroidbp.
-
-hidl_interface {
-    name: "vendor.nxp.nxpnfc@2.0",
-    root: "vendor.nxp.nxpnfc",
-    srcs: [
-        "types.hal",
-        "INxpNfc.hal",
-    ],
-    interfaces: [
-        "android.hidl.base@1.0",
-    ],
-    types: [
-    ],
-    gen_java: true,
-}
diff --git a/extns/intf/nxpnfclegacy/1.0/Android.bp b/extns/intf/nxpnfclegacy/1.0/Android.bp
deleted file mode 100644
index bb89272..0000000
--- a/extns/intf/nxpnfclegacy/1.0/Android.bp
+++ /dev/null
@@ -1,16 +0,0 @@
-// This file is autogenerated by hidl-gen -Landroidbp.
-
-hidl_interface {
-    name: "vendor.nxp.nxpnfclegacy@1.0",
-    root: "vendor.nxp.nxpnfclegacy",
-    srcs: [
-        "types.hal",
-        "INxpNfcLegacy.hal",
-    ],
-    interfaces: [
-        "android.hidl.base@1.0",
-    ],
-    types: [
-    ],
-    gen_java: true,
-}
diff --git a/extns/intf/nxpnfclegacy/Android.bp b/extns/intf/nxpnfclegacy/Android.bp
deleted file mode 100644
index 9e452d3..0000000
--- a/extns/intf/nxpnfclegacy/Android.bp
+++ /dev/null
@@ -1,4 +0,0 @@
-hidl_package_root {
-    name: "vendor.nxp.nxpnfclegacy",
-    path: "hardware/nxp/nfc/extns/intf/nxpnfclegacy",
-}
diff --git a/halimpl/ese-clients/inc/DwpEseUpdater.h b/halimpl/ese-clients/inc/DwpEseUpdater.h
index 34ab6c6..62118b9 100755
--- a/halimpl/ese-clients/inc/DwpEseUpdater.h
+++ b/halimpl/ese-clients/inc/DwpEseUpdater.h
@@ -17,6 +17,7 @@
  ******************************************************************************/
 
 #pragma once
+#ifdef ENABLE_ESE_CLIENT
 #include "EseUpdateChecker.h"
 #include "JcDnld.h"
 
@@ -132,3 +133,4 @@
   *******************************************************************************/
   void eSeClientUpdateHandler();
 };
+#endif
diff --git a/halimpl/hal/phNxpNciHal.cc b/halimpl/hal/phNxpNciHal.cc
index b7e9be6..0284845 100644
--- a/halimpl/hal/phNxpNciHal.cc
+++ b/halimpl/hal/phNxpNciHal.cc
@@ -33,7 +33,7 @@
 #include "spi_spm.h"
 #include <vendor/nxp/hardware/nfc/2.0/types.h>
 #include "Nxp_Features.h"
-#include "NxpNfc.h"
+#include <vendor/nxp/hardware/nfc/2.0/INqNfc.h>
 
 using namespace android::hardware::nfc::V1_1;
 using namespace android::hardware::nfc::V1_2;
@@ -477,16 +477,6 @@
     return NFCSTATUS_REJECTED;
   }
 
-  if (nfcFL.nfcNxpEse == true) {
-    uint32_t level = 0x03;
-    int spi_current_state = phNxpNciHal_getSPMStatus(level);
-    NXPLOG_NCIHAL_D("spi_current_state  = %4x ", spi_current_state);
-    if (spi_current_state != P61_STATE_IDLE) {
-      NXPLOG_NCIHAL_E("FW download denied while SPI in use, Continue NFC init");
-      return NFCSTATUS_REJECTED;
-    }
-  }
-
   nxpncihal_ctrl.phNxpNciGpioInfo.state = GPIO_UNKNOWN;
   phNxpNciHal_gpio_restore(GPIO_STORE);
 
@@ -3736,7 +3726,8 @@
  *                  update the acutual state of operation in arg pointer
  *
  ******************************************************************************/
-int phNxpNciHal_ioctl(long arg, void* p_data) {
+int phNxpNciHal_ioctl(long /* arg */, void* /* p_data */) {
+#ifdef ENABLE_ESE_CLIENT
   NXPLOG_NCIHAL_D("%s : enter - arg = %ld", __func__, arg);
   ese_nxp_IoctlInOutData_t* pInpOutData = (ese_nxp_IoctlInOutData_t*)p_data;
   int ret = -1;
@@ -3759,7 +3750,8 @@
         break;
   }
   NXPLOG_NCIHAL_D("%s : exit - ret = %d", __func__, ret);
-  return ret;
+#endif
+  return -1;
 }
 
 /******************************************************************************
@@ -4424,6 +4416,19 @@
 }
 
 /******************************************************************************
+ * Function         phNxpNciHal_do_factory_reset
+ *
+ * Description      This function is called during factory reset to clear/reset
+ *                  nfc sub-system persistant data.
+ *
+ * Returns          void.
+ *
+ *****************************************************************************/
+void phNxpNciHal_do_factory_reset(void) {
+  phNxpNciHal_reset_nfcee_session(false);
+}
+
+/******************************************************************************
  * Function         phNxpNciHal_print_res_status
  *
  * Description      This function is called to process the response status
@@ -4863,7 +4868,8 @@
  * Returns          0 as success -1 as failed.
  *
  *******************************************************************************/
-int32_t phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus HciStatus){
+int32_t phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus /* HciStatus */){
+#ifdef ENABLE_ESE_CLIENT
     int ret = -1;
     ese_nxp_IoctlInOutData_t InpOutData;
     NXPLOG_NCIHAL_D("%s Enter ", __func__);
@@ -4876,7 +4882,8 @@
       gpEseAdapt->HalNfccNtf(HAL_ESE_IOCTL_HCI_INIT_STATUS_UPDATE, &InpOutData);
 
     NXPLOG_NCIHAL_D("%s Exit ", __func__);
-    return ret;
+#endif
+    return -1;
 }
 
 /******************************************************************************
@@ -4931,6 +4938,7 @@
 *******************************************************************************/
 NFCSTATUS phNxpNciHal_resetEse() {
   NFCSTATUS status = NFCSTATUS_FAILED;
+#ifdef ENABLE_ESE_CLIENT
   int level = 0;
   NXPLOG_NCIHAL_D("%s Entry ", __func__);
   if (nfcFL.chipType == pn557) {
@@ -4946,12 +4954,14 @@
   } else {
     ALOGD("ESE Reset Feature not supported");
   }
-
+#endif
   return status;
 }
 
-void seteSEClientState(uint8_t state) {
+void seteSEClientState(uint8_t /* state */) {
+#ifdef ENABLE_ESE_CLIENT
   DwpEseUpdater::setSpiEseClientState(state);
+#endif
 }
 
 /******************************************************************************
@@ -4990,7 +5000,9 @@
 bool phNxpNciHal_setSystemProperty(string key, string value) { key = value = ""; return false; }
 
 void eSEClientUpdate_NFC_Thread() {
+#ifdef ENABLE_ESE_CLIENT
   DwpEseUpdater::eSEClientUpdate_NFC_Thread();
+#endif
 }
 
 /******************************************************************************
diff --git a/halimpl/hal/phNxpNciHal.h b/halimpl/hal/phNxpNciHal.h
index 1cea407..4be4320 100644
--- a/halimpl/hal/phNxpNciHal.h
+++ b/halimpl/hal/phNxpNciHal.h
@@ -22,7 +22,9 @@
 #include "NxpNfcCapability.h"
 #include <vendor/nxp/hardware/nfc/2.0/types.h>
 #include "DwpEseUpdater.h"
+#ifdef ENABLE_ESE_CLIENT
 #include "EseUpdateChecker.h"
+#endif
 
 using namespace std;
 
diff --git a/halimpl/hal/phNxpNciHal_ext.cc b/halimpl/hal/phNxpNciHal_ext.cc
index 92cfa65..d1cc13c 100644
--- a/halimpl/hal/phNxpNciHal_ext.cc
+++ b/halimpl/hal/phNxpNciHal_ext.cc
@@ -107,7 +107,8 @@
 **                            : 0X01 for RF ON
 **
 *******************************************************************************/
-void phNxpNciHal_sendRfEvtToEseHal(uint8_t rfEvtType) {
+void phNxpNciHal_sendRfEvtToEseHal(uint8_t /* rfEvtType */ ) {
+#ifdef ENABLE_ESE_CLIENT
   ese_nxp_IoctlInOutData_t inpOutData;
   gpEseAdapt = &EseAdaptation::GetInstance();
   gpEseAdapt->Initialize();
@@ -120,6 +121,7 @@
   inpOutData.inp.data_source = 2;
   if (gpEseAdapt != NULL)
         gpEseAdapt->HalNfccNtf(HAL_ESE_IOCTL_RF_STATUS_UPDATE, &inpOutData);
+#endif
 }
 
 /*******************************************************************************
@@ -134,8 +136,10 @@
 NFCSTATUS phNxpNciHal_process_ext_rsp(uint8_t* p_ntf, uint16_t* p_len) {
   NFCSTATUS status = NFCSTATUS_SUCCESS;
   uint16_t rf_technology_length_param = 0;
+#ifdef ENABLE_ESE_CLIENT
   gpEseAdapt = &EseAdaptation::GetInstance();
   gpEseAdapt->Initialize();
+#endif
   /*parse and decode LxDebug Notifications*/
     if(p_ntf[0] == 0x6F && (p_ntf[1] == 0x35 || p_ntf[1] == 0x36))
     {
@@ -362,6 +366,7 @@
                        sizeof(unsigned long))) {
       NXPLOG_NCIHAL_D("RF_STATUS_UPDATE_ENABLE : %lu", rf_update_enable);
     }
+#ifdef ENABLE_ESE_CLIENT
     if (rf_update_enable == 0x01) {
       ese_nxp_IoctlInOutData_t inpOutData;
       memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t));
@@ -371,6 +376,7 @@
       if (gpEseAdapt != NULL)
           gpEseAdapt->HalNfccNtf(HAL_ESE_IOCTL_RF_ACTION_NTF, &inpOutData);
     }
+#endif
   }
 
 if(nfcFL.nfccFL._NFCC_FORCE_NCI1_0_INIT == true) {
diff --git a/halimpl/hal/phNxpNciHal_nciParser.cc b/halimpl/hal/phNxpNciHal_nciParser.cc
index bc03035..318b895 100755
--- a/halimpl/hal/phNxpNciHal_nciParser.cc
+++ b/halimpl/hal/phNxpNciHal_nciParser.cc
@@ -18,7 +18,7 @@
 
 #include <dlfcn.h>
 #include <string.h>
-
+#include "phNfcTypes.h"
 #include "phNxpLog.h"
 
 typedef void* tNCI_PARSER_INSTANCE;
diff --git a/halimpl/inc/phNxpNciHal_Adaptation.h b/halimpl/inc/phNxpNciHal_Adaptation.h
index 913787b..a36f8c6 100644
--- a/halimpl/inc/phNxpNciHal_Adaptation.h
+++ b/halimpl/inc/phNxpNciHal_Adaptation.h
@@ -65,6 +65,7 @@
 int phNxpNciHal_MinInit(nfc_stack_callback_t* p_cback,
                         nfc_stack_data_callback_t* p_data_cback);
 void phNxpNciHal_reset_nfcee_session(bool force_session_reset);
+void phNxpNciHal_do_factory_reset(void);
 int phNxpNciHal_Minclose(void);
 int phNxpNciHal_getFWDownloadFlag(uint8_t* fwDnldRequest);
 #endif /* _PHNXPNCIHAL_ADAPTATION_H_ */
diff --git a/halimpl/src/halLibnfc/src/Android.bp b/halimpl/src/halLibnfc/src/Android.bp
index 590e0f6..3aee030 100755
--- a/halimpl/src/halLibnfc/src/Android.bp
+++ b/halimpl/src/halLibnfc/src/Android.bp
@@ -41,7 +41,7 @@
         "gki/common",
     ],
     include_dirs: [
-        "vendor/nxp/opensource/halimpl/extns/impl/",
+        "vendor/nxp/opensource/halimpl/extns/impl/nxpnfc/2.0/",
     ],
     srcs: [
         "nfa/dm/*.cc",
diff --git a/halimpl/utils/phNxpConfig.cpp b/halimpl/utils/phNxpConfig.cpp
index 8c57313..0eb62b1 100644
--- a/halimpl/utils/phNxpConfig.cpp
+++ b/halimpl/utils/phNxpConfig.cpp
@@ -182,7 +182,7 @@
 
 namespace nxp {
 
-void findConfigFilePathFromTransportConfigPaths(const string& configName, string& filePath);
+bool findConfigFilePathFromTransportConfigPaths(const string& configName, string& filePath);
 
 class CNfcParam : public string {
  public:
diff --git a/nfc_vendor_product.mk b/nfc_vendor_product.mk
index 52be57d..e4197f3 100644
--- a/nfc_vendor_product.mk
+++ b/nfc_vendor_product.mk
@@ -3,7 +3,7 @@
 TARGET_USES_NQ_NFC := true
 endif
 
-NQ_VENDOR_NFC += vendor.nxp.hardware.nfc@1.2-service
+NQ_VENDOR_NFC += vendor.nxp.hardware.nfc@2.0-service
 NQ_VENDOR_NFC += nfc_nci.nqx.default.hw
 
 ifeq ($(strip $(TARGET_USES_NQ_NFC)),true)