Enable BT as default mode in TV profile 96/44496/1 accepted/tizen/mobile/20150723.005337 accepted/tizen/tv/20150723.005421 accepted/tizen/wearable/20150723.005520 submit/tizen_mobile/20150722.133126 submit/tizen_tv/20150722.133122 submit/tizen_wearable/20150722.133118
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 22 Jul 2015 13:29:24 +0000 (22:29 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 22 Jul 2015 13:29:24 +0000 (22:29 +0900)
Change-Id: Ia0c3fea5149d3c9360a5dae19fc05bcfdc607bf1
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-service/bt-service-adapter.c
bt-service/bt-service-main.c
bt-service/include/bt-service-adapter.h
bt-service/include/bt-service-common.h

index 6d2676f..977b34f 100644 (file)
@@ -994,6 +994,17 @@ void _bt_adapter_start_enable_timer(void)
        return;
 }
 
+static gboolean __bt_adapter_enabled_cb(gpointer user_data)
+{
+       BT_DBG("+");
+
+       __bt_set_enabled();
+       _bt_adapter_set_status(BT_ACTIVATED);
+
+       return FALSE;
+}
+
+
 int _bt_enable_adapter(void)
 {
        GDBusProxy *proxy;
@@ -1022,6 +1033,22 @@ int _bt_enable_adapter(void)
 
        _bt_adapter_set_status(BT_ACTIVATING);
 
+#ifdef TIZEN_TV
+{
+       int adapter_status = BT_ADAPTER_DISABLED;
+
+       if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
+               BT_ERR("Set vconf failed");
+
+       _bt_check_adapter(&adapter_status);
+       if (adapter_status == BT_ADAPTER_ENABLED) {
+               g_idle_add(__bt_adapter_enabled_cb, NULL);
+               _bt_adapter_start_enable_timer();
+               return BLUETOOTH_ERROR_NONE;
+       }
+}
+#endif
+
        proxy = __bt_get_core_proxy();
        if (!proxy)
                return BLUETOOTH_ERROR_INTERNAL;
@@ -1329,6 +1356,7 @@ int _bt_reset_adapter(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
+#ifndef TIZEN_TV
 int _bt_check_adapter(int *status)
 {
 
@@ -1347,6 +1375,52 @@ int _bt_check_adapter(int *status)
        g_free(adapter_path);
        return BLUETOOTH_ERROR_NONE;
 }
+#else
+int _bt_check_adapter(int *status)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *result;
+       GVariant *temp;
+       gboolean powered = FALSE;
+
+       BT_CHECK_PARAMETER(status, return);
+
+       *status = BT_ADAPTER_DISABLED;
+
+       proxy = _bt_get_adapter_properties_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "Powered"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               BT_ERR("Failed to get local address");
+               if (error != NULL) {
+                       BT_ERR("Failed to get local address (Error: %s)", error->message);
+                       g_clear_error(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_variant_get(result, "(v)", &temp);
+       powered = g_variant_get_boolean(temp);
+       BT_DBG("powered: %d", powered);
+
+       if (powered)
+               *status = BT_ADAPTER_ENABLED;
+
+       g_variant_unref(result);
+       g_variant_unref(temp);
+       return BLUETOOTH_ERROR_NONE;
+}
+#endif
 
 int _bt_enable_adapter_le(void)
 {
@@ -2493,3 +2567,7 @@ int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data)
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_get_enable_timer_id(void)
+{
+       return timer_id;
+}
index 8f6cc8d..7a3c939 100644 (file)
@@ -166,11 +166,14 @@ static gboolean __bt_check_bt_service(void *data)
 #if 0
        int ps_mode_deactivation = 0;
 #endif
-
        status = _bt_adapter_get_status();
        le_status = _bt_adapter_get_le_status();
        BT_DBG("State: %d, LE State: %d", status, le_status);
 
+#ifdef TIZEN_TV
+       if (_bt_get_enable_timer_id() == 0)
+               _bt_enable_adapter();
+#else
        if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0) {
                BT_DBG("no bluetooth device info, so BT was disabled at previous session");
        }
@@ -214,7 +217,7 @@ static gboolean __bt_check_bt_service(void *data)
                                (le_status != BT_LE_ACTIVATING && le_status != BT_LE_ACTIVATED)){
                }
        }
-
+#endif
        return FALSE;
 }
 
index 03c0c4d..d399a28 100644 (file)
@@ -146,6 +146,8 @@ int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data);
 
 int __bt_disable_cb(void);
 
+int _bt_get_enable_timer_id(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 0073b09..a5fec2a 100644 (file)
@@ -104,7 +104,11 @@ extern "C" {
 #define BT_AGENT_NEW_LINE "\r\n"
 
 #define BT_MAX_DBUS_TIMEOUT 45000
+#ifndef TIZEN_TV
 #define BT_ENABLE_TIMEOUT 20000 /* 20 seconds */
+#else
+#define BT_ENABLE_TIMEOUT 5000 /* 5 seconds */
+#endif
 #define BT_DISCOVERY_FINISHED_DELAY 200
 
 #define MANAGER_EVENT_MATCH_RULE \