diff options
author | Tatsujin Chin <c910335@gmail.com> | 2023-01-06 17:56:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-06 01:56:29 -0800 |
commit | 23715574c78dd89ae587942b87b401fe18113a5c (patch) | |
tree | 1d8a08058fb5df727d6758aa4652f8ee18bca026 | |
parent | 8d044d22674bff6b2fd748d5d95c0e4329721d96 (diff) | |
download | mobly-23715574c78dd89ae587942b87b401fe18113a5c.tar.gz |
Fix list_fastboot_devices for other usb interfaces (#859)
-rw-r--r-- | mobly/controllers/android_device.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/mobly/controllers/android_device.py b/mobly/controllers/android_device.py index b8d51d4..54166a5 100644 --- a/mobly/controllers/android_device.py +++ b/mobly/controllers/android_device.py @@ -183,7 +183,7 @@ def _start_services_on_ads(ads): 'services failed to start.') -def parse_device_list(device_list_str, key): +def parse_device_list(device_list_str, key=None): """Parses a byte string representing a list of devices. The string is generated by calling either adb or fastboot. The tokens in @@ -191,7 +191,9 @@ def parse_device_list(device_list_str, key): Args: device_list_str: Output of adb or fastboot. - key: The token that signifies a device in device_list_str. + key: The token that signifies a device in device_list_str. Only devices + with the specified key in device_list_str are parsed, such as 'device' or + 'fastbootd'. If not specified, all devices listed are parsed. Returns: A list of android device serial numbers. @@ -204,7 +206,7 @@ def parse_device_list(device_list_str, key): results = [] for line in clean_lines: tokens = line.strip().split('\t') - if len(tokens) == 2 and tokens[1] == key: + if len(tokens) == 2 and (key is None or tokens[1] == key): results.append(tokens[0]) return results @@ -249,7 +251,7 @@ def list_fastboot_devices(): A list of android device serials. Empty if there's none. """ out = fastboot.FastbootProxy().devices() - return parse_device_list(out, 'fastboot') + return parse_device_list(out) def get_instances(serials): |