Chromium Code Reviews| Index: build/android/pylib/android_commands.py |
| diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py |
| index db87172e432954a2318726ebcee45521ba1b79ff..91118253e326824bc86630503b9f2dc6483e2dac 100644 |
| --- a/build/android/pylib/android_commands.py |
| +++ b/build/android/pylib/android_commands.py |
| @@ -24,10 +24,8 @@ import time |
| import cmd_helper |
| import constants |
| -import screenshot |
| import system_properties |
| from utils import host_utils |
| -from device import device_utils |
| try: |
| from pylib import pexpect |
| @@ -1712,6 +1710,16 @@ class AndroidCommands(object): |
| return False |
| + @staticmethod |
| + def GetTimestamp(): |
| + return time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) |
| + |
| + @staticmethod |
| + 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(self, host_file): |
|
craigdh
2014/04/17 16:31:02
should host_file default to None?
|
| """Saves a screenshot image to |host_file| on the host. |
| @@ -1722,7 +1730,15 @@ class AndroidCommands(object): |
| Returns: |
| Resulting host file name of the screenshot. |
| """ |
| - return screenshot.TakeScreenshot(device_utils.DeviceUtils(self), host_file) |
| + host_file = os.path.abspath(host_file or |
| + 'screenshot-%s.png' % self.GetTimestamp()) |
| + self.EnsureHostDirectory(host_file) |
| + device_file = '%s/screenshot.png' % self.GetExternalStorage() |
| + self.RunShellCommand( |
| + '/system/bin/screencap -p %s' % device_file) |
| + self.PullFileFromDevice(device_file, host_file) |
| + self.RunShellCommand('rm -f "%s"' % device_file) |
| + return host_file |
| def PullFileFromDevice(self, device_file, host_file): |
| """Download |device_file| on the device from to |host_file| on the host. |