Improve device lost handling

Handle the error case when the platform calls device_lost_cb without calling device_discovered_cb first.

PiperOrigin-RevId: 539791976
This commit is contained in:
Janusz Sobczak
2023-06-12 16:28:01 -07:00
committed by Copybara-Service
parent 6f69e97421
commit 4f73e87a6f
+5
View File
@@ -73,6 +73,11 @@ bool BluetoothClassicMedium::StartDiscovery(DiscoveryCallback callback) {
[this](api::BluetoothDevice& device) {
MutexLock lock(&mutex_);
auto item = devices_.extract(&device);
if (!item) {
NEARBY_LOGS(WARNING)
<< "Removing unknown device: " << device.GetMacAddress();
return;
}
auto& context = *item.mapped();
NEARBY_LOG(INFO, "Removing device=%p, impl=%p", &context.device,
&device);