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 import logging | 4 import logging |
5 import os | 5 import os |
6 import re | 6 import re |
7 import subprocess | 7 import subprocess |
8 | 8 |
9 from telemetry.core import util | 9 from telemetry.core import util |
10 from telemetry.internal.platform import device | 10 from telemetry.internal.platform import device |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if len(devices) > 1: | 122 if len(devices) > 1: |
123 logging.warn( | 123 logging.warn( |
124 'Multiple devices attached. Please specify one of the following:\n' + | 124 'Multiple devices attached. Please specify one of the following:\n' + |
125 '\n'.join([' --device=%s' % d.device_id for d in devices])) | 125 '\n'.join([' --device=%s' % d.device_id for d in devices])) |
126 return None | 126 return None |
127 return devices[0] | 127 return devices[0] |
128 | 128 |
129 | 129 |
130 def CanDiscoverDevices(): | 130 def CanDiscoverDevices(): |
131 """Returns true if devices are discoverable via adb.""" | 131 """Returns true if devices are discoverable via adb.""" |
132 if os.name != 'posix': | |
133 return False | |
134 | |
135 adb_path = constants.GetAdbPath() | 132 adb_path = constants.GetAdbPath() |
136 if os.path.isabs(adb_path) and not os.path.exists(adb_path): | 133 if os.path.isabs(adb_path) and not os.path.exists(adb_path): |
137 return False | 134 return False |
138 try: | 135 try: |
139 with open(os.devnull, 'w') as devnull: | 136 with open(os.devnull, 'w') as devnull: |
140 adb_process = subprocess.Popen( | 137 adb_process = subprocess.Popen( |
141 ['adb', 'devices'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 138 ['adb', 'devices'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
142 stdin=devnull) | 139 stdin=devnull) |
143 stdout = adb_process.communicate()[0] | 140 stdout = adb_process.communicate()[0] |
144 if re.search(re.escape('????????????\tno permissions'), stdout) != None: | 141 if re.search(re.escape('????????????\tno permissions'), stdout) != None: |
(...skipping 19 matching lines...) Expand all Loading... |
164 """ | 161 """ |
165 if options.android_blacklist_file: | 162 if options.android_blacklist_file: |
166 blacklist = device_blacklist.Blacklist(options.android_blacklist_file) | 163 blacklist = device_blacklist.Blacklist(options.android_blacklist_file) |
167 else: | 164 else: |
168 blacklist = None | 165 blacklist = None |
169 | 166 |
170 if not CanDiscoverDevices(): | 167 if not CanDiscoverDevices(): |
171 return [] | 168 return [] |
172 else: | 169 else: |
173 return AndroidDevice.GetAllConnectedDevices(blacklist) | 170 return AndroidDevice.GetAllConnectedDevices(blacklist) |
OLD | NEW |