| Index: tools/telemetry/telemetry/internal/platform/android_platform_backend.py
|
| diff --git a/tools/telemetry/telemetry/internal/platform/android_platform_backend.py b/tools/telemetry/telemetry/internal/platform/android_platform_backend.py
|
| index 86264d887713967afa7e15fc42cf3fa98f23ecda..77547e63ccc5a40d24b5d7c8ccac8d763cb4b138 100644
|
| --- a/tools/telemetry/telemetry/internal/platform/android_platform_backend.py
|
| +++ b/tools/telemetry/telemetry/internal/platform/android_platform_backend.py
|
| @@ -3,6 +3,7 @@
|
| # found in the LICENSE file.
|
|
|
| import logging
|
| +import numbers
|
| import os
|
| import re
|
| import shutil
|
| @@ -501,7 +502,47 @@ class AndroidPlatformBackend(
|
| return old_flag
|
|
|
| def ForwardHostToDevice(self, host_port, device_port):
|
| - self._device.adb.Forward('tcp:%d' % host_port, device_port)
|
| + """Forward host to device using adb.
|
| +
|
| + Also prints lots of useful debug information in case of failure.
|
| +
|
| + Args:
|
| + host_port, device_port: The host and device ports to pair. Each may be
|
| + given as an integer (assumed to be a tcp port), or a string with
|
| + a named socket.
|
| + """
|
| + if isinstance(host_port, numbers.Integral):
|
| + host_port = 'tcp:%d' % host_port
|
| + if isinstance(device_port, numbers.Integral):
|
| + device_port = 'tcp:%d' % device_port
|
| + try:
|
| + self._device.adb.Forward(host_port, device_port)
|
| + logging.info('Forwarding host %s to device %s.', host_port, device_port)
|
| + except Exception:
|
| + logging.exception('Failed to forward %s to %s.', host_port, device_port)
|
| + logging.warning('Currently forwarding:')
|
| + try:
|
| + for line in self._device.adb.ForwardList().splitlines():
|
| + logging.warning(' %s', line)
|
| + except Exception:
|
| + logging.warning('Exception raised while listing forwarded connections.')
|
| +
|
| + logging.warning('Host tcp ports in use:')
|
| + try:
|
| + for line in subprocess.check_output(['netstat', '-t']).splitlines():
|
| + logging.warning(' %s', line)
|
| + except Exception:
|
| + logging.warning('Exception raised while listing tcp ports.')
|
| +
|
| + logging.warning('Device unix domain sockets in use:')
|
| + try:
|
| + for line in self._device.ReadFile('/proc/net/unix', as_root=True,
|
| + force_pull=True).splitlines():
|
| + logging.warning(' %s', line)
|
| + except Exception:
|
| + logging.warning('Exception raised while listing unix domain sockets.')
|
| +
|
| + raise # Re-raise the exception.
|
|
|
| def StopForwardingHost(self, host_port):
|
| for line in self._device.adb.ForwardList().strip().splitlines():
|
|
|