From 3f81504dc11da84e4f2d96f5a8843d0f96653684 Mon Sep 17 00:00:00 2001 From: eidenkim Date: Thu, 14 Apr 2022 08:57:36 -0700 Subject: [PATCH] Nearby Connections - Fixed crash when starting the app on devices with no Bluetooth adapter PiperOrigin-RevId: 441773811 --- .../windows/bluetooth_classic_server_socket.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc b/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc index 113ec647..d33518e4 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc @@ -123,6 +123,14 @@ Exception BluetoothServerSocket::StartListening(bool radioDiscoverable) { LeaveCriticalSection(&critical_section_); + return {Exception::kFailed}; + } catch (const winrt::hresult_error& ex) { + NEARBY_LOGS(ERROR) << __func__ + << ": Exception setting up for listen: " << ex.code() + << ": " << winrt::to_string(ex.message()); + + LeaveCriticalSection(&critical_section_); + return {Exception::kFailed}; } @@ -145,6 +153,14 @@ Exception BluetoothServerSocket::StartAdvertising() { LeaveCriticalSection(&critical_section_); + return {Exception::kFailed}; + } catch (const winrt::hresult_error& ex) { + NEARBY_LOGS(ERROR) << __func__ + << ": Exception calling StartAdvertising: " << ex.code() + << ": " << winrt::to_string(ex.message()); + + LeaveCriticalSection(&critical_section_); + return {Exception::kFailed}; }