1
Author: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
2
Description: Don't enable discoverable during init if timeout is valid
4
Backport of the upstream patch 8819626.
6
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/1419874
8
Index: bluez-4.101/plugins/mgmtops.c
9
===================================================================
10
--- bluez-4.101.orig/plugins/mgmtops.c
11
+++ bluez-4.101/plugins/mgmtops.c
12
@@ -223,7 +223,8 @@ static int mgmt_set_discoverable(int ind
13
struct mgmt_hdr *hdr = (void *) buf;
14
struct mgmt_cp_set_discoverable *cp = (void *) &buf[sizeof(*hdr)];
16
- DBG("index %d discoverable %d", index, discoverable);
17
+ DBG("index %d discoverable %d timeout %d", index,
18
+ discoverable, timeout);
20
memset(buf, 0, sizeof(buf));
21
hdr->opcode = htobs(MGMT_OP_SET_DISCOVERABLE);
22
@@ -322,7 +323,11 @@ static void update_settings(struct btd_a
23
if (on_mode == MODE_DISCOVERABLE && !mgmt_discoverable(settings)) {
24
if(!mgmt_connectable(settings))
25
mgmt_set_connectable(index, TRUE);
26
- mgmt_set_discoverable(index, TRUE, discoverable_timeout);
27
+ if (discoverable_timeout > 0) {
28
+ /* Ensure that discoverable mode is off */
29
+ mgmt_set_discoverable(index, FALSE, 0);
31
+ mgmt_set_discoverable(index, TRUE, discoverable_timeout);
32
} else if (on_mode == MODE_CONNECTABLE && !mgmt_connectable(settings)) {
33
mgmt_set_connectable(index, TRUE);
34
} else if (mgmt_powered(settings)) {