From 2d6b8fe603ffdd0b884a27ea90ebc4c90cd5d5ff Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 25 Jul 2018 11:39:55 +0300 Subject: [PATCH] adapter: Check pending when setting DiscoverableTimeout This makes DiscoverableTimeout check if discoverable is already pending and don't attempt to set it once again which may cause discoverable to be re-enabled when in fact the application just want to set the timeout alone. Change-Id: I5ffb43845cf90698ed92e0d06301e77d4fbee8b7 Signed-off-by: himanshu --- src/adapter.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/adapter.c b/src/adapter.c index f8c057d..b0207e2 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -6638,6 +6638,7 @@ static void property_set_discoverable_timeout( GDBusPendingPropertySet id, void *user_data) { struct btd_adapter *adapter = user_data; + bool enabled; dbus_uint32_t value; dbus_message_iter_get_basic(iter, &value); @@ -6651,8 +6652,19 @@ static void property_set_discoverable_timeout( g_dbus_emit_property_changed(dbus_conn, adapter->path, ADAPTER_INTERFACE, "DiscoverableTimeout"); + if (adapter->pending_settings & MGMT_SETTING_DISCOVERABLE) { + if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) + enabled = false; + else + enabled = true; + } else { + if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) + enabled = true; + else + enabled = false; + } - if (adapter->current_settings & MGMT_SETTING_DISCOVERABLE) + if (enabled) set_discoverable(adapter, 0x01, adapter->discoverable_timeout); } -- 2.7.4