Enable to use USB bluetooth dongle 67/40867/2
authorseungku kim <seungku.kim@samsung.com>
Wed, 10 Jun 2015 04:51:07 +0000 (13:51 +0900)
committerseungku kim <seungku.kim@samsung.com>
Wed, 10 Jun 2015 11:04:11 +0000 (20:04 +0900)
Change-Id: I914991d1bf7e289f070462de2ac67ed64c652fdc

bt-api/bt-adapter-le.c
bt-core/bt-core-adapter.c
bt-core/bt-core-main.c
bt-core/bt-core-noti-handler.c
bt-service/bt-request-handler.c
bt-service/bt-service-adapter.c
bt-service/bt-service-event-receiver.c
bt-service/bt-service-main.c
include/bt-internal-types.h

index ee15181..552a410 100644 (file)
@@ -44,7 +44,6 @@ BT_EXPORT_API int bluetooth_check_adapter_le(void)
                return BLUETOOTH_ADAPTER_LE_DISABLED;
        }
 
-#ifdef ENABLE_TIZEN_2_4
        ret = vconf_get_int(VCONFKEY_BT_LE_STATUS, &value);
        if (ret != 0) {
                BT_ERR("fail to get vconf key!");
@@ -54,9 +53,6 @@ BT_EXPORT_API int bluetooth_check_adapter_le(void)
        BT_DBG("value : %d", value);
        return value == VCONFKEY_BT_LE_STATUS_ON ? BLUETOOTH_ADAPTER_LE_ENABLED :
                                                BLUETOOTH_ADAPTER_LE_DISABLED;
-#else
-       return value = BLUETOOTH_ADAPTER_LE_DISABLED;
-#endif
 }
 
 BT_EXPORT_API int bluetooth_enable_adapter_le(void)
index a7707b0..efae116 100644 (file)
@@ -138,53 +138,6 @@ static int __execute_command(const char *cmd, char *const arg_list[])
        return 0;
 }
 
-static DBusGProxy *_bt_get_connman_proxy(void)
-{
-       DBusGProxy *proxy;
-
-       if (conn == NULL) {
-               conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
-               retv_if(conn == NULL, NULL);
-       }
-
-       proxy = dbus_g_proxy_new_for_name(conn,
-                       CONNMAN_DBUS_NAME,
-                       CONNMAN_BLUETOOTH_TECHNOLOGY_PATH,
-                       CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE);
-       retv_if(proxy == NULL, NULL);
-
-       return proxy;
-}
-
-static int _bt_power_adapter(gboolean powered)
-{
-       GValue state = { 0 };
-       GError *error = NULL;
-       DBusGProxy *proxy;
-
-       proxy = _bt_get_connman_proxy();
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       g_value_init(&state, G_TYPE_BOOLEAN);
-       g_value_set_boolean(&state, powered);
-
-       BT_DBG("set power property state: %d to connman", powered);
-
-       dbus_g_proxy_call(proxy, "SetProperty", &error,
-                               G_TYPE_STRING, "Powered",
-                               G_TYPE_VALUE, &state,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       if (error != NULL) {
-               BT_ERR("Powered set err: \n [%s]", error->message);
-               g_error_free(error);
-               g_value_unset(&state);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       return BLUETOOTH_ERROR_NONE;
-}
-
-
 int _bt_enable_adapter(void)
 {
        int ret;
@@ -193,7 +146,6 @@ int _bt_enable_adapter(void)
 
        BT_INFO("");
 
-#ifdef __TIZEN_MOBILE__
        status = _bt_core_get_status();
        if (status != BT_DEACTIVATED) {
                BT_ERR("Invalid state %d", status);
@@ -210,17 +162,18 @@ int _bt_enable_adapter(void)
        }
 
        __bt_core_set_status(BT_ACTIVATING);
-
+#ifdef USB_BLUETOOTH
+       char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", "pscan", NULL};
+       ret = __execute_command("/usr/bin/hciconfig", argv_up);
+#else
        ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
+#endif
        if (ret < 0) {
                BT_ERR("running script failed");
                ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh", NULL);
                __bt_core_set_status(BT_DEACTIVATED);
                return -1;
        }
-#else
-       _bt_power_adapter(TRUE);
-#endif
 
        return 0;
 }
@@ -232,7 +185,6 @@ int _bt_disable_adapter(void)
 
        BT_INFO_C("Disable adapter");
 
-#ifdef __TIZEN_MOBILE__
        le_status = _bt_core_get_le_status();
        BT_DBG("le_status : %d", le_status);
        if (le_status == BT_LE_ACTIVATED) {
@@ -246,7 +198,12 @@ int _bt_disable_adapter(void)
        status = _bt_core_get_status();
        if (status == BT_ACTIVATING) {
                /* Forcely terminate */
+#ifdef USB_BLUETOOTH
+               char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+               if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
+#else
                if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
+#endif
                        BT_ERR("running script failed");
                }
                _bt_core_terminate();
@@ -256,22 +213,24 @@ int _bt_disable_adapter(void)
        }
 
        __bt_core_set_status(BT_DEACTIVATING);
-
+#ifdef USB_BLUETOOTH
+       char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+       if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
+#else
        if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
+#endif
                BT_ERR("running script failed");
                __bt_core_set_status( BT_ACTIVATED);
                return -1;
        }
-#else
-       _bt_power_adapter(FALSE);
-#endif
+
        return 0;
 }
 
 int _bt_enable_adapter_le(void)
 {
        BT_DBG("");
-#ifdef __TIZEN_MOBILE__
+
        int ret;
        bt_status_t status;
        bt_le_status_t le_status;
@@ -282,7 +241,12 @@ int _bt_enable_adapter_le(void)
        if (status == BT_DEACTIVATED) {
                __bt_core_set_le_status(BT_LE_ACTIVATING);
                BT_DBG("Activate BT");
+#ifdef USB_BLUETOOTH
+               char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", "pscan", NULL};
+               ret = __execute_command("/usr/bin/hciconfig", argv_up);
+#else
                ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
+#endif
                if (ret < 0) {
                        BT_ERR("running script failed");
                        ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh &", NULL);
@@ -293,9 +257,7 @@ int _bt_enable_adapter_le(void)
        } else {
                __bt_core_set_le_status(BT_LE_ACTIVATED);
        }
-#else
-       _bt_power_adapter(TRUE);
-#endif
+
        return 0;
 }
 
@@ -303,7 +265,6 @@ int _bt_disable_adapter_le(void)
 {
        BT_DBG("+");
 
-#ifdef __TIZEN_MOBILE__
        bt_status_t status;
        bt_le_status_t le_status;
 
@@ -316,8 +277,12 @@ int _bt_disable_adapter_le(void)
 
        if (status == BT_DEACTIVATED) {
                __bt_core_set_le_status(BT_LE_DEACTIVATING);
-
+#ifdef USB_BLUETOOTH
+               char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+               if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
+#else
                if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
+#endif
                        BT_ERR("running script failed");
                        __bt_core_set_le_status(BT_LE_ACTIVATED);
                        return -1;
@@ -325,9 +290,6 @@ int _bt_disable_adapter_le(void)
        }
 
        __bt_core_set_le_status(BT_LE_DEACTIVATED);
-#else
-       _bt_power_adapter(FALSE);
-#endif
 
        BT_DBG("-");
        return 0;
@@ -362,10 +324,9 @@ static void __bt_core_update_status(void)
 
        if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
                BT_ERR("no bluetooth device info, so BT was disabled at previous session");
-#ifdef ENABLE_TIZEN_2_4
+
        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0)
                BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
-#endif
 
        BT_INFO("bt_status = %d, bt_le_status = %d", bt_status, bt_le_status);
 
@@ -651,10 +612,8 @@ static gboolean __bt_core_disable_timeout_cb(gpointer data)
        if (adapter_status_le == BT_LE_ACTIVATED) {
                int bt_le_status_before_mode = 0;
 
-#ifdef ENABLE_TIZEN_2_4
                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                        _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
-#endif
 
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
                _bt_disable_adapter_le();
@@ -723,10 +682,9 @@ void _bt_core_adapter_removed_cb(void)
        __bt_core_set_le_status(BT_LE_DEACTIVATED);
        if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
                BT_ERR("Set vconf failed");
-#ifdef ENABLE_TIZEN_2_4
+
        if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
                BT_ERR("Set vconf failed");
-#endif
 
 #if 0
        if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
index 542b8d7..d7c03f8 100644 (file)
@@ -116,7 +116,9 @@ static gboolean __bt_check_bt_core(void *data)
 
                /* Enable the BT */
                _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
+#ifndef USB_BLUETOOTH
                _bt_enable_adapter();
+#endif
        } else if (bt_status == VCONFKEY_BT_STATUS_OFF &&
                        (flight_mode_deactivation == 1 || ps_mode_deactivation > 0)) {
                _bt_core_handle_flight_mode_noti();
@@ -131,7 +133,9 @@ static gboolean __bt_check_bt_core(void *data)
 
                /* Enable the BT LE */
                _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
+#ifndef USB_BLUETOOTH
                _bt_enable_adapter_le();
+#endif
        } else {
                status = _bt_core_get_status();
                le_status = _bt_core_get_le_status();
index 1ee0c26..467bb8b 100644 (file)
@@ -91,19 +91,21 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
                                _bt_core_set_bt_status(BT_FLIGHT_MODE, bt_status_before_mode);
 
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
+#ifndef USB_BLUETOOTH
                        _bt_disable_adapter();
+#endif
                }
 
                if (adapter_status_le == BT_LE_ACTIVATED) {
                        int bt_le_status_before_mode = 0;
 
-#ifdef ENABLE_TIZEN_2_4
                        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                                _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
-#endif
 
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
+#ifndef USB_BLUETOOTH
                        _bt_disable_adapter_le();
+#endif
                }
        } else {
                int flight_mode_value = 0;
@@ -135,14 +137,18 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
                    _bt_core_get_bt_status(BT_FLIGHT_MODE) != 0) {
                        _bt_core_set_bt_status(BT_FLIGHT_MODE, 0);
                        _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
+#ifndef USB_BLUETOOTH
                        _bt_enable_adapter();
+#endif
                }
 
                if (adapter_status_le == BT_LE_DEACTIVATED &&
                    _bt_core_get_bt_le_status(BT_FLIGHT_MODE) != 0) {
                        _bt_core_set_bt_le_status(BT_FLIGHT_MODE, 0);
                        _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
+#ifndef USB_BLUETOOTH
                        _bt_enable_adapter_le();
+#endif
                }
        }
 }
@@ -166,18 +172,21 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                                _bt_core_set_bt_status(BT_POWER_SAVING_MODE, bt_status_before_mode);
 
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
+#ifndef USB_BLUETOOTH
                        _bt_disable_adapter();
+#endif
                }
                if (adapter_status_le == BT_LE_ACTIVATED) {
                        int bt_le_status_before_mode = 0;
-#ifdef ENABLE_TIZEN_2_4
+
                        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                                _bt_core_set_bt_le_status(BT_POWER_SAVING_MODE, bt_le_status_before_mode);
-#endif
 
                        /* Disable the BT LE */
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
+#ifndef USB_BLUETOOTH
                        _bt_disable_adapter_le();
+#endif
                }
        } else {
                int ps_mode_value = 0;
@@ -200,14 +209,18 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                if (adapter_status == BT_DEACTIVATED && (_bt_core_get_bt_status(BT_POWER_SAVING_MODE) != 0)) {
                        _bt_core_set_bt_status(BT_POWER_SAVING_MODE, 0);
                        _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
+#ifndef USB_BLUETOOTH
                        _bt_enable_adapter();
+#endif
                }
                BT_DBG("BT LE status before Emergency mode() :%d", _bt_core_get_bt_le_status(BT_POWER_SAVING_MODE));
                if (adapter_status_le == BT_LE_DEACTIVATED &&  _bt_core_get_bt_le_status(BT_POWER_SAVING_MODE) != 0) {
                        _bt_core_set_bt_le_status(BT_POWER_SAVING_MODE, 0);
                        /* Enable the BT LE */
                        _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
+#ifndef USB_BLUETOOTH
                        _bt_enable_adapter_le();
+#endif
                }
        }
 }
index 1484486..71e872a 100644 (file)
@@ -272,7 +272,7 @@ static void __bt_service_method(GDBusConnection *connection,
                g_variant_unref(param3);
                g_variant_unref(param4);
                g_variant_unref(param5);
-               g_free(sender);
+//             g_free(sender);
                FN_END;
                return;
 fail:
@@ -297,7 +297,7 @@ fail:
                g_variant_unref(param3);
                g_variant_unref(param4);
                g_variant_unref(param5);
-               g_free(sender);
+//             g_free(sender);
        }
 
        FN_END;
index 83714f4..b1bb8e2 100644 (file)
@@ -34,6 +34,9 @@
 #ifdef ENABLE_TIZEN_2_4
 #include <journal/device.h>
 #endif
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+
 #include <bundle.h>
 #if 0
 #include <eventsystem.h>
@@ -505,6 +508,7 @@ static void __bt_set_local_name(void)
 
 static int __bt_set_enabled(void)
 {
+       BT_DBG("+");
        int adapter_status = BT_ADAPTER_DISABLED;
        int result = BLUETOOTH_ERROR_NONE;
 
@@ -536,6 +540,7 @@ static int __bt_set_enabled(void)
        /* Send enabled event to API */
        _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
                                g_variant_new("(i)", result));
+       BT_DBG("-");
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -553,9 +558,11 @@ void _bt_set_disabled(int result)
        ret_pm_ignore = vconf_get_int(VCONFKEY_PM_KEY_IGNORE, &pm_ignore_mode);
 
        /* Update the vconf BT status in normal Deactivation case only */
+
+#if 0
        if (ret == 0 && power_off_status == VCONFKEY_SYSMAN_POWER_OFF_NONE &&
                ret_pm_ignore == 0 && pm_ignore_mode != VCONFKEY_PM_KEY_LOCK) {
-
+#endif
                BT_DBG("Update vconf for BT normal Deactivation");
 
                if (result == BLUETOOTH_ERROR_TIMEOUT)
@@ -570,7 +577,7 @@ void _bt_set_disabled(int result)
                                                        EVT_VAL_BT_OFF) != ES_R_OK)
                        BT_ERR("Fail to set value");
 #endif
-       }
+//
 
        if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
                BT_ERR("Set vconf failed\n");
@@ -594,11 +601,10 @@ static int __bt_set_le_enabled(void)
 
        __bt_set_local_name();
 
-#ifdef ENABLE_TIZEN_2_4
        /* Update Bluetooth Status to notify other modules */
        if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_ON) != 0)
                BT_ERR("Set vconf failed\n");
-#endif
+
 #if 0
        if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
                                                EVT_VAL_BT_LE_ON) != ES_R_OK)
@@ -639,11 +645,10 @@ void _bt_set_le_disabled(int result)
 
        /* Update Bluetooth Status to notify other modules */
        BT_DBG("Update vconf for BT LE normal Deactivation");
-#ifdef ENABLE_TIZEN_2_4
+
        if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
                BT_ERR("Set vconf failed\n");
        _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
-#endif
 #if 0
        if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
                                                EVT_VAL_BT_LE_OFF) != ES_R_OK)
@@ -776,6 +781,45 @@ static void __bt_state_event_handler(const char *event_name, bundle *data, void
 #endif
 }
 
+//#ifdef USB_BLUETOOTH
+#if 0
+static int _bt_set_powered(gboolean is_powered)
+{
+       DBusGProxy *proxy;
+       GValue powered = { 0 };
+       GError *error = NULL;
+
+       if (__bt_is_factory_test_mode()) {
+               BT_ERR("Unable to set power in factory binary !!");
+               return BLUETOOTH_ERROR_NOT_SUPPORT;
+       }
+
+       proxy = _bt_get_adapter_properties_proxy();
+
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       g_value_init(&powered, G_TYPE_BOOLEAN);
+       g_value_set_boolean(&powered, is_powered);
+
+       dbus_g_proxy_call(proxy, "Set", &error,
+                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
+                       G_TYPE_STRING, "Powered",
+                       G_TYPE_VALUE, &powered,
+                       G_TYPE_INVALID, G_TYPE_INVALID);
+
+       g_value_unset(&powered);
+       if (error != NULL) {
+               BT_ERR("Powered set err:[%s]", error->message);
+               g_error_free(error);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_INFO("Set powered [%d]", is_powered);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+#endif
+
 void _bt_handle_adapter_added(void)
 {
        BT_DBG("+");
@@ -889,6 +933,18 @@ static gboolean __bt_enable_timeout_cb(gpointer user_data)
        if (!proxy)
                return FALSE;
 
+//#ifdef USB_BLUETOOTH
+#if 0
+       if (_bt_set_powered(FALSE)) {
+               BT_ERR("BT adapter power down failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
+               BT_ERR("Set vconf failed");
+
+       _bt_adapter_set_status(BT_DEACTIVATED);
+#else
        /* Clean up the process */
        result = g_dbus_proxy_call_sync(proxy,
                                "DisableAdapter",
@@ -909,6 +965,8 @@ static gboolean __bt_enable_timeout_cb(gpointer user_data)
        }
 
        g_variant_unref(result);
+#endif
+
        _bt_set_disabled(BLUETOOTH_ERROR_TIMEOUT);
 
        _bt_terminate_service(NULL);
@@ -932,6 +990,19 @@ static gboolean __bt_enable_le_timeout_cb(gpointer user_data)
        if (!proxy)
                return FALSE;
 
+//#ifdef USB_BLUETOOTH
+#if 0
+       if (_bt_set_powered(FALSE)) {
+               BT_ERR("BT LE adapter power down failed");
+
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
+               BT_ERR("Set vconf failed");
+
+       _bt_adapter_set_status(BT_DEACTIVATED);
+#else
        /* Clean up the process */
        result = g_dbus_proxy_call_sync(proxy,
                                "DisableAdapterLe",
@@ -951,6 +1022,8 @@ static gboolean __bt_enable_le_timeout_cb(gpointer user_data)
        }
 
        g_variant_unref(result);
+#endif
+
        _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
 
        _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
@@ -1029,6 +1102,25 @@ int _bt_enable_adapter(void)
                }
        }
 
+//#ifdef USB_BLUETOOTH
+#if 0
+       if (_bt_set_powered(TRUE)) {
+               BT_ERR("BT adapter power up failed");
+               _bt_adapter_set_status(BT_DEACTIVATED);
+#if 0
+               /* Display notification */
+               notification_status_message_post(BT_STR_NOT_SUPPORT);
+#endif
+               /* Terminate myself */
+               g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON) != 0)
+               BT_ERR("Set vconf failed");
+
+       _bt_adapter_set_status(BT_ACTIVATED);
+#else
        result = g_dbus_proxy_call_sync(proxy, "EnableAdapter",
                                         NULL,
                                         G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
@@ -1056,6 +1148,8 @@ int _bt_enable_adapter(void)
                return BLUETOOTH_ERROR_INTERNAL;
        }
        g_variant_unref(result);
+#endif
+
        if (le_status == BT_LE_ACTIVATED) {
                __bt_set_enabled();
        } else {
@@ -1184,6 +1278,18 @@ int __bt_disable_cb(void)
                }
        }
 
+//#ifdef USB_BLUETOOTH
+#if 0
+       if (_bt_set_powered(FALSE)) {
+               BT_ERR("BT adapter power down failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
+               BT_ERR("Set vconf failed");
+
+       _bt_adapter_set_status(BT_DEACTIVATED);
+#else
        proxy = __bt_get_core_proxy();
        retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
 
@@ -1206,6 +1312,8 @@ int __bt_disable_cb(void)
        }
 
        g_variant_unref(result);
+#endif
+
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -1368,6 +1476,25 @@ int _bt_enable_adapter_le(void)
        proxy = __bt_get_core_proxy();
        retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
 
+//#ifdef USB_BLUETOOTH
+#if 0
+       if (_bt_set_powered(TRUE)) {
+               BT_ERR("BT LE adapter power up failed");
+               _bt_adapter_set_status(BT_DEACTIVATED);
+#if 0
+               /* Display notification */
+               notification_status_message_post(BT_STR_NOT_SUPPORT);
+#endif
+               /* Terminate myself */
+               g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_ON) != 0)
+               BT_ERR("Set vconf failed");
+
+       _bt_adapter_set_le_status(BT_LE_ACTIVATED);
+#else
        result = g_dbus_proxy_call_sync(proxy, "EnableAdapterLe",
                                        NULL,
                                        G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
@@ -1402,6 +1529,7 @@ int _bt_enable_adapter_le(void)
 
        if (result)
                g_variant_unref(result);
+#endif
 
        _bt_adapter_start_le_enable_timer();
 
@@ -1439,6 +1567,18 @@ int _bt_disable_adapter_le(void)
        if (!proxy)
                return BLUETOOTH_ERROR_INTERNAL;
 
+//#ifdef USB_BLUETOOTH
+#if 0
+       if (_bt_set_powered(FALSE)) {
+               BT_ERR("BT LE adapter power down failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
+               BT_ERR("Set vconf failed");
+
+       _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
+#else
        result = g_dbus_proxy_call_sync(proxy,
                                "DisableAdapterLe",
                                NULL,
@@ -1458,6 +1598,8 @@ int _bt_disable_adapter_le(void)
        }
 
        g_variant_unref(result);
+#endif
+
        _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
        BT_DBG("le status : %d", _bt_adapter_get_le_status());
        BT_DBG("-");
index d15a7f4..7b1d256 100644 (file)
@@ -720,7 +720,7 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path)
                        g_variant_get(val, "b" ,&powered);
                        BT_DBG("Powered = %d", powered);
                        if (powered == FALSE) {
-#ifdef TIZEN_TV
+#ifdef USB_BLUETOOTH
                                _bt_handle_adapter_removed();
 #else
                                if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_state) == 0 &&
@@ -729,15 +729,13 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path)
                                }
 #endif
 
-#ifdef ENABLE_TIZEN_2_4
                                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_state) == 0 &&
                                        bt_state != VCONFKEY_BT_LE_STATUS_OFF) {
                                        _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
                                }
-#endif
                        }
                        else {
-#ifdef TIZEN_TV
+#ifdef USB_BLUETOOTH
                                _bt_handle_adapter_added();
 #endif
                        }
@@ -2253,8 +2251,14 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
        if (strcasecmp(signal_name, "InterfacesAdded") == 0) {
                g_variant_get(parameters, "(&o@a{sa{sv}})", &obj_path, &value);
 
-               if (strcasecmp(obj_path, BT_BLUEZ_HCI_PATH) == 0)
+               if (strcasecmp(obj_path, BT_BLUEZ_HCI_PATH) == 0){
+#ifdef USB_BLUETOOTH
+                       BT_DBG("Enable Adapter");
+                       _bt_enable_adapter();
+#else
                        _bt_handle_adapter_added();
+#endif
+               }
                else {
                        bt_event = __bt_parse_event(value);
                        if (bt_event == BT_DEVICE_EVENT) {
@@ -2328,6 +2332,11 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
                }
                g_variant_unref(value);
        } else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
+#ifdef USB_BLUETOOTH
+               BT_DBG("InterfacesRemoved");
+               _bt_handle_adapter_removed();
+#endif
+
                if (g_strcmp0(interface_name, BT_MEDIATRANSPORT_INTERFACE) == 0) {
                        bt_event = BT_MEDIA_TRANSFER_EVENT;
                } else if (g_strcmp0(interface_name, BT_DEVICE_INTERFACE) == 0) {
index 6b2ca29..1139f72 100644 (file)
@@ -99,7 +99,6 @@ gboolean _bt_terminate_service(gpointer user_data)
                }
        }
 
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_status) < 0) {
                BT_ERR("no bluetooth device info, so BT was disabled at previous session");
        } else {
@@ -114,7 +113,6 @@ gboolean _bt_terminate_service(gpointer user_data)
 #endif
                }
        }
-#endif
 
        if (main_loop != NULL) {
                g_main_loop_quit(main_loop);
@@ -177,11 +175,9 @@ static gboolean __bt_check_bt_service(void *data)
                BT_DBG("no bluetooth device info, so BT was disabled at previous session");
        }
 
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0) {
                BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
        }
-#endif
 
        if (vconf_get_int(BT_OFF_DUE_TO_FLIGHT_MODE, &flight_mode_deactivation) != 0)
                BT_ERR("Fail to get the flight_mode_deactivation value");
@@ -216,7 +212,10 @@ static gboolean __bt_check_bt_service(void *data)
 
                if ((status != BT_ACTIVATING && status != BT_ACTIVATED) &&
                                (le_status != BT_LE_ACTIVATING && le_status != BT_LE_ACTIVATED)){
+//#ifndef USB_BLUETOOTH
+#if 0
                        _bt_terminate_service(NULL);
+#endif
                }
        }
 
index da69648..3867731 100644 (file)
@@ -415,6 +415,14 @@ typedef struct {
 #define BT_HID_DEVICE_CONNECTED "HIDConnected"
 #define BT_HID_DEVICE_DISCONNECTED "HIDDisconnected"
 
+/* These vconfkey value should be removed after vconf internal package provides them */
+#define VCONFKEY_BT_LE_STATUS  "db/bluetooth/lestatus"
+enum {
+       VCONFKEY_BT_LE_STATUS_OFF = 0x0000,
+       VCONFKEY_BT_LE_STATUS_ON = 0x0001
+};
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */