mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fix __FrameHandler3::CxxCallCatchBlock crashes at Nearby Connections layer
PiperOrigin-RevId: 542085514
This commit is contained in:
committed by
Copybara-Service
parent
1973b09849
commit
7eca4d74c6
@@ -210,6 +210,8 @@ void BleGattServer::Stop() {
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,6 +346,8 @@ bool BleGattServer::InitializeGattServer() {
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
@@ -396,6 +400,8 @@ bool BleGattServer::StartAdvertisement(const ByteArray& service_data,
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
|
||||
is_advertising_ = false;
|
||||
@@ -434,6 +440,8 @@ bool BleGattServer::StopAdvertisement() {
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -484,6 +492,8 @@ bool BleGattServer::StopAdvertisement() {
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
|
||||
deferral.Complete();
|
||||
@@ -582,6 +592,8 @@ void BleGattServer::Characteristic_SubscribedClientsChanged(
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,6 +645,8 @@ void BleGattServer::NotifyValueChanged(
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +223,9 @@ bool BleMedium::StartAdvertising(
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,6 +264,9 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +328,9 @@ bool BleMedium::StartScanning(
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,6 +371,9 @@ bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,6 +250,9 @@ bool BleV2Medium::StartScanning(const Uuid& service_uuid,
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,6 +301,9 @@ std::unique_ptr<BleV2Medium::ScanningSession> BleV2Medium::StartScanning(
|
||||
<< ": Exception to start BLE scanning: " << ex.code()
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
return nullptr;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": BLE Scanning already started.";
|
||||
@@ -359,6 +365,10 @@ std::unique_ptr<BleV2Medium::ScanningSession> BleV2Medium::StartScanning(
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
return absl::InternalError(
|
||||
"Bad status stopping Ble scanning");
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return absl::InternalError(
|
||||
"Bad status stopping Ble scanning");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -429,6 +439,8 @@ std::unique_ptr<api::ble_v2::GattClient> BleV2Medium::ConnectToGattServer(
|
||||
} catch (const winrt::hresult_error& error) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code()
|
||||
<< ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -471,6 +483,9 @@ bool BleV2Medium::StopScanning() {
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,6 +641,9 @@ bool BleV2Medium::StartBleAdvertising(
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,6 +680,9 @@ bool BleV2Medium::StopBleAdvertising() {
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,6 +744,9 @@ bool BleV2Medium::StartGattAdvertising(
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,6 +785,9 @@ bool BleV2Medium::StopGattAdvertising() {
|
||||
<< ": " << winrt::to_string(ex.message());
|
||||
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ bool BluetoothPairing::InitiatePairing(
|
||||
<< ": Failed to initiate pairing. WinRT exception: "
|
||||
<< error.code() << ": "
|
||||
<< winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -137,6 +139,8 @@ bool BluetoothPairing::FinishPairing(
|
||||
<< ": Failed to finish pairing. WinRT exception: "
|
||||
<< error.code() << ": "
|
||||
<< winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -167,6 +171,8 @@ bool BluetoothPairing::CancelPairing() {
|
||||
<< ": Failed to cancel ongoing pairing process. "
|
||||
<< "WinRT exception: " << error.code() << ": "
|
||||
<< winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -195,6 +201,8 @@ bool BluetoothPairing::Unpair() {
|
||||
<< ": Failed to unpaired with device. WinRT exception: "
|
||||
<< error.code() << ": "
|
||||
<< winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -212,6 +220,8 @@ bool BluetoothPairing::IsPaired() {
|
||||
<< ": Failed to get IsPaired. WinRT exception: "
|
||||
<< error.code() << ": "
|
||||
<< winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -259,6 +269,8 @@ void BluetoothPairing::OnPairingRequested(
|
||||
<< __func__
|
||||
<< ": Failed to request to pair with device. WinRT exception: "
|
||||
<< error.code() << ": " << winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
pairing_callback_.on_pairing_error_cb(PairingError::kFailed);
|
||||
}
|
||||
@@ -322,6 +334,8 @@ void BluetoothPairing::OnPair(DevicePairingResult& pairing_result) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Failed to get Pairing Result Status."
|
||||
<< " WinRT exception: " << error.code() << ": "
|
||||
<< winrt::to_string(error.message());
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
}
|
||||
pairing_callback_.on_pairing_error_cb(PairingError::kFailed);
|
||||
}
|
||||
|
||||
@@ -100,6 +100,9 @@ bool PreferencesRepository::SavePreferences(json preferences) {
|
||||
} catch (const std::exception& e) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to save preferences file: " << e.what();
|
||||
return false;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -130,6 +133,9 @@ std::optional<json> PreferencesRepository::AttemptLoad() {
|
||||
} catch (const std::exception& e) {
|
||||
NEARBY_LOGS(ERROR) << "Exception while loading preferences: " << e.what();
|
||||
return std::nullopt;
|
||||
} catch (...) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Unknown exception.";
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user