From 2a304f2362a41017dfe91255d221186182436a81 Mon Sep 17 00:00:00 2001 From: Luke Zhang Date: Fri, 13 Nov 2015 11:40:28 -0800 Subject: Fixed the issue that BT cannot be turned on after overnight testing change wait_for_patch_download to wait for patch download from other modules only. Change-Id: I82bd32c4c886d77b2e1cc6b79bae222be71512f6 Crs-fixed: 934110 --- libbt-vendor/src/bt_vendor_qcom.c | 42 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/libbt-vendor/src/bt_vendor_qcom.c b/libbt-vendor/src/bt_vendor_qcom.c index 014cb50..464defd 100644 --- a/libbt-vendor/src/bt_vendor_qcom.c +++ b/libbt-vendor/src/bt_vendor_qcom.c @@ -50,7 +50,9 @@ #endif #define CMD_TIMEOUT 0x22 -void wait_for_patch_download(); + +static void wait_for_patch_download(bool is_ant_req); + /****************************************************************************** ** Externs ******************************************************************************/ @@ -238,8 +240,8 @@ bool can_perform_action(char action) { ALOGV("%s: on : value is: %d", __func__, value); if(value == 1) { - property_get("wc_transport.patch_dnld_inprog", inProgress, "0"); - if((is_soc_initialized() == true) || (strcmp(inProgress,"1") == 0)) + property_get("wc_transport.patch_dnld_inprog", inProgress, "null"); + if((is_soc_initialized() == true) || (strcmp(inProgress,"null") != 0)) { value++; ALOGV("%s: on : value is incremented to : %d", __func__, value); @@ -249,15 +251,19 @@ bool can_perform_action(char action) { { value++; } + if (value == 1) can_perform = true; - else if (value > 2) return false; - } else { + else if (value > 2) + return false; + } + else { ALOGV("%s: off : value is: %d", __func__, value); value--; if (value == 0) can_perform = true; - else if (value < 0) return false; + else if (value < 0) + return false; } snprintf(ref_count, 3, "%d", value); @@ -765,12 +771,14 @@ static int op(bt_vendor_opcode_t opcode, void *param) break; case BT_SOC_ROME: { - wait_for_patch_download(); + wait_for_patch_download(is_ant_req); property_get("ro.bluetooth.emb_wp_mode", emb_wp_mode, false); if (!is_soc_initialized()) { - if (property_set("wc_transport.patch_dnld_inprog", "1") < 0) { - ALOGE("%s: Failed to set property", __FUNCTION__); + char* dlnd_inprog = is_ant_req ? "ant" : "bt"; + if (property_set("wc_transport.patch_dnld_inprog", dlnd_inprog) < 0) { + ALOGE("%s: Failed to set dnld_inprog %s", __FUNCTION__, dlnd_inprog); } + fd = userial_vendor_open((tUSERIAL_CFG *) &userial_init_cfg); if (fd < 0) { ALOGE("userial_vendor_open returns err"); @@ -843,7 +851,7 @@ static int op(bt_vendor_opcode_t opcode, void *param) } } } - if (property_set("wc_transport.patch_dnld_inprog", "0") < 0) { + if (property_set("wc_transport.patch_dnld_inprog", "null") < 0) { ALOGE("%s: Failed to set property", __FUNCTION__); } @@ -1061,7 +1069,7 @@ static void ssr_cleanup(int reason) { int ret; unsigned char trig_ssr = 0xEE; ALOGI("ssr_cleanup"); - if (property_set("wc_transport.patch_dnld_inprog", "0") < 0) { + if (property_set("wc_transport.patch_dnld_inprog", "null") < 0) { ALOGE("%s: Failed to set property", __FUNCTION__); } @@ -1115,12 +1123,18 @@ static void cleanup( void ) /* Check for one of the cients ANT/BT patch download is already in ** progress if yes wait till complete */ -void wait_for_patch_download() { +void wait_for_patch_download(bool is_ant_req) { ALOGV("%s:", __FUNCTION__); char inProgress[PROPERTY_VALUE_MAX] = {'\0'}; while (1) { - property_get("wc_transport.patch_dnld_inprog", inProgress, "0"); - if(strcmp(inProgress,"1") == 0) { + property_get("wc_transport.patch_dnld_inprog", inProgress, "null"); + + if(is_ant_req && !strcmp(inProgress,"bt") ) { + //ANT request, wait for BT to finish + usleep(50000); + } + else if(!is_ant_req && !strcmp(inProgress,"ant") ) { + //BT request, wait for ANT to finish usleep(50000); } else { -- cgit v1.2.3