1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
8 from telemetry.core import util
9 from telemetry.core.backends.chrome import android_browser_finder
10 from telemetry.core.platform import profiler
12 class AndroidScreenRecordingProfiler(profiler.Profiler):
13 """Captures a screen recording on Android."""
15 def __init__(self, browser_backend, platform_backend, output_path, state):
16 super(AndroidScreenRecordingProfiler, self).__init__(
17 browser_backend, platform_backend, output_path, state)
18 self._output_path = output_path + '.mp4'
19 self._recorder = subprocess.Popen(
20 [os.path.join(util.GetChromiumSrcDir(), 'build', 'android',
23 '--file', self._output_path,
24 '--device', browser_backend.adb.device()],
25 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
29 return 'android-screen-recorder'
32 def is_supported(cls, browser_type):
33 if browser_type == 'any':
34 return android_browser_finder.CanFindAvailableBrowsers()
35 return browser_type.startswith('android')
37 def CollectProfile(self):
38 self._recorder.communicate(input='\n')
40 print 'Screen recording saved as %s' % self._output_path
41 print 'To view, open in Chrome or a video player'
42 return [self._output_path]