From 2effd810aef1ed7e8c58893acc794f423e41d06d Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 9 Aug 2017 21:01:53 -0700 Subject: binding: bluetooth: cancel autoconnect when discovery mode requested Autoconnection was causing some devices not to be spotted ever when discovery mode was requested It can be safely assumed on user loading the Bluetooth setting page no currently paired devices are expected to autoconnected Change-Id: Ic66d97e559e5ed8fada4ca0a4a7bb481a19bdc36 Bug-AGL: SPEC-795 Signed-off-by: Matt Ranostay --- binding-bluetooth/bluetooth-manager.c | 7 ++++++- binding-bluetooth/bluetooth-manager.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/binding-bluetooth/bluetooth-manager.c b/binding-bluetooth/bluetooth-manager.c index 407518f..2ff8925 100644 --- a/binding-bluetooth/bluetooth-manager.c +++ b/binding-bluetooth/bluetooth-manager.c @@ -1258,7 +1258,7 @@ static void *bt_event_loop_thread() BluetoothManage_InitFlag_Set(TRUE); BluetoothMonitorInit(); - g_timeout_add_seconds(5, bt_autoconnect, NULL); + BluetoothManage.autoconnect = g_timeout_add_seconds(5, bt_autoconnect, NULL); LOGD("g_main_loop_run\n"); g_main_loop_run(cli.clientloop); @@ -1493,6 +1493,11 @@ int adapter_start_discovery() return -1; } + if (BluetoothManage.autoconnect > 0) { + LOGW("Canceling autoconnection for discovery mode\n"); + g_source_remove(BluetoothManage.autoconnect); + } + value = g_dbus_connection_call_sync(cli.system_conn, BLUEZ_SERVICE, ADAPTER_PATH, ADAPTER_INTERFACE, "StartDiscovery", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, diff --git a/binding-bluetooth/bluetooth-manager.h b/binding-bluetooth/bluetooth-manager.h index 54d7ff8..36222df 100644 --- a/binding-bluetooth/bluetooth-manager.h +++ b/binding-bluetooth/bluetooth-manager.h @@ -161,6 +161,7 @@ typedef struct { gboolean inited; GMutex m; gint watch; + guint autoconnect; GSList * device; GSList * priorities; } stBluetoothManage; -- cgit