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

Unified Diff: build/android/pylib/device/device_utils.py

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 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 | « build/android/pylib/device/device_filter.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/device_utils.py
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index ddda0178bc8a60603c0475c4e6f8f005e03b6ddc..46aec6fc9df0eb7b94b89628457567a692299b81 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -30,7 +30,6 @@ from pylib.device import adb_wrapper
from pylib.device import decorators
from pylib.device import device_blacklist
from pylib.device import device_errors
-from pylib.device import device_filter
from pylib.device import intent
from pylib.device import logcat_monitor
from pylib.device.commands import install_commands
@@ -854,29 +853,27 @@ class DeviceUtils(object):
if not real_device_path:
return [(host_path, device_path)]
- host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path])
+ host_checksums = md5sum.CalculateHostMd5Sums([real_host_path])
device_paths_to_md5 = (
real_device_path if os.path.isfile(real_host_path)
else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path))
- for _, p in host_hash_tuples))
- device_hash_tuples = md5sum.CalculateDeviceMd5Sums(
+ for p in host_checksums.iterkeys()))
+ device_checksums = md5sum.CalculateDeviceMd5Sums(
device_paths_to_md5, self)
if os.path.isfile(host_path):
- if (not device_hash_tuples
- or device_hash_tuples[0].hash != host_hash_tuples[0].hash):
+ host_checksum = host_checksums.get(real_host_path)
+ device_checksum = device_checksums.get(real_device_path)
+ if host_checksum != device_checksum:
return [(host_path, device_path)]
else:
return []
else:
- device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples)
to_push = []
- for host_hash, host_abs_path in (
- (h.hash, h.path) for h in host_hash_tuples):
+ for host_abs_path, host_checksum in host_checksums.iteritems():
device_abs_path = '%s/%s' % (
real_device_path, os.path.relpath(host_abs_path, real_host_path))
- if (device_abs_path not in device_tuple_dict
- or device_tuple_dict[device_abs_path] != host_hash):
+ if (device_checksums.get(device_abs_path) != host_checksum):
to_push.append((host_abs_path, device_abs_path))
return to_push
@@ -1542,6 +1539,18 @@ class DeviceUtils(object):
return self._cache['run_pie']
+ def GetClientCache(self, client_name):
+ """Returns client cache."""
+ if client_name not in self._client_caches:
+ self._client_caches[client_name] = {}
+ return self._client_caches[client_name]
+
+ def _ClearCache(self):
+ """Clears all caches."""
+ for client in self._client_caches:
+ self._client_caches[client].clear()
+ self._cache.clear()
+
@classmethod
def parallel(cls, devices=None, async=False):
"""Creates a Parallelizer to operate over the provided list of devices.
@@ -1560,8 +1569,7 @@ class DeviceUtils(object):
A Parallelizer operating over |devices|.
"""
if not devices:
- devices = adb_wrapper.AdbWrapper.Devices(
- filters=device_filter.DefaultFilters())
+ devices = cls.HealthyDevices()
if not devices:
raise device_errors.NoDevicesError()
@@ -1571,14 +1579,15 @@ class DeviceUtils(object):
else:
return parallelizer.SyncParallelizer(devices)
- def GetClientCache(self, client_name):
- """Returns client cache."""
- if client_name not in self._client_caches:
- self._client_caches[client_name] = {}
- return self._client_caches[client_name]
+ @classmethod
+ def HealthyDevices(cls):
+ blacklist = device_blacklist.ReadBlacklist()
+ def blacklisted(adb):
+ if adb.GetDeviceSerial() in blacklist:
+ logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial())
+ return True
+ return False
+
+ return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices()
+ if not blacklisted(adb)]
- def _ClearCache(self):
- """Clears all caches."""
- for client in self._client_caches:
- self._client_caches[client].clear()
- self._cache.clear()
« no previous file with comments | « build/android/pylib/device/device_filter.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698