Loading system/hci/src/bt_hci_bdroid.c +12 −2 Original line number Original line Diff line number Diff line Loading @@ -74,6 +74,8 @@ void init_vnd_if(unsigned char *local_bdaddr); bt_hc_callbacks_t *bt_hc_cbacks = NULL; bt_hc_callbacks_t *bt_hc_cbacks = NULL; tHCI_IF *p_hci_if; tHCI_IF *p_hci_if; volatile bool fwcfg_acked; volatile bool fwcfg_acked; // Cleanup state indication. volatile bool has_cleaned_up = false; /****************************************************************************** /****************************************************************************** ** Local type definitions ** Local type definitions Loading Loading @@ -325,6 +327,7 @@ static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr) hc_cb.epilog_timer_created = false; hc_cb.epilog_timer_created = false; fwcfg_acked = false; fwcfg_acked = false; has_cleaned_up = false; pthread_mutex_init(&hc_cb.worker_thread_lock, NULL); pthread_mutex_init(&hc_cb.worker_thread_lock, NULL); Loading Loading @@ -446,9 +449,15 @@ static int tx_hc_cmd(TRANSAC transac, char *p_buf, int len) { return BT_HC_STATUS_SUCCESS; return BT_HC_STATUS_SUCCESS; } } /** Closes the interface */ // Closes the interface. // This routine is not thread safe. static void cleanup(void) static void cleanup(void) { { if (has_cleaned_up) { ALOGW("%s Already cleaned up for this session\n", __func__); return; } BTHCDBG("cleanup"); BTHCDBG("cleanup"); if (hc_cb.worker_thread) if (hc_cb.worker_thread) Loading Loading @@ -484,6 +493,7 @@ static void cleanup( void ) fwcfg_acked = false; fwcfg_acked = false; bt_hc_cbacks = NULL; bt_hc_cbacks = NULL; has_cleaned_up = true; } } static const bt_hc_interface_t bluetoothHCLibInterface = { static const bt_hc_interface_t bluetoothHCLibInterface = { Loading system/main/bte_main.c +18 −7 Original line number Original line Diff line number Diff line Loading @@ -84,7 +84,6 @@ BOOLEAN hci_logging_enabled = FALSE; /* by default, turn hci log off */ BOOLEAN hci_logging_config = FALSE; /* configured from bluetooth framework */ BOOLEAN hci_logging_config = FALSE; /* configured from bluetooth framework */ char hci_logfile[256] = HCI_LOGGING_FILENAME; char hci_logfile[256] = HCI_LOGGING_FILENAME; /******************************************************************************* /******************************************************************************* ** Static variables ** Static variables *******************************************************************************/ *******************************************************************************/ Loading @@ -92,6 +91,8 @@ static bt_hc_interface_t *bt_hc_if=NULL; static const bt_hc_callbacks_t hc_callbacks; static const bt_hc_callbacks_t hc_callbacks; static BOOLEAN lpm_enabled = FALSE; static BOOLEAN lpm_enabled = FALSE; static bt_preload_retry_cb_t preload_retry_cb; static bt_preload_retry_cb_t preload_retry_cb; // Lock to serialize cleanup requests from upper layer. static pthread_mutex_t cleanup_lock; /******************************************************************************* /******************************************************************************* ** Static functions ** Static functions Loading Loading @@ -171,6 +172,9 @@ void bte_main_boot_entry(void) /* Initialize trace feature */ /* Initialize trace feature */ BTTRC_TraceInit(MAX_TRACE_RAM_SIZE, &BTE_TraceLogBuf[0], BTTRC_METHOD_RAM); BTTRC_TraceInit(MAX_TRACE_RAM_SIZE, &BTE_TraceLogBuf[0], BTTRC_METHOD_RAM); #endif #endif pthread_mutex_init(&cleanup_lock, NULL); } } /****************************************************************************** /****************************************************************************** Loading @@ -184,6 +188,8 @@ void bte_main_boot_entry(void) ******************************************************************************/ ******************************************************************************/ void bte_main_shutdown() void bte_main_shutdown() { { pthread_mutex_destroy(&cleanup_lock); GKI_shutdown(); GKI_shutdown(); } } Loading Loading @@ -325,12 +331,17 @@ static void bte_hci_disable(void) { { APPL_TRACE_DEBUG("%s", __FUNCTION__); APPL_TRACE_DEBUG("%s", __FUNCTION__); if (bt_hc_if) if (!bt_hc_if) { return; // Cleanup is not thread safe and must be protected. pthread_mutex_lock(&cleanup_lock); if (hci_logging_enabled == TRUE || hci_logging_config == TRUE) if (hci_logging_enabled == TRUE || hci_logging_config == TRUE) bt_hc_if->logging(BT_HC_LOGGING_OFF, hci_logfile); bt_hc_if->logging(BT_HC_LOGGING_OFF, hci_logfile); bt_hc_if->cleanup(); bt_hc_if->cleanup(); } pthread_mutex_unlock(&cleanup_lock); } } /******************************************************************************* /******************************************************************************* Loading Loading
system/hci/src/bt_hci_bdroid.c +12 −2 Original line number Original line Diff line number Diff line Loading @@ -74,6 +74,8 @@ void init_vnd_if(unsigned char *local_bdaddr); bt_hc_callbacks_t *bt_hc_cbacks = NULL; bt_hc_callbacks_t *bt_hc_cbacks = NULL; tHCI_IF *p_hci_if; tHCI_IF *p_hci_if; volatile bool fwcfg_acked; volatile bool fwcfg_acked; // Cleanup state indication. volatile bool has_cleaned_up = false; /****************************************************************************** /****************************************************************************** ** Local type definitions ** Local type definitions Loading Loading @@ -325,6 +327,7 @@ static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr) hc_cb.epilog_timer_created = false; hc_cb.epilog_timer_created = false; fwcfg_acked = false; fwcfg_acked = false; has_cleaned_up = false; pthread_mutex_init(&hc_cb.worker_thread_lock, NULL); pthread_mutex_init(&hc_cb.worker_thread_lock, NULL); Loading Loading @@ -446,9 +449,15 @@ static int tx_hc_cmd(TRANSAC transac, char *p_buf, int len) { return BT_HC_STATUS_SUCCESS; return BT_HC_STATUS_SUCCESS; } } /** Closes the interface */ // Closes the interface. // This routine is not thread safe. static void cleanup(void) static void cleanup(void) { { if (has_cleaned_up) { ALOGW("%s Already cleaned up for this session\n", __func__); return; } BTHCDBG("cleanup"); BTHCDBG("cleanup"); if (hc_cb.worker_thread) if (hc_cb.worker_thread) Loading Loading @@ -484,6 +493,7 @@ static void cleanup( void ) fwcfg_acked = false; fwcfg_acked = false; bt_hc_cbacks = NULL; bt_hc_cbacks = NULL; has_cleaned_up = true; } } static const bt_hc_interface_t bluetoothHCLibInterface = { static const bt_hc_interface_t bluetoothHCLibInterface = { Loading
system/main/bte_main.c +18 −7 Original line number Original line Diff line number Diff line Loading @@ -84,7 +84,6 @@ BOOLEAN hci_logging_enabled = FALSE; /* by default, turn hci log off */ BOOLEAN hci_logging_config = FALSE; /* configured from bluetooth framework */ BOOLEAN hci_logging_config = FALSE; /* configured from bluetooth framework */ char hci_logfile[256] = HCI_LOGGING_FILENAME; char hci_logfile[256] = HCI_LOGGING_FILENAME; /******************************************************************************* /******************************************************************************* ** Static variables ** Static variables *******************************************************************************/ *******************************************************************************/ Loading @@ -92,6 +91,8 @@ static bt_hc_interface_t *bt_hc_if=NULL; static const bt_hc_callbacks_t hc_callbacks; static const bt_hc_callbacks_t hc_callbacks; static BOOLEAN lpm_enabled = FALSE; static BOOLEAN lpm_enabled = FALSE; static bt_preload_retry_cb_t preload_retry_cb; static bt_preload_retry_cb_t preload_retry_cb; // Lock to serialize cleanup requests from upper layer. static pthread_mutex_t cleanup_lock; /******************************************************************************* /******************************************************************************* ** Static functions ** Static functions Loading Loading @@ -171,6 +172,9 @@ void bte_main_boot_entry(void) /* Initialize trace feature */ /* Initialize trace feature */ BTTRC_TraceInit(MAX_TRACE_RAM_SIZE, &BTE_TraceLogBuf[0], BTTRC_METHOD_RAM); BTTRC_TraceInit(MAX_TRACE_RAM_SIZE, &BTE_TraceLogBuf[0], BTTRC_METHOD_RAM); #endif #endif pthread_mutex_init(&cleanup_lock, NULL); } } /****************************************************************************** /****************************************************************************** Loading @@ -184,6 +188,8 @@ void bte_main_boot_entry(void) ******************************************************************************/ ******************************************************************************/ void bte_main_shutdown() void bte_main_shutdown() { { pthread_mutex_destroy(&cleanup_lock); GKI_shutdown(); GKI_shutdown(); } } Loading Loading @@ -325,12 +331,17 @@ static void bte_hci_disable(void) { { APPL_TRACE_DEBUG("%s", __FUNCTION__); APPL_TRACE_DEBUG("%s", __FUNCTION__); if (bt_hc_if) if (!bt_hc_if) { return; // Cleanup is not thread safe and must be protected. pthread_mutex_lock(&cleanup_lock); if (hci_logging_enabled == TRUE || hci_logging_config == TRUE) if (hci_logging_enabled == TRUE || hci_logging_config == TRUE) bt_hc_if->logging(BT_HC_LOGGING_OFF, hci_logfile); bt_hc_if->logging(BT_HC_LOGGING_OFF, hci_logfile); bt_hc_if->cleanup(); bt_hc_if->cleanup(); } pthread_mutex_unlock(&cleanup_lock); } } /******************************************************************************* /******************************************************************************* Loading