summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/android/pylib/ports.py3
-rw-r--r--tools/chrome_remote_control/chrome_remote_control/adb_commands.py37
-rw-r--r--tools/chrome_remote_control/chrome_remote_control/android_browser_backend.py2
-rw-r--r--tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py6
4 files changed, 16 insertions, 32 deletions
diff --git a/build/android/pylib/ports.py b/build/android/pylib/ports.py
index e9b6b90..06b9f58 100644
--- a/build/android/pylib/ports.py
+++ b/build/android/pylib/ports.py
@@ -51,7 +51,8 @@ def AllocateTestServerPort():
fp_lock = open(constants.TEST_SERVER_PORT_LOCKFILE, 'w')
fcntl.flock(fp_lock, fcntl.LOCK_EX)
# Get current valid port and calculate next valid port.
- assert os.path.exists(constants.TEST_SERVER_PORT_FILE)
+ if not os.path.exists(constants.TEST_SERVER_PORT_FILE):
+ ResetTestServerPortAllocation()
with open(constants.TEST_SERVER_PORT_FILE, 'r+') as fp:
port = int(fp.read())
ports_tried.append(port)
diff --git a/tools/chrome_remote_control/chrome_remote_control/adb_commands.py b/tools/chrome_remote_control/chrome_remote_control/adb_commands.py
index 2cdea47..d0a3528 100644
--- a/tools/chrome_remote_control/chrome_remote_control/adb_commands.py
+++ b/tools/chrome_remote_control/chrome_remote_control/adb_commands.py
@@ -119,12 +119,12 @@ class AdbCommands(object):
def IsRootEnabled(self):
return self._adb.IsRootEnabled()
-def HasForwarder(adb):
- return adb.FileExistsOnDevice('/data/local/tmp/forwarder')
-
-def HowToInstallForwarder():
- return 'adb push out/$BUILD_TYPE/forwarder %s' % (
- '/data/local/tmp/forwarder')
+def HasForwarder(adb, buildtype=None):
+ if not buildtype:
+ return (HasForwarder(adb, buildtype='Release') or
+ HasForwarder(adb, buildtype='Debug'))
+ return (os.path.exists(os.path.join('out', buildtype, 'device_forwarder')) and
+ os.path.exists(os.path.join('out', buildtype, 'host_forwarder')))
class Forwarder(object):
def __init__(self, adb, host_port):
@@ -134,27 +134,12 @@ class Forwarder(object):
tool = valgrind_tools.BaseTool()
self._host_port = host_port
-
- # Currently, Forwarder requires that ../out/Debug/forwarder exists,
- # in case it needs to push it to the device. However, to get to here,
- # android_browser_finder has ensured that device HasForwarder, above.
- #
- # Therefore, here, we just need to instantiate the forwarder, no push
- # needed.
- #
- # To do this, we monkey patch adb.PushIfNeeded to a noop.
- #
- # TODO(nduca): Fix build.android.pylib.Forwarder to not need this.
- real_push_if_needed = adb.Adb().PushIfNeeded
- def FakePush(_, device_path):
- assert adb.FileExistsOnDevice(device_path)
- try:
- adb.Adb().PushIfNeeded = FakePush
- self._forwarder = forwarder.Forwarder(
+ buildtype = 'Debug'
+ if HasForwarder(adb, 'Release'):
+ buildtype = 'Release'
+ self._forwarder = forwarder.Forwarder(
adb.Adb(), port_pairs,
- tool, 'localhost', 'unused')
- finally:
- adb.Adb().PushIfNeeded = real_push_if_needed
+ tool, '127.0.0.1', buildtype)
self._device_port = self._forwarder.DevicePortForHostPort(self._host_port)
@property
diff --git a/tools/chrome_remote_control/chrome_remote_control/android_browser_backend.py b/tools/chrome_remote_control/chrome_remote_control/android_browser_backend.py
index 961501c..223b8c8 100644
--- a/tools/chrome_remote_control/chrome_remote_control/android_browser_backend.py
+++ b/tools/chrome_remote_control/chrome_remote_control/android_browser_backend.py
@@ -26,7 +26,7 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend):
# Kill old browser.
self._adb.KillAll(self._package)
- self._adb.KillAll('forwarder')
+ self._adb.KillAll('device_forwarder')
self._adb.Forward('tcp:9222', self._devtools_remote_port)
# Chrome Android doesn't listen to --user-data-dir.
diff --git a/tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py b/tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py
index 92c6a28..ec12c90 100644
--- a/tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py
+++ b/tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py
@@ -136,11 +136,9 @@ def FindAllAvailableBrowsers(options, logging=real_logging):
# but make it accessible to the device.
if len(possible_browsers) and not adb_commands.HasForwarder(adb):
logging.warn('chrome_remote_control detected an android device. However,')
- logging.warn('Chrome\'s port-forwarder app is not installed on the device.')
+ logging.warn('Chrome\'s port-forwarder app is not available.')
logging.warn('To build:')
- logging.warn(' make -j16 out/$BUILDTYPE/forwarder')
- logging.warn('And then install it:')
- logging.warn(' %s', adb_commands.HowToInstallForwarder())
+ logging.warn(' make -j16 host_forwarder device_forwarder')
logging.warn('')
logging.warn('')
return []