Merge tag 'LA.UM.7.3.r1-06900-sdm845.0' into HEAD

"LA.UM.7.3.r1-06900-sdm845.0"

Change-Id: I8e6e0f0883d7b094e523ed710bfc65410a568c88
diff --git a/Android.mk b/Android.mk
index a4bfb20..33849b6 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,3 +1,5 @@
+ifeq ($(call my-dir),$(call project-path-for,bt-vendor))
+
 LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
@@ -13,3 +15,5 @@
 ifeq ($(TARGET_USE_QTI_BT_STACK),true)
 include $(TMP_LOCAL_PATH)/bthost_ipc/Android.mk
 endif #TARGET_USE_QTI_BT_STACK
+
+endif
diff --git a/libbt-vendor/Android.mk b/libbt-vendor/Android.mk
index f15bb04..091dfec 100644
--- a/libbt-vendor/Android.mk
+++ b/libbt-vendor/Android.mk
@@ -45,12 +45,8 @@
 LOCAL_C_INCLUDES += \
         $(LOCAL_PATH)/include \
         external/bluetooth/bluedroid/hci/include \
-        vendor/qcom/opensource/commonsys/system/bt/hci/include \
-        $(TARGET_OUT_HEADERS)/bt/hci_qcomm_init \
-        $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
-
-LOCAL_ADDITIONAL_DEPENDENCIES += \
-$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+        system/bt/hci/include \
+        $(TARGET_OUT_HEADERS)/bt/hci_qcomm_init
 
 ifeq ($(BOARD_HAS_QCA_BT_AR3002), true)
 LOCAL_C_FLAGS := \
@@ -63,22 +59,29 @@
 
 LOCAL_SHARED_LIBRARIES := \
         libcutils \
-        liblog \
-        libbtnv
+        liblog
+
+LOCAL_HEADER_LIBRARIES := \
+        generated_kernel_headers \
+        libutils_headers
 
 LOCAL_MODULE := libbt-vendor
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
 LOCAL_MODULE_OWNER := qcom
 
-ifdef TARGET_2ND_ARCH
-LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
-LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
+LOCAL_VENDOR_MODULE := true
+
+ifeq ($(QCOM_BT_USE_BTNV),true)
+LOCAL_CFLAGS += -DBT_NV_SUPPORT
+ifeq ($(QCPATH),)
+LOCAL_SHARED_LIBRARIES += libdl
+LOCAL_CFLAGS += -DBT_NV_SUPPORT_DL
 else
-LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
+LOCAL_SHARED_LIBRARIES += libbtnv
+endif
 endif
 
-LOCAL_CFLAGS += -DBT_NV_SUPPORT
 LOCAL_CFLAGS += -Wno-unused-variable
 LOCAL_CFLAGS += -Wno-unused-label
 LOCAL_CFLAGS += -Wno-user-defined-warnings
@@ -90,7 +93,12 @@
 ifneq ($(BOARD_ANT_WIRELESS_DEVICE),)
 LOCAL_CFLAGS += -DENABLE_ANT
 endif
-#LOCAL_CFLAGS += -DREAD_BT_ADDR_FROM_PROP
+ifeq ($(QCOM_BT_READ_ADDR_FROM_PROP),true)
+LOCAL_CFLAGS += -DREAD_BT_ADDR_FROM_PROP
+endif
+ifeq ($(QCOM_BT_USE_OLD_WCNSS_FILTER),true)
+LOCAL_CFLAGS += -DUSE_OLD_WCNSS_FILTER
+endif
 
 #include $(LOCAL_PATH)/vnd_buildcfg.mk
 
diff --git a/libbt-vendor/include/bt_vendor_qcom.h b/libbt-vendor/include/bt_vendor_qcom.h
index fe1fe3f..7d08afa 100644
--- a/libbt-vendor/include/bt_vendor_qcom.h
+++ b/libbt-vendor/include/bt_vendor_qcom.h
@@ -45,6 +45,12 @@
 }bt_soc_type;
 
 typedef enum {
+    FM_VND_OP_POWER_CTRL = (unsigned int)BT_VND_OP_A2DP_OFFLOAD_STOP + 1,
+    BT_VND_OP_FM_USERIAL_OPEN,
+    BT_VND_OP_FM_USERIAL_CLOSE,
+}bt_fm_serial;
+
+typedef enum {
     BT_VND_OP_ANT_USERIAL_OPEN = 254,
     BT_VND_OP_ANT_USERIAL_CLOSE
 }ant_serial;
diff --git a/libbt-vendor/include/hci_uart.h b/libbt-vendor/include/hci_uart.h
index 21e9689..50740d7 100644
--- a/libbt-vendor/include/hci_uart.h
+++ b/libbt-vendor/include/hci_uart.h
@@ -20,6 +20,7 @@
 #define HCI_UART_H
 
 #include <asm-generic/ioctls.h>
+#include <termios.h>
 
 /* Variables to identify the platform */
 /*BT HS UART TTY DEVICE */
diff --git a/libbt-vendor/include/hw_ar3k.h b/libbt-vendor/include/hw_ar3k.h
index 2129548..03a9f42 100644
--- a/libbt-vendor/include/hw_ar3k.h
+++ b/libbt-vendor/include/hw_ar3k.h
@@ -18,6 +18,8 @@
 #ifndef HW_AR3K_H
 #define HW_AR3K_H
 
+#include <sys/socket.h>
+
 /******************************************************************************
 **  Constants & Macros
 ******************************************************************************/
@@ -46,7 +48,7 @@
 #error "Unknown byte order"
 #endif
 
-#define FW_PATH "/system/etc/firmware/ar3k/"
+#define FW_PATH "/vendor/firmware/ar3k/"
 
 #define STREAM_TO_UINT16(u16, p) \
     {u16 = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); (p) += 2;}
diff --git a/libbt-vendor/include/hw_rome.h b/libbt-vendor/include/hw_rome.h
index 08efb39..8383a60 100644
--- a/libbt-vendor/include/hw_rome.h
+++ b/libbt-vendor/include/hw_rome.h
@@ -151,13 +151,13 @@
 #define EXTRACT_BYTE(val, pos)      (char) (((val) >> (8 * (pos))) & 0xFF)
 #define CALC_SEG_SIZE(len, max)   ((plen) % (max))?((plen/max)+1) : ((plen) / (max))
 
-#define ROME_FW_PATH                      "/system/etc/firmware/rampatch.img"
-#define ROME_RAMPATCH_TLV_PATH            "/system/etc/firmware/rampatch_tlv.img"
-#define ROME_NVM_TLV_PATH                 "/system/etc/firmware/nvm_tlv.bin"
-#define ROME_RAMPATCH_TLV_1_0_3_PATH      "/system/etc/firmware/rampatch_tlv_1.3.tlv"
-#define ROME_NVM_TLV_1_0_3_PATH           "/system/etc/firmware/nvm_tlv_1.3.bin"
-#define ROME_RAMPATCH_TLV_2_0_1_PATH      "/system/etc/firmware/rampatch_tlv_2.1.tlv"
-#define ROME_NVM_TLV_2_0_1_PATH           "/system/etc/firmware/nvm_tlv_2.1.bin"
+#define ROME_FW_PATH                      "/vendor/firmware/rampatch.img"
+#define ROME_RAMPATCH_TLV_PATH            "/vendor/firmware/rampatch_tlv.img"
+#define ROME_NVM_TLV_PATH                 "/vendor/firmware/nvm_tlv.bin"
+#define ROME_RAMPATCH_TLV_1_0_3_PATH      "/vendor/firmware/rampatch_tlv_1.3.tlv"
+#define ROME_NVM_TLV_1_0_3_PATH           "/vendor/firmware/nvm_tlv_1.3.bin"
+#define ROME_RAMPATCH_TLV_2_0_1_PATH      "/vendor/firmware/rampatch_tlv_2.1.tlv"
+#define ROME_NVM_TLV_2_0_1_PATH           "/vendor/firmware/nvm_tlv_2.1.bin"
 #define ROME_RAMPATCH_TLV_3_0_0_PATH      "/bt_firmware/image/btfw30.tlv"
 #define ROME_NVM_TLV_3_0_0_PATH           "/bt_firmware/image/btnv30.bin"
 #define ROME_RAMPATCH_TLV_3_0_2_PATH      "/bt_firmware/image/btfw32.tlv"
diff --git a/libbt-vendor/src/bt_vendor_persist.cpp b/libbt-vendor/src/bt_vendor_persist.cpp
index 519e826..db895fd 100644
--- a/libbt-vendor/src/bt_vendor_persist.cpp
+++ b/libbt-vendor/src/bt_vendor_persist.cpp
@@ -27,7 +27,27 @@
 #include "bt_vendor_persist.h"
 
 #ifdef BT_NV_SUPPORT
+#ifdef BT_NV_SUPPORT_DL
+#include <dlfcn.h>
+// All figured out through investigation of this code...
+typedef struct {
+   unsigned char bd_addr[6];
+   // This is a bit dangerous, but this struct
+   // is unknown (however not used outside of this context)
+   unsigned char unknown[58];
+} nv_persist_item_type;
+typedef enum {
+  NV_SUCCESS = 0,
+} nv_persist_stat_enum_type;
+#define TRUE 1
+#define FALSE 0
+#define NV_BD_ADDR_I 1
+// ...except this, which was found through experimentation
+#define NV_READ_F 0
+#else
 #include "bt_nv.h"
+#endif
+#define LOG_TAG "QCOM-BTNV"
 #include <utils/Log.h>
 
 /*===========================================================================
@@ -56,11 +76,28 @@
   nv_persist_item_type my_nv_item;
   nv_persist_stat_enum_type cmd_result;
   boolean result = FALSE;
+#ifdef BT_NV_SUPPORT_DL
+  int (*bt_nv_cmd)(int, int, nv_persist_item_type *, int);
+  void *lib = dlopen("libbtnv.so", RTLD_NOW);
+
+  if (!lib) {
+    ALOGE("Failed to open libbtnv.so: %s", dlerror());
+    return FALSE;
+  }
+
+  bt_nv_cmd = (int (*)(int, int, nv_persist_item_type *, int))dlsym(lib, "bt_nv_cmd");
+  if (!bt_nv_cmd) {
+    ALOGE("Failed to find bt_nv_cmd: %s", dlerror());
+    dlclose(lib);
+    return FALSE;
+  }
+#endif
 
   switch(nv_item)
   {
     case NV_BD_ADDR_I:
-      cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F,  NV_BD_ADDR_I, &my_nv_item);
+      // A strange default parameter is used here. A debugger shows 4 parameters being passed.
+      cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F,  NV_BD_ADDR_I, &my_nv_item, 0);
       ALOGI("CMD result: %d", cmd_result);
       if (NV_SUCCESS != cmd_result)
       {
@@ -86,6 +123,9 @@
       }
       break;
   }
+#ifdef BT_NV_SUPPORT_DL
+  dlclose(lib);
+#endif
   return result;
 }
 #endif /* End of BT_NV_SUPPORT */
diff --git a/libbt-vendor/src/bt_vendor_qcom.c b/libbt-vendor/src/bt_vendor_qcom.c
index d6d354f..b855723 100644
--- a/libbt-vendor/src/bt_vendor_qcom.c
+++ b/libbt-vendor/src/bt_vendor_qcom.c
@@ -24,33 +24,41 @@
  *
  ******************************************************************************/
 #define LOG_TAG "bt_vendor"
-#define BLUETOOTH_MAC_ADDR_BOOT_PROPERTY "ro.vendor.boot.btmacaddr"
+#define BLUETOOTH_MAC_ADDR_BOOT_PROPERTY "ro.boot.btmacaddr"
 
-#include <utils/Log.h>
-#include <cutils/properties.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <unistd.h>
-#include <pthread.h>
+#include "bt_vendor_lib.h"
+#include "bt_vendor_persist.h"
 #include "bt_vendor_qcom.h"
-#include "hci_uart.h"
 #include "hci_smd.h"
+#include "hci_uart.h"
+#include "hw_rome.h"
+
+#include <fcntl.h>
+#include <linux/un.h>
+#include <pthread.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include <cutils/properties.h>
 #include <cutils/sockets.h>
-#include <linux/un.h>
-#include "bt_vendor_persist.h"
-#include "hw_rome.h"
-#include "bt_vendor_lib.h"
+#include <utils/Log.h>
 #define WAIT_TIMEOUT 200000
 #define BT_VND_OP_GET_LINESPEED 30
 
 #define STOP_WCNSS_FILTER 0xDD
 #define STOP_WAIT_TIMEOUT   1000
 
-#define SOC_INIT_PROPERTY "vendor.wc_transport.soc_initialized"
+#ifndef USE_OLD_WCNSS_FILTER
+#define PREFIX "vendor."
+#else
+#define PREFIX ""
+#endif
 
-#define BT_VND_FILTER_START "vendor.wc_transport.start_hci"
+#define SOC_INIT_PROPERTY PREFIX "wc_transport.soc_initialized"
+
+#define BT_VND_FILTER_START PREFIX "wc_transport.start_hci"
 
 #define CMD_TIMEOUT  0x22
 
@@ -195,7 +203,7 @@
     ALOGI("bt-vendor : get_bt_soc_type");
 
     ret = property_get("vendor.qcom.bluetooth.soc", bt_soc_type, NULL);
-    if (ret != 0) {
+    if (ret >= 0) {
         ALOGI("vendor.qcom.bluetooth.soc set to %s\n", bt_soc_type);
         if (!strncasecmp(bt_soc_type, "rome", sizeof("rome"))) {
             return BT_SOC_ROME;
@@ -231,7 +239,7 @@
     char inProgress[PROPERTY_VALUE_MAX] = {'\0'};
     int value, ret;
 
-    property_get("vendor.wc_transport.ref_count", ref_count, "0");
+    property_get(PREFIX "wc_transport.ref_count", ref_count, "0");
 
     value = atoi(ref_count);
     ALOGV("%s: ref_count: %s\n",__func__,  ref_count);
@@ -270,7 +278,7 @@
     snprintf(ref_count, 3, "%d", value);
     ALOGV("%s: updated ref_count is: %s", __func__, ref_count);
 
-    ret  = property_set("vendor.wc_transport.ref_count", ref_count);
+    ret  = property_set(PREFIX "wc_transport.ref_count", ref_count);
     if (ret < 0) {
         ALOGE("%s: Error while updating property: %d\n", __func__, ret);
         return false;
@@ -287,55 +295,41 @@
 
        ALOGV("%s: Entry ", __func__);
 
-       if ((soc_type = get_bt_soc_type()) == BT_SOC_CHEROKEE) {
-           property_get("vendor.wc_transport.hci_filter_status", value, "0");
-           if (strcmp(value, "0") == 0) {
-               ALOGI("%s: hci_filter has been stopped already", __func__);
+       property_get(PREFIX "wc_transport.hci_filter_status", value, "0");
+       if (strcmp(value, "0") == 0) {
+           ALOGI("%s: hci_filter has been stopped already", __func__);
+       }
+       else {
+           filter_ctrl = connect_to_local_socket("wcnssfilter_ctrl");
+           if (filter_ctrl < 0) {
+               ALOGI("%s: Error while connecting to CTRL_SOCK, filter should stopped: %d",
+                     __func__, filter_ctrl);
            }
            else {
-               filter_ctrl = connect_to_local_socket("wcnssfilter_ctrl");
-               if (filter_ctrl < 0) {
-                   ALOGI("%s: Error while connecting to CTRL_SOCK, filter should stopped: %d",
-                          __func__, filter_ctrl);
+               retval = write(filter_ctrl, &stop_val, 1);
+               if (retval != 1) {
+                   ALOGI("%s: problem writing to CTRL_SOCK, ignore: %d", __func__, retval);
+                   //Ignore and fallback
                }
-               else {
-                   retval = write(filter_ctrl, &stop_val, 1);
-                   if (retval != 1) {
-                       ALOGI("%s: problem writing to CTRL_SOCK, ignore: %d", __func__, retval);
-                       //Ignore and fallback
-                   }
 
-                   close(filter_ctrl);
-               }
+               close(filter_ctrl);
            }
+       }
 
-           /* Ensure Filter is closed by checking the status before
-              RFKILL 0 operation. this should ideally comeout very
-              quick */
-           for(i=0; i<500; i++) {
-               property_get(BT_VND_FILTER_START, value, "false");
-               if (strcmp(value, "false") == 0) {
-                   ALOGI("%s: WCNSS_FILTER stopped", __func__);
-                   usleep(STOP_WAIT_TIMEOUT * 10);
-                   break;
-               } else {
-                   /*sleep of 1ms, This should give enough time for FILTER to
-                   exit with all necessary cleanup*/
-                   usleep(STOP_WAIT_TIMEOUT);
-               }
+       /* Ensure Filter is closed by checking the status before
+          RFKILL 0 operation. this should ideally comeout very
+          quick */
+       for(i=0; i<500; i++) {
+           property_get(BT_VND_FILTER_START, value, "false");
+           if (strcmp(value, "false") == 0) {
+               ALOGI("%s: WCNSS_FILTER stopped", __func__);
+               usleep(STOP_WAIT_TIMEOUT * 10);
+               break;
+           } else {
+               /*sleep of 1ms, This should give enough time for FILTER to
+               exit with all necessary cleanup*/
+               usleep(STOP_WAIT_TIMEOUT);
            }
-
-           /*Never use SIGKILL to stop the filter*/
-           /* Filter will be stopped by below two conditions
-            - by Itself, When it realizes there are no CONNECTED clients
-            - Or through STOP_WCNSS_FILTER byte on Control socket
-            both of these ensure clean shutdown of chip
-           */
-           //property_set(BT_VND_FILTER_START, "false");
-       } else if (soc_type == BT_SOC_ROME) {
-           property_set(BT_VND_FILTER_START, "false");
-       } else {
-           ALOGI("%s: Unknown soc type %d, Unexpected!", __func__, soc_type);
        }
 
        ALOGV("%s: Exit ", __func__);
@@ -353,8 +347,8 @@
            //Filter should have been started OR in the process of initializing
            //Make sure of hci_filter_status and return the state based on it
        } else {
-           property_set("vendor.wc_transport.clean_up","0");
-           property_set("vendor.wc_transport.hci_filter_status", "0");
+           property_set(PREFIX "wc_transport.clean_up","0");
+           property_set(PREFIX "wc_transport.hci_filter_status", "0");
            property_set(BT_VND_FILTER_START, "true");
            ALOGV("%s: %s set to true ", __func__, BT_VND_FILTER_START );
        }
@@ -364,7 +358,7 @@
          comesup and ready to accept the connections */
        //sched_yield();
        for(i=0; i<45; i++) {
-          property_get("vendor.wc_transport.hci_filter_status", value, "0");
+          property_get(PREFIX "wc_transport.hci_filter_status", value, "0");
           if (strcmp(value, "1") == 0) {
                init_success = 1;
                break;
@@ -488,7 +482,7 @@
     }
     if (!memcmp(enable_ldo, "true", 4)) {
         ALOGI("External LDO has been configured");
-        ret = property_set("vendor.wc_transport.extldo", "enabled");
+        ret = property_set(PREFIX "wc_transport.extldo", "enabled");
         if (ret < 0) {
             ALOGI("%s: Not able to set property vendor.wc_transport.extldo\n", __func__);
         }
@@ -498,7 +492,7 @@
     if(on == '0'){
         ALOGE("Stopping HCI filter as part of CTRL:OFF");
         stop_hci_filter();
-        property_set("vendor.wc_transport.soc_initialized", "0");
+        property_set(PREFIX "wc_transport.soc_initialized", "0");
     }
 
     if (q->soc_type >= BT_SOC_CHEROKEE && q->soc_type < BT_SOC_RESERVED) {
@@ -638,7 +632,7 @@
 
     temp->rfkill_id = -1;
     temp->enable_extldo = FALSE;
-    temp->cb = cb;
+    temp->cb = (bt_vendor_callbacks_t*)cb;
     temp->ant_fd = -1;
     temp->soc_type = get_bt_soc_type();
     soc_init(temp->soc_type);
@@ -648,7 +642,7 @@
     snprintf(prop, sizeof(prop), "%02x:%02x:%02x:%02x:%02x:%02x",
              temp->bdaddr[0], temp->bdaddr[1], temp->bdaddr[2],
              temp->bdaddr[3], temp->bdaddr[4], temp->bdaddr[5]);
-    ret = property_set("vendor.wc_transport.stack_bdaddr", prop);
+    ret = property_set(PREFIX "wc_transport.stack_bdaddr", prop);
     if (ret < 0) {
         ALOGE("Failed to set vendor.wc_transport.stack_bdaddr prop, ret = %d", ret);
         ret = -BT_STATUS_PROP_FAILURE;
@@ -915,7 +909,7 @@
                             property_get("ro.vendor.bluetooth.emb_wp_mode", emb_wp_mode, false);
                             if (!is_soc_initialized()) {
                                 char* dlnd_inprog = is_ant_req ? "ant" : "bt";
-                                if (property_set("vendor.wc_transport.patch_dnld_inprog", dlnd_inprog) < 0) {
+                                if (property_set(PREFIX "wc_transport.patch_dnld_inprog", dlnd_inprog) < 0) {
                                     ALOGE("%s: Failed to set dnld_inprog %s", __FUNCTION__, dlnd_inprog);
                                 }
 
@@ -938,7 +932,7 @@
                                     }
                                 }
                                 ALOGV("rome_soc_init is started");
-                                property_set("vendor.wc_transport.soc_initialized", "0");
+                                property_set(PREFIX "wc_transport.soc_initialized", "0");
 #ifdef READ_BT_ADDR_FROM_PROP
                                 /*Give priority to read BD address from boot property*/
                                 ignore_boot_prop = FALSE;
@@ -946,18 +940,14 @@
                                     ALOGV("BD address read from Boot property: %s\n", bd_addr);
                                     tok =  strtok(bd_addr, ":");
                                     while (tok != NULL) {
-                                        ALOGV("bd add [%d]: %d ", i, strtol(tok, NULL, 16));
+                                        ALOGV("bd add [%d]: %ld ", i, strtol(tok, NULL, 16));
                                         if (i>=6) {
                                             ALOGE("bd property of invalid length");
                                             ignore_boot_prop = TRUE;
                                             break;
                                         }
-                                        if (i == 6 && !ignore_boot_prop) {
-                                            ALOGV("Valid BD address read from prop");
-                                            memcpy(q->bdaddr, local_bd_addr_from_prop, sizeof(vnd_local_bd_addr));
-                                            ignore_boot_prop = FALSE;
-                                        } else {
-                                            ALOGE("There are not enough tokens in BD addr");
+                                        if (!validate_tok(tok)) {
+                                            ALOGE("Invalid token in BD address");
                                             ignore_boot_prop = TRUE;
                                             break;
                                         }
@@ -967,7 +957,7 @@
                                     }
                                     if (i == 6 && !ignore_boot_prop) {
                                         ALOGV("Valid BD address read from prop");
-                                        memcpy(vnd_local_bd_addr, local_bd_addr_from_prop, sizeof(vnd_local_bd_addr));
+                                        memcpy(q->bdaddr, local_bd_addr_from_prop, sizeof(q->bdaddr));
                                         ignore_boot_prop = FALSE;
                                     } else {
                                         ALOGE("There are not enough tokens in BD addr");
@@ -979,31 +969,33 @@
                                      ignore_boot_prop = TRUE;
                                 }
 #endif //READ_BT_ADDR_FROM_PROP
+#ifdef BT_NV_SUPPORT
                                     /* Always read BD address from NV file */
                                 if(ignore_boot_prop && !bt_vendor_nv_read(1, q->bdaddr))
                                 {
                                    /* Since the BD address is configured in boot time We should not be here */
                                    ALOGI("Failed to read BD address. Use the one from bluedroid stack/ftm");
                                 }
+#endif
                                 if(rome_soc_init(fd, (char*)q->bdaddr)<0) {
                                     retval = -1;
                                 } else {
                                     ALOGV("rome_soc_init is completed");
-                                    property_set("vendor.wc_transport.soc_initialized", "1");
+                                    property_set(PREFIX "wc_transport.soc_initialized", "1");
                                     skip_init = false;
                                 }
                             }
-                            if (property_set("vendor.wc_transport.patch_dnld_inprog", "null") < 0) {
+                            if (property_set(PREFIX "wc_transport.patch_dnld_inprog", "null") < 0) {
                                 ALOGE("%s: Failed to set property", __FUNCTION__);
                             }
 
-                            property_set("vendor.wc_transport.clean_up","0");
+                            property_set(PREFIX "wc_transport.clean_up","0");
                             if (retval != -1) {
                                 retval = start_hci_filter();
                                 if (retval < 0) {
                                     ALOGE("%s: WCNSS_FILTER wouldn't have started in time\n", __func__);
-                                    property_set("vendor.wc_transport.hci_filter_status", "-1");
-                                    property_set("vendor.wc_transport.start_hci", "false");
+                                    property_set(PREFIX "wc_transport.hci_filter_status", "-1");
+                                    property_set(PREFIX "wc_transport.start_hci", "false");
                                     bt_powerup(0);
                                 } else {
 #ifdef ENABLE_ANT
@@ -1068,8 +1060,8 @@
                                  Set the following property to -1 so that the SSR cleanup routine
                                  can reset SOC.
                                  */
-                                property_set("vendor.wc_transport.hci_filter_status", "-1");
-                                property_set("vendor.wc_transport.start_hci", "false");
+                                property_set(PREFIX "wc_transport.hci_filter_status", "-1");
+                                property_set(PREFIX "wc_transport.start_hci", "false");
                                 bt_powerup(0);
                             } else {
 #ifdef ENABLE_ANT
@@ -1126,7 +1118,7 @@
         case BT_VND_OP_ANT_USERIAL_CLOSE:
             {
                 ALOGI("bt-vendor : BT_VND_OP_ANT_USERIAL_CLOSE");
-                property_set("vendor.wc_transport.clean_up","1");
+                property_set(PREFIX "wc_transport.clean_up","1");
                 if (q->ant_fd != -1) {
                     ALOGE("closing ant_fd");
                     close(q->ant_fd);
@@ -1139,7 +1131,7 @@
         case BT_VND_OP_FM_USERIAL_CLOSE:
             {
                 ALOGI("bt-vendor : BT_VND_OP_FM_USERIAL_CLOSE");
-                property_set("vendor.wc_transport.clean_up","1");
+                property_set(PREFIX "wc_transport.clean_up","1");
                 if (q->fm_fd != -1) {
                     ALOGE("closing fm_fd");
                     close(q->fm_fd);
@@ -1160,7 +1152,7 @@
                     case BT_SOC_AR3K:
                     case BT_SOC_CHEROKEE:
                     {
-                        property_set("vendor.wc_transport.clean_up","1");
+                        property_set(PREFIX "wc_transport.clean_up","1");
                         userial_vendor_close();
                         break;
                     }
@@ -1268,7 +1260,7 @@
                   case BT_SOC_ROME:
                        {
                            char value[PROPERTY_VALUE_MAX] = {'\0'};
-                           property_get("vendor.wc_transport.hci_filter_status", value, "0");
+                           property_get(PREFIX "wc_transport.hci_filter_status", value, "0");
                            if(is_soc_initialized()&& (strcmp(value,"1") == 0))
                            {
                               __hw_epilog_process();
@@ -1350,7 +1342,7 @@
         ALOGE("ssr_cleanup called with NULL context");
         goto out;
     }
-    if (property_set("vendor.wc_transport.patch_dnld_inprog", "null") < 0) {
+    if (property_set(PREFIX "wc_transport.patch_dnld_inprog", "null") < 0) {
         ALOGE("Failed to set property");
     }
 
@@ -1418,7 +1410,7 @@
     ALOGV("%s:", __FUNCTION__);
     char inProgress[PROPERTY_VALUE_MAX] = {'\0'};
     while (1) {
-        property_get("vendor.wc_transport.patch_dnld_inprog", inProgress, "null");
+        property_get(PREFIX "wc_transport.patch_dnld_inprog", inProgress, "null");
 
         if(is_ant_req && !(strcmp(inProgress,"bt"))) {
            //ANT request, wait for BT to finish
@@ -1450,7 +1442,7 @@
     {
         case BT_SOC_ROME:
             ALOGI("%s: ROME case", __func__);
-            property_get("vendor.wc_transport.patch_dnld_inprog", inProgress, "null");
+            property_get(PREFIX "wc_transport.patch_dnld_inprog", inProgress, "null");
             if(strcmp(inProgress,"null") == 0) {
                 retval = false;
             } else {
@@ -1477,7 +1469,7 @@
     enabled = true;
 #endif
 
-    ret = property_get("vendor.wc_transport.force_special_byte", value, NULL);
+    ret = property_get(PREFIX "wc_transport.force_special_byte", value, NULL);
 
     if (ret) {
         enabled = (strcmp(value, "false") ==0) ? false : true;
diff --git a/libbt-vendor/src/hardware.c b/libbt-vendor/src/hardware.c
index e37e7dd..50c260b 100644
--- a/libbt-vendor/src/hardware.c
+++ b/libbt-vendor/src/hardware.c
@@ -26,21 +26,22 @@
 
 #define LOG_TAG "bt_vendor"
 
-#include <utils/Log.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <cutils/properties.h>
-#include <stdlib.h>
 #include "bt_hci_bdroid.h"
 #include "bt_vendor_qcom.h"
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <time.h>
 #include <unistd.h>
+
+#include <cutils/properties.h>
+#include <utils/Log.h>
 #define MAX_CNT_RETRY 100
 
 int hw_config(int nState)
@@ -82,7 +83,7 @@
 int readTrpState()
 {
     char szBtStatus[PROPERTY_VALUE_MAX] = {0, };
-    if(property_get("bluetooth.status", szBtStatus, "") < 0){
+    if(property_get("vendor.bluetooth.status", szBtStatus, "") < 0){
         ALOGE("Fail to get bluetooth status");
         return FALSE;
     }
diff --git a/libbt-vendor/src/hci_smd.c b/libbt-vendor/src/hci_smd.c
index ba575b7..63b2a98 100644
--- a/libbt-vendor/src/hci_smd.c
+++ b/libbt-vendor/src/hci_smd.c
@@ -24,17 +24,19 @@
 
 #define LOG_TAG "bt_vendor"
 
-#include <utils/Log.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
 #include "bt_vendor_qcom.h"
 #include "hci_smd.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
 #include <string.h>
-#include <cutils/properties.h>
+#include <termios.h>
 #include <unistd.h>
 
+#include <cutils/properties.h>
+#include <utils/Log.h>
+
 /*****************************************************************************
 **   Macros & Constants
 *****************************************************************************/
diff --git a/libbt-vendor/src/hci_uart.c b/libbt-vendor/src/hci_uart.c
index 9e96a13..fa0fc0f 100644
--- a/libbt-vendor/src/hci_uart.c
+++ b/libbt-vendor/src/hci_uart.c
@@ -26,16 +26,19 @@
 
 #define LOG_TAG "bt_vendor"
 
-#include <utils/Log.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
 #include "bt_vendor_qcom.h"
 #include "hci_uart.h"
+
+#include <asm-generic/ioctls.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
 #include <string.h>
+#include <termios.h>
 #include <unistd.h>
 
+#include <utils/Log.h>
+
 /******************************************************************************
 **  Constants & Macros
 ******************************************************************************/
diff --git a/libbt-vendor/src/hw_ar3k.c b/libbt-vendor/src/hw_ar3k.c
index 79a385c..edb2118 100644
--- a/libbt-vendor/src/hw_ar3k.c
+++ b/libbt-vendor/src/hw_ar3k.c
@@ -34,29 +34,28 @@
 
 #define LOG_TAG "bt_vendor"
 
-#include <sys/socket.h>
-#include <utils/Log.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <cutils/properties.h>
-#include <stdlib.h>
-#include <termios.h>
-#include <string.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/uio.h>
-
 #include "bt_hci_bdroid.h"
 #include "bt_vendor_qcom.h"
 #include "hci_uart.h"
 #include "hw_ar3k.h"
 
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <termios.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <cutils/properties.h>
+#include <utils/Log.h>
 /******************************************************************************
 **  Variables
 ******************************************************************************/
diff --git a/libbt-vendor/src/hw_rome.c b/libbt-vendor/src/hw_rome.c
index 199ab71..74b554a 100644
--- a/libbt-vendor/src/hw_rome.c
+++ b/libbt-vendor/src/hw_rome.c
@@ -34,27 +34,29 @@
 
 #define LOG_TAG "bt_vendor"
 
-#include <sys/socket.h>
-#include <utils/Log.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <cutils/properties.h>
-#include <stdlib.h>
-#include <termios.h>
-#include <string.h>
-#include <stdbool.h>
-#include <unistd.h>
 #include "bt_hci_bdroid.h"
 #include "bt_vendor_qcom.h"
 #include "hci_uart.h"
 #include "hw_rome.h"
 
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <termios.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <cutils/properties.h>
+#include <utils/Log.h>
+
 #define BT_VERSION_FILEPATH "/data/misc/bluedroid/bt_fw_version.txt"
 
 #ifdef __cplusplus
@@ -156,30 +158,30 @@
         {
             case EDL_PATCH_VER_RES_EVT:
             case EDL_APP_VER_RES_EVT:
-                ALOGI("\t Current Product ID\t\t: 0x%08x",
-                    productid = (unsigned int)(rsp[PATCH_PROD_ID_OFFSET +3] << 24 |
-                                        rsp[PATCH_PROD_ID_OFFSET+2] << 16 |
-                                        rsp[PATCH_PROD_ID_OFFSET+1] << 8 |
-                                        rsp[PATCH_PROD_ID_OFFSET]  ));
+                productid = (unsigned int)(rsp[PATCH_PROD_ID_OFFSET +3] << 24 |
+                                    rsp[PATCH_PROD_ID_OFFSET+2] << 16 |
+                                    rsp[PATCH_PROD_ID_OFFSET+1] << 8 |
+                                    rsp[PATCH_PROD_ID_OFFSET]  );
+                ALOGI("\t Current Product ID\t\t: 0x%08x", productid);
 
                 /* Patch Version indicates FW patch version */
-                ALOGI("\t Current Patch Version\t\t: 0x%04x",
-                    (patchversion = (unsigned short)(rsp[PATCH_PATCH_VER_OFFSET + 1] << 8 |
-                                            rsp[PATCH_PATCH_VER_OFFSET] )));
+                patchversion = (unsigned short)(rsp[PATCH_PATCH_VER_OFFSET + 1] << 8 |
+                                       rsp[PATCH_PATCH_VER_OFFSET] );
+                ALOGI("\t Current Patch Version\t\t: 0x%04x", patchversion);
 
                 /* ROM Build Version indicates ROM build version like 1.0/1.1/2.0 */
-                ALOGI("\t Current ROM Build Version\t: 0x%04x", buildversion =
-                    (int)(rsp[PATCH_ROM_BUILD_VER_OFFSET + 1] << 8 |
-                                            rsp[PATCH_ROM_BUILD_VER_OFFSET] ));
+                buildversion = (int)(rsp[PATCH_ROM_BUILD_VER_OFFSET + 1] << 8 |
+                                       rsp[PATCH_ROM_BUILD_VER_OFFSET] );
+                ALOGI("\t Current ROM Build Version\t: 0x%04x", buildversion);
 
                 /* In case rome 1.0/1.1, there is no SOC ID version available */
                 if (paramlen - 10)
                 {
-                    ALOGI("\t Current SOC Version\t\t: 0x%08x", soc_id =
-                        (unsigned int)(rsp[PATCH_SOC_VER_OFFSET +3] << 24 |
-                                                rsp[PATCH_SOC_VER_OFFSET+2] << 16 |
-                                                rsp[PATCH_SOC_VER_OFFSET+1] << 8 |
-                                                rsp[PATCH_SOC_VER_OFFSET]  ));
+                    soc_id = (unsigned int)(rsp[PATCH_SOC_VER_OFFSET +3] << 24 |
+                                     rsp[PATCH_SOC_VER_OFFSET+2] << 16 |
+                                     rsp[PATCH_SOC_VER_OFFSET+1] << 8 |
+                                     rsp[PATCH_SOC_VER_OFFSET]  );
+                    ALOGI("\t Current SOC Version\t\t: 0x%08x", soc_id);
                 }
 
                 if (NULL != (btversionfile = fopen(BT_VERSION_FILEPATH, "wb"))) {
diff --git a/tools/hidl_client/Android.mk b/tools/hidl_client/Android.mk
index 8dab06a..4bf7bbe 100644
--- a/tools/hidl_client/Android.mk
+++ b/tools/hidl_client/Android.mk
@@ -1,7 +1,6 @@
 LOCAL_PATH:= $(call my-dir)
 
-
-
+ifneq ($(QCPATH),)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=     \
@@ -29,3 +28,4 @@
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
+endif