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

Unified Diff: build/android/pylib/android_commands.py

Issue 19596002: [Translate] Return before the new delegate is created if needed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/pylib/utils/emulator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 2dab2c1cfa4eaeca96cebdd2ee5595440365ebf0..e282ec86f1f144cbc6970520518c6cc0c9b259d4 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -65,6 +65,23 @@ MD5SUM_DEVICE_FOLDER = constants.TEST_EXECUTABLE_DIR + '/md5sum/'
MD5SUM_DEVICE_PATH = MD5SUM_DEVICE_FOLDER + 'md5sum_bin'
MD5SUM_LD_LIBRARY_PATH = 'LD_LIBRARY_PATH=%s' % MD5SUM_DEVICE_FOLDER
+def GetEmulators():
+ """Returns a list of emulators. Does not filter by status (e.g. offline).
+
+ Both devices starting with 'emulator' will be returned in below output:
+
+ * daemon not running. starting it now on port 5037 *
+ * daemon started successfully *
+ List of devices attached
+ 027c10494100b4d7 device
+ emulator-5554 offline
+ emulator-5558 device
+ """
+ re_device = re.compile('^emulator-[0-9]+', re.MULTILINE)
+ devices = re_device.findall(cmd_helper.GetCmdOutput([constants.ADB_PATH,
+ 'devices']))
+ return devices
+
def GetAVDs():
"""Returns a list of AVDs."""
@@ -73,11 +90,11 @@ def GetAVDs():
return avds
-def GetAttachedDevices(hardware=True, emulator=True, offline=False):
- """Returns a list of attached, android devices and emulators.
+def GetAttachedDevices():
+ """Returns a list of attached, online android devices.
If a preferred device has been set with ANDROID_SERIAL, it will be first in
- the returned list. The arguments specify what devices to include in the list.
+ the returned list.
Example output:
@@ -86,39 +103,10 @@ def GetAttachedDevices(hardware=True, emulator=True, offline=False):
List of devices attached
027c10494100b4d7 device
emulator-5554 offline
-
- Args:
- hardware: Include attached actual devices that are online.
- emulator: Include emulators (i.e. AVD's) currently on host.
- offline: Include devices and emulators that are offline.
-
- Returns: List of devices.
"""
- adb_devices_output = cmd_helper.GetCmdOutput([constants.ADB_PATH, 'devices'])
-
re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE)
- online_devices = re_device.findall(adb_devices_output)
-
- re_device = re.compile('^(emulator-[0-9]+)\tdevice', re.MULTILINE)
- emulator_devices = re_device.findall(adb_devices_output)
-
- re_device = re.compile('^([a-zA-Z0-9_:.-]+)\toffline$', re.MULTILINE)
- offline_devices = re_device.findall(adb_devices_output)
-
- devices = []
- # First determine list of online devices (e.g. hardware and/or emulator).
- if hardware and emulator:
- devices = online_devices
- elif hardware:
- devices = [device for device in online_devices
- if device not in emulator_devices]
- elif emulator:
- devices = emulator_devices
-
- # Now add offline devices if offline is true
- if offline:
- devices = devices + offline_devices
-
+ devices = re_device.findall(cmd_helper.GetCmdOutput([constants.ADB_PATH,
+ 'devices']))
preferred_device = os.environ.get('ANDROID_SERIAL')
if preferred_device in devices:
devices.remove(preferred_device)
@@ -126,6 +114,16 @@ def GetAttachedDevices(hardware=True, emulator=True, offline=False):
return devices
+def GetAttachedOfflineDevices():
+ """Returns a list of attached, offline android devices.
+
+ Returns: List of devices with status 'offline'.
+ """
+ re_device = re.compile('^([a-zA-Z0-9_:.-]+)\toffline$', re.MULTILINE)
+ return re_device.findall(cmd_helper.GetCmdOutput([constants.ADB_PATH,
+ 'devices']))
+
+
def IsDeviceAttached(device):
"""Return true if the device is attached and online."""
return device in GetAttachedDevices()
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/pylib/utils/emulator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698