android: don't try to disconnect devices which aren't connected
If you try to disconnect a device and there are none, certain versions
of adb return 1, which leads to a TargetError and stops everything in
its tracks.
Try to mitigate this by checking if the device we want to disconnect is
connected before we make the disconnect call.
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
diff --git a/devlib/utils/android.py b/devlib/utils/android.py
index e6db188..93c1fda 100644
--- a/devlib/utils/android.py
+++ b/devlib/utils/android.py
@@ -291,7 +291,7 @@
_check_env()
if not device:
return
- if ":" in device:
+ if ":" in device and device in adb_list_devices():
command = "adb disconnect " + device
logger.debug(command)
retval = subprocess.call(command, stdout=open(os.devnull, 'wb'), shell=True)