diff options
author | Jamie Gennis <jgennis@google.com> | 2013-06-03 16:40:54 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2013-06-03 16:55:21 -0700 |
commit | 664f21bcaf14044e5e9b09cb7beb8724d18fb851 (patch) | |
tree | 7ad51a517d59c4442c0404317e559676afef9ee7 /systrace.py | |
parent | 18bb528287dd9407583346b9826de4a433481131 (diff) | |
download | chromium-trace-664f21bcaf14044e5e9b09cb7beb8724d18fb851.tar.gz |
systrace: add support for older platform versions.
This change re-adds the old Systrace script from before JB MR2 and exec's it
from systrace.py when it detects that the device's SDK-version is less than 18.
This change also modifies the pre-JB-MR2 script to generate HTML that is
compatible with the latest script.js and style.css.
Change-Id: I29c3327e95f8fd0a4aab730845abac84e66848ef
Diffstat (limited to 'systrace.py')
-rwxr-xr-x | systrace.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/systrace.py b/systrace.py index 3b2585ed..41d0cba5 100755 --- a/systrace.py +++ b/systrace.py @@ -15,12 +15,46 @@ import errno, optparse, os, select, subprocess, sys, time, zlib flattened_css_file = 'style.css' flattened_js_file = 'script.js' +class OptionParserIgnoreErrors(optparse.OptionParser): + def error(self, msg): + pass + + def exit(self): + pass + + def print_usage(self): + pass + + def print_help(self): + pass + + def print_version(self): + pass + +def get_device_sdk_version(): + getprop_args = ['adb', 'shell', 'getprop', 'ro.build.version.sdk'] + + parser = OptionParserIgnoreErrors() + parser.add_option('-e', '--serial', dest='device_serial', type='string') + options, args = parser.parse_args() + if options.device_serial is not None: + getprop_args[1:1] = ['-s', options.device_serial] + + version = subprocess.check_output(getprop_args) + + return int(version) + def add_adb_serial(command, serial): if serial != None: command.insert(1, serial) command.insert(1, '-s') def main(): + device_sdk_version = get_device_sdk_version() + if device_sdk_version < 18: + legacy_script = os.path.join(os.path.dirname(sys.argv[0]), 'systrace-legacy.py') + os.execv(legacy_script, sys.argv) + usage = "Usage: %prog [options] [category1 [category2 ...]]" desc = "Example: %prog -b 32768 -t 15 gfx input view sched freq" parser = optparse.OptionParser(usage=usage, description=desc) |