#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_FEATURE_BT_DPM
+#include "bt-service-adapter-le.h"
+
+#ifdef TIZEN_DPM_ENABLE
#include "bt-service-dpm.h"
#endif
GList *g_alarm_list;
} bt_service_alarm_mgr_t;
-#define BT_RECOVERY_MAX_COUNT 3
-
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;
static GDBusProxy *core_proxy = NULL;
static guint timer_id = 0;
static guint le_timer_id = 0;
-static int recovery_cnt = BT_RECOVERY_MAX_COUNT;
-static guint recovery_timer = 0;
+static gboolean is_recovery_mode;
+static gboolean in_power_off;
+static guint poweroff_subscribe_id;
static uint status_reg_id;
#define BT_CORE_NAME "org.projectx.bt_core"
#define BT_DISABLE_TIME 500 /* 500 ms */
-#define BT_RECOVERY_TIME_W 2000 /*2 sec*/
-#define BT_RECOVERY_TIME 5000 /*5 sec*/
-
static int alarm_cb(alarm_id_t alarm_id, void* user_param);
static void alarm_data_free(void *data);
visible_timer.event_id = 0;
visible_timer.timeout = 0;
- if (!TIZEN_PROFILE_WEARABLE) {
- if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
- BT_ERR("Set vconf failed\n");
- }
+#ifndef TIZEN_PROFILE_WEARABLE
+ if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+ BT_ERR("Set vconf failed\n");
+#endif
return FALSE;
}
visible_timer.event_id = 0;
visible_timer.timeout = 0;
- if (!TIZEN_PROFILE_WEARABLE) {
- if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
- BT_ERR("Set vconf failed\n");
- }
+#ifndef TIZEN_PROFILE_WEARABLE
+ if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+ BT_ERR("Set vconf failed\n");
+#endif
}
/* 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;
- 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
- }
+#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
}
+#endif
+#endif
if (timeout <= 0)
rssi = g_variant_get_int16(value);
} else if (!g_strcmp0(key, "UUIDs")) {
__bt_get_service_list(value, dev_info);
- } else if (!g_strcmp0(key, "ManufacturerDataLen")) {
+ } else if (!g_strcmp0(key, "LegacyManufacturerDataLen")) {
dev_info->manufacturer_data.data_len = g_variant_get_uint16(value);
- } else if (!g_strcmp0(key, "ManufacturerData")) {
+ } else if (!g_strcmp0(key, "LegacyManufacturerData")) {
manufacturer_data = g_byte_array_new();
g_variant_get(value, "ay", &char_value_iter);
while (g_variant_iter_loop(char_value_iter, "y", &char_value))
void _bt_set_discovery_status(gboolean mode)
{
is_discovering = mode;
- discovery_req = FALSE;
}
void _bt_set_cancel_by_user(gboolean value)
is_le_intended = value;
}
+static void __bt_set_in_poweroff(void)
+{
+ BT_INFO("Set in_power_off to TRUE");
+ in_power_off = TRUE;
+}
+
+static gboolean __bt_is_in_poweroff(void)
+{
+ return in_power_off;
+}
+
static void __bt_phone_name_changed_cb(keynode_t *node, void *data)
{
char *phone_name = NULL;
char *ptr = NULL;
- ret_if(node == NULL);
+ if (node == NULL)
+ return;
if (vconf_keynode_get_type(node) == VCONF_TYPE_STRING) {
phone_name = vconf_keynode_get_str(node);
return BLUETOOTH_ERROR_INTERNAL;
}
- 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");
- }
+#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
/* 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
+ /* 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");
}
/* 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");
+ BT_ERR("Set vconf failed");
+
+ /* set packet length to max size to enable packet length extension */
+ if (BLUETOOTH_ERROR_NONE != _bt_le_set_max_packet_len())
+ BT_ERR("Fail to set max packet length");
if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
EVT_VAL_BT_LE_ON) != ES_R_OK)
/* Send disabled event */
_bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_DISABLED,
- g_variant_new("(i)", result));
+ g_variant_new("(i)", result));
}
void *_bt_get_adapter_agent(void)
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)
+static void __bt_poweroff_event_filter(GDBusConnection *connection,
+ const gchar *sender_name, const gchar *object_path,
+ const gchar *interface_name, const gchar *signal_name,
+ GVariant *parameters, gpointer user_data)
{
- BT_DBG("+");
+ int state = 0;
- 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");
+ g_variant_get(parameters, "(i)", &state);
+
+ if (state != BT_DEVICED_POWEROFF_SIGNAL_POWEROFF &&
+ state != BT_DEVICED_POWEROFF_SIGNAL_REBOOT) {
+ BT_DBG("Not interested event : %d", state);
+ return;
}
- 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");
+ if (_bt_adapter_get_status() == BT_ACTIVATING) {
+ BT_INFO("Just update VCONFKEY_BT_STATUS in Power off");
+ if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON))
+ BT_ERR("Set VCONFKEY_BT_STATUS failed");
+ } else {
+ __bt_set_in_poweroff();
}
}
+void _bt_service_register_poweroff_event(void)
+{
+ if (poweroff_subscribe_id)
+ return;
+
+ poweroff_subscribe_id = g_dbus_connection_signal_subscribe(
+ _bt_gdbus_get_system_gconn(), NULL,
+ BT_DEVICED_POWEROFF_INTERFACE,
+ BT_DEVICED_POWEROFF_SIGNAL,
+ BT_DEVICED_POWEROFF_OBJECT_PATH,
+ NULL, 0, __bt_poweroff_event_filter, NULL, NULL);
+}
+
+void _bt_service_unregister_poweroff_event(void)
+{
+ if (poweroff_subscribe_id == 0)
+ return;
+
+ g_dbus_connection_signal_unsubscribe(_bt_gdbus_get_system_gconn(),
+ poweroff_subscribe_id);
+ poweroff_subscribe_id = 0;
+}
+
+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
+
+#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
+}
+
void _bt_service_unregister_vconf_handler(void)
{
BT_DBG("+");
- if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
- vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
- }
+#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_PROFILE_WEARABLE) {
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
- (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
}
static void __bt_state_event_handler(const char *event_name, bundle *data, void *user_data)
BT_DBG("bt_state: (%s)", bt_le_status);
}
-static gboolean __bt_adapter_recovery_cb(gpointer data)
-{
- int ret = 0;
-
- BT_DBG("+");
-
- recovery_timer = 0;
-
- _bt_service_initialize();
-
- ret = _bt_enable_adapter_check_status();
- if (ret == BLUETOOTH_ERROR_NONE) {
- ret = _bt_enable_adapter();
- if (ret < 0)
- BT_ERR("_bt_enable_adapter() failed");
-
- ret = _bt_enable_adapter_le();
- if (ret < 0)
- BT_ERR("_bt_enable_adapter_le() failed");
- }
-
- recovery_cnt--;
-
- BT_DBG("-");
-
- return FALSE;
-}
-
void _bt_handle_adapter_added(void)
{
BT_DBG("+");
}
*/
- recovery_cnt = -1;
-
status = _bt_adapter_get_status();
le_status = _bt_adapter_get_le_status();
BT_INFO("status : %d", status);
BT_INFO("le_status : %d", le_status);
- if (!TIZEN_FEATURE_BT_USB_DONGLE) {
+
+#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) {
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");
if (0 != ret)
ERR("vconf_ignore_key_changed failed\n");
- /* 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 */
-
- if (!TIZEN_FEATURE_BT_USB_DONGLE) {
- _bt_destroy_agent(adapter_agent);
- adapter_agent = NULL;
-
- if (recovery_cnt > 0) {
- /* Send disabled event */
- _bt_set_disabled(BLUETOOTH_ERROR_NONE);
- _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
- g_variant_new("(i)", BLUETOOTH_ERROR_NONE));
-
- if (recovery_timer > 0)
- g_source_remove(recovery_timer);
-
- if (TIZEN_PROFILE_WEARABLE) {
- recovery_timer = g_timeout_add(BT_RECOVERY_TIME_W,
- (GSourceFunc)__bt_adapter_recovery_cb, NULL);
- } else {
- recovery_timer = g_timeout_add(BT_RECOVERY_TIME,
- (GSourceFunc)__bt_adapter_recovery_cb, NULL);
- }
+#ifndef USB_BLUETOOTH
+ _bt_destroy_agent(adapter_agent);
+ adapter_agent = NULL;
- if (eventsystem_unregister_event(status_reg_id) != ES_R_OK)
- BT_ERR("Fail to unregister system event");
- return;
- }
+ if (is_recovery_mode == TRUE) {
+ /* Send disabled event */
+ _bt_set_disabled(BLUETOOTH_ERROR_NONE);
- if (recovery_timer == 0)
- _bt_reliable_terminate_service(NULL);
+ /* Will recover BT by bt-core, so set the mode as activating */
+ _bt_adapter_set_status(BT_ACTIVATING);
+ is_recovery_mode = FALSE;
} else {
- _bt_set_disabled(BLUETOOTH_ERROR_NONE);
- _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
- g_variant_new("(i)", BLUETOOTH_ERROR_NONE));
+ _bt_reliable_terminate_service(NULL);
}
+#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);
- if (recovery_cnt > 0) {
- BT_ERR("Try recovery again(remain:%d)", recovery_cnt);
- if (recovery_timer > 0)
- g_source_remove(recovery_timer);
-
- if (TIZEN_PROFILE_WEARABLE) {
- recovery_timer = g_timeout_add(BT_RECOVERY_TIME_W,
- (GSourceFunc)__bt_adapter_recovery_cb, NULL);
- } else {
- recovery_timer = g_timeout_add(BT_RECOVERY_TIME,
- (GSourceFunc)__bt_adapter_recovery_cb, NULL);
- }
-
- return FALSE;
- }
-
- if (!TIZEN_FEATURE_BT_USB_DONGLE)
- _bt_terminate_service(NULL);
+#ifndef USB_BLUETOOTH
+ _bt_terminate_service(NULL);
+#endif
return FALSE;
}
}
g_variant_unref(result);
+ _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
- if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED)
- _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
+ _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
if (_bt_adapter_get_status() == BT_DEACTIVATED)
_bt_terminate_service(NULL);
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);
-if (TIZEN_PROFILE_TV) {
+#ifdef TIZEN_TV
+{
int adapter_status = BT_ADAPTER_DISABLED;
if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
return BLUETOOTH_ERROR_NONE;
}
}
+#endif
+
+ if (__bt_is_in_poweroff() == TRUE) {
+ BT_INFO("Just update VCONFKEY_BT_STATUS in Power off");
+ if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON) != 0)
+ BT_ERR("Set VCONFKEY_BT_STATUS failed");
+ return BLUETOOTH_ERROR_NONE;
+ }
proxy = __bt_get_core_proxy();
if (!proxy)
g_clear_error(&error);
}
g_variant_unref(result);
+#ifndef USB_BLUETOOTH
/* Terminate myself */
- if (!TIZEN_FEATURE_BT_USB_DONGLE)
- g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
+ g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
+#endif
return BLUETOOTH_ERROR_INTERNAL;
}
g_variant_unref(result);
return BLUETOOTH_ERROR_NONE;
}
-static gboolean __bt_set_powered(gboolean powered)
-{
- GDBusProxy *proxy;
- GError *error = NULL;
- GVariant *result;
-
- BT_DBG("");
-
- proxy = _bt_get_adapter_properties_proxy();
- retv_if(proxy == NULL, FALSE);
-
- result = g_dbus_proxy_call_sync(proxy, "Set",
- g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Powered",
- g_variant_new("b", powered)),
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (!result) {
- if (error != NULL) {
- BT_ERR("Failed to set powered property (Error: %s)",
- error->message);
- g_clear_error(&error);
- } else {
- BT_ERR("Failed to set powered property");
- }
- return FALSE;
- }
-
- BT_INFO("Set powered [%d]", powered);
- g_variant_unref(result);
- return TRUE;
-}
-
static gboolean __bt_disconnect_all(void)
{
int i;
GVariant *result;
GError *error = NULL;
GArray *device_list;
- bluetooth_device_info_t info;
+ bluetooth_device_info_t *info;
guint size;
char *device_path = NULL;
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
for (i = 0; i < size; i++) {
- info = g_array_index(device_list,
+ info = &g_array_index(device_list,
bluetooth_device_info_t, i);
- if (info.connected != BLUETOOTH_CONNECTED_LINK_NONE) {
+ if (info->connected != BLUETOOTH_CONNECTED_LINK_NONE) {
BT_DBG("Found Connected device");
- _bt_convert_addr_type_to_string(address, info.device_address.addr);
+ _bt_convert_addr_type_to_string(address, info->device_address.addr);
device_path = _bt_get_device_object_path(address);
if (device_path == NULL)
continue;
{
BT_DBG("");
_bt_set_disabled(BLUETOOTH_ERROR_NONE);
- _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
- g_variant_new("(i)", BLUETOOTH_ERROR_NONE));
return FALSE;
}
{
BT_DBG("+");
int ret;
- bt_le_status_t le_status;
if (_bt_adapter_get_status() == BT_DEACTIVATING) {
BT_DBG("Disabling in progress");
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 */
-
- le_status = _bt_adapter_get_le_status();
- if (le_status == BT_LE_ACTIVATED && is_le_intended == TRUE) {
- __bt_disconnect_all();
- } else {
- if (le_status == BT_LE_ACTIVATED)
- _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
-
- __bt_set_powered(FALSE);
- }
-
+ __bt_disconnect_all();
ret = _bt_disable_cb();
BT_DBG("-");
int _bt_recover_adapter(void)
{
BT_DBG("+");
+ GDBusProxy *proxy;
+ GVariant *result;
+ GError *error = NULL;
if (_bt_adapter_get_status() == BT_DEACTIVATING) {
BT_ERR("Disabling in progress");
return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
}
- recovery_cnt = BT_RECOVERY_MAX_COUNT;
+ _bt_adapter_set_status(BT_DEACTIVATING);
- _bt_disable_adapter();
- _bt_disable_adapter_le();
+ proxy = __bt_get_core_proxy();
+ retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
+
+ result = g_dbus_proxy_call_sync(proxy,
+ "RecoverAdapter",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (!result) {
+ if (error != NULL) {
+ BT_ERR("Failed to RecoverAdapter (Error: %s)", error->message);
+ g_clear_error(&error);
+ } else
+ BT_ERR("Failed to RecoverAdapter");
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ is_recovery_mode = TRUE;
+
+ g_variant_unref(result);
+ __bt_disconnect_all();
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
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 {
+}
+#else
+int _bt_check_adapter(int *status)
+{
GDBusProxy *proxy;
GError *error = NULL;
GVariant *result;
g_variant_unref(temp);
return BLUETOOTH_ERROR_NONE;
}
-}
+#endif
int _bt_enable_adapter_le(void)
{
if (status == BT_DEACTIVATING || le_status == BT_LE_DEACTIVATING) {
BT_ERR("Disabling in progress");
- _bt_set_le_intended_status(FALSE);
return BLUETOOTH_ERROR_DEVICE_BUSY;
}
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_FEATURE_BT_DPM
- _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
+#ifdef TIZEN_DPM_ENABLE
if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE &&
- discoverable_state == DPM_RESTRICTED) {
- if (headed_plugin_info->plugin_headed_enabled)
- headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT_HANDSFREE");
-
+ _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
+ _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT_HANDSFREE");
return BLUETOOTH_ERROR_ACCESS_DENIED;
}
if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE &&
- discoverable_state == DPM_RESTRICTED) {
- if (headed_plugin_info->plugin_headed_enabled)
- headed_plugin_info->headed_plugin->bt_launch_dpmpopup("DPM_POLICY_DISABLE_BT");
-
+ _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
+ _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT");
return BLUETOOTH_ERROR_ACCESS_DENIED;
}
#endif
return BLUETOOTH_ERROR_INTERNAL;
}
- discovery_req = TRUE;
+ is_discovering = TRUE;
cancel_by_user = FALSE;
/* discovery status will be change in event */
g_variant_unref(result);
return BLUETOOTH_ERROR_INTERNAL;
}
- discovery_req = TRUE;
+ is_discovering = 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 || discovery_req);
+ return is_discovering;
}
gboolean _bt_is_connectable(void)
}
dev_info->service_index = i;
g_variant_iter_free(iter);
- } else if (strcasecmp(key, "ManufacturerDataLen") == 0) {
+ } else if (strcasecmp(key, "LegacyManufacturerDataLen") == 0) {
dev_info->manufacturer_data.data_len = g_variant_get_uint16(value);
- } else if (strcasecmp(key, "ManufacturerData") == 0) {
+ } else if (strcasecmp(key, "LegacyManufacturerData") == 0) {
manufacturer_data = g_byte_array_new();
g_variant_get(value, "ay", &char_value_iter);
while (g_variant_iter_loop(char_value_iter, "y", &char_value))
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;
}
-#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
+ g_idle_add((GSourceFunc)_bt_adapter_request_delayed_cb, (void*)function);
return BLUETOOTH_ERROR_NONE;
}
+
int _bt_get_enable_timer_id(void)
{
return timer_id;
}
+