Bug 1335944 - Delay devicemanagerADB sdk check until connect() time. r=bc, a=test-only
authorGeoff Brown <gbrown@mozilla.com>
Thu, 02 Feb 2017 09:29:08 -0700
changeset 378152 f78fc2f94d078089b75b6a055a5ae72205386e6a
parent 378151 cfb67ac16037824372bb5f90b9eb80800cd0a4bf
child 378153 f4a0fbbefd444b54ab3d2daae5cb297fa7988acd
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbc, test-only
bugs1335944
milestone53.0a2
Bug 1335944 - Delay devicemanagerADB sdk check until connect() time. r=bc, a=test-only
testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -80,16 +80,25 @@ class DeviceManagerADB(DeviceManager):
         if not self.connected:
             # try to connect to the device over tcp/ip if we have a hostname
             if self.host:
                 self._connectRemoteADB()
 
             # verify that we can connect to the device. can't continue
             self._verifyDevice()
 
+            # Note SDK version
+            try:
+                proc = self._runCmd(["shell", "getprop", "ro.build.version.sdk"],
+                                    timeout=self.short_timeout)
+                self._sdk_version = int(proc.output[0])
+            except (OSError, ValueError):
+                self._sdk_version = 0
+            self._logger.info("Detected Android sdk %d" % self._sdk_version)
+
             # Some commands require root to work properly, even with ADB (e.g.
             # grabbing APKs out of /data). For these cases, we check whether
             # we're running as root. If that isn't true, check for the
             # existence of an su binary
             self._checkForRoot()
 
             # can we use zip to speed up some file operations? (currently not
             # required)
@@ -754,21 +763,17 @@ class DeviceManagerADB(DeviceManager):
         if self._adbPath != 'adb':
             if not os.access(self._adbPath, os.X_OK):
                 raise DMError("invalid adb path, or adb not executable: %s" % self._adbPath)
 
         try:
             re_version = re.compile(r'Android Debug Bridge version (.*)')
             proc = self._runCmd(["version"], timeout=self.short_timeout)
             self._adb_version = re_version.match(proc.output[0]).group(1)
-            self._logger.info("Detected adb %s", self._adb_version)
-            proc = self._runCmd(["shell", "getprop", "ro.build.version.sdk"],
-                                timeout=self.short_timeout)
-            self._sdk_version = int(proc.output[0])
-            self._logger.info("Detected Android sdk %s", self._sdk_version)
+            self._logger.info("Detected adb %s" % self._adb_version)
         except os.error as err:
             raise DMError(
                 "unable to execute ADB (%s): ensure Android SDK is installed "
                 "and adb is in your $PATH" % err)
 
     def _verifyDevice(self):
         # If there is a device serial number, see if adb is connected to it
         if self._deviceSerial: