Merge "Fix adb flakiness on reboot"
This commit is contained in:
commit
f7a1c476ff
2 changed files with 16 additions and 2 deletions
|
|
@ -139,8 +139,10 @@ int get_available_local_transport_index();
|
||||||
int init_socket_transport(atransport *t, int s, int port, int local);
|
int init_socket_transport(atransport *t, int s, int port, int local);
|
||||||
void init_usb_transport(atransport *t, usb_handle *usb, ConnectionState state);
|
void init_usb_transport(atransport *t, usb_handle *usb, ConnectionState state);
|
||||||
|
|
||||||
|
std::string getEmulatorSerialString(int console_port);
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
atransport* find_emulator_transport_by_adb_port(int adb_port);
|
atransport* find_emulator_transport_by_adb_port(int adb_port);
|
||||||
|
atransport* find_emulator_transport_by_console_port(int console_port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int service_to_fd(const char* name, const atransport* transport);
|
int service_to_fd(const char* name, const atransport* transport);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,8 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
if (find_emulator_transport_by_adb_port(adb_port) != nullptr) {
|
if (find_emulator_transport_by_adb_port(adb_port) != nullptr ||
|
||||||
|
find_emulator_transport_by_console_port(console_port) != nullptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +121,7 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
|
||||||
D("client: connected on remote on fd %d", fd);
|
D("client: connected on remote on fd %d", fd);
|
||||||
close_on_exec(fd);
|
close_on_exec(fd);
|
||||||
disable_tcp_nagle(fd);
|
disable_tcp_nagle(fd);
|
||||||
std::string serial = android::base::StringPrintf("emulator-%d", console_port);
|
std::string serial = getEmulatorSerialString(console_port);
|
||||||
if (register_socket_transport(fd, serial.c_str(), adb_port, 1) == 0) {
|
if (register_socket_transport(fd, serial.c_str(), adb_port, 1) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -431,6 +432,11 @@ static atransport* find_emulator_transport_by_adb_port_locked(int adb_port)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getEmulatorSerialString(int console_port)
|
||||||
|
{
|
||||||
|
return android::base::StringPrintf("emulator-%d", console_port);
|
||||||
|
}
|
||||||
|
|
||||||
atransport* find_emulator_transport_by_adb_port(int adb_port)
|
atransport* find_emulator_transport_by_adb_port(int adb_port)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(local_transports_lock);
|
std::lock_guard<std::mutex> lock(local_transports_lock);
|
||||||
|
|
@ -438,6 +444,12 @@ atransport* find_emulator_transport_by_adb_port(int adb_port)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atransport* find_emulator_transport_by_console_port(int console_port)
|
||||||
|
{
|
||||||
|
return find_transport(getEmulatorSerialString(console_port).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Only call this function if you already hold local_transports_lock. */
|
/* Only call this function if you already hold local_transports_lock. */
|
||||||
int get_available_local_transport_index_locked()
|
int get_available_local_transport_index_locked()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue