Skip to content

Commit 1cc465b

Browse files
committed
sync list of protocol before engaging automatic mode.
1 parent d06dbb6 commit 1cc465b

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

base/src/main/java/com/windscribe/vpn/autoconnection/AutoConnectionManager.kt

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -302,22 +302,29 @@ class AutoConnectionManager(
302302
}
303303

304304
private fun engageAutomaticMode() {
305-
listOfProtocols.sortBy {
306-
it.type
307-
}
308-
val disconnectedProtocolList =
309-
listOfProtocols.filter { it.type == ProtocolConnectionStatus.Disconnected }
310-
if (disconnectedProtocolList.isNotEmpty()) {
311-
disconnectedProtocolList[0].type = ProtocolConnectionStatus.NextUp
312-
disconnectedProtocolList[0].autoConnectTimeLeft = 10
313-
showConnectionFailureDialog(
314-
listOfProtocols,
315-
retry = { engageAutomaticMode() })
316-
} else {
317-
logger.debug("Showing all protocol failed dialog.")
318-
lastKnownProtocolInformation = null
319-
reset()
320-
showAllProtocolFailedDialog()
305+
synchronized(listOfProtocols) {
306+
listOfProtocols.sortBy {
307+
it.type
308+
}
309+
310+
val disconnectedProtocolList =
311+
listOfProtocols.filter { it.type == ProtocolConnectionStatus.Disconnected }
312+
313+
if (disconnectedProtocolList.isNotEmpty()) {
314+
val first = disconnectedProtocolList[0]
315+
first.type = ProtocolConnectionStatus.NextUp
316+
first.autoConnectTimeLeft = 10
317+
318+
showConnectionFailureDialog(
319+
listOfProtocols,
320+
retry = { engageAutomaticMode() }
321+
)
322+
} else {
323+
logger.debug("Showing all protocol failed dialog.")
324+
lastKnownProtocolInformation = null
325+
reset()
326+
showAllProtocolFailedDialog()
327+
}
321328
}
322329
}
323330

0 commit comments

Comments
 (0)