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

Unified Diff: tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py

Issue 11361165: [chrome_remote_control] Rename chrome_remote_control to telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
Index: tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py
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
deleted file mode 100644
index a0d4b04da800467fdc61a9af0267197d6e8c11a1..0000000000000000000000000000000000000000
--- a/tools/chrome_remote_control/chrome_remote_control/android_browser_finder.py
+++ /dev/null
@@ -1,149 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-"""Finds android browsers that can be controlled by chrome_remote_control."""
-
-import os
-import logging as real_logging
-import re
-import subprocess
-
-from chrome_remote_control import adb_commands
-from chrome_remote_control import android_browser_backend
-from chrome_remote_control import android_platform
-from chrome_remote_control import browser
-from chrome_remote_control import possible_browser
-
-ALL_BROWSER_TYPES = ','.join([
- 'android-content-shell',
- 'android-chrome',
- 'android-jb-system-chrome',
- ])
-
-CHROME_PACKAGE = 'com.google.android.apps.chrome'
-CHROME_ACTIVITY = '.Main'
-CHROME_COMMAND_LINE = '/data/local/chrome-command-line'
-CHROME_DEVTOOLS_REMOTE_PORT = 'localabstract:chrome_devtools_remote'
-
-CHROME_JB_SYSTEM_PACKAGE = 'com.android.chrome'
-CHROME_JB_SYSTEM_DEVTOOLS_REMOTE_PORT = 'localabstract:chrome_devtools_remote'
-
-CONTENT_SHELL_PACKAGE = 'org.chromium.content_shell'
-CONTENT_SHELL_ACTIVITY = '.ContentShellActivity'
-CONTENT_SHELL_COMMAND_LINE = '/data/local/tmp/content-shell-command-line'
-CONTENT_SHELL_DEVTOOLS_REMOTE_PORT = (
- 'localabstract:content_shell_devtools_remote')
-
-# adb shell pm list packages
-# adb
-# intents to run (pass -D url for the rest)
-# com.android.chrome/.Main
-# com.google.android.apps.chrome/.Main
-
-class PossibleAndroidBrowser(possible_browser.PossibleBrowser):
- """A launchable android browser instance."""
- def __init__(self, browser_type, options, *args):
- super(PossibleAndroidBrowser, self).__init__(
- browser_type, options)
- self._args = args
-
- def __repr__(self):
- return 'PossibleAndroidBrowser(browser_type=%s)' % self.browser_type
-
- def Create(self):
- backend = android_browser_backend.AndroidBrowserBackend(
- self._options, *self._args)
- platform = android_platform.AndroidPlatform(
- self._args[0].Adb(), self._args[1],
- self._args[1] + self._args[4])
- return browser.Browser(backend, platform)
-
-def FindAllAvailableBrowsers(options, logging=real_logging):
- """Finds all the desktop browsers available on this machine."""
- if not adb_commands.IsAndroidSupported():
- return []
-
- # See if adb even works.
- try:
- with open(os.devnull, 'w') as devnull:
- proc = subprocess.Popen(['adb', 'devices'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- stdin=devnull)
- stdout, _ = proc.communicate()
- if re.search(re.escape('????????????\tno permissions'), stdout) != None:
- logging.warn(
- ('adb devices reported a permissions error. Consider '
- 'restarting adb as root:'))
- logging.warn(' adb kill-server')
- logging.warn(' sudo `which adb` devices\n\n')
- except OSError:
- logging.info('No adb command found. ' +
- 'Will not try searching for Android browsers.')
- return []
-
- device = None
- if not options.android_device:
- devices = adb_commands.GetAttachedDevices()
- else:
- devices = []
-
- if len(devices) == 0:
- logging.info('No android devices found.')
- return []
-
- if len(devices) > 1:
- logging.warn('Multiple devices attached. ' +
- 'Please specify a device explicitly.')
- return []
-
- device = devices[0]
-
- adb = adb_commands.AdbCommands(device=device)
-
- # See if adb is root
- if not adb.IsRootEnabled():
- logging.warn('ADB is not root. Please make it root by doing:')
- logging.warn(' adb root')
- return []
-
- packages = adb.RunShellCommand('pm list packages')
- possible_browsers = []
- if 'package:' + CONTENT_SHELL_PACKAGE in packages:
- b = PossibleAndroidBrowser('android-content-shell',
- options, adb,
- CONTENT_SHELL_PACKAGE, True,
- CONTENT_SHELL_COMMAND_LINE,
- CONTENT_SHELL_ACTIVITY,
- CONTENT_SHELL_DEVTOOLS_REMOTE_PORT)
- possible_browsers.append(b)
-
- if 'package:' + CHROME_PACKAGE in packages:
- b = PossibleAndroidBrowser('android-chrome',
- options, adb,
- CHROME_PACKAGE, False,
- CHROME_COMMAND_LINE,
- CHROME_ACTIVITY,
- CHROME_DEVTOOLS_REMOTE_PORT)
- possible_browsers.append(b)
-
- if 'package:' + CHROME_JB_SYSTEM_PACKAGE in packages:
- b = PossibleAndroidBrowser('android-jb-system-chrome',
- options, adb,
- CHROME_JB_SYSTEM_PACKAGE, False,
- CHROME_COMMAND_LINE,
- CHROME_ACTIVITY,
- CHROME_JB_SYSTEM_DEVTOOLS_REMOTE_PORT)
- possible_browsers.append(b)
-
- # See if the "forwarder" is installed -- we need this to host content locally
- # 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 available.')
- logging.warn('To build:')
- logging.warn(' make -j16 host_forwarder device_forwarder')
- logging.warn('')
- logging.warn('')
- return []
- return possible_browsers

Powered by Google App Engine
This is Rietveld 408576698