From 9fe742684c9d154c6ca9b6e035d6d380e0cc4bdf Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Fri, 6 May 2016 02:37:24 -0700 Subject: [PATCH] adb: search for a maximum of 16 emulators. Android Wear has unfortunately been using port 5601 for years, which falls into the range of ports we were previously polling for Android emulators. Reduce the maximum number of emulators we can support so that 5601 no longer falls within our range. Bug: http://b/26468076 Change-Id: I931809cfa412122f4781eebe0164facab12c95f0 --- adb/transport_local.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index 4121f472c..4f3e1f51b 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp @@ -37,14 +37,19 @@ #include "adb_utils.h" #if ADB_HOST + +// Android Wear has been using port 5601 in all of its documentation/tooling, +// but we search for emulators on ports [5554, 5555 + ADB_LOCAL_TRANSPORT_MAX]. +// Avoid stomping on their port by limiting the number of emulators that can be +// connected. +#define ADB_LOCAL_TRANSPORT_MAX 16 + +ADB_MUTEX_DEFINE(local_transports_lock); + /* we keep a list of opened transports. The atransport struct knows to which * local transport it is connected. The list is used to detect when we're * trying to connect twice to a given local transport. */ -#define ADB_LOCAL_TRANSPORT_MAX 64 - -ADB_MUTEX_DEFINE( local_transports_lock ); - static atransport* local_transports[ ADB_LOCAL_TRANSPORT_MAX ]; #endif /* ADB_HOST */