1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-02-07 13:40:48 +00:00

utils/android: Try to ping adb devices regardless of connection type

Previously if a device was connected over usb then the adb_connect
method would assume the device was already connected. This can cause
issues when rebooting and the device is not ready by the time devlib
attempts to reconnect to it causing the next command to fail. Now still
only execute the 'connect' command when the device is connected over the
network, however always trying pinging the device to see if it is
connected before returning.
This commit is contained in:
Marc Bonnici 2018-06-04 14:35:54 +01:00 committed by setrofim
parent 5cafd2ec4d
commit fe0d6eda2a

View File

@ -317,18 +317,15 @@ def adb_get_device(timeout=None, adb_server=None):
def adb_connect(device, timeout=None, attempts=MAX_ATTEMPTS): def adb_connect(device, timeout=None, attempts=MAX_ATTEMPTS):
_check_env() _check_env()
# Connect is required only for ADB-over-IP
if "." not in device:
logger.debug('Device connected via USB, connect not required')
return
tries = 0 tries = 0
output = None output = None
while tries <= attempts: while tries <= attempts:
tries += 1 tries += 1
if device: if device:
command = 'adb connect {}'.format(device) if "." in device: # Connect is required only for ADB-over-IP
logger.debug(command) command = 'adb connect {}'.format(device)
output, _ = check_output(command, shell=True, timeout=timeout) logger.debug(command)
output, _ = check_output(command, shell=True, timeout=timeout)
if _ping(device): if _ping(device):
break break
time.sleep(10) time.sleep(10)