Index: build/android/pylib/forwarder.py |
diff --git a/build/android/pylib/forwarder.py b/build/android/pylib/forwarder.py |
index 40a5d36fae3305753d68b6bffc46cfb97bc2b355..7635033e67538f7608b66ad91bf22c3cc104d779 100644 |
--- a/build/android/pylib/forwarder.py |
+++ b/build/android/pylib/forwarder.py |
@@ -24,9 +24,7 @@ def _MakeBinaryPath(build_type, binary_name): |
class Forwarder(object): |
"""Thread-safe class to manage port forwards from the device to the host.""" |
- # Unix Abstract socket path: |
_DEVICE_ADB_CONTROL_PORT = 'chrome_device_forwarder' |
- _TIMEOUT_SECS = 30 |
_DEVICE_FORWARDER_FOLDER = (constants.TEST_EXECUTABLE_DIR + |
'/forwarder/') |
@@ -70,19 +68,16 @@ class Forwarder(object): |
""" |
with self._lock: |
self._InitDeviceLocked(tool) |
- self._InitHostLocked() |
host_name = '127.0.0.1' |
redirection_commands = [ |
- '%d:%d:%d:%s' % (self._host_adb_control_port, device, host, |
- host_name) for device, host in port_pairs] |
- logging.info('Command format: <ADB port>:<Device port>' + |
- '[:<Forward to port>:<Forward to address>]') |
+ ['--serial-id=' + self._adb.Adb().GetSerialNumber(), str(device), |
+ str(host)] for device, host in port_pairs] |
logging.info('Forwarding using commands: %s', redirection_commands) |
for redirection_command in redirection_commands: |
try: |
(exit_code, output) = cmd_helper.GetCmdStatusAndOutput( |
- [self._host_forwarder_path, redirection_command]) |
+ [self._host_forwarder_path] + redirection_command) |
except OSError as e: |
if e.errno == 2: |
raise Exception('Unable to start host forwarder. Make sure you have' |
@@ -101,19 +96,6 @@ class Forwarder(object): |
logging.info('Forwarding device port: %d to host port: %d.', |
device_port, host_port) |
- def _InitHostLocked(self): |
- """Initializes the host forwarder process (only once).""" |
- if self._host_adb_control_port: |
- return |
- self._host_adb_control_port = ports.AllocateTestServerPort() |
- if not self._host_adb_control_port: |
- raise Exception('Failed to allocate a TCP port in the host machine.') |
- if cmd_helper.RunCmd( |
- ['adb', '-s', self._adb._adb.GetSerialNumber(), 'forward', |
- 'tcp:%s' % self._host_adb_control_port, |
- 'localabstract:%s' % Forwarder._DEVICE_ADB_CONTROL_PORT]) != 0: |
- raise Exception('Error while running adb forward.') |
- |
def _InitDeviceLocked(self, tool): |
"""Initializes the device forwarder process (only once).""" |
if self._device_initialized: |
@@ -138,10 +120,10 @@ class Forwarder(object): |
""" |
with self._lock: |
# Please note the minus sign below. |
bulach
2013/07/02 13:13:06
how about changing this too? :)
could remove the c
Philippe
2013/07/02 15:58:25
Yeah, good point :) The '-' sign was introduced in
|
- redirection_command = '%d:-%d' % ( |
- self._host_adb_control_port, device_port) |
+ redirection_command = [ |
+ '--serial-id=' + self._adb.Adb().GetSerialNumber(), str(-device_port)] |
(exit_code, output) = cmd_helper.GetCmdStatusAndOutput( |
- [self._host_forwarder_path, redirection_command]) |
+ [self._host_forwarder_path] + redirection_command) |
if exit_code != 0: |
raise Exception('%s exited with %d:\n%s' % ( |
self._host_forwarder_path, exit_code, '\n'.join(output))) |