From 7bc42638e68108fa84929daeff1f457136c3898b Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Wed, 21 Sep 2016 14:52:26 +0900 Subject: [PATCH] Fix BT enable / disable problem in the odroid target Change-Id: Ie8feaee46ccbfe516e3be08ec3b589278d75b1fa Signed-off-by: DoHyun Pyun --- bt-core/bt-core-adapter.c | 11 +++++++++-- bt-service/bt-service-adapter-le.c | 10 ++++++++++ bt-service/bt-service-adapter.c | 22 +++++++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/bt-core/bt-core-adapter.c b/bt-core/bt-core-adapter.c index b4aa62d..503f5dd 100644 --- a/bt-core/bt-core-adapter.c +++ b/bt-core/bt-core-adapter.c @@ -143,16 +143,19 @@ int _bt_enable_adapter(void) { int ret; bt_status_t status; +#if 0 bt_le_status_t le_status; - +#endif BT_INFO(""); status = _bt_core_get_status(); if (status != BT_DEACTIVATED) { BT_ERR("Invalid state %d", status); + g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL); return -1; } +#if 0 /* only the concept of private */ le_status = _bt_core_get_le_status(); if (le_status == BT_LE_ACTIVATED) { /* Turn on PSCAN, (ISCAN if needed) */ @@ -162,6 +165,7 @@ int _bt_enable_adapter(void) g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL); return 0; } +#endif __bt_core_set_status(BT_ACTIVATING); #ifdef USB_BLUETOOTH @@ -188,13 +192,15 @@ int _bt_enable_adapter(void) int _bt_disable_adapter(void) { bt_status_t status; +#if 0 bt_le_status_t le_status; +#endif BT_INFO_C("Disable adapter"); +#if 0 /* only the concept of private */ le_status = _bt_core_get_le_status(); BT_DBG("le_status : %d", le_status); -#if 0 /* only the concept of private */ if (le_status == BT_LE_ACTIVATED) { /* Turn off PSCAN, (ISCAN if needed) */ /* Return with 0 for the Disabled response. */ @@ -220,6 +226,7 @@ int _bt_disable_adapter(void) return 0; } else if (status != BT_ACTIVATED) { BT_ERR("Invalid state %d", status); + g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL); } __bt_core_set_status(BT_DEACTIVATING); diff --git a/bt-service/bt-service-adapter-le.c b/bt-service/bt-service-adapter-le.c index eddbd36..5a8aeb3 100644 --- a/bt-service/bt-service-adapter-le.c +++ b/bt-service/bt-service-adapter-le.c @@ -1365,6 +1365,11 @@ int _bt_start_le_scan(const char *sender) GVariant *ret; bt_adapter_le_scanner_t *scanner = __bt_find_scanner_from_list(sender); + /* Before finishing kernel merge, temperary return TRUE always for TCT issue */ +#ifdef USB_BLUETOOTH + return BLUETOOTH_ERROR_NONE; +#endif + if (scanner == NULL) { scanner = g_malloc0(sizeof(bt_adapter_le_scanner_t)); retv_if(scanner == NULL, BLUETOOTH_ERROR_INTERNAL); @@ -1460,6 +1465,11 @@ int _bt_stop_le_scan(const char *sender) gboolean next_scanning = FALSE; gboolean need_scan_filter = TRUE; +/* Before finishing kernel merge, temperary return TRUE always for TCT issue */ +#ifdef USB_BLUETOOTH + return BLUETOOTH_ERROR_NONE; +#endif + if (scanner == NULL || scanner->is_scanning == FALSE) return BLUETOOTH_ERROR_NOT_IN_OPERATION; diff --git a/bt-service/bt-service-adapter.c b/bt-service/bt-service-adapter.c index 5d075ad..5482ef4 100644 --- a/bt-service/bt-service-adapter.c +++ b/bt-service/bt-service-adapter.c @@ -545,6 +545,7 @@ static int __bt_set_enabled(void) #endif __bt_set_local_name(); + _bt_set_discovery_status(FALSE); return BLUETOOTH_ERROR_NONE; } @@ -585,12 +586,17 @@ void _bt_set_disabled(int result) _bt_cancel_queued_transfers(); _bt_adapter_set_status(BT_DEACTIVATED); + _bt_set_discovery_status(FALSE); +#ifndef USB_BLUETOOTH if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED) { +#endif /* Send disabled event */ _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED, g_variant_new("(i)", result)); +#ifndef USB_BLUETOOTH } +#endif BT_INFO("Adapter disabled"); } @@ -790,11 +796,21 @@ void _bt_handle_adapter_added(void) BT_DBG("status : %d", status); BT_DBG("le_status : %d", le_status); +#ifndef USB_BLUETOOTH adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE); if (!adapter_agent) { BT_ERR("Fail to register agent"); return; } +#else + if (adapter_agent == NULL) { + adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE); + if (!adapter_agent) { + BT_ERR("Fail to register agent"); + return; + } + } +#endif if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE) BT_ERR("Fail to register media player"); @@ -858,11 +874,13 @@ void _bt_handle_adapter_removed(void) ERR("vconf_ignore_key_changed failed\n"); } +#ifndef USB_BLUETOOTH _bt_destroy_agent(adapter_agent); adapter_agent = NULL; -#ifndef USB_BLUETOOTH _bt_reliable_terminate_service(NULL); +#else + _bt_set_disabled(BLUETOOTH_ERROR_NONE); #endif if (eventsystem_unregister_event(status_reg_id) != ES_R_OK) { @@ -1079,8 +1097,10 @@ int _bt_enable_adapter(void) g_clear_error(&error); } g_variant_unref(result); +#ifndef USB_BLUETOOTH /* Terminate myself */ g_idle_add((GSourceFunc)_bt_terminate_service, NULL); +#endif return BLUETOOTH_ERROR_INTERNAL; } g_variant_unref(result); -- 2.7.4