diff --git a/core/src/main/kotlin/com/malinskiy/marathon/execution/Scheduler.kt b/core/src/main/kotlin/com/malinskiy/marathon/execution/Scheduler.kt index 3d15da8b7..e3e703258 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/execution/Scheduler.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/execution/Scheduler.kt @@ -66,9 +66,10 @@ class Scheduler( initializeCache(scope) try { + logger.debug("Waiting for a device...") withTimeout(deviceProvider.deviceInitializationTimeoutMillis) { while (pools.isEmpty()) { - delay(100) + delay(500L) } } } catch (e: TimeoutCancellationException) { diff --git a/vendor/vendor-android/ddmlib/src/main/kotlin/com/malinskiy/marathon/android/ddmlib/DdmlibDeviceProvider.kt b/vendor/vendor-android/ddmlib/src/main/kotlin/com/malinskiy/marathon/android/ddmlib/DdmlibDeviceProvider.kt index 002483405..fc0138edf 100644 --- a/vendor/vendor-android/ddmlib/src/main/kotlin/com/malinskiy/marathon/android/ddmlib/DdmlibDeviceProvider.kt +++ b/vendor/vendor-android/ddmlib/src/main/kotlin/com/malinskiy/marathon/android/ddmlib/DdmlibDeviceProvider.kt @@ -13,7 +13,6 @@ import com.malinskiy.marathon.device.DeviceEvent import com.malinskiy.marathon.device.DeviceEvent.DeviceConnected import com.malinskiy.marathon.device.DeviceEvent.DeviceDisconnected import com.malinskiy.marathon.device.DeviceProvider -import com.malinskiy.marathon.exceptions.NoDevicesException import com.malinskiy.marathon.execution.Configuration import com.malinskiy.marathon.execution.StrictRunChecker import com.malinskiy.marathon.io.AttachmentManager @@ -68,33 +67,7 @@ class DdmlibDeviceProvider( AndroidDebugBridge.addDeviceChangeListener(this) logger.debug("Creating ADB bridge") - val adb = AndroidDebugBridge.createBridge(vendorConfiguration.adbPath.absolutePath, false, ADB_INIT_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS) - - var getDevicesCountdown = config.noDevicesTimeoutMillis - val sleepTime = DEFAULT_DDM_LIB_SLEEP_TIME - while (!adb.hasInitialDeviceList() || !adb.hasDevices() && getDevicesCountdown >= 0) { - logger.debug("No devices, waiting...") - - try { - delay(sleepTime) - } catch (e: InterruptedException) { - throw TimeoutException("Timeout getting device list", e) - } - getDevicesCountdown -= sleepTime - } - - logger.debug("Finished waiting for a device") - - if (adb.devices.isNotEmpty()) { - logger.debug("Initial connected devices: {}", adb.devices.joinToString(", ")) - adb.devices.forEach { - deviceConnected(it) - } - } - - if (!adb.hasInitialDeviceList() || !adb.hasDevices()) { - throw NoDevicesException() - } + AndroidDebugBridge.createBridge(vendorConfiguration.adbPath.absolutePath, false, ADB_INIT_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS) } private fun getDeviceOrPut(androidDevice: DdmlibAndroidDevice): DdmlibAndroidDevice { @@ -118,8 +91,6 @@ class DdmlibDeviceProvider( } } - private fun AndroidDebugBridge.hasDevices(): Boolean = devices.isNotEmpty() - override suspend fun terminate() { job.completeRecursively() job.join() @@ -250,6 +221,5 @@ class DdmlibDeviceProvider( companion object { private val ADB_INIT_TIMEOUT = Duration.ofSeconds(60) private const val DEFAULT_DDM_LIB_TIMEOUT = 30000 - private const val DEFAULT_DDM_LIB_SLEEP_TIME = 500L } }