Commit 3a8cbce8 authored by tonyg@chromium.org's avatar tonyg@chromium.org

[Telemetry] Allow telemetry to run without adb root.

Without root the user must manually enable devtools debugging in settings. This
limitation is acceptable as we are able to detect it and instruct the user.

BUG=154415
TEST=Run a telemetry test on a production android image

Review URL: https://codereview.chromium.org/11784007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175353 0039d316-1c4b-4281-b951-d872f2087c98
parent d2b0ae0d
...@@ -78,6 +78,15 @@ class AdbCommands(object): ...@@ -78,6 +78,15 @@ class AdbCommands(object):
""" """
return self._adb.RunShellCommand(command, timeout_time, log_result) return self._adb.RunShellCommand(command, timeout_time, log_result)
def CloseApplication(self, package):
"""Attempt to close down the application, using increasing violence.
Args:
package: Name of the process to kill off, e.g.
com.google.android.apps.chrome
"""
self._adb.CloseApplication(package)
def KillAll(self, process): def KillAll(self, process):
"""Android version of killall, connected via adb. """Android version of killall, connected via adb.
......
...@@ -5,6 +5,7 @@ import json ...@@ -5,6 +5,7 @@ import json
import logging import logging
import os import os
import subprocess import subprocess
import sys
import tempfile import tempfile
from telemetry import adb_commands from telemetry import adb_commands
...@@ -29,7 +30,7 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend): ...@@ -29,7 +30,7 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend):
self._devtools_remote_port = devtools_remote_port self._devtools_remote_port = devtools_remote_port
# Kill old browser. # Kill old browser.
self._adb.KillAll(self._package) self._adb.CloseApplication(self._package)
self._adb.KillAll('device_forwarder') self._adb.KillAll('device_forwarder')
self._adb.Forward('tcp:%d' % self._port, self._devtools_remote_port) self._adb.Forward('tcp:%d' % self._port, self._devtools_remote_port)
...@@ -65,7 +66,7 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend): ...@@ -65,7 +66,7 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend):
self._adb.Push(f.name, cmdline_file) self._adb.Push(f.name, cmdline_file)
# Force devtools protocol on, if not already done. # Force devtools protocol on, if not already done.
if not is_content_shell: if not is_content_shell and self._adb.IsRootEnabled():
# Make sure we can find the apps' prefs file # Make sure we can find the apps' prefs file
app_data_dir = '/data/data/%s' % self._package app_data_dir = '/data/data/%s' % self._package
prefs_file = (app_data_dir + prefs_file = (app_data_dir +
...@@ -110,6 +111,13 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend): ...@@ -110,6 +111,13 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend):
try: try:
self._WaitForBrowserToComeUp() self._WaitForBrowserToComeUp()
self._PostBrowserStartupInitialization() self._PostBrowserStartupInitialization()
except browser_gone_exception.BrowserGoneException:
logging.critical('Failed to connect to browser.')
if not self._adb.IsRootEnabled():
logging.critical(
'Ensure web debugging is enabled in Chrome at '
'"Settings > Developer tools > Enable USB Web debugging".')
sys.exit(1)
except: except:
import traceback import traceback
traceback.print_exc() traceback.print_exc()
...@@ -128,7 +136,7 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend): ...@@ -128,7 +136,7 @@ class AndroidBrowserBackend(browser_backend.BrowserBackend):
super(AndroidBrowserBackend, self).Close() super(AndroidBrowserBackend, self).Close()
self._adb.RunShellCommand('rm %s' % self._cmdline_file) self._adb.RunShellCommand('rm %s' % self._cmdline_file)
self._adb.KillAll(self._package) self._adb.CloseApplication(self._package)
def IsBrowserRunning(self): def IsBrowserRunning(self):
pids = self._adb.ExtractPid(self._package) pids = self._adb.ExtractPid(self._package)
......
...@@ -103,12 +103,6 @@ def FindAllAvailableBrowsers(options, logging=real_logging): ...@@ -103,12 +103,6 @@ def FindAllAvailableBrowsers(options, logging=real_logging):
adb = adb_commands.AdbCommands(device=device) 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') packages = adb.RunShellCommand('pm list packages')
possible_browsers = [] possible_browsers = []
if 'package:' + CONTENT_SHELL_PACKAGE in packages: if 'package:' + CONTENT_SHELL_PACKAGE in packages:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment