Generate BT disable HAL event when bluez is terminated 66/219166/4
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 3 Dec 2019 00:10:46 +0000 (09:10 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 3 Dec 2019 01:43:11 +0000 (10:43 +0900)
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 <dh79.pyun@samsung.com>
bt-oal/bluez_hal/src/bt-hal-event-receiver.c

index 9572875..e88edbc 100644 (file)
@@ -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) {