Fix __FrameHandler3::CxxCallCatchBlock crashes at Nearby Connections layer

PiperOrigin-RevId: 542085514
This commit is contained in:
Aaron Yu
2023-06-20 16:43:14 -07:00
committed by Copybara-Service
parent 1973b09849
commit 7eca4d74c6
6 changed files with 98 additions and 0 deletions
@@ -149,6 +149,9 @@ void BluetoothClassicMedium::OnScanModeChanged(
<< ": OnScanModeChanged exception: " << ex.code() << ": "
<< winrt::to_string(ex.message());
return;
} catch (...) {
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
return;
}
}
@@ -220,6 +223,8 @@ void BluetoothClassicMedium::InitializeDeviceWatcher() {
NEARBY_LOGS(ERROR) << __func__
<< ": InitializeDeviceWatcher exception: " << ex.code()
<< ": " << winrt::to_string(ex.message());
} catch (...) {
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
}
}
@@ -343,6 +348,9 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
<< ex.code()
<< ", error message: " << winrt::to_string(ex.message());
return nullptr;
} catch (...) {
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
return nullptr;
}
}
@@ -373,6 +381,8 @@ std::unique_ptr<api::BluetoothPairing> BluetoothClassicMedium::CreatePairing(
<< ": Failed to create pairing. WinRT exception: "
<< error.code() << ": "
<< winrt::to_string(error.message());
} catch (...) {
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
}
return nullptr;
}
@@ -806,6 +816,18 @@ bool BluetoothClassicMedium::StartAdvertising(bool radio_discoverable) {
rfcomm_provider_ = nullptr;
}
return false;
} catch (...) {
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
if (server_socket_ != nullptr) {
server_socket_->Close();
server_socket_ = nullptr;
}
if (rfcomm_provider_ != nullptr) {
rfcomm_provider_ = nullptr;
}
return false;
}
}
@@ -836,6 +858,9 @@ bool BluetoothClassicMedium::StopAdvertising() {
<< ": StopAdvertising exception: " << ex.code() << ": "
<< winrt::to_string(ex.message());
return false;
} catch (...) {
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
return false;
}
}