Diff between 28ef9c48c26fc84752506e35a92cc8c633de29f8 and 92e869f47a7bfd75c5d56b1d72318f7e42e5bbb0

Changed Files

File Additions Deletions Status
android/bluetooth.c +12 -24 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 734adeb..4e4397a 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1323,17 +1323,18 @@ static void update_device(struct device *dev, int8_t rssi,
 					HAL_EV_REMOTE_DEVICE_PROPS, size, buf);
 }
 
-static bool is_new_device(const struct device *dev)
+static bool is_new_device(const struct device *dev, unsigned int flags)
 {
-	if (!dev)
-		return true;
-
 	if (dev->found)
 		return false;
 
 	if (dev->bond_state == HAL_BOND_STATE_BONDED)
 		return false;
 
+	if (dev->bdaddr_type != BDADDR_BREDR &&
+				!(flags & (EIR_LIM_DISC | EIR_GEN_DISC)))
+		return false;
+
 	return true;
 }
 
@@ -1348,35 +1349,22 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 
 	eir_parse(&eir, data, data_len);
 
-	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;
-		}
-	}
+	dev = get_device(bdaddr, bdaddr_type);
 
 	/* Device found event needs to be send also for known device if this is
 	 * new discovery session. Otherwise framework will ignore it.
 	 */
-	if (is_new_device(dev)) {
-		if (!dev)
-			dev = create_device(bdaddr, bdaddr_type);
-
+	if (is_new_device(dev, eir.flags))
 		update_new_device(dev, rssi, &eir);
-	} else {
+	else
 		update_device(dev, rssi, &eir, bdaddr_type);
-	}
 
 	eir_data_free(&eir);
 
+	/* Notify Gatt if its registered for LE events */
+	if (bdaddr_type != BDADDR_BREDR && gatt_device_found_cb)
+		gatt_device_found_cb(bdaddr, bdaddr_type, rssi, data_len, data);
+
 	if (dev->bond_state != HAL_BOND_STATE_BONDED)
 		cache_device(dev);