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

Side by Side Diff: build/android/devil/android/device_utils.py

Issue 1386353005: DeviceUtils: Write checksums to cache even when not reading them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 posixpath.join(device_path, relative_dir, f) for f in filenames) 1132 posixpath.join(device_path, relative_dir, f) for f in filenames)
1133 1133
1134 def device_sums_helper(): 1134 def device_sums_helper():
1135 if self._enable_device_files_cache: 1135 if self._enable_device_files_cache:
1136 cache_entry = self._cache['device_path_checksums'].get(device_path) 1136 cache_entry = self._cache['device_path_checksums'].get(device_path)
1137 if cache_entry and cache_entry[0] == ignore_other_files: 1137 if cache_entry and cache_entry[0] == ignore_other_files:
1138 return dict(cache_entry[1]) 1138 return dict(cache_entry[1])
1139 1139
1140 sums = md5sum.CalculateDeviceMd5Sums(specific_device_paths, self) 1140 sums = md5sum.CalculateDeviceMd5Sums(specific_device_paths, self)
1141 1141
1142 if self._enable_device_files_cache: 1142 cache_entry = [ignore_other_files, sums]
1143 cache_entry = [ignore_other_files, sums] 1143 self._cache['device_path_checksums'][device_path] = cache_entry
1144 self._cache['device_path_checksums'][device_path] = cache_entry
1145 return dict(sums) 1144 return dict(sums)
1146 1145
1147 host_checksums, device_checksums = reraiser_thread.RunAsync(( 1146 host_checksums, device_checksums = reraiser_thread.RunAsync((
1148 lambda: md5sum.CalculateHostMd5Sums([host_path]), 1147 lambda: md5sum.CalculateHostMd5Sums([host_path]),
1149 device_sums_helper)) 1148 device_sums_helper))
1150 except EnvironmentError as e: 1149 except EnvironmentError as e:
1151 logging.warning('Error calculating md5: %s', e) 1150 logging.warning('Error calculating md5: %s', e)
1152 return ([(host_path, device_path)], [], [], lambda: 0) 1151 return ([(host_path, device_path)], [], [], lambda: 0)
1153 1152
1154 to_push = [] 1153 to_push = []
(...skipping 11 matching lines...) Expand all
1166 device_abs_path = posixpath.join( 1165 device_abs_path = posixpath.join(
1167 device_path, os.path.relpath(host_abs_path, host_path)) 1166 device_path, os.path.relpath(host_abs_path, host_path))
1168 device_checksum = device_checksums.pop(device_abs_path, None) 1167 device_checksum = device_checksums.pop(device_abs_path, None)
1169 if device_checksum == host_checksum: 1168 if device_checksum == host_checksum:
1170 up_to_date.append(host_abs_path) 1169 up_to_date.append(host_abs_path)
1171 else: 1170 else:
1172 to_push.append((host_abs_path, device_abs_path)) 1171 to_push.append((host_abs_path, device_abs_path))
1173 to_delete = device_checksums.keys() 1172 to_delete = device_checksums.keys()
1174 1173
1175 def cache_commit_func(): 1174 def cache_commit_func():
1176 if not self._enable_device_files_cache:
1177 return
1178 new_sums = {posixpath.join(device_path, path[len(host_path) + 1:]): val 1175 new_sums = {posixpath.join(device_path, path[len(host_path) + 1:]): val
1179 for path, val in host_checksums.iteritems()} 1176 for path, val in host_checksums.iteritems()}
1180 cache_entry = [ignore_other_files, new_sums] 1177 cache_entry = [ignore_other_files, new_sums]
1181 self._cache['device_path_checksums'][device_path] = cache_entry 1178 self._cache['device_path_checksums'][device_path] = cache_entry
1182 1179
1183 return (to_push, up_to_date, to_delete, cache_commit_func) 1180 return (to_push, up_to_date, to_delete, cache_commit_func)
1184 1181
1185 def _ComputeDeviceChecksumsForApks(self, package_name): 1182 def _ComputeDeviceChecksumsForApks(self, package_name):
1186 ret = self._cache['package_apk_checksums'].get(package_name) 1183 ret = self._cache['package_apk_checksums'].get(package_name)
1187 if ret is None: 1184 if ret is None:
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions 2053 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions
2057 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions): 2054 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions):
2058 permissions.append('android.permission.READ_EXTERNAL_STORAGE') 2055 permissions.append('android.permission.READ_EXTERNAL_STORAGE')
2059 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions) 2056 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions)
2060 if cmd: 2057 if cmd:
2061 output = self.RunShellCommand(cmd) 2058 output = self.RunShellCommand(cmd)
2062 if output: 2059 if output:
2063 logging.warning('Possible problem when granting permissions. Blacklist ' 2060 logging.warning('Possible problem when granting permissions. Blacklist '
2064 'may need to be updated.') 2061 'may need to be updated.')
2065 logging.warning(output) 2062 logging.warning(output)
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