#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"
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;
/* 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("+");
}
#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;