From 119fd7dc246a8d871bffe81b88d283b621b81eaf Mon Sep 17 00:00:00 2001 From: Chris Redpath Date: Thu, 6 Oct 2016 16:34:14 +0100 Subject: [PATCH] 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 --- devlib/utils/android.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ def adb_disconnect(device): _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)