| 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 | 9 |
| 10 import collections | 10 import collections |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 if device: | 240 if device: |
| 241 self._adb.SetTargetSerial(device) | 241 self._adb.SetTargetSerial(device) |
| 242 self._device = device | 242 self._device = device |
| 243 self._logcat = None | 243 self._logcat = None |
| 244 self.logcat_process = None | 244 self.logcat_process = None |
| 245 self._logcat_tmpoutfile = None | 245 self._logcat_tmpoutfile = None |
| 246 self._pushed_files = [] | 246 self._pushed_files = [] |
| 247 self._device_utc_offset = None | 247 self._device_utc_offset = None |
| 248 self._potential_push_size = 0 | 248 self._potential_push_size = 0 |
| 249 self._actual_push_size = 0 | 249 self._actual_push_size = 0 |
| 250 self._md5sum_build_dir = '' | |
| 251 self._external_storage = '' | 250 self._external_storage = '' |
| 252 self._util_wrapper = '' | 251 self._util_wrapper = '' |
| 253 | 252 |
| 254 def _LogShell(self, cmd): | 253 def _LogShell(self, cmd): |
| 255 """Logs the adb shell command.""" | 254 """Logs the adb shell command.""" |
| 256 if self._device: | 255 if self._device: |
| 257 device_repr = self._device[-4:] | 256 device_repr = self._device[-4:] |
| 258 else: | 257 else: |
| 259 device_repr = '????' | 258 device_repr = '????' |
| 260 logging.info('[%s]> %s', device_repr, cmd) | 259 logging.info('[%s]> %s', device_repr, cmd) |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 """Gets the md5sum of a host path and device path. | 774 """Gets the md5sum of a host path and device path. |
| 776 | 775 |
| 777 Args: | 776 Args: |
| 778 host_path: Path (file or directory) on the host. | 777 host_path: Path (file or directory) on the host. |
| 779 device_path: Path on the device. | 778 device_path: Path on the device. |
| 780 | 779 |
| 781 Returns: | 780 Returns: |
| 782 A tuple containing lists of the host and device md5sum results as | 781 A tuple containing lists of the host and device md5sum results as |
| 783 created by _ParseMd5SumOutput(). | 782 created by _ParseMd5SumOutput(). |
| 784 """ | 783 """ |
| 785 if not self._md5sum_build_dir: | 784 md5sum_dist_path = os.path.join(constants.GetOutDirectory(), |
| 786 default_build_type = os.environ.get('BUILD_TYPE', 'Debug') | 785 'md5sum_dist') |
| 787 build_dir = '%s/%s/' % ( | 786 assert os.path.exists(md5sum_dist_path), 'Please build md5sum.' |
| 788 cmd_helper.OutDirectory().get(), default_build_type) | 787 command = 'push %s %s' % (md5sum_dist_path, MD5SUM_DEVICE_FOLDER) |
| 789 md5sum_dist_path = '%s/md5sum_dist' % build_dir | 788 assert _HasAdbPushSucceeded(self._adb.SendCommand(command)) |
| 790 if not os.path.exists(md5sum_dist_path): | |
| 791 build_dir = '%s/Release/' % cmd_helper.OutDirectory().get() | |
| 792 md5sum_dist_path = '%s/md5sum_dist' % build_dir | |
| 793 assert os.path.exists(md5sum_dist_path), 'Please build md5sum.' | |
| 794 command = 'push %s %s' % (md5sum_dist_path, MD5SUM_DEVICE_FOLDER) | |
| 795 assert _HasAdbPushSucceeded(self._adb.SendCommand(command)) | |
| 796 self._md5sum_build_dir = build_dir | |
| 797 | 789 |
| 798 cmd = (MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper + ' ' + | 790 cmd = (MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper + ' ' + |
| 799 MD5SUM_DEVICE_PATH + ' ' + device_path) | 791 MD5SUM_DEVICE_PATH + ' ' + device_path) |
| 800 device_hash_tuples = _ParseMd5SumOutput( | 792 device_hash_tuples = _ParseMd5SumOutput( |
| 801 self.RunShellCommand(cmd, timeout_time=2 * 60)) | 793 self.RunShellCommand(cmd, timeout_time=2 * 60)) |
| 802 assert os.path.exists(host_path), 'Local path not found %s' % host_path | 794 assert os.path.exists(host_path), 'Local path not found %s' % host_path |
| 803 md5sum_output = cmd_helper.GetCmdOutput( | 795 md5sum_output = cmd_helper.GetCmdOutput( |
| 804 ['%s/md5sum_bin_host' % self._md5sum_build_dir, host_path]) | 796 [os.path.join(constants.GetOutDirectory(), 'md5sum_bin_host'), |
| 797 host_path]) |
| 805 host_hash_tuples = _ParseMd5SumOutput(md5sum_output.splitlines()) | 798 host_hash_tuples = _ParseMd5SumOutput(md5sum_output.splitlines()) |
| 806 return (host_hash_tuples, device_hash_tuples) | 799 return (host_hash_tuples, device_hash_tuples) |
| 807 | 800 |
| 808 def GetFilesChanged(self, host_path, device_path): | 801 def GetFilesChanged(self, host_path, device_path): |
| 809 """Compares the md5sum of a host path against a device path. | 802 """Compares the md5sum of a host path against a device path. |
| 810 | 803 |
| 811 Note: Ignores extra files on the device. | 804 Note: Ignores extra files on the device. |
| 812 | 805 |
| 813 Args: | 806 Args: |
| 814 host_path: Path (file or directory) on the host. | 807 host_path: Path (file or directory) on the host. |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 """ | 1539 """ |
| 1547 def __init__(self, output): | 1540 def __init__(self, output): |
| 1548 self._output = output | 1541 self._output = output |
| 1549 | 1542 |
| 1550 def write(self, data): | 1543 def write(self, data): |
| 1551 data = data.replace('\r\r\n', '\n') | 1544 data = data.replace('\r\r\n', '\n') |
| 1552 self._output.write(data) | 1545 self._output.write(data) |
| 1553 | 1546 |
| 1554 def flush(self): | 1547 def flush(self): |
| 1555 self._output.flush() | 1548 self._output.flush() |
| OLD | NEW |