OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
6 | 6 |
7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
8 """ | 8 """ |
9 | 9 |
10 import collections | 10 import collections |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 List of devices attached | 77 List of devices attached |
78 027c10494100b4d7 device | 78 027c10494100b4d7 device |
79 emulator-5554 offline | 79 emulator-5554 offline |
80 emulator-5558 device | 80 emulator-5558 device |
81 """ | 81 """ |
82 re_device = re.compile('^emulator-[0-9]+', re.MULTILINE) | 82 re_device = re.compile('^emulator-[0-9]+', re.MULTILINE) |
83 devices = re_device.findall(cmd_helper.GetCmdOutput(['adb', 'devices'])) | 83 devices = re_device.findall(cmd_helper.GetCmdOutput(['adb', 'devices'])) |
84 return devices | 84 return devices |
85 | 85 |
86 | 86 |
| 87 def GetAVDs(): |
| 88 """Returns a list of AVDs.""" |
| 89 re_avd = re.compile('^[ ]+Name: ([a-zA-Z0-9_:.-]+)', re.MULTILINE) |
| 90 avds = re_avd.findall(cmd_helper.GetCmdOutput(['android', 'list', 'avd'])) |
| 91 return avds |
| 92 |
| 93 |
87 def GetAttachedDevices(): | 94 def GetAttachedDevices(): |
88 """Returns a list of attached, online android devices. | 95 """Returns a list of attached, online android devices. |
89 | 96 |
90 If a preferred device has been set with ANDROID_SERIAL, it will be first in | 97 If a preferred device has been set with ANDROID_SERIAL, it will be first in |
91 the returned list. | 98 the returned list. |
92 | 99 |
93 Example output: | 100 Example output: |
94 | 101 |
95 * daemon not running. starting it now on port 5037 * | 102 * daemon not running. starting it now on port 5037 * |
96 * daemon started successfully * | 103 * daemon started successfully * |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 if len(process_results) <= 8: | 945 if len(process_results) <= 8: |
939 continue | 946 continue |
940 # Column 0 is the executable name | 947 # Column 0 is the executable name |
941 # Column 1 is the pid | 948 # Column 1 is the pid |
942 # Column 8 is the Inode in use | 949 # Column 8 is the Inode in use |
943 if process_results[8] == socket_name: | 950 if process_results[8] == socket_name: |
944 pids.append( (int(process_results[1]), process_results[0]) ) | 951 pids.append( (int(process_results[1]), process_results[0]) ) |
945 break | 952 break |
946 logging.info('PidsUsingDevicePort: %s', pids) | 953 logging.info('PidsUsingDevicePort: %s', pids) |
947 return pids | 954 return pids |
OLD | NEW |