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

Unified Diff: tools/telemetry/telemetry/core/platform/profiler/tcpdump_profiler.py

Issue 1145153005: Revert of [Android] Remove adb_commands from telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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/telemetry/telemetry/core/platform/profiler/tcpdump_profiler.py
diff --git a/tools/telemetry/telemetry/core/platform/profiler/tcpdump_profiler.py b/tools/telemetry/telemetry/core/platform/profiler/tcpdump_profiler.py
index 16962c82f53988658494b46d7ea3d42b5d3a9d85..6ad22c4e664257c1c06746506e4eb3be2b9e1b40 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/tcpdump_profiler.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/tcpdump_profiler.py
@@ -2,20 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import logging
import os
import signal
import subprocess
import sys
import tempfile
-from telemetry.core import util
from telemetry.core.platform import profiler
from telemetry.core.platform.profiler import android_prebuilt_profiler_helper
-
-util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android')
-from pylib import device_signal # pylint: disable=import-error
-from pylib.device import device_errors # pylint: disable=import-error
_TCP_DUMP_BASE_OPTS = ['-i', 'any', '-p', '-s', '0', '-w']
@@ -29,30 +23,28 @@
_DEVICE_DUMP_FILE = '/sdcard/tcpdump_profiles/capture.pcap'
- def __init__(self, device, output_path):
- self._device = device
+ def __init__(self, adb, output_path):
+ self._adb = adb
self._output_path = output_path
- self._device.RunShellCommand('mkdir -p ' +
- os.path.dirname(self._DEVICE_DUMP_FILE))
+ self._adb.RunShellCommand('mkdir -p ' +
+ os.path.dirname(self._DEVICE_DUMP_FILE))
self._proc = subprocess.Popen(
- ['adb', '-s', self._device.adb.GetDeviceSerial(),
+ ['adb', '-s', self._adb.device_serial(),
'shell', android_prebuilt_profiler_helper.GetDevicePath('tcpdump')] +
_TCP_DUMP_BASE_OPTS +
[self._DEVICE_DUMP_FILE])
def CollectProfile(self):
- try:
- self._device.KillAll('tcpdump', signum=device_signal.SIGTERM)
- except device_errors.CommandFailedError:
- logging.exception('Unable to kill TCPDump.')
+ tcpdump_pid = self._adb.ExtractPid('tcpdump')
+ if not tcpdump_pid or not tcpdump_pid[0]:
raise Exception('Unable to find TCPDump. Check your device is rooted '
'and tcpdump is installed at ' +
android_prebuilt_profiler_helper.GetDevicePath('tcpdump'))
-
+ self._adb.RunShellCommand('kill -term ' + tcpdump_pid[0])
self._proc.terminate()
host_dump = os.path.join(self._output_path,
os.path.basename(self._DEVICE_DUMP_FILE))
- self._device.PullFile(self._DEVICE_DUMP_FILE, host_dump)
+ self._adb.device().PullFile(self._DEVICE_DUMP_FILE, host_dump)
print 'TCP dump available at: %s ' % host_dump
print 'Use Wireshark to open it.'
return host_dump
@@ -106,9 +98,9 @@
browser_backend, platform_backend, output_path, state)
if platform_backend.GetOSName() == 'android':
android_prebuilt_profiler_helper.InstallOnDevice(
- browser_backend.device, 'tcpdump')
+ browser_backend.adb.device(), 'tcpdump')
self._platform_profiler = _TCPDumpProfilerAndroid(
- browser_backend.device, output_path)
+ browser_backend.adb, output_path)
else:
self._platform_profiler = _TCPDumpProfilerLinux(output_path)

Powered by Google App Engine
This is Rietveld 408576698