• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修訂eec5e52ea24a9b86a9cee75c1e3207e9378b41c8 (tree)
時間2016-10-13 07:27:45
作者Lingfeng Yang <lfy@goog...>
CommiterBo Hu

Log Message

Fix adb flakiness on reboot

bug: 31950237

There are two lists of active ADB transports (devices),
and with the emulator, they can go out of sync.

This CL more conservatively checks if there are no
transports in either list before commiting to
register a new transport for the emulator.

Change-Id: Id1201dc59c70825881dad80925c2e5bcc13dbd5e
(cherry picked from commit edaedfd5da41b2f5aa14b4d52742a6d8caa49214)

Change Summary

差異

--- a/adb/adb.h
+++ b/adb/adb.h
@@ -160,8 +160,10 @@ int get_available_local_transport_index();
160160 int init_socket_transport(atransport *t, int s, int port, int local);
161161 void init_usb_transport(atransport *t, usb_handle *usb, ConnectionState state);
162162
163+std::string getEmulatorSerialString(int console_port);
163164 #if ADB_HOST
164165 atransport* find_emulator_transport_by_adb_port(int adb_port);
166+atransport* find_emulator_transport_by_console_port(int console_port);
165167 #endif
166168
167169 int service_to_fd(const char* name, const atransport* transport);
--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -99,7 +99,8 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
9999 int fd = -1;
100100
101101 #if ADB_HOST
102- if (find_emulator_transport_by_adb_port(adb_port) != nullptr) {
102+ if (find_emulator_transport_by_adb_port(adb_port) != nullptr ||
103+ find_emulator_transport_by_console_port(console_port) != nullptr) {
103104 return -1;
104105 }
105106
@@ -116,7 +117,7 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
116117 D("client: connected on remote on fd %d", fd);
117118 close_on_exec(fd);
118119 disable_tcp_nagle(fd);
119- std::string serial = android::base::StringPrintf("emulator-%d", console_port);
120+ std::string serial = getEmulatorSerialString(console_port);
120121 if (register_socket_transport(fd, serial.c_str(), adb_port, 1) == 0) {
121122 return 0;
122123 }
@@ -360,6 +361,11 @@ atransport* find_emulator_transport_by_adb_port_locked(int adb_port)
360361 return NULL;
361362 }
362363
364+std::string getEmulatorSerialString(int console_port)
365+{
366+ return android::base::StringPrintf("emulator-%d", console_port);
367+}
368+
363369 atransport* find_emulator_transport_by_adb_port(int adb_port)
364370 {
365371 adb_mutex_lock( &local_transports_lock );
@@ -368,6 +374,12 @@ atransport* find_emulator_transport_by_adb_port(int adb_port)
368374 return result;
369375 }
370376
377+atransport* find_emulator_transport_by_console_port(int console_port)
378+{
379+ return find_transport(getEmulatorSerialString(console_port).c_str());
380+}
381+
382+
371383 /* Only call this function if you already hold local_transports_lock. */
372384 int get_available_local_transport_index_locked()
373385 {