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

Unified Diff: build/android/pylib/screenshot.py

Issue 234803006: [Android] Move screenshot implementation back into AndroidCommands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + default host_path=None 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/pylib/android_commands.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/screenshot.py
diff --git a/build/android/pylib/screenshot.py b/build/android/pylib/screenshot.py
index 228af88f2cb4e73b0ffc3a4e861627b6daf6d29e..edf149caa74e05275ef5fc9b699a0550c47ea691 100644
--- a/build/android/pylib/screenshot.py
+++ b/build/android/pylib/screenshot.py
@@ -4,7 +4,6 @@
import os
import tempfile
-import time
from pylib import cmd_helper
@@ -13,34 +12,6 @@ import pylib.android_commands
import pylib.device.device_utils
-def _GetTimestamp():
- return time.strftime('%Y-%m-%d-%H%M%S', time.localtime())
-
-
-def _EnsureHostDirectory(host_file):
- host_dir = os.path.dirname(os.path.abspath(host_file))
- if not os.path.exists(host_dir):
- os.makedirs(host_dir)
-
-
-def TakeScreenshot(device, host_file):
- """Saves a screenshot image to |host_file| on the host.
-
- Args:
- device: DeviceUtils instance.
- host_file: Path to the image file to store on the host.
- """
- host_file = os.path.abspath(host_file or
- 'screenshot-%s.png' % _GetTimestamp())
- _EnsureHostDirectory(host_file)
- device_file = '%s/screenshot.png' % device.old_interface.GetExternalStorage()
- device.old_interface.RunShellCommand(
- '/system/bin/screencap -p %s' % device_file)
- device.old_interface.PullFileFromDevice(device_file, host_file)
- device.old_interface.RunShellCommand('rm -f "%s"' % device_file)
- return host_file
-
-
class VideoRecorder(object):
"""Records a screen capture video from an Android Device (KitKat or newer).
@@ -61,7 +32,8 @@ class VideoRecorder(object):
self._device = device
self._device_file = (
'%s/screen-recording.mp4' % device.old_interface.GetExternalStorage())
- self._host_file = host_file or 'screen-recording-%s.mp4' % _GetTimestamp()
+ self._host_file = host_file or ('screen-recording-%s.mp4' %
+ device.old_interface.GetTimestamp())
self._host_file = os.path.abspath(self._host_file)
self._recorder = None
self._recorder_pids = None
@@ -81,7 +53,7 @@ class VideoRecorder(object):
def Start(self):
"""Start recording video."""
- _EnsureHostDirectory(self._host_file)
+ self._device.old_interface.EnsureHostDirectory(self._host_file)
self._recorder_stdout = tempfile.mkstemp()[1]
self._recorder = cmd_helper.Popen(
self._args, stdout=open(self._recorder_stdout, 'w'))
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698