| OLD | NEW | 
|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. | 
| 6 | 6 | 
| 7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. | 
| 8 """ | 8 """ | 
| 9 # pylint: disable-all | 9 # pylint: disable-all | 
| 10 | 10 | 
| 11 import collections | 11 import collections | 
| 12 import datetime | 12 import datetime | 
| 13 import inspect | 13 import inspect | 
| 14 import json | 14 import json | 
| 15 import logging | 15 import logging | 
| 16 import os | 16 import os | 
| 17 import re | 17 import re | 
| 18 import shlex | 18 import shlex | 
| 19 import signal | 19 import signal | 
| 20 import subprocess | 20 import subprocess | 
| 21 import sys | 21 import sys | 
| 22 import tempfile | 22 import tempfile | 
| 23 import time | 23 import time | 
| 24 | 24 | 
| 25 import cmd_helper | 25 import cmd_helper | 
| 26 import constants | 26 import constants | 
| 27 import screenshot | 27 import screenshot | 
| 28 import system_properties | 28 import system_properties | 
| 29 from utils import host_utils | 29 from utils import host_utils | 
|  | 30 from device import device_utils | 
| 30 | 31 | 
| 31 try: | 32 try: | 
| 32   from pylib import pexpect | 33   from pylib import pexpect | 
| 33 except ImportError: | 34 except ImportError: | 
| 34   pexpect = None | 35   pexpect = None | 
| 35 | 36 | 
| 36 sys.path.append(os.path.join( | 37 sys.path.append(os.path.join( | 
| 37     constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) | 38     constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) | 
| 38 import adb_interface | 39 import adb_interface | 
| 39 import am_instrument_parser | 40 import am_instrument_parser | 
| (...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1714   def TakeScreenshot(self, host_file): | 1715   def TakeScreenshot(self, host_file): | 
| 1715     """Saves a screenshot image to |host_file| on the host. | 1716     """Saves a screenshot image to |host_file| on the host. | 
| 1716 | 1717 | 
| 1717     Args: | 1718     Args: | 
| 1718       host_file: Absolute path to the image file to store on the host or None to | 1719       host_file: Absolute path to the image file to store on the host or None to | 
| 1719                  use an autogenerated file name. | 1720                  use an autogenerated file name. | 
| 1720 | 1721 | 
| 1721     Returns: | 1722     Returns: | 
| 1722       Resulting host file name of the screenshot. | 1723       Resulting host file name of the screenshot. | 
| 1723     """ | 1724     """ | 
| 1724     return screenshot.TakeScreenshot(self, host_file) | 1725     return screenshot.TakeScreenshot(device_utils.DeviceUtils(self), host_file) | 
| 1725 | 1726 | 
| 1726   def PullFileFromDevice(self, device_file, host_file): | 1727   def PullFileFromDevice(self, device_file, host_file): | 
| 1727     """Download |device_file| on the device from to |host_file| on the host. | 1728     """Download |device_file| on the device from to |host_file| on the host. | 
| 1728 | 1729 | 
| 1729     Args: | 1730     Args: | 
| 1730       device_file: Absolute path to the file to retrieve from the device. | 1731       device_file: Absolute path to the file to retrieve from the device. | 
| 1731       host_file: Absolute path to the file to store on the host. | 1732       host_file: Absolute path to the file to store on the host. | 
| 1732     """ | 1733     """ | 
| 1733     assert self._adb.Pull(device_file, host_file) | 1734     assert self._adb.Pull(device_file, host_file) | 
| 1734     assert os.path.exists(host_file) | 1735     assert os.path.exists(host_file) | 
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1907   """ | 1908   """ | 
| 1908   def __init__(self, output): | 1909   def __init__(self, output): | 
| 1909     self._output = output | 1910     self._output = output | 
| 1910 | 1911 | 
| 1911   def write(self, data): | 1912   def write(self, data): | 
| 1912     data = data.replace('\r\r\n', '\n') | 1913     data = data.replace('\r\r\n', '\n') | 
| 1913     self._output.write(data) | 1914     self._output.write(data) | 
| 1914 | 1915 | 
| 1915   def flush(self): | 1916   def flush(self): | 
| 1916     self._output.flush() | 1917     self._output.flush() | 
| OLD | NEW | 
|---|