#include "bt-service-main.h"
#include "bt-service-avrcp.h"
#include "bt-service-device.h"
+#include "bt-service-adapter-le.h"
+
#ifdef TIZEN_DPM_ENABLE
#include "bt-service-dpm.h"
#endif
static guint timer_id = 0;
static guint le_timer_id = 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"
GDBusProxy *device_proxy;
gchar *address = NULL;
gchar *name = NULL;
+ gchar *alias = NULL;
unsigned int cod = 0;
gint rssi = 0;
gboolean trust = FALSE;
} else if (!g_strcmp0(key, "Address")) {
g_variant_get(value, "s", &address);
} else if (!g_strcmp0(key, "Alias")) {
- g_variant_get(value, "s", &name);
+ g_variant_get(value, "s", &alias);
} else if (!g_strcmp0(key, "Name")) {
- if (!name)
- g_variant_get(value, "s", &name);
+ g_variant_get(value, "s", &name);
} else if (!g_strcmp0(key, "Class")) {
cod = g_variant_get_uint32(value);
} else if (!g_strcmp0(key, "Connected")) {
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))
if ((paired == FALSE) && (trust == FALSE)) {
g_free(address);
+ g_free(alias);
g_free(name);
return BLUETOOTH_ERROR_NOT_PAIRED;
}
_bt_divide_device_class(&dev_info->device_class, cod);
- g_strlcpy(dev_info->device_name.name, name,
+ g_strlcpy(dev_info->device_name.name, alias ? alias : name,
BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
dev_info->rssi = rssi;
dev_info->connected = connected;
ret = BLUETOOTH_ERROR_NONE;
g_free(address);
+ g_free(alias);
g_free(name);
return ret;
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;
(const char **)&ptr))
*ptr = '\0';
+ BT_INFO("device_name is changed to %s", phone_name);
_bt_set_local_name(phone_name);
+ } else {
+ BT_ERR("phone_name is NOT valid");
}
+ } else {
+ BT_ERR("vconf type is NOT string");
}
}
/* 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)
}
#endif
+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)
+{
+ int state = 0;
+
+ 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 (_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("+");
status = _bt_adapter_get_status();
le_status = _bt_adapter_get_le_status();
- BT_DBG("status : %d", status);
- BT_DBG("le_status : %d", le_status);
+ BT_INFO("status : %d", status);
+ BT_INFO("le_status : %d", le_status);
#ifndef USB_BLUETOOTH
adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
_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) {
}
#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)
return BLUETOOTH_ERROR_INTERNAL;
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;
GError *error = NULL;
if (_bt_adapter_get_status() == BT_DEACTIVATING) {
- BT_DBG("Disabling in progress");
+ BT_ERR("Disabling in progress");
return BLUETOOTH_ERROR_IN_PROGRESS;
}
if (_bt_adapter_get_status() == BT_DEACTIVATED) {
- BT_DBG("Already disabled");
+ BT_ERR("Already disabled");
return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
}
}
g_variant_iter_free(iter);
g_variant_unref(result);
+ g_variant_unref(temp);
BT_DBG("Service Used? %d", *used);
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;
}
}
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))
return BLUETOOTH_ERROR_NONE;
}
-#ifdef TIZEN_TV
+
int _bt_get_enable_timer_id(void)
{
return timer_id;
}
-#endif
+