From 56b7daf88dc3e36360818a2ea78875b4a2e63fec Mon Sep 17 00:00:00 2001 From: edwinwu Date: Tue, 17 Aug 2021 17:55:12 -0700 Subject: [PATCH] Fixes bluetooth_medium is not supported then don't continue for BleDiscoveredHandler. PiperOrigin-RevId: 391418495 --- cpp/core/internal/mediums/bluetooth_classic.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpp/core/internal/mediums/bluetooth_classic.cc b/cpp/core/internal/mediums/bluetooth_classic.cc index 6f870b17..bfa15992 100644 --- a/cpp/core/internal/mediums/bluetooth_classic.cc +++ b/cpp/core/internal/mediums/bluetooth_classic.cc @@ -407,11 +407,21 @@ BluetoothSocket BluetoothClassic::AttemptToConnect( BluetoothDevice BluetoothClassic::GetRemoteDevice( const std::string& mac_address) { MutexLock lock(&mutex_); + + if (!IsAvailableLocked()) { + return {}; + } + return medium_.GetRemoteDevice(mac_address); } std::string BluetoothClassic::GetMacAddress() const { MutexLock lock(&mutex_); + + if (!IsAvailableLocked()) { + return {}; + } + return medium_.GetMacAddress(); }