Modify the condition of checking BT enabled 58/12358/1 accepted/tizen/20131120.213454 accepted/tizen/20131204.185412 accepted/tizen/generic/20140115.081851 accepted/tizen/ivi/20140114.223037 accepted/tizen/mobile/20140116.162338 submit/tizen/20131114.044854 submit/tizen/20131118.024159 submit/tizen/20131120.024558 submit/tizen/20140114.215644
authorWu zheng <wu.zheng@intel.com>
Thu, 14 Nov 2013 03:37:00 +0000 (11:37 +0800)
committerWu zheng <wu.zheng@intel.com>
Thu, 14 Nov 2013 03:37:00 +0000 (11:37 +0800)
BT chip is enabled after IVI startup.

It is different with mobile.

It results in that the condition of checking BT enabled
need to be modified on IVI.

Change-Id: Ie4d41c763284b0faa4a063da680321ecffa790d4

bt-api/bt-adapter.c
bt-api/bt-common.c
bt-api/include/bt-common.h

index 68441c0..7522fae 100644 (file)
@@ -62,12 +62,21 @@ static int __bt_fill_device_list(GArray *out_param2, GPtrArray **dev_list)
 
 BT_EXPORT_API int bluetooth_check_adapter(void)
 {
+#ifdef __TIZEN_MOBILE__
        int ret;
 
        ret = _bt_get_adapter_path(_bt_get_system_gconn(), NULL);
 
        return ret == BLUETOOTH_ERROR_NONE ? BLUETOOTH_ADAPTER_ENABLED :
                                                BLUETOOTH_ADAPTER_DISABLED;
+#else
+       gboolean powered;
+
+       powered = _bt_get_adapter_power(_bt_get_system_gconn());
+
+       return powered == TRUE ? BLUETOOTH_ADAPTER_ENABLED :
+                                               BLUETOOTH_ADAPTER_DISABLED;
+#endif
 }
 
 BT_EXPORT_API int bluetooth_enable_adapter(void)
index c7265f0..670c0df 100644 (file)
@@ -323,11 +323,44 @@ DBusGProxy *_bt_get_adapter_proxy(DBusGConnection *conn)
        }
 
        adapter_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               adapter_path, BT_ADAPTER_INTERFACE);
+                               adapter_path, BT_PROPERTIES_INTERFACE);
 
        return adapter_proxy;
 }
 
+gboolean _bt_get_adapter_power(DBusGConnection *conn)
+{
+       DBusGProxy *proxy = NULL;
+       gboolean powered;
+       GValue powered_v = { 0 };
+       GError *err = NULL;
+
+       BT_DBG("+");
+
+       proxy = _bt_get_adapter_proxy(conn);
+       retv_if(proxy == NULL, FALSE);
+
+       if (!dbus_g_proxy_call(proxy, "Get", &err,
+                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
+                       G_TYPE_STRING, "Powered",
+                       G_TYPE_INVALID,
+                       G_TYPE_VALUE, &powered_v,
+                       G_TYPE_INVALID)) {
+               if (err != NULL) {
+                       BT_ERR("Getting property failed: [%s]\n", err->message);
+                       g_error_free(err);
+               }
+               return FALSE;
+       }
+
+       powered = (gboolean)g_value_get_boolean(&powered_v);
+
+       BT_DBG("powered = %d", powered);
+       BT_DBG("-");
+
+       return powered;
+}
+
 void _bt_device_path_to_address(const char *device_path, char *device_address)
 {
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
index e1063df..77ebe8b 100644 (file)
@@ -138,6 +138,8 @@ extern "C" {
 #define BT_ADAPTER_INTERFACE "org.bluez.Adapter1"
 #define BT_DEVICE_INTERFACE "org.bluez.Device1"
 
+#define BT_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
+
 #define BT_BLUEZ_NAME "org.bluez"
 #define BT_DBUS_NAME "org.projectx.bt"
 #define BT_SERVICE_PATH "/org/projectx/bt_service"
@@ -216,6 +218,8 @@ int _bt_copy_utf8_string(char *dest, const char *src, unsigned int length);
 
 int _bt_get_adapter_path(DBusGConnection *g_conn, char *path);
 
+gboolean _bt_get_adapter_power(DBusGConnection *conn);
+
 DBusGProxy *_bt_get_adapter_proxy(DBusGConnection *conn);
 
 void _bt_device_path_to_address(const char *device_path, char *device_address);