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

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

Issue 1281923003: [Android] Add --blacklist-file as a command-line option. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix telemetry_unittests Created 5 years, 4 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/internal/platform/android_device.py
diff --git a/tools/telemetry/telemetry/internal/platform/android_device.py b/tools/telemetry/telemetry/internal/platform/android_device.py
index a2c278da094d1290553153935aa708e65be2e946..5c73d343d5e568bb21cbdba0efbe16dbf927056b 100644
--- a/tools/telemetry/telemetry/internal/platform/android_device.py
+++ b/tools/telemetry/telemetry/internal/platform/android_device.py
@@ -12,6 +12,7 @@ from telemetry.internal.platform.profiler import monsoon
util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android')
from pylib import constants
+from pylib.device import device_blacklist
from pylib.device import device_errors
from pylib.device import device_utils
@@ -33,8 +34,8 @@ class AndroidDevice(device.Device):
self._enable_performance_mode = enable_performance_mode
@classmethod
- def GetAllConnectedDevices(cls):
- device_serials = GetDeviceSerials()
+ def GetAllConnectedDevices(cls, blacklist):
+ device_serials = GetDeviceSerials(blacklist)
return [cls(s) for s in device_serials]
@property
@@ -46,20 +47,20 @@ class AndroidDevice(device.Device):
return self._enable_performance_mode
-def _ListSerialsOfHealthyOnlineDevices():
+def _ListSerialsOfHealthyOnlineDevices(blacklist):
return [d.adb.GetDeviceSerial()
- for d in device_utils.DeviceUtils.HealthyDevices() if
- d.IsOnline()]
+ for d in device_utils.DeviceUtils.HealthyDevices(blacklist)
+ if d.IsOnline()]
-def GetDeviceSerials():
+def GetDeviceSerials(blacklist):
"""Return the list of device serials of healthy 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.
"""
- device_serials = _ListSerialsOfHealthyOnlineDevices()
+ device_serials = _ListSerialsOfHealthyOnlineDevices(blacklist)
# 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
@@ -81,8 +82,8 @@ The Monsoon's power output has been enabled. Please now ensure that:
Waiting for device...
""")
- util.WaitFor(_ListSerialsOfHealthyOnlineDevices(), 600)
- device_serials = _ListSerialsOfHealthyOnlineDevices()
+ util.WaitFor(_ListSerialsOfHealthyOnlineDevices(blacklist), 600)
+ device_serials = _ListSerialsOfHealthyOnlineDevices(blacklist)
except IOError:
return []
@@ -103,12 +104,19 @@ def GetDevice(finder_options):
'No adb command found. Will not try searching for Android browsers.')
return None
- if finder_options.device and finder_options.device in GetDeviceSerials():
+ if (finder_options.device
+ and finder_options.device in GetDeviceSerials(finder_options)):
return AndroidDevice(
finder_options.device,
enable_performance_mode=not finder_options.no_performance_mode)
- devices = AndroidDevice.GetAllConnectedDevices()
+ if finder_options.android_blacklist_file:
+ blacklist = device_blacklist.Blacklist(
+ finder_options.android_blacklist_file)
+ else:
+ blacklist = None
+
+ devices = AndroidDevice.GetAllConnectedDevices(blacklist)
if len(devices) == 0:
logging.info('No android devices found.')
return None
@@ -142,17 +150,22 @@ def CanDiscoverDevices():
try:
os.environ['PATH'] = os.pathsep.join(
[os.path.dirname(adb_path), os.environ['PATH']])
- device_utils.DeviceUtils.HealthyDevices()
+ device_utils.DeviceUtils.HealthyDevices(None)
return True
except (device_errors.CommandFailedError, device_errors.CommandTimeoutError,
OSError):
return False
-def FindAllAvailableDevices(_):
+def FindAllAvailableDevices(options):
"""Returns a list of available devices.
"""
+ if options.android_blacklist_file:
+ blacklist = device_blacklist.Blacklist(options.android_blacklist_file)
+ else:
+ blacklist = None
+
if not CanDiscoverDevices():
return []
else:
- return AndroidDevice.GetAllConnectedDevices()
+ return AndroidDevice.GetAllConnectedDevices(blacklist)

Powered by Google App Engine
This is Rietveld 408576698