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

Unified Diff: build/android/tombstones.py

Issue 221823011: [Android] Change object types from AndroidCommands to DeviceUtils in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « build/android/surface_stats.py ('k') | build/android/update_verification.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/tombstones.py
diff --git a/build/android/tombstones.py b/build/android/tombstones.py
index e1192d77df8a4fbba0b97ea0de7448540fdfac61..cb1d700ee099de110e4ac730c73d6a36c79d8441 100755
--- a/build/android/tombstones.py
+++ b/build/android/tombstones.py
@@ -17,18 +17,20 @@ import sys
import optparse
from pylib import android_commands
+from pylib.device import device_utils
-def _ListTombstones(adb):
+def _ListTombstones(device):
"""List the tombstone files on the device.
Args:
- adb: An instance of AndroidCommands.
+ device: An instance of DeviceUtils.
Yields:
Tuples of (tombstone filename, date time of file on device).
"""
- lines = adb.RunShellCommand('TZ=UTC su -c ls -a -l /data/tombstones')
+ lines = device.old_interface.RunShellCommand(
+ 'TZ=UTC su -c ls -a -l /data/tombstones')
for line in lines:
if 'tombstone' in line and not 'No such file or directory' in line:
details = line.split()
@@ -37,39 +39,43 @@ def _ListTombstones(adb):
yield details[-1], t
-def _GetDeviceDateTime(adb):
+def _GetDeviceDateTime(device):
"""Determine the date time on the device.
Args:
- adb: An instance of AndroidCommands.
+ device: An instance of DeviceUtils.
Returns:
A datetime instance.
"""
- device_now_string = adb.RunShellCommand('TZ=UTC date')
+ device_now_string = device.old_interface.RunShellCommand('TZ=UTC date')
return datetime.datetime.strptime(
device_now_string[0], '%a %b %d %H:%M:%S %Z %Y')
-def _GetTombstoneData(adb, tombstone_file):
+def _GetTombstoneData(device, tombstone_file):
"""Retrieve the tombstone data from the device
Args:
+ device: An instance of DeviceUtils.
tombstone_file: the tombstone to retrieve
Returns:
A list of lines
"""
- return adb.GetProtectedFileContents('/data/tombstones/' + tombstone_file)
+ return device.old_interface.GetProtectedFileContents(
+ '/data/tombstones/' + tombstone_file)
-def _EraseTombstone(adb, tombstone_file):
+def _EraseTombstone(device, tombstone_file):
"""Deletes a tombstone from the device.
Args:
+ device: An instance of DeviceUtils.
tombstone_file: the tombstone to delete.
"""
- return adb.RunShellCommandWithSU('rm /data/tombstones/' + tombstone_file)
+ return device.old_interface.RunShellCommandWithSU(
+ 'rm /data/tombstones/' + tombstone_file)
def _ResolveSymbols(tombstone_data, include_stack):
@@ -125,15 +131,15 @@ def _ResolveTombstones(jobs, tombstones):
print '\n'.join(data)
-def _GetTombstonesForDevice(adb, options):
- """Returns a list of tombstones on a given adb connection.
+def _GetTombstonesForDevice(device, options):
+ """Returns a list of tombstones on a given device.
Args:
- adb: An instance of Androidcommands.
+ device: An instance of DeviceUtils.
options: command line arguments from OptParse
"""
ret = []
- all_tombstones = list(_ListTombstones(adb))
+ all_tombstones = list(_ListTombstones(device))
if not all_tombstones:
print 'No device attached? Or no tombstones?'
return ret
@@ -144,19 +150,19 @@ def _GetTombstonesForDevice(adb, options):
# Only resolve the most recent unless --all-tombstones given.
tombstones = all_tombstones if options.all_tombstones else [all_tombstones[0]]
- device_now = _GetDeviceDateTime(adb)
+ device_now = _GetDeviceDateTime(device)
for tombstone_file, tombstone_time in tombstones:
- ret += [{'serial': adb.Adb().GetSerialNumber(),
+ ret += [{'serial': device.old_interface.Adb().GetSerialNumber(),
'device_now': device_now,
'time': tombstone_time,
'file': tombstone_file,
'stack': options.stack,
- 'data': _GetTombstoneData(adb, tombstone_file)}]
+ 'data': _GetTombstoneData(device, tombstone_file)}]
# Erase all the tombstones if desired.
if options.wipe_tombstones:
for tombstone_file, _ in all_tombstones:
- _EraseTombstone(adb, tombstone_file)
+ _EraseTombstone(device, tombstone_file)
return ret
@@ -184,9 +190,9 @@ def main():
devices = android_commands.GetAttachedDevices()
tombstones = []
- for device in devices:
- adb = android_commands.AndroidCommands(device)
- tombstones += _GetTombstonesForDevice(adb, options)
+ for device_serial in devices:
+ device = device_utils.DeviceUtils(device_serial)
+ tombstones += _GetTombstonesForDevice(device, options)
_ResolveTombstones(options.jobs, tombstones)
« no previous file with comments | « build/android/surface_stats.py ('k') | build/android/update_verification.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698