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

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 1286763002: device_utils.Install: Calculate host md5s at the same time as device md5s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style nits Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
11 import collections 11 import collections
12 import contextlib 12 import contextlib
13 import itertools 13 import itertools
14 import logging 14 import logging
15 import multiprocessing 15 import multiprocessing
16 import os 16 import os
17 import posixpath 17 import posixpath
18 import re 18 import re
19 import shutil 19 import shutil
20 import sys 20 import sys
21 import tempfile 21 import tempfile
22 import threading
22 import time 23 import time
23 import zipfile 24 import zipfile
24 25
25 import pylib.android_commands 26 import pylib.android_commands
26 from pylib import cmd_helper 27 from pylib import cmd_helper
27 from pylib import constants 28 from pylib import constants
28 from pylib import device_signal 29 from pylib import device_signal
29 from pylib.constants import keyevent 30 from pylib.constants import keyevent
30 from pylib.device import adb_wrapper 31 from pylib.device import adb_wrapper
31 from pylib.device import decorators 32 from pylib.device import decorators
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 def _ComputeDeviceChecksumsForApks(self, package_name): 1086 def _ComputeDeviceChecksumsForApks(self, package_name):
1086 ret = self._cache['package_apk_checksums'].get(package_name) 1087 ret = self._cache['package_apk_checksums'].get(package_name)
1087 if ret is None: 1088 if ret is None:
1088 device_paths = self._GetApplicationPathsInternal(package_name) 1089 device_paths = self._GetApplicationPathsInternal(package_name)
1089 file_to_checksums = md5sum.CalculateDeviceMd5Sums(device_paths, self) 1090 file_to_checksums = md5sum.CalculateDeviceMd5Sums(device_paths, self)
1090 ret = set(file_to_checksums.values()) 1091 ret = set(file_to_checksums.values())
1091 self._cache['package_apk_checksums'][package_name] = ret 1092 self._cache['package_apk_checksums'][package_name] = ret
1092 return ret 1093 return ret
1093 1094
1094 def _ComputeStaleApks(self, package_name, host_apk_paths): 1095 def _ComputeStaleApks(self, package_name, host_apk_paths):
1095 host_checksums = md5sum.CalculateHostMd5Sums(host_apk_paths) 1096 host_checksums_holder = [None]
1097 def compute_host_checksums():
1098 host_checksums_holder[0] = md5sum.CalculateHostMd5Sums(host_apk_paths)
1099
1100 host_thread = threading.Thread(target=compute_host_checksums)
1101 host_thread.start()
1096 device_checksums = self._ComputeDeviceChecksumsForApks(package_name) 1102 device_checksums = self._ComputeDeviceChecksumsForApks(package_name)
1103 host_thread.join()
1104 host_checksums = host_checksums_holder[0]
1097 stale_apks = [k for (k, v) in host_checksums.iteritems() 1105 stale_apks = [k for (k, v) in host_checksums.iteritems()
1098 if v not in device_checksums] 1106 if v not in device_checksums]
1099 return stale_apks, set(host_checksums.values()) 1107 return stale_apks, set(host_checksums.values())
1100 1108
1101 def _PushFilesImpl(self, host_device_tuples, files): 1109 def _PushFilesImpl(self, host_device_tuples, files):
1102 size = sum(host_utils.GetRecursiveDiskUsage(h) for h, _ in files) 1110 size = sum(host_utils.GetRecursiveDiskUsage(h) for h, _ in files)
1103 file_count = len(files) 1111 file_count = len(files)
1104 dir_size = sum(host_utils.GetRecursiveDiskUsage(h) 1112 dir_size = sum(host_utils.GetRecursiveDiskUsage(h)
1105 for h, _ in host_device_tuples) 1113 for h, _ in host_device_tuples)
1106 dir_file_count = 0 1114 dir_file_count = 0
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() 1888 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices()
1881 if not blacklisted(adb)] 1889 if not blacklisted(adb)]
1882 1890
1883 @decorators.WithTimeoutAndRetriesFromInstance() 1891 @decorators.WithTimeoutAndRetriesFromInstance()
1884 def RestartAdbd(self, timeout=None, retries=None): 1892 def RestartAdbd(self, timeout=None, retries=None):
1885 logging.info('Restarting adbd on device.') 1893 logging.info('Restarting adbd on device.')
1886 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: 1894 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script:
1887 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) 1895 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT)
1888 self.RunShellCommand(['source', script.name], as_root=True) 1896 self.RunShellCommand(['source', script.name], as_root=True)
1889 self.adb.WaitForDevice() 1897 self.adb.WaitForDevice()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698