#include <string.h>
#include <vconf.h>
#include <syspopup_caller.h>
-#include <aul.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
#include <bundle.h>
#include <eventsystem.h>
#include <bundle_internal.h>
#include "bt-service-network.h"
#include "bt-service-obex-server.h"
#include "bt-service-opp-client.h"
+#include "bt-service-map-client.h"
#include "bt-service-agent.h"
#include "bt-service-main.h"
#include "bt-service-avrcp.h"
#include "bt-service-device.h"
-#ifdef TIZEN_DPM_ENABLE
+#ifdef TIZEN_FEATURE_BT_DPM
#include "bt-service-dpm.h"
#endif
static bt_service_alarm_mgr_t alarm_mgr = {0, };
static gboolean is_discovering;
+static gboolean discovery_req;
static gboolean cancel_by_user;
static bt_status_t adapter_status = BT_DEACTIVATED;
static bt_le_status_t adapter_le_status = BT_LE_DEACTIVATED;
visible_timer.event_id = 0;
visible_timer.timeout = 0;
-#ifndef TIZEN_PROFILE_WEARABLE
- if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
- BT_ERR("Set vconf failed\n");
-#endif
+ if (!TIZEN_PROFILE_WEARABLE) {
+ if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+ BT_ERR("Set vconf failed\n");
+ }
return FALSE;
}
visible_timer.event_id = 0;
visible_timer.timeout = 0;
-#ifndef TIZEN_PROFILE_WEARABLE
- if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
- BT_ERR("Set vconf failed\n");
-#endif
+ if (!TIZEN_PROFILE_WEARABLE) {
+ if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+ BT_ERR("Set vconf failed\n");
+ }
}
/* Switch Off visibility in Bluez */
_bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0);
{
int result;
alarm_id_t alarm_id;
+#ifdef TIZEN_FEATURE_BT_DPM
+ int discoverable_state = DPM_BT_ERROR;
+#endif
__bt_visibility_alarm_remove();
visible_timer.timeout = timeout;
-#ifndef TIZEN_PROFILE_WEARABLE
-#ifdef TIZEN_DPM_ENABLE
- if (_bt_dpm_get_bluetooth_limited_discoverable_state() != DPM_RESTRICTED) {
-#endif
- if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
- BT_ERR("Set vconf failed");
-#ifdef TIZEN_DPM_ENABLE
- }
+ if (!TIZEN_PROFILE_WEARABLE) {
+#ifdef TIZEN_FEATURE_BT_DPM
+ _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
+ if (discoverable_state != DPM_RESTRICTED) {
#endif
+ if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
+ BT_ERR("Set vconf failed");
+#ifdef TIZEN_FEATURE_BT_DPM
+ }
#endif
+ }
if (timeout <= 0)
void _bt_set_discovery_status(gboolean mode)
{
is_discovering = mode;
+ discovery_req = FALSE;
}
void _bt_set_cancel_by_user(gboolean value)
return BLUETOOTH_ERROR_INTERNAL;
}
-#ifdef TIZEN_PROFILE_MOBILE || defined(TIZEN_PROFILE_IVI)
- /* BT setting UI will control Mobile's visible mode. So in the FRWK...set the visible mode as off: */
- if (_bt_set_discoverable_mode(
- BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0) != BLUETOOTH_ERROR_NONE)
- BT_ERR("Set connectable mode failed");
-#else
-#ifdef TIZEN_TV
- if (_bt_set_discoverable_mode(
- BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0) != BLUETOOTH_ERROR_NONE)
- BT_ERR("Fail to set discoverable mode");
-#endif
-#endif
+ if (TIZEN_PROFILE_MOBILE || TIZEN_PROFILE_IVI) {
+ /* BT setting UI will control Mobile's visible mode. So in the FRWK...set the visible mode as off: */
+ if (_bt_set_discoverable_mode(
+ BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0) != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Set connectable mode failed");
+ } else if (TIZEN_PROFILE_TV) {
+ if (_bt_set_discoverable_mode(
+ BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0) != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Fail to set discoverable mode");
+ }
/* Update Bluetooth Status to notify other modules */
if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON) != 0)
_bt_adapter_set_status(BT_DEACTIVATED);
_bt_set_discovery_status(FALSE);
-#ifndef USB_BLUETOOTH
- if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
-#endif
+ if (TIZEN_FEATURE_BT_USB_DONGLE ||
+ _bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
/* Send disabled event */
_bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
g_variant_new("(i)", result));
-#ifndef USB_BLUETOOTH
}
-#endif
BT_INFO("Adapter disabled");
}
return BLUETOOTH_ERROR_NONE;
}
-#if defined(TIZEN_FEATURE_FLIGHTMODE_ENABLED) || (!defined(TIZEN_PROFILE_WEARABLE))
static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
{
gboolean flight_mode = FALSE;
_bt_enable_core();
}
-#endif
void _bt_service_register_vconf_handler(void)
{
BT_DBG("+");
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
- if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
- BT_ERR("Unable to register key handler");
-#else
- BT_DBG("Telephony is disabled");
-#endif
+ if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+ if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
+ BT_ERR("Unable to register key handler");
+ } else {
+ BT_DBG("Telephony is disabled");
+ }
-#ifndef TIZEN_PROFILE_WEARABLE
- if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
- (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
- BT_ERR("Unable to register key handler");
-#endif
+ if (!TIZEN_PROFILE_WEARABLE) {
+ if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
+ (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
+ BT_ERR("Unable to register key handler");
+ }
}
void _bt_service_unregister_vconf_handler(void)
{
BT_DBG("+");
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
-#endif
+ if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
+ }
-#ifndef TIZEN_PROFILE_WEARABLE
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
- (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
-#endif
+ if (!TIZEN_PROFILE_WEARABLE) {
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
+ (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
+ }
}
static void __bt_state_event_handler(const char *event_name, bundle *data, void *user_data)
BT_DBG("status : %d", status);
BT_DBG("le_status : %d", le_status);
-#ifndef USB_BLUETOOTH
- adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
- if (!adapter_agent) {
- BT_ERR("Fail to register agent");
- return;
- }
-#else
- if (adapter_agent == NULL) {
+ if (!TIZEN_FEATURE_BT_USB_DONGLE) {
adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
if (!adapter_agent) {
BT_ERR("Fail to register agent");
return;
}
+ } else {
+ if (adapter_agent == NULL) {
+ adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
+ if (!adapter_agent) {
+ BT_ERR("Fail to register agent");
+ return;
+ }
+ }
}
-#endif
if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE)
BT_ERR("Fail to register media player");
_bt_adapter_set_status(BT_ACTIVATED);
}
- _bt_service_register_vconf_handler();
-
/* eventsystem */
if (eventsystem_register_event(SYS_EVENT_BT_STATE, &status_reg_id,
(eventsystem_handler)__bt_state_event_handler, NULL) != ES_R_OK) {
if (0 != ret)
ERR("vconf_ignore_key_changed failed\n");
-#ifndef USB_BLUETOOTH
- _bt_destroy_agent(adapter_agent);
- adapter_agent = NULL;
+/* unregister all the services/servers/profiles registered on bluez-adapter
+ once adapter is removed, reinitializing of the state-varaibles becomes
+ a problem */
+ if (_bt_unregister_obex_server() != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Fail to unregister obex server");
- if (is_recovery_mode == TRUE) {
- /* Send disabled event */
- _bt_set_disabled(BLUETOOTH_ERROR_NONE);
+ if (_bt_unregister_media_player() != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Fail to unregister media player");
+
+/* Other unregister APIs should be placed here */
+
+ if (!TIZEN_FEATURE_BT_USB_DONGLE) {
+ _bt_destroy_agent(adapter_agent);
+ adapter_agent = NULL;
+
+ if (is_recovery_mode == TRUE) {
+ /* Send disabled event */
+ _bt_set_disabled(BLUETOOTH_ERROR_NONE);
- /* Will recover BT by bt-core, so set the mode as activating */
- _bt_adapter_set_status(BT_ACTIVATING);
- is_recovery_mode = FALSE;
+ /* Will recover BT by bt-core, so set the mode as activating */
+ _bt_adapter_set_status(BT_ACTIVATING);
+ is_recovery_mode = FALSE;
+ } else {
+ _bt_reliable_terminate_service(NULL);
+ }
} else {
- _bt_reliable_terminate_service(NULL);
+ _bt_set_disabled(BLUETOOTH_ERROR_NONE);
}
-#else
- _bt_set_disabled(BLUETOOTH_ERROR_NONE);
-#endif
if (eventsystem_unregister_event(status_reg_id) != ES_R_OK)
BT_ERR("Fail to unregister system event");
g_variant_unref(result);
_bt_set_disabled(BLUETOOTH_ERROR_TIMEOUT);
-#ifndef USB_BLUETOOTH
- _bt_terminate_service(NULL);
-#endif
+ if (!TIZEN_FEATURE_BT_USB_DONGLE)
+ _bt_terminate_service(NULL);
return FALSE;
}
return;
}
-#ifdef TIZEN_TV
static gboolean __bt_adapter_enabled_cb(gpointer user_data)
{
BT_DBG("+");
return FALSE;
}
-#endif
int _bt_enable_adapter_check_status(void)
{
_bt_adapter_set_status(BT_ACTIVATING);
-#ifdef TIZEN_TV
-{
+if (TIZEN_PROFILE_TV) {
int adapter_status = BT_ADAPTER_DISABLED;
if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
return BLUETOOTH_ERROR_NONE;
}
}
-#endif
proxy = __bt_get_core_proxy();
if (!proxy)
g_clear_error(&error);
}
g_variant_unref(result);
-#ifndef USB_BLUETOOTH
/* Terminate myself */
- g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
-#endif
+ if (!TIZEN_FEATURE_BT_USB_DONGLE)
+ g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
return BLUETOOTH_ERROR_INTERNAL;
}
g_variant_unref(result);
g_source_remove(timer_id);
timer_id = 0;
}
+/* unregister all the services/servers/profiles registered on bluez-adapter
+ once adapter is removed, reinitializing of the state-varaibles becomes
+ a problem */
+ if (_bt_unregister_obex_server() != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Fail to unregister obex server");
+
+ if (_bt_unregister_media_player() != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Fail to unregister media player");
+/* Other unregister APIs should be placed here */
__bt_disconnect_all();
ret = _bt_disable_cb();
return BLUETOOTH_ERROR_NONE;
}
-#ifndef TIZEN_TV
int _bt_check_adapter(int *status)
{
-
+if (!TIZEN_PROFILE_TV) {
char *adapter_path = NULL;
BT_CHECK_PARAMETER(status, return);
g_free(adapter_path);
return BLUETOOTH_ERROR_NONE;
-}
-#else
-int _bt_check_adapter(int *status)
-{
+} else {
GDBusProxy *proxy;
GError *error = NULL;
GVariant *result;
g_variant_unref(temp);
return BLUETOOTH_ERROR_NONE;
}
-#endif
+}
int _bt_enable_adapter_le(void)
{
GError *error = NULL;
GDBusProxy *proxy;
GVariant *result;
+#ifdef TIZEN_FEATURE_BT_DPM
+ int discoverable_state = DPM_BT_ERROR;
+#endif
proxy = _bt_get_adapter_properties_proxy();
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-#ifdef TIZEN_DPM_ENABLE
+#ifdef TIZEN_FEATURE_BT_DPM
+ _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE &&
- _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
- _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT_HANDSFREE");
+ discoverable_state == DPM_RESTRICTED) {
+ if (headed_plugin_info->plugin_headed_enabled)
+ headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT_HANDSFREE");
+
return BLUETOOTH_ERROR_ACCESS_DENIED;
}
if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE &&
- _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
- _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT");
+ discoverable_state == DPM_RESTRICTED) {
+ if (headed_plugin_info->plugin_headed_enabled)
+ headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT");
+
return BLUETOOTH_ERROR_ACCESS_DENIED;
}
#endif
return BLUETOOTH_ERROR_INTERNAL;
}
- is_discovering = TRUE;
+ discovery_req = TRUE;
cancel_by_user = FALSE;
/* discovery status will be change in event */
g_variant_unref(result);
return BLUETOOTH_ERROR_INTERNAL;
}
- is_discovering = TRUE;
+ discovery_req = TRUE;
cancel_by_user = FALSE;
/* discovery status will be change in event */
g_variant_unref(result);
return ret;
}
+ discovery_req = FALSE;
cancel_by_user = TRUE;
/* discovery status will be change in event */
g_variant_unref(result);
gboolean _bt_is_discovering(void)
{
- return is_discovering;
+ return (is_discovering || discovery_req);
}
gboolean _bt_is_connectable(void)
return BLUETOOTH_ERROR_INTERNAL;
}
- BT_INFO("### Set connectable [%d]", is_connectable);
+ BT_INFO_C("### Set connectable [%d]", is_connectable);
g_variant_unref(result);
return BLUETOOTH_ERROR_NONE;
}
gint compare_alarm(gconstpointer list_data, gconstpointer data)
{
+#ifdef ARCH64
+ alarm_id_t alarm_id = (alarm_id_t)(uintptr_t)data;
+#else
alarm_id_t alarm_id = (alarm_id_t)data;
+#endif
bt_service_alarm_t *p_data = (bt_service_alarm_t *)list_data;
if (p_data->alarm_id == alarm_id)
static gboolean _bt_adapter_request_delayed_cb(gpointer user_data)
{
int result;
+#ifdef ARCH64
+ int function = (int)(uintptr_t)user_data;
+#else
int function = (int)user_data;
+#endif
switch (function) {
case BT_ENABLE_ADAPTER:
return BLUETOOTH_ERROR_INTERNAL;
}
- g_idle_add((GSourceFunc)_bt_adapter_request_delayed_cb, (void*)function);
+#ifdef ARCH64
+ g_idle_add((GSourceFunc)_bt_adapter_request_delayed_cb, (void *)(uintptr_t)function);
+#else
+ g_idle_add((GSourceFunc)_bt_adapter_request_delayed_cb, (void *)function);
+#endif
return BLUETOOTH_ERROR_NONE;
}
-#ifdef TIZEN_TV
int _bt_get_enable_timer_id(void)
{
return timer_id;
}
-#endif