Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4361)

Unified Diff: build/android/pylib/forwarder.py

Issue 15008004: Add device port unmapping support to forwarder2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address David's comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/chrome_test_server_spawner.py ('k') | tools/android/forwarder2/daemon.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/forwarder.py
diff --git a/build/android/pylib/forwarder.py b/build/android/pylib/forwarder.py
index 508d943f7a39df47f575bdfa0bfee705d18f2a56..f5cde9e29da230201fa3c4ec48408c8319f5cb3c 100644
--- a/build/android/pylib/forwarder.py
+++ b/build/android/pylib/forwarder.py
@@ -67,20 +67,20 @@ class Forwarder(object):
Raises:
Exception on failure to forward the port.
"""
- host_adb_control_port = ports.AllocateTestServerPort()
- if not host_adb_control_port:
+ 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.')
self._adb.PushIfNeeded(
self._device_forwarder_path_on_host, Forwarder._DEVICE_FORWARDER_FOLDER)
redirection_commands = [
- '%d:%d:%d:%s' % (host_adb_control_port, device, host,
+ '%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>]')
logging.info('Forwarding using commands: %s', redirection_commands)
if cmd_helper.RunCmd(
['adb', '-s', self._adb._adb.GetSerialNumber(), 'forward',
- 'tcp:%s' % host_adb_control_port,
+ 'tcp:%s' % self._host_adb_control_port,
'localabstract:%s' % Forwarder._DEVICE_ADB_CONTROL_PORT]) != 0:
raise Exception('Error while running adb forward.')
@@ -114,6 +114,15 @@ class Forwarder(object):
logging.info('Forwarding device port: %d to host port: %d.', device_port,
host_port)
+ def UnmapDevicePort(self, device_port):
+ # Please note the minus sign below.
+ redirection_command = '%d:-%d' % (self._host_adb_control_port, device_port)
+ (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
+ [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)))
+
@staticmethod
def KillHost(build_type):
logging.info('Killing host_forwarder.')
« no previous file with comments | « build/android/pylib/chrome_test_server_spawner.py ('k') | tools/android/forwarder2/daemon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698