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

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

Issue 2899093002: [devil] Allow instantiation of AdbWrapper with USB bus identifer.
Patch Set: [devil] Reorganize comments and add warning when instantiating an AdbWrapper from USB id. 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..b63d11479b880eb2a360c37d3bcecbd91e65b613 100644
--- a/devil/devil/android/sdk/adb_wrapper.py
+++ b/devil/devil/android/sdk/adb_wrapper.py
@@ -111,7 +111,10 @@ def _IsExtraneousLine(line, send_cmd):
class AdbWrapper(object):
- """A wrapper around a local Android Debug Bridge executable."""
+ """A wrapper around a local Android Debug Bridge executable.
+
+ WARNING: Not all features are supported when using a USB ID.
+ """
_adb_path = lazy.WeakConstant(_FindAdb)
_adb_version = lazy.WeakConstant(_GetVersion)
@@ -120,10 +123,16 @@ 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.
+
"""
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("Not all features are supported when using a USB ID.")
+
self._device_serial = str(device_serial)
class PersistentShell(object):
@@ -824,15 +833,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