mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
devlib/AndroidTarget: Move ADB disconnect code into connection.
The `AndroidTarget` would ensure that when connecting to a IP target that it disconnected first to prevent the connection getting stuck if the connection was not closed correctly. Move this code into the `AdbConnection` instead as this is more relevant.
This commit is contained in:
parent
01dd80df34
commit
75621022be
@ -1225,13 +1225,6 @@ class AndroidTarget(Target):
|
|||||||
|
|
||||||
def connect(self, timeout=30, check_boot_completed=True): # pylint: disable=arguments-differ
|
def connect(self, timeout=30, check_boot_completed=True): # pylint: disable=arguments-differ
|
||||||
device = self.connection_settings.get('device')
|
device = self.connection_settings.get('device')
|
||||||
if device and ':' in device:
|
|
||||||
# ADB does not automatically remove a network device from it's
|
|
||||||
# devices list when the connection is broken by the remote, so the
|
|
||||||
# adb connection may have gone "stale", resulting in adb blocking
|
|
||||||
# indefinitely when making calls to the device. To avoid this,
|
|
||||||
# always disconnect first.
|
|
||||||
adb_disconnect(device)
|
|
||||||
super(AndroidTarget, self).connect(timeout=timeout, check_boot_completed=check_boot_completed)
|
super(AndroidTarget, self).connect(timeout=timeout, check_boot_completed=check_boot_completed)
|
||||||
|
|
||||||
def kick_off(self, command, as_root=None):
|
def kick_off(self, command, as_root=None):
|
||||||
|
@ -425,6 +425,12 @@ def adb_connect(device, timeout=None, attempts=MAX_ATTEMPTS):
|
|||||||
tries += 1
|
tries += 1
|
||||||
if device:
|
if device:
|
||||||
if "." in device: # Connect is required only for ADB-over-IP
|
if "." in device: # Connect is required only for ADB-over-IP
|
||||||
|
# ADB does not automatically remove a network device from it's
|
||||||
|
# devices list when the connection is broken by the remote, so the
|
||||||
|
# adb connection may have gone "stale", resulting in adb blocking
|
||||||
|
# indefinitely when making calls to the device. To avoid this,
|
||||||
|
# always disconnect first.
|
||||||
|
adb_disconnect(device)
|
||||||
command = 'adb connect {}'.format(quote(device))
|
command = 'adb connect {}'.format(quote(device))
|
||||||
logger.debug(command)
|
logger.debug(command)
|
||||||
output, _ = check_output(command, shell=True, timeout=timeout)
|
output, _ = check_output(command, shell=True, timeout=timeout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user