diff --git a/adb/Android.bp b/adb/Android.bp index ae8e386e4..fd68bc343 100644 --- a/adb/Android.bp +++ b/adb/Android.bp @@ -24,7 +24,6 @@ cc_defaults { "-Wno-missing-field-initializers", "-Wvla", ], - rtti: true, use_version_lib: true, diff --git a/adb/transport.cpp b/adb/transport.cpp index 87416549b..f59a13583 100644 --- a/adb/transport.cpp +++ b/adb/transport.cpp @@ -1305,11 +1305,7 @@ void register_usb_transport(usb_handle* usb, const char* serial, const char* dev void unregister_usb_transport(usb_handle* usb) { std::lock_guard lock(transport_lock); transport_list.remove_if([usb](atransport* t) { - auto connection = t->connection(); - if (auto usb_connection = dynamic_cast(connection.get())) { - return usb_connection->handle_ == usb && t->GetConnectionState() == kCsNoPerm; - } - return false; + return t->GetUsbHandle() == usb && t->GetConnectionState() == kCsNoPerm; }); } #endif diff --git a/adb/transport.h b/adb/transport.h index d593700dc..790004fdd 100644 --- a/adb/transport.h +++ b/adb/transport.h @@ -37,6 +37,7 @@ #include "adb.h" #include "adb_unique_fd.h" +#include "usb.h" typedef std::unordered_set FeatureSet; @@ -242,6 +243,9 @@ class atransport { return connection_; } + void SetUsbHandle(usb_handle* h) { usb_handle_ = h; } + usb_handle* GetUsbHandle() { return usb_handle_; } + const TransportId id; size_t ref_count = 0; bool online = false; @@ -333,6 +337,9 @@ class atransport { // The underlying connection object. std::shared_ptr connection_ GUARDED_BY(mutex_); + // USB handle for the connection, if available. + usb_handle* usb_handle_ = nullptr; + // A callback that will be invoked when the atransport needs to reconnect. ReconnectCallback reconnect_; diff --git a/adb/transport_usb.cpp b/adb/transport_usb.cpp index c471bf985..2e5918ab6 100644 --- a/adb/transport_usb.cpp +++ b/adb/transport_usb.cpp @@ -180,6 +180,7 @@ void init_usb_transport(atransport* t, usb_handle* h) { auto connection = std::make_unique(h); t->SetConnection(std::make_unique(std::move(connection))); t->type = kTransportUsb; + t->SetUsbHandle(h); } int is_adb_interface(int usb_class, int usb_subclass, int usb_protocol) {