Index: tools/profile_chrome/main.py |
diff --git a/tools/profile_chrome/main.py b/tools/profile_chrome/main.py |
index 7d015e6126fa5981cae2c228315a5eaa876f02b7..0f9f1498e3ecacfa84c22e732d4536d9f2a8f028 100755 |
--- a/tools/profile_chrome/main.py |
+++ b/tools/profile_chrome/main.py |
@@ -165,10 +165,14 @@ When in doubt, just try out --trace-frame-viewer. |
logging.getLogger().setLevel(logging.DEBUG) |
devices = android_commands.GetAttachedDevices() |
- if not options.device and len(devices) != 1: |
- parser.error('Exactly 1 device must be attached.') |
- device = device_utils.DeviceUtils( |
- next((d for d in devices if d == options.device), devices[0])) |
+ device = None |
+ if options.device in devices: |
+ device = options.device |
+ elif not options.device and len(devices) == 1: |
+ device = devices[0] |
+ if not device: |
+ parser.error('Use -d/--device to select a device:\n' + '\n'.join(devices)) |
+ device = device_utils.DeviceUtils(device) |
package_info = profiler.GetSupportedBrowsers()[options.browser] |
if options.chrome_categories in ['list', 'help']: |