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

Unified Diff: build/android/pylib/android_commands.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 | « no previous file | build/android/pylib/screenshot.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b734d17597838541dbda1a12527f05949a2d9eac 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,7 +1710,17 @@ class AndroidCommands(object):
return False
- def TakeScreenshot(self, host_file):
+ @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=None):
"""Saves a screenshot image to |host_file| on the host.
Args:
@@ -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.
« no previous file with comments | « no previous file | build/android/pylib/screenshot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698