adb: remove incorrect use of RTTI.
We were dynamic_casting to UsbConnection to check for USB connections, but the actual type was a BlockingConnectionAdapter wrapping a UsbConnection, with the result that unplugging an inaccessible (due to permissions) device on Linux wouldn't make the device go away. Test: manual Change-Id: Icb4acea5fd3c3baa9691698686213e122e898e4a
This commit is contained in:
parent
36b5dd845c
commit
ce5ce87a66
4 changed files with 9 additions and 6 deletions
|
@ -24,7 +24,6 @@ cc_defaults {
|
|||
"-Wno-missing-field-initializers",
|
||||
"-Wvla",
|
||||
],
|
||||
rtti: true,
|
||||
|
||||
use_version_lib: true,
|
||||
|
||||
|
|
|
@ -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<std::recursive_mutex> lock(transport_lock);
|
||||
transport_list.remove_if([usb](atransport* t) {
|
||||
auto connection = t->connection();
|
||||
if (auto usb_connection = dynamic_cast<UsbConnection*>(connection.get())) {
|
||||
return usb_connection->handle_ == usb && t->GetConnectionState() == kCsNoPerm;
|
||||
}
|
||||
return false;
|
||||
return t->GetUsbHandle() == usb && t->GetConnectionState() == kCsNoPerm;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "adb.h"
|
||||
#include "adb_unique_fd.h"
|
||||
#include "usb.h"
|
||||
|
||||
typedef std::unordered_set<std::string> 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> 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_;
|
||||
|
||||
|
|
|
@ -180,6 +180,7 @@ void init_usb_transport(atransport* t, usb_handle* h) {
|
|||
auto connection = std::make_unique<UsbConnection>(h);
|
||||
t->SetConnection(std::make_unique<BlockingConnectionAdapter>(std::move(connection)));
|
||||
t->type = kTransportUsb;
|
||||
t->SetUsbHandle(h);
|
||||
}
|
||||
|
||||
int is_adb_interface(int usb_class, int usb_subclass, int usb_protocol) {
|
||||
|
|
Loading…
Reference in a new issue