diff --git a/connections/implementation/mediums/bluetooth_classic.cc b/connections/implementation/mediums/bluetooth_classic.cc index d020256e..f6c421cb 100644 --- a/connections/implementation/mediums/bluetooth_classic.cc +++ b/connections/implementation/mediums/bluetooth_classic.cc @@ -29,6 +29,7 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" #include "internal/platform/socket.h" +#include "internal/platform/types.h" #include "internal/platform/uuid.h" namespace nearby { @@ -378,7 +379,7 @@ bool BluetoothClassic::StartAcceptingConnections( MediumSocket* virtual_socket) mutable { if (callback) { callback(listening_service_id, - *(dynamic_cast(virtual_socket))); + *(down_cast(virtual_socket))); } }); } @@ -417,7 +418,7 @@ bool BluetoothClassic::StartAcceptingConnections( if (callback) { callback( service_id, - *(dynamic_cast( + *(down_cast( multiplex_socket->GetVirtualSocket(service_id)))); callback_called = true; } @@ -505,7 +506,7 @@ BluetoothSocket BluetoothClassic::Connect(BluetoothDevice& bluetooth_device, multiplex_socket->EstablishVirtualSocket(service_id); // Should not happen. auto* bluetooth_socket = - dynamic_cast(virtual_socket); + down_cast(virtual_socket); if (bluetooth_socket == nullptr) { NEARBY_LOGS(INFO) << "Failed to cast to BluetoothSocket for " << service_id @@ -591,7 +592,7 @@ BluetoothSocket BluetoothClassic::AttemptToConnect( MultiplexSocket::CreateOutgoingSocket(&socket, service_id); auto* virtual_socket = multiplex_socket->GetVirtualSocket(service_id); // Should not happen. - auto* bluetooth_socket = dynamic_cast(virtual_socket); + auto* bluetooth_socket = down_cast(virtual_socket); if (bluetooth_socket == nullptr) { NEARBY_LOGS(INFO) << "Failed to cast to BluetoothSocket for " << service_id << " with " << bluetooth_device.GetName(); diff --git a/connections/implementation/mediums/multiplex/multiplex_socket.cc b/connections/implementation/mediums/multiplex/multiplex_socket.cc index 50ad72a1..933121d8 100644 --- a/connections/implementation/mediums/multiplex/multiplex_socket.cc +++ b/connections/implementation/mediums/multiplex/multiplex_socket.cc @@ -38,6 +38,7 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" #include "internal/platform/socket.h" +#include "internal/platform/types.h" #include "proto/connections_enums.pb.h" namespace nearby { @@ -692,7 +693,7 @@ MediumSocket* MultiplexSocket::ReMapAndGetVirtualSocket( MutexLock lock(&virtual_socket_mutex_); for (auto& [hash_key, virtual_socket] : virtual_sockets_) { auto output_stream = - dynamic_cast( + down_cast( &(virtual_socket->GetOutputStream())); if (output_stream == nullptr) { continue;