#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
#include <syspopup_caller.h>
#endif
+#ifdef __TIZEN_MOBILE__
#include <aul.h>
-
+#endif
#include "alarm.h"
#include "bluetooth-api.h"
}
}
+#ifdef __TIZEN_MOBILE__
static void __launch_bt_service(int status, int run_type)
{
bundle *kb;
bundle_free(kb);
}
+#endif
-static void __bt_adapter_set_status(bt_status_t status)
+void _bt_adapter_set_status(bt_status_t status)
{
adapter_status = status;
}
free(phone_name);
}
-static int __bt_set_enabled(void)
+void _bt_set_enabled(void)
{
- int enabled = FALSE;
int result = BLUETOOTH_ERROR_NONE;
- _bt_check_adapter(&enabled);
+ _bt_adapter_set_status(BT_ACTIVATED);
- if (enabled == FALSE) {
- BT_ERR("Bluetoothd is not running");
- return BLUETOOTH_ERROR_INTERNAL;
+ // register agent if it was not previously done.
+ if (!adapter_agent) {
+ BT_DBG("");
+ _bt_handle_adapter_added();
}
__bt_set_visible_mode();
/* Send enabled event to API */
_bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
- return BLUETOOTH_ERROR_NONE;
}
-static void __bt_set_disabled(int result)
+void _bt_set_disabled(void)
{
+ int result = BLUETOOTH_ERROR_NONE;
+
+ _bt_adapter_set_status(BT_DEACTIVATED);
+
/* Update Bluetooth Status to notify other modules */
if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
BT_ERR("Set vconf failed\n");
void _bt_handle_adapter_added(void)
{
- adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
- if (!adapter_agent) {
+ BT_DBG("");
+
+ adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
+ if (!adapter_agent) {
BT_ERR("Fail to register agent");
return;
- }
+ }
#ifdef __TIZEN_MOBILE__
+ if (!aul_app_is_running("com.samsung.bluetooth"))
+ __launch_bt_service(0, 0);
+
if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE)
BT_ERR("Fail to register media player");
#endif
vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
__bt_flight_mode_cb, NULL);
-
- __bt_set_enabled();
-
- __bt_adapter_set_status(BT_ACTIVATED);
}
void _bt_handle_adapter_removed(void)
{
- __bt_adapter_set_status(BT_DEACTIVATED);
+ BT_DBG("");
vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
(vconf_callback_fn)__bt_phone_name_changed_cb);
_bt_destroy_agent(adapter_agent);
adapter_agent = NULL;
- __bt_set_disabled(BLUETOOTH_ERROR_NONE);
-
_bt_terminate_service(NULL);
}
DBusGProxy *_bt_init_core_proxy(void)
{
- DBusGProxy *proxy;
+ DBusGProxy *proxy;
DBusGConnection *conn;
conn = _bt_get_system_gconn();
if (!conn)
return NULL;
- proxy = dbus_g_proxy_new_for_name(conn, BT_CORE_NAME,
+ proxy = dbus_g_proxy_new_for_name(conn, BT_CORE_NAME,
BT_CORE_PATH, BT_CORE_INTERFACE);
if (!proxy)
return NULL;
- core_proxy = proxy;
+ core_proxy = proxy;
- return proxy;
+ return proxy;
}
static DBusGProxy *__bt_get_core_proxy(void)
{
- return (core_proxy) ? core_proxy : _bt_init_core_proxy();
+ return (core_proxy) ? core_proxy : _bt_init_core_proxy();
}
int _bt_enable_adapter(void)
return BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
}
- __bt_adapter_set_status(BT_ACTIVATING);
+ _bt_adapter_set_status(BT_ACTIVATING);
proxy = __bt_get_core_proxy();
if (!proxy)
G_TYPE_INVALID,
G_TYPE_INVALID) == FALSE) {
- __bt_adapter_set_status(BT_DEACTIVATED);
+ _bt_adapter_set_status(BT_DEACTIVATED);
if (err != NULL) {
BT_ERR("Bt core call failed: [%s]", err->message);
}
/* Display notification */
- status_message_post(BT_STR_NOT_SUPPORT);
+ notification_status_message_post(BT_STR_NOT_SUPPORT);
/* Terminate myself */
g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
}
- __bt_adapter_set_status(BT_DEACTIVATING);
+ _bt_adapter_set_status(BT_DEACTIVATING);
proxy = __bt_get_core_proxy();
if (!proxy)
if (dbus_g_proxy_call(proxy, "DisableAdapter", NULL,
G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
BT_ERR("Bt core call failed");
- __bt_adapter_set_status(BT_ACTIVATED);
+ _bt_adapter_set_status(BT_ACTIVATED);
return BLUETOOTH_ERROR_INTERNAL;
- }
+ }
return BLUETOOTH_ERROR_NONE;
}
int _bt_check_adapter(int *status)
{
- char *adapter_path = NULL;
-
BT_CHECK_PARAMETER(status, return);
*status = 0; /* 0: disabled */
- adapter_path = _bt_get_adapter_path();
-
- if (adapter_path != NULL)
+ if (_bt_get_adapter_power())
*status = 1; /* 1: enabled */
- g_free(adapter_path);
return BLUETOOTH_ERROR_NONE;
}