OSDN Git Service

android/bluetooth: Filter out not discoverable LE devices
authorSzymon Janc <szymon.janc@tieto.com>
Sun, 23 Mar 2014 21:40:51 +0000 (22:40 +0100)
committerSzymon Janc <szymon.janc@tieto.com>
Mon, 24 Mar 2014 13:23:44 +0000 (14:23 +0100)
Filter out unknown LE devices that do not have Discoverable flag or
Limited Discoverable flag set.

android/bluetooth.c

index d2795e3..ce4cc86 100644 (file)
@@ -1271,6 +1271,19 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 
        dev = find_device(bdaddr);
 
+       if (bdaddr_type != BDADDR_BREDR) {
+               /* Notify Gatt if its registered for LE events */
+               if (gatt_device_found_cb)
+                       gatt_device_found_cb(bdaddr, bdaddr_type, rssi,
+                                                       sizeof(eir), &eir);
+
+               if (!dev && adapter.cur_discovery_type != SCAN_TYPE_NONE &&
+                               !(eir.flags & (EIR_LIM_DISC | EIR_GEN_DISC))) {
+                       eir_data_free(&eir);
+                       return;
+               }
+       }
+
        /* Device found event needs to be send also for known device if this is
         * new discovery session. Otherwise framework will ignore it.
         */
@@ -1283,11 +1296,6 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
                update_device(dev, rssi, &eir);
        }
 
-       /* Notify Gatt if its registered for LE events */
-       if (gatt_device_found_cb && (dev->bdaddr_type & BDADDR_LE))
-               gatt_device_found_cb(&dev->bdaddr, dev->bdaddr_type,
-                                               dev->rssi, sizeof(eir), &eir);
-
        eir_data_free(&eir);
 
        if (dev->bond_state != HAL_BOND_STATE_BONDED)