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

Unified Diff: devil/devil/android/sdk/adb_wrapper.py

Issue 2899093002: [devil] Allow instantiation of AdbWrapper with USB bus identifer.
Patch Set: Allow AdbWrapper to specify devices using either serial number or USB id. serial number Created 3 years, 5 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: devil/devil/android/sdk/adb_wrapper.py
diff --git a/devil/devil/android/sdk/adb_wrapper.py b/devil/devil/android/sdk/adb_wrapper.py
index e2ca0139b7ab4090c0241002530181587ed6884e..9890f11735375197f5c02a8ce17b7a38bf3a1d0e 100644
--- a/devil/devil/android/sdk/adb_wrapper.py
+++ b/devil/devil/android/sdk/adb_wrapper.py
@@ -120,10 +120,19 @@ class AdbWrapper(object):
"""Initializes the AdbWrapper.
Args:
- device_serial: The device serial number as a string.
+ device_serial: The device serial number or USB bus ID as a string.
+
+ WARNING: Some features may not be supported with USB ID.
+
"""
if not device_serial:
raise ValueError('A device serial must be specified')
+
+ # TODO: Improve support for instances created from a USB ID.
+ if "usb:" in device_serial:
+ logger.warning("Some features may not be supported when selecting "
+ "devices by USB Id.")
+
self._device_serial = str(device_serial)
class PersistentShell(object):
@@ -824,16 +833,21 @@ class AdbWrapper(object):
retries: (optional) Number of retries to attempt.
Returns:
- One of 'offline', 'bootloader', or 'device'.
+ One of 'offline', 'bootloader', 'unauthorized', 'no' [permissions],
+ or 'device'.
"""
# TODO(jbudorick): Revert to using get-state once it doesn't cause a
# a protocol fault.
# return self._RunDeviceAdbCmd(['get-state'], timeout, retries).strip()
- lines = self._RawDevices(timeout=timeout, retries=retries)
+ lines = self._RawDevices(timeout=timeout, retries=retries, long_list=True)
for line in lines:
- if len(line) >= 2 and line[0] == self._device_serial:
+ if not len(line) >= 3:
+ continue
+
+ if line[0] == self._device_serial or line[2] == self._device_serial:
return line[1]
+
return 'offline'
def GetDevPath(self, timeout=DEFAULT_TIMEOUT, retries=DEFAULT_RETRIES):
« no previous file with comments | « no previous file | devil/devil/android/sdk/adb_wrapper_test.py » ('j') | devil/devil/android/sdk/adb_wrapper_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698