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

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

Issue 1105323002: [Android] Remove more uses of android_commands from build/android/pylib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 46aec6fc9df0eb7b94b89628457567a692299b81..33fde341b7e6cde128317485ab36c7bf09c31363 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -175,6 +175,37 @@ class DeviceUtils(object):
assert hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR)
assert hasattr(self, decorators.DEFAULT_RETRIES_ATTR)
+ def __eq__(self, other):
+ """Checks whether |other| refers to the same device as |self|.
+
+ Args:
+ other: The object to compare to. This can be a basestring, an instance
+ of adb_wrapper.AdbWrapper, or an instance of DeviceUtils.
+ Returns:
+ Whether |other| refers to the same device as |self|.
+ """
+ if isinstance(other, basestring):
perezju 2015/04/28 14:36:19 why not just do like we do in AdbWrapper, i.e.:
jbudorick 2015/04/28 15:52:53 Wow, that's much better. Done.
+ other_serial = other
+ elif isinstance(other, adb_wrapper.AdbWrapper):
+ other_serial = other.GetDeviceSerial()
+ elif isinstance(other, DeviceUtils):
+ other_serial = other.adb.GetDeviceSerial()
+ else:
+ return False
+ return self.adb.GetDeviceSerial() == other_serial
+
+ def __lt__(self, other):
+ """Compares two instances of DeviceUtils.
+
+ This merely compares their serial numbers.
+
+ Args:
+ other: The instance of DeviceUtils to compare to.
+ Returns:
+ Whether |self| is less than |other|.
+ """
+ return self.adb.GetDeviceSerial() < other.adb.GetDeviceSerial()
+
def __str__(self):
"""Returns the device serial."""
return self.adb.GetDeviceSerial()

Powered by Google App Engine
This is Rietveld 408576698