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

Side by Side Diff: build/android/screenshot.py

Issue 386053002: [Android] Switch to DeviceUtils versions of GetPid, TakeScreenshot, and GetIoStats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « build/android/pylib/screenshot.py ('k') | tools/android/adb_profile_chrome/perf_controller.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Takes a screenshot or a screen video capture from an Android device.""" 7 """Takes a screenshot or a screen video capture from an Android device."""
8 8
9 import logging 9 import logging
10 import optparse 10 import optparse
11 import os 11 import os
12 import sys 12 import sys
13 13
14 from pylib import android_commands 14 from pylib import android_commands
15 from pylib import screenshot 15 from pylib import screenshot
16 from pylib.device import device_utils 16 from pylib.device import device_utils
17 17
18 def _PrintMessage(heading, eol='\n'): 18 def _PrintMessage(heading, eol='\n'):
19 sys.stdout.write('%s%s' % (heading, eol)) 19 sys.stdout.write('%s%s' % (heading, eol))
20 sys.stdout.flush() 20 sys.stdout.flush()
21 21
22 22
23 def _CaptureScreenshot(device, host_file): 23 def _CaptureScreenshot(device, host_file):
24 host_file = device.old_interface.TakeScreenshot(host_file) 24 host_file = device.TakeScreenshot(host_file)
25 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file)) 25 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file))
26 26
27 27
28 def _CaptureVideo(device, host_file, options): 28 def _CaptureVideo(device, host_file, options):
29 size = tuple(map(int, options.size.split('x'))) if options.size else None 29 size = tuple(map(int, options.size.split('x'))) if options.size else None
30 recorder = screenshot.VideoRecorder(device, 30 recorder = screenshot.VideoRecorder(device,
31 megabits_per_second=options.bitrate, 31 megabits_per_second=options.bitrate,
32 size=size, 32 size=size,
33 rotate=options.rotate) 33 rotate=options.rotate)
34 try: 34 try:
35 recorder.Start() 35 recorder.Start()
36 _PrintMessage('Recording. Press Enter to stop...', eol='') 36 _PrintMessage('Recording. Press Enter to stop...', eol='')
37 raw_input() 37 raw_input()
38 finally: 38 finally:
39 recorder.Stop() 39 recorder.Stop()
40 recorder.Pull(host_file) 40 host_file = recorder.Pull(host_file)
41 _PrintMessage('Video written to %s' % os.path.abspath(host_file)) 41 _PrintMessage('Video written to %s' % os.path.abspath(host_file))
42 42
43 43
44 def main(): 44 def main():
45 # Parse options. 45 # Parse options.
46 parser = optparse.OptionParser(description=__doc__, 46 parser = optparse.OptionParser(description=__doc__,
47 usage='screenshot.py [options] [filename]') 47 usage='screenshot.py [options] [filename]')
48 parser.add_option('-d', '--device', metavar='ANDROID_DEVICE', help='Serial ' 48 parser.add_option('-d', '--device', metavar='ANDROID_DEVICE', help='Serial '
49 'number of Android device to use.', default=None) 49 'number of Android device to use.', default=None)
50 parser.add_option('-f', '--file', help='Save result to file instead of ' 50 parser.add_option('-f', '--file', help='Save result to file instead of '
(...skipping 29 matching lines...) Expand all
80 80
81 if options.video: 81 if options.video:
82 _CaptureVideo(device, host_file, options) 82 _CaptureVideo(device, host_file, options)
83 else: 83 else:
84 _CaptureScreenshot(device, host_file) 84 _CaptureScreenshot(device, host_file)
85 return 0 85 return 0
86 86
87 87
88 if __name__ == '__main__': 88 if __name__ == '__main__':
89 sys.exit(main()) 89 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/screenshot.py ('k') | tools/android/adb_profile_chrome/perf_controller.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698