Merge "Bluetooth: Fix for BT crashes during preload timeout"
diff --git a/libbt-vendor/src/bt_vendor_qcom.c b/libbt-vendor/src/bt_vendor_qcom.c
index 77ccd55..86dd5ce 100644
--- a/libbt-vendor/src/bt_vendor_qcom.c
+++ b/libbt-vendor/src/bt_vendor_qcom.c
@@ -52,7 +52,7 @@
 extern int check_embedded_mode(int fd);
 extern int rome_get_addon_feature_list(int fd);
 extern int rome_ver;
-extern int enable_controller_log(int fd);
+extern int enable_controller_log(int fd, unsigned char req);
 /******************************************************************************
 **  Variables
 ******************************************************************************/
@@ -619,7 +619,7 @@
     uint8_t local_bd_addr_from_prop[6];
     char* tok;
 #endif
-
+    bool skip_init = true;
     ALOGV("bt-vendor : op for %d", opcode);
 
     switch(opcode)
@@ -811,6 +811,7 @@
                                         ALOGV("rome_soc_init is completed");
                                         property_set("wc_transport.soc_initialized", "1");
                                         userial_clock_operation(fd, USERIAL_OP_CLK_OFF);
+                                        skip_init = false;
                                         /*Close the UART port*/
                                         close(fd);
                                     }
@@ -842,7 +843,11 @@
                                              rome_get_addon_feature_list(fd);
                                          }
                                      }
-                                     enable_controller_log(fd);
+                                     if (!skip_init) {
+                                         /*Skip if already sent*/
+                                         enable_controller_log(fd, is_ant_req);
+                                         skip_init = true;
+                                     }
                                      for (idx=0; idx < CH_MAX; idx++)
                                           (*fd_array)[idx] = fd;
                                           retval = 1;
diff --git a/libbt-vendor/src/hw_rome.c b/libbt-vendor/src/hw_rome.c
index 06241f5..6dcb183 100644
--- a/libbt-vendor/src/hw_rome.c
+++ b/libbt-vendor/src/hw_rome.c
@@ -1700,7 +1700,7 @@
 }
 
 
-void enable_controller_log (int fd)
+void enable_controller_log (int fd, unsigned char wait_for_evt)
 {
    int ret = 0;
    /* VS command to enable controller logging to the HOST. By default it is disabled */
@@ -1713,16 +1713,22 @@
    // value at cmd[5]: 1 - to enable, 0 - to disable
    ret = (strcmp(value, "true") == 0) ? cmd[5] = 0x01: 0;
    ALOGI("%s: %d", __func__, ret);
+   /* Ignore vsc evt if wait_for_evt is true */
+   if (wait_for_evt) wait_vsc_evt = FALSE;
 
    ret = hci_send_vs_cmd(fd, (unsigned char *)cmd, rsp, 6);
    if (ret != 6) {
        ALOGE("%s: command failed", __func__);
    }
-
+   /*Ignore hci_event if wait_for_evt is true*/
+   if (wait_for_evt)
+       goto end;
    ret = read_hci_event(fd, rsp, HCI_MAX_EVENT_SIZE);
    if (ret < 0) {
        ALOGE("%s: Failed to get CC for enable SoC log", __FUNCTION__);
    }
+end:
+   wait_vsc_evt = TRUE;
    return;
 }
 
@@ -1862,14 +1868,6 @@
             }
             ALOGI("%s: Download TLV file successfully ", __FUNCTION__);
 
-            /* This function sends a vendor specific command to enable/disable
-             * controller logs on need. Once the command is received to the SOC,
-             * It would start sending cotroller's print strings and LMP RX/TX
-             * packets to the HOST (over the UART) which will be logged in QXDM.
-             * The property 'enablebtsoclog' used to send this command on BT init
-             * sequence.
-             */
-
             /* Get SU FM label information */
             if((err = rome_get_build_info_req(fd)) <0){
                 ALOGI("%s: Fail to get Rome FW SU Build info (0x%x)", __FUNCTION__, err);