Skip to content

Commit

Permalink
Avoid duplicate DeviceConnected events
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Chelombitko committed Dec 31, 2024
1 parent e9e7cc1 commit cadcc6d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ class DdmlibDeviceProvider(
AndroidDebugBridge.addDeviceChangeListener(this)

logger.debug("Creating ADB bridge")

val oldAdb = AndroidDebugBridge.getBridge()
val adb = AndroidDebugBridge.createBridge(vendorConfiguration.adbPath.absolutePath, false, ADB_INIT_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS)
val newAdbCreated = adb !== oldAdb
if (!newAdbCreated) {
logger.debug("Reusing existing ADB bridge")
}

var getDevicesCountdown = config.noDevicesTimeoutMillis
val sleepTime = DEFAULT_DDM_LIB_SLEEP_TIME
Expand All @@ -83,7 +89,7 @@ class DdmlibDeviceProvider(

logger.debug("Finished waiting for a device")

if (adb.devices.isNotEmpty()) {
if (!newAdbCreated && adb.devices.isNotEmpty()) {
logger.debug("Initial connected devices: {}", adb.devices.joinToString(", "))
adb.devices.forEach {
deviceConnected(it)
Expand Down

0 comments on commit cadcc6d

Please sign in to comment.