summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjbudorick@chromium.org <jbudorick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 18:59:30 +0000
committerjbudorick@chromium.org <jbudorick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 18:59:30 +0000
commitf0f4b9730e547189baa999f657179d3756297d0c (patch)
tree2c7ab002938b40f6650d9d1cee573642dcd66b37 /tools
parent4c0bb96313936a342a73705c64b6b929abd5c185 (diff)
downloadchromium_src-f0f4b9730e547189baa999f657179d3756297d0c.zip
chromium_src-f0f4b9730e547189baa999f657179d3756297d0c.tar.gz
chromium_src-f0f4b9730e547189baa999f657179d3756297d0c.tar.bz2
[Android] Switch to DeviceUtils version of RunShellCommand.
BUG=267773 Review URL: https://codereview.chromium.org/333933003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/android/adb_profile_chrome/perf_controller.py5
-rw-r--r--tools/android/adb_profile_chrome/systrace_controller.py2
-rw-r--r--tools/memory_inspector/memory_inspector/backends/android/android_backend.py15
-rw-r--r--tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py25
-rw-r--r--tools/telemetry/telemetry/core/forwarders/android_forwarder.py10
-rw-r--r--tools/telemetry/telemetry/core/platform/android_platform_backend.py9
-rw-r--r--tools/telemetry/telemetry/core/platform/power_monitor/android_ds2784_power_monitor.py4
-rw-r--r--tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py2
-rw-r--r--tools/telemetry/telemetry/core/platform/profiler/android_prebuilt_profiler_helper.py2
-rw-r--r--tools/telemetry/telemetry/core/platform/profiler/android_profiling_helper.py2
-rw-r--r--tools/telemetry/telemetry/core/platform/profiler/netlog_profiler.py3
-rw-r--r--tools/telemetry/telemetry/core/platform/profiler/perf_profiler.py3
-rw-r--r--tools/telemetry/telemetry/core/platform/profiler/v8_profiler.py3
13 files changed, 39 insertions, 46 deletions
diff --git a/tools/android/adb_profile_chrome/perf_controller.py b/tools/android/adb_profile_chrome/perf_controller.py
index 064300d..523fb85 100644
--- a/tools/android/adb_profile_chrome/perf_controller.py
+++ b/tools/android/adb_profile_chrome/perf_controller.py
@@ -65,8 +65,7 @@ class _PerfProfiler(object):
def SignalAndWait(self):
perf_pids = self._device.old_interface.ExtractPid('perf')
- self._device.old_interface.RunShellCommand(
- 'kill -SIGINT ' + ' '.join(perf_pids))
+ self._device.RunShellCommand('kill -SIGINT ' + ' '.join(perf_pids))
self._perf_process.wait()
self._perf_control.ForceAllCpusOnline(False)
@@ -117,7 +116,7 @@ class PerfProfilerController(controllers.BaseController):
@classmethod
def GetCategories(cls, device):
perf_binary = cls._PrepareDevice(device)
- return device.old_interface.RunShellCommand('%s list' % perf_binary)
+ return device.RunShellCommand('%s list' % perf_binary)
def StartTracing(self, _):
self._perf_instance = _PerfProfiler(self._device,
diff --git a/tools/android/adb_profile_chrome/systrace_controller.py b/tools/android/adb_profile_chrome/systrace_controller.py
index 369bc88..3ec4cc7 100644
--- a/tools/android/adb_profile_chrome/systrace_controller.py
+++ b/tools/android/adb_profile_chrome/systrace_controller.py
@@ -37,7 +37,7 @@ class SystraceController(controllers.BaseController):
@staticmethod
def GetCategories(device):
- return device.old_interface.RunShellCommand('atrace --list_categories')
+ return device.RunShellCommand('atrace --list_categories')
def StartTracing(self, _):
self._thread = threading.Thread(target=self._CollectData)
diff --git a/tools/memory_inspector/memory_inspector/backends/android/android_backend.py b/tools/memory_inspector/memory_inspector/backends/android/android_backend.py
index ef022155..2116bb6 100644
--- a/tools/memory_inspector/memory_inspector/backends/android/android_backend.py
+++ b/tools/memory_inspector/memory_inspector/backends/android/android_backend.py
@@ -260,8 +260,7 @@ class AndroidDevice(backends.Device):
return self._sys_stats
dump_out = '\n'.join(
- self.underlying_device.old_interface.RunShellCommand(
- _PSEXT_PATH_ON_DEVICE))
+ self.underlying_device.RunShellCommand(_PSEXT_PATH_ON_DEVICE))
stats = json.loads(dump_out)
assert(all([x in stats for x in ['cpu', 'processes', 'time', 'mem']])), (
'ps_ext returned a malformed JSON dictionary.')
@@ -288,13 +287,12 @@ class AndroidDevice(backends.Device):
prebuilts_fetcher.GetIfChanged(local_path)
with open(local_path, 'rb') as f:
local_hash = hashlib.md5(f.read()).hexdigest()
- device_md5_out = self.underlying_device.old_interface.RunShellCommand(
+ device_md5_out = self.underlying_device.RunShellCommand(
'md5 "%s"' % path_on_device)
if local_hash in device_md5_out:
return
self.underlying_device.old_interface.Adb().Push(local_path, path_on_device)
- self.underlying_device.old_interface.RunShellCommand(
- 'chmod 755 "%s"' % path_on_device)
+ self.underlying_device.RunShellCommand('chmod 755 "%s"' % path_on_device)
@property
def name(self):
@@ -317,7 +315,7 @@ class AndroidProcess(backends.Process):
def DumpMemoryMaps(self):
"""Grabs and parses memory maps through memdump."""
cmd = '%s %d' % (_MEMDUMP_PATH_ON_DEVICE, self.pid)
- dump_out = self.device.underlying_device.old_interface.RunShellCommand(cmd)
+ dump_out = self.device.underlying_device.RunShellCommand(cmd)
return memdump_parser.Parse(dump_out)
def DumpNativeHeap(self):
@@ -325,14 +323,13 @@ class AndroidProcess(backends.Process):
# TODO(primiano): grab also mmap bt (depends on pending framework change).
dump_file_path = _DUMPHEAP_OUT_FILE_PATH % self.pid
cmd = 'am dumpheap -n %d %s' % (self.pid, dump_file_path)
- self.device.underlying_device.old_interface.RunShellCommand(cmd)
+ self.device.underlying_device.RunShellCommand(cmd)
# TODO(primiano): Some pre-KK versions of Android might need a sleep here
# as, IIRC, 'am dumpheap' did not wait for the dump to be completed before
# returning. Double check this and either add a sleep or remove this TODO.
dump_out = self.device.underlying_device.old_interface.GetFileContents(
dump_file_path)
- self.device.underlying_device.old_interface.RunShellCommand(
- 'rm %s' % dump_file_path)
+ self.device.underlying_device.RunShellCommand('rm %s' % dump_file_path)
return dumpheap_native_parser.Parse(dump_out)
def GetStats(self):
diff --git a/tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py b/tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py
index 46fdd76..3ead0bf 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py
@@ -33,10 +33,11 @@ class AndroidBrowserBackendSettings(object):
raise NotImplementedError()
def RemoveProfile(self):
- files = self.adb.RunShellCommandWithSU('ls "%s"' % self.profile_dir)
+ files = self.adb.device().RunShellCommand(
+ 'ls "%s"' % self.profile_dir, root=True)
# Don't delete lib, since it is created by the installer.
paths = ['"%s/%s"' % (self.profile_dir, f) for f in files if f != 'lib']
- self.adb.RunShellCommandWithSU('rm -r %s' % ' '.join(paths))
+ self.adb.device().RunShellCommand('rm -r %s' % ' '.join(paths), root=True)
def PushProfile(self, _):
logging.critical('Profiles cannot be overriden with current configuration')
@@ -91,16 +92,18 @@ class ChromeBackendSettings(AndroidBrowserBackendSettings):
self.adb.device().old_interface.EfficientDeviceDirectoryCopy(
saved_profile_location, self.profile_dir)
- dumpsys = self.adb.RunShellCommand('dumpsys package %s' % self.package)
+ dumpsys = self.adb.device().RunShellCommand(
+ 'dumpsys package %s' % self.package)
id_line = next(line for line in dumpsys if 'userId=' in line)
uid = re.search('\d+', id_line).group()
- files = self.adb.RunShellCommandWithSU('ls "%s"' % self.profile_dir)
+ files = self.adb.device().RunShellCommand(
+ 'ls "%s"' % self.profile_dir, root=True)
files.remove('lib')
paths = ['%s/%s' % (self.profile_dir, f) for f in files]
for path in paths:
extended_path = '%s %s/* %s/*/* %s/*/*/*' % (path, path, path, path)
- self.adb.RunShellCommand('chown %s.%s %s' %
- (uid, uid, extended_path))
+ self.adb.device().RunShellCommand(
+ 'chown %s.%s %s' % (uid, uid, extended_path))
class ContentShellBackendSettings(AndroidBrowserBackendSettings):
def __init__(self, adb, package):
@@ -215,8 +218,8 @@ class AndroidBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
# Set the debug app if needed.
if self._adb.IsUserBuild():
logging.debug('User build device, setting debug app')
- self._adb.RunShellCommand('am set-debug-app --persistent %s' %
- self._backend_settings.package)
+ self._adb.device().RunShellCommand(
+ 'am set-debug-app --persistent %s' % self._backend_settings.package)
def _SetUpCommandLine(self):
def QuoteIfNeeded(arg):
@@ -272,7 +275,7 @@ class AndroidBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
def Start(self):
self._SetUpCommandLine()
- self._adb.RunShellCommand('logcat -c')
+ self._adb.device().RunShellCommand('logcat -c')
if self.browser_options.startup_url:
url = self.browser_options.startup_url
elif self.browser_options.profile_dir:
@@ -378,7 +381,7 @@ class AndroidBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
# pulled down is really needed e.g. .pak files.
if not os.path.exists(self._output_profile_path):
os.makedirs(self._output_profile_pathame)
- files = self.adb.RunShellCommandWithSU(
+ files = self.adb.device().RunShellCommand(
'ls "%s"' % self._backend_settings.profile_dir)
for f in files:
# Don't pull lib, since it is created by the installer.
@@ -400,7 +403,7 @@ class AndroidBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
return local_port
def GetStandardOutput(self):
- return '\n'.join(self._adb.RunShellCommand('logcat -d -t 500'))
+ return '\n'.join(self._adb.device().RunShellCommand('logcat -d -t 500'))
def GetStackTrace(self):
def Decorate(title, content):
diff --git a/tools/telemetry/telemetry/core/forwarders/android_forwarder.py b/tools/telemetry/telemetry/core/forwarders/android_forwarder.py
index 60138e4..4c542f5 100644
--- a/tools/telemetry/telemetry/core/forwarders/android_forwarder.py
+++ b/tools/telemetry/telemetry/core/forwarders/android_forwarder.py
@@ -184,7 +184,7 @@ class AndroidRndisConfigurator(object):
def _FindDeviceRndisInterface(self):
"""Returns the name of the RNDIS network interface if present."""
- config = self._device.old_interface.RunShellCommand('netcfg')
+ config = self._device.RunShellCommand('netcfg')
interfaces = [line.split()[0] for line in config]
candidates = [iface for iface in interfaces if re.match('rndis|usb', iface)]
if candidates:
@@ -257,8 +257,8 @@ doit &
'prefix': script_prefix }
self._device.old_interface.SetFileContents('%s.sh' % script_prefix, script)
# TODO(szym): run via su -c if necessary.
- self._device.old_interface.RunShellCommand('rm %s.log' % script_prefix)
- self._device.old_interface.RunShellCommand('. %s.sh' % script_prefix)
+ self._device.RunShellCommand('rm %s.log' % script_prefix)
+ self._device.RunShellCommand('. %s.sh' % script_prefix)
self._WaitForDevice()
result = self._device.old_interface.GetFileContents(
'%s.log' % script_prefix)
@@ -332,7 +332,7 @@ doit &
else:
excluded = 'no interfaces excluded on other devices'
addresses += [line.split()[2]
- for line in device.old_interface.RunShellCommand('netcfg')
+ for line in device.RunShellCommand('netcfg')
if excluded not in line]
return addresses
@@ -421,7 +421,7 @@ doit &
netmask = _Long2Ip(netmask)
# TODO(szym) run via su -c if necessary.
- self._device.old_interface.RunShellCommand(
+ self._device.RunShellCommand(
'ifconfig %s %s netmask %s up' % (device_iface, device_ip, netmask))
# Enabling the interface sometimes breaks adb.
self._WaitForDevice()
diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend.py b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
index 5115d59..5242cb4 100644
--- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
@@ -184,8 +184,7 @@ class AndroidPlatformBackend(
raise NotImplementedError()
def FlushDnsCache(self):
- self._device.old_interface.RunShellCommandWithSU(
- 'ndc resolver flushdefaultif')
+ self._device.RunShellCommand('ndc resolver flushdefaultif', root=True)
def LaunchApplication(
self, application, parameters=None, elevate_privilege=False):
@@ -197,8 +196,7 @@ class AndroidPlatformBackend(
raise NotImplementedError("elevate_privilege isn't supported on android.")
if not parameters:
parameters = ''
- self._device.old_interface.RunShellCommand(
- 'am start ' + parameters + ' ' + application)
+ self._device.RunShellCommand('am start ' + parameters + ' ' + application)
def IsApplicationRunning(self, application):
if application in _HOST_APPLICATIONS:
@@ -269,8 +267,7 @@ class AndroidPlatformBackend(
command = 'ps'
if pid:
command += ' -p %d' % pid
- ps = self._device.old_interface.RunShellCommand(
- command, log_result=False)[1:]
+ ps = self._device.RunShellCommand(command)[1:]
output = []
for line in ps:
data = line.split()
diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/android_ds2784_power_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/android_ds2784_power_monitor.py
index 8b66e89..8d4ae26 100644
--- a/tools/telemetry/telemetry/core/platform/power_monitor/android_ds2784_power_monitor.py
+++ b/tools/telemetry/telemetry/core/platform/power_monitor/android_ds2784_power_monitor.py
@@ -45,7 +45,7 @@ class DS2784PowerMonitor(power_monitor.PowerMonitor):
android_prebuilt_profiler_helper.InstallOnDevice(
self._device, 'file_poller')
self._powermonitor_process_port = int(
- self._device.old_interface.RunShellCommand(
+ self._device.RunShellCommand(
'%s %d %s %s %s' % (self._file_poller_binary, SAMPLE_RATE_HZ,
CHARGE_COUNTER, CURRENT, VOLTAGE))[0])
@@ -53,7 +53,7 @@ class DS2784PowerMonitor(power_monitor.PowerMonitor):
assert self._powermonitor_process_port, (
'StartMonitoringPower() not called.')
try:
- result = '\n'.join(self._device.old_interface.RunShellCommand(
+ result = '\n'.join(self._device.RunShellCommand(
'%s %d' % (self._file_poller_binary,
self._powermonitor_process_port)))
assert result, 'PowerMonitor produced no output'
diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py
index 15e80f0..9432d70 100644
--- a/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py
+++ b/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py
@@ -46,7 +46,7 @@ class DumpsysPowerMonitor(power_monitor.PowerMonitor):
package = self._browser._browser_backend.package
# By default, 'dumpsys batterystats' measures power consumption during the
# last unplugged period.
- result = self._device.old_interface.RunShellCommand(
+ result = self._device.RunShellCommand(
'dumpsys batterystats -c %s' % package)
assert result, 'Dumpsys produced no output'
return DumpsysPowerMonitor.ParseSamplingOutput(package, result)
diff --git a/tools/telemetry/telemetry/core/platform/profiler/android_prebuilt_profiler_helper.py b/tools/telemetry/telemetry/core/platform/profiler/android_prebuilt_profiler_helper.py
index fa838ea..6d689d1 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/android_prebuilt_profiler_helper.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/android_prebuilt_profiler_helper.py
@@ -28,6 +28,6 @@ def InstallOnDevice(device, profiler_binary):
device_binary_path = GetDevicePath(profiler_binary)
device.old_interface.PushIfNeeded(host_path, device_binary_path)
- device.old_interface.RunShellCommand('chmod 777 ' + device_binary_path)
+ device.RunShellCommand('chmod 777 ' + device_binary_path)
return True
diff --git a/tools/telemetry/telemetry/core/platform/profiler/android_profiling_helper.py b/tools/telemetry/telemetry/core/platform/profiler/android_profiling_helper.py
index f2e2144..8b64093 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/android_profiling_helper.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/android_profiling_helper.py
@@ -36,7 +36,7 @@ def _ElfSectionMd5Sum(elf_file, section):
def _FindMatchingUnstrippedLibraryOnHost(device, lib):
lib_base = os.path.basename(lib)
- device_md5 = device.old_interface.RunShellCommandWithSU('md5 "%s"' % lib)[0]
+ device_md5 = device.RunShellCommand('md5 "%s"' % lib, root=True)[0]
device_md5 = device_md5.split(' ', 1)[0]
def FindMatchingStrippedLibrary(out_path):
diff --git a/tools/telemetry/telemetry/core/platform/profiler/netlog_profiler.py b/tools/telemetry/telemetry/core/platform/profiler/netlog_profiler.py
index c3d8ef0..0e3115a 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/netlog_profiler.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/netlog_profiler.py
@@ -38,8 +38,7 @@ class NetLogProfiler(profiler.Profiler):
self._browser_backend.adb.device().old_interface.Adb().Pull(
output_file, host_output_file)
# Clean the device
- self._browser_backend.adb.device().old_interface.RunShellCommand(
- 'rm %s' % output_file)
+ self._browser_backend.adb.device().RunShellCommand('rm %s' % output_file)
output_file = host_output_file
print 'Net-internals log saved as %s' % output_file
print 'To view, open in chrome://net-internals'
diff --git a/tools/telemetry/telemetry/core/platform/profiler/perf_profiler.py b/tools/telemetry/telemetry/core/platform/profiler/perf_profiler.py
index f32eba3..6b460d9 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/perf_profiler.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/perf_profiler.py
@@ -101,8 +101,7 @@ class _SingleProcessPerfProfiler(object):
if self._is_android:
device = self._browser_backend.adb.device()
perf_pids = device.old_interface.ExtractPid('perf')
- device.old_interface.RunShellCommand(
- 'kill -SIGINT ' + ' '.join(perf_pids))
+ device.RunShellCommand('kill -SIGINT ' + ' '.join(perf_pids))
util.WaitFor(lambda: not device.old_interface.ExtractPid('perf'),
timeout=2)
self._proc.send_signal(signal.SIGINT)
diff --git a/tools/telemetry/telemetry/core/platform/profiler/v8_profiler.py b/tools/telemetry/telemetry/core/platform/profiler/v8_profiler.py
index a804cfe..e29bb07 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/v8_profiler.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/v8_profiler.py
@@ -40,8 +40,7 @@ class V8Profiler(profiler.Profiler):
self._browser_backend.adb.device().old_interface.Adb().Pull(
output_file, host_output_file)
# Clean the device
- self._browser_backend.adb.device().old_interface.RunShellCommand(
- 'rm %s' % output_file)
+ self._browser_backend.adb.device().RunShellCommand('rm %s' % output_file)
output_file = host_output_file
print 'V8 profile saved as %s' % output_file
print 'To view, open in ' \