Skip to content

Commit

Permalink
android fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcleinman committed Oct 18, 2024
1 parent 9019d2d commit 23ce998
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import android.net.NetworkRequest
import android.os.Build
import android.os.CountDownTimer
import mozilla.telemetry.glean.GleanTimerId
import java.time.LocalDateTime
import org.mozilla.firefox.vpn.daemon.GleanMetrics.ConnectionHealth
import org.mozilla.firefox.vpn.daemon.GleanMetrics.Session
import java.time.LocalDateTime
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors

Expand All @@ -36,8 +36,8 @@ class ConnectionHealth(service: VPNService) {
private var lastHealthStatus = ConnectionStability.Stable
private var connectionHealthTimerId: GleanTimerId? = null

private val SERVER_SWITCH_COOLDOWN_TIME = 15 // 15 minutes
private var nextPossibleServerSwitch = LocalDateTime.now().plusMinutes(SERVER_SWITCH_COOLDOWN_TIME)
private val SERVER_SWITCH_COOLDOWN_MINUTES: Long = 15
private var nextPossibleServerSwitch = LocalDateTime.now().plusMinutes(SERVER_SWITCH_COOLDOWN_MINUTES)

var mActive = false
var mVPNNetwork: Network? = null
Expand Down Expand Up @@ -246,7 +246,7 @@ class ConnectionHealth(service: VPNService) {
if (fallbackServerIsReachable) {
recordMetrics(ConnectionStability.Unstable)

if (nextPossibleServerSwitch < LocalDateTime.now()) {
if (LocalDateTime.now() < nextPossibleServerSwitch) {
Log.i(TAG, "Want to switch servers, but it has not been enough time since last server switch")
taskDone()
return@Runnable
Expand All @@ -257,7 +257,7 @@ class ConnectionHealth(service: VPNService) {
mService.mainLooper.run {
// Silent server switch to a different server in same geo
Session.daemonSilentServerSwitch.record()
nextPossibleServerSwitch = LocalDateTime.now().plusMinutes(SERVER_SWITCH_COOLDOWN_TIME)
nextPossibleServerSwitch = LocalDateTime.now().plusMinutes(SERVER_SWITCH_COOLDOWN_MINUTES)
mService.reconnect(true)
}
mResetUsed = true
Expand Down

0 comments on commit 23ce998

Please sign in to comment.