From d3c8604cc409f34338a1f244de7d9bc7a0cf524a Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Tue, 3 Dec 2019 09:10:46 +0900 Subject: [PATCH] Generate BT disable HAL event when bluez is terminated If tizen don't use BT USB type's dongle, bluez should be terminated during BT off. To reduce the timing issue, postpone BT disable HAL event. Change-Id: I330796316a4ebfcc3fb297c6eef3be0ed3c85836 Signed-off-by: DoHyun Pyun --- bt-oal/bluez_hal/src/bt-hal-event-receiver.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c index 9572875..e88edbc 100644 --- a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c +++ b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c @@ -288,6 +288,10 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg) /* TODO: Need to check this operation!! */ if (powered == FALSE) { DBG("###### Adapter Powered Down ######"); + DBG("Pending disalbed event after bluetoothd is terminated"); +#if 0 + /* We should send the disable event for USB dongle type's target in here. So remain thie code */ + struct hal_ev_adapter_state_changed ev; ev.state = HAL_POWER_OFF; event_cb(HAL_EV_ADAPTER_STATE_CHANGED, &ev, sizeof(ev)); @@ -298,6 +302,7 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg) #endif /* Destroy Agent */ _bt_hal_destroy_adapter_agent(); +#endif } else { DBG("###### Adapter Powered Up ######"); if (_bt_hal_get_adapter_request_state()) { @@ -1078,9 +1083,21 @@ static gboolean __bt_hal_event_manager(gpointer data) return FALSE; if (strcasecmp(name, BT_HAL_BLUEZ_NAME) == 0) { + struct hal_ev_adapter_state_changed ev; + struct hal_ev_le_state_changed le_ev; + DBG("Bluetoothd is terminated"); - /* TODO: Handle Bluetoothd terminating scenario */ + /* Send the disable event in here */ + + ev.state = HAL_POWER_OFF; + le_ev.state = HAL_POWER_OFF; + + event_cb(HAL_EV_ADAPTER_STATE_CHANGED, &ev, sizeof(ev)); + event_cb(HAL_EV_LE_STATE_CHANGED, &le_ev, sizeof(le_ev)); + + /* Destroy Agent */ + _bt_hal_destroy_adapter_agent(); _bt_hal_le_deinit(); } } else if (g_strcmp0(param->interface_name, BT_HAL_PROPERTIES_INTERFACE) == 0) { -- 2.7.4