OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Finds devices that can be controlled by telemetry.""" | 5 """Finds devices that can be controlled by telemetry.""" |
6 | 6 |
7 from telemetry.internal.platform import android_device | 7 from telemetry.internal.platform import android_device |
8 from telemetry.internal.platform import cros_device | 8 from telemetry.internal.platform import cros_device |
9 from telemetry.internal.platform import desktop_device | 9 from telemetry.internal.platform import desktop_device |
10 | 10 |
11 DEVICES = [ | 11 DEVICES = [ |
12 android_device, | 12 android_device, |
13 cros_device, | 13 cros_device, |
14 desktop_device, | 14 desktop_device, |
15 ] | 15 ] |
16 | 16 |
17 | 17 |
18 def _GetAllAvailableDevices(options): | 18 def _GetAllAvailableDevices(options): |
19 """Returns a list of all available devices.""" | 19 """Returns a list of all available devices.""" |
20 devices = [] | 20 devices = [] |
21 for device in DEVICES: | 21 for device in DEVICES: |
22 devices.extend(device.FindAllAvailableDevices(options)) | 22 devices.extend(device.FindAllAvailableDevices(options)) |
23 return devices | 23 return devices |
24 | 24 |
25 | 25 |
26 def GetDevicesMatchingOptions(options): | 26 def GetDevicesMatchingOptions(options): |
27 """Returns a list of devices matching the options.""" | 27 """Returns a list of devices matching the options.""" |
28 devices = [] | 28 devices = [] |
29 remote_platform_options = options.remote_platform_options | 29 remote_platform_options = options.remote_platform_options |
30 if (not remote_platform_options.device or | 30 if (not remote_platform_options.device or |
31 remote_platform_options.device == 'list'): | 31 remote_platform_options.device == 'list'): |
32 devices = _GetAllAvailableDevices(options) | 32 devices = _GetAllAvailableDevices(options) |
33 elif remote_platform_options.device == 'android': | 33 elif remote_platform_options.device == 'android': |
34 devices = android_device.FindAllAvailableDevices(options) | 34 devices = android_device.FindAllAvailableDevices(options) |
35 else: | 35 else: |
36 devices = _GetAllAvailableDevices(options) | 36 devices = _GetAllAvailableDevices(options) |
37 devices = [d for d in devices if d.guid == | 37 devices = [d for d in devices if d.guid == |
38 options.remote_platform_options.device] | 38 options.remote_platform_options.device] |
39 | 39 |
40 devices.sort(key=lambda device: device.name) | 40 devices.sort(key=lambda device: device.name) |
41 return devices | 41 return devices |
OLD | NEW |