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

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

Issue 2899093002: [devil] Allow instantiation of AdbWrapper with USB bus identifer.
Patch Set: [devil] Refactor AdbWrapper.GetState() to support USB ids Created 3 years, 7 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..8067616888244a80c43f317f9325e6cd807ca159 100644
--- a/devil/devil/android/sdk/adb_wrapper.py
+++ b/devil/devil/android/sdk/adb_wrapper.py
@@ -120,7 +120,12 @@ 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: Not all devil features are supported when using a USB ID.
rnephew (Reviews Here) 2017/05/30 18:21:12 I'm wondering if we can detect if we suspect that
kavefish 2017/05/30 19:27:20 That's interesting. Detection should be straightfo
+
+ # TODO: Improve support for instances created from a USB ID.
+
"""
if not device_serial:
rnephew (Reviews Here) 2017/05/30 18:21:12 TODO should be moved here outside the class level
raise ValueError('A device serial must be specified')
@@ -824,15 +829,17 @@ class AdbWrapper(object):
retries: (optional) Number of retries to attempt.
Returns:
- One of 'offline', 'bootloader', or 'device'.
+ One of 'offline', 'bootloader', or 'unauthorized', or
+ '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 len(line) >= 3 and (line[0] == self._device_serial or line[2] ==
+ self._device_serial):
return line[1]
return 'offline'
« 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