diff --git a/android/bluetooth.c b/android/bluetooth.c
index 38ee9a9..655844d 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
adapter.le_scanning = true;
- /* If core is discovering, don't bother */
- if (adapter.cur_discovery_type != SCAN_TYPE_NONE)
+ /*
+ * If core is discovering - just set expected next scan type.
+ * It will be triggered in case current scan session is almost done
+ * i.e. we missed LE phase in interleaved scan, or we're trying to
+ * connect to device that was already discovered.
+ */
+ if (adapter.cur_discovery_type != SCAN_TYPE_NONE) {
+ adapter.exp_discovery_type = SCAN_TYPE_LE;
return true;
+ }
if (start_discovery(SCAN_TYPE_LE))
return true;
if (get_supported_discovery_type() != SCAN_TYPE_LE)
break;
- if (gatt_device_found_cb) {
+ if (adapter.exp_discovery_type == SCAN_TYPE_LE) {
status = HAL_STATUS_BUSY;
goto failed;
}
goto failed;
}
- adapter.exp_discovery_type = gatt_device_found_cb ?
- SCAN_TYPE_LE : SCAN_TYPE_NONE;
+ if (adapter.exp_discovery_type != SCAN_TYPE_LE)
+ adapter.exp_discovery_type = SCAN_TYPE_NONE;
+
break;
}