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

Unified Diff: tools/telemetry/telemetry/core/platform/android_device.py

Issue 760653002: Telemetry --device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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: tools/telemetry/telemetry/core/platform/android_device.py
diff --git a/tools/telemetry/telemetry/core/platform/android_device.py b/tools/telemetry/telemetry/core/platform/android_device.py
index 73fad60e9f523f79e9377194377efc4c1099231e..e04f2e0de5cdf090e0fb6c5aaac283d1c3c29beb 100644
--- a/tools/telemetry/telemetry/core/platform/android_device.py
+++ b/tools/telemetry/telemetry/core/platform/android_device.py
@@ -31,17 +31,30 @@ class AndroidDevice(device.Device):
@classmethod
def GetAllConnectedDevices(cls):
- device_serials = adb_commands.GetAttachedDevices()
- # The monsoon provides power for the device, so for devices with no
- # real battery, we need to turn them on after the monsoon enables voltage
- # output to the device.
- if not device_serials:
- try:
- m = monsoon.Monsoon(wait=False)
- m.SetUsbPassthrough(1)
- m.SetVoltage(3.8)
- m.SetMaxCurrent(8)
- logging.warn("""
+ device_serials = GetDeviceSerials()
+ return [cls(s) for s in device_serials]
+
+ @property
+ def device_id(self):
+ return self._device_id
+
+ @property
+ def enable_performance_mode(self):
+ return self._enable_performance_mode
+
+
+def GetDeviceSerials():
+ device_serials = adb_commands.GetAttachedDevices()
+ # The monsoon provides power for the device, so for devices with no
+ # real battery, we need to turn them on after the monsoon enables voltage
+ # output to the device.
+ if not device_serials:
+ try:
+ m = monsoon.Monsoon(wait=False)
+ m.SetUsbPassthrough(1)
+ m.SetVoltage(3.8)
+ m.SetMaxCurrent(8)
+ logging.warn("""
Monsoon power monitor detected, but no Android devices.
The Monsoon's power output has been enabled. Please now ensure that:
@@ -52,19 +65,11 @@ The Monsoon's power output has been enabled. Please now ensure that:
Waiting for device...
""")
- util.WaitFor(adb_commands.GetAttachedDevices, 600)
- device_serials = adb_commands.GetAttachedDevices()
- except IOError:
- return []
- return [cls(s) for s in device_serials]
-
- @property
- def device_id(self):
- return self._device_id
-
- @property
- def enable_performance_mode(self):
- return self._enable_performance_mode
+ util.WaitFor(adb_commands.GetAttachedDevices, 600)
+ device_serials = adb_commands.GetAttachedDevices()
+ except IOError:
+ return []
+ return device_serials
def GetDevice(finder_options):
@@ -74,9 +79,9 @@ def GetDevice(finder_options):
'No adb command found. Will not try searching for Android browsers.')
return None
- if finder_options.android_device:
+ if finder_options.device and finder_options.device in GetDeviceSerials():
return AndroidDevice(
- finder_options.android_device,
+ finder_options.device,
enable_performance_mode=not finder_options.no_performance_mode)
devices = AndroidDevice.GetAllConnectedDevices()
@@ -121,3 +126,11 @@ def CanDiscoverDevices():
return True
return False
+
+def FindAllAvailableDevices(_):
+ """Returns a list of available devices.
+ """
+ if not CanDiscoverDevices():
+ return []
+ else:
+ return AndroidDevice.GetAllConnectedDevices()
« no previous file with comments | « tools/telemetry/telemetry/core/device_finder.py ('k') | tools/telemetry/telemetry/core/platform/android_device_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698