mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
minor: disable stats job when app is closed
Adds a slight battery performance improvement #437
This commit is contained in:
+1
-1
@@ -273,7 +273,7 @@ constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val STATS_START_DELAY = 5_000L
|
||||
const val STATS_START_DELAY = 1_000L
|
||||
const val VPN_STATISTIC_CHECK_INTERVAL = 1_000L
|
||||
const val VPN_RESTART_DELAY = 1_000L
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ constructor(
|
||||
}
|
||||
|
||||
private suspend fun initTunnel() {
|
||||
if (tunnelService.get().getState() == TunnelState.UP) tunnelService.get().startStatsJob()
|
||||
val activeTunnels = appDataRepository.tunnels.getActive()
|
||||
if (activeTunnels.isNotEmpty() &&
|
||||
tunnelService.get().getState() == TunnelState.DOWN
|
||||
|
||||
@@ -215,4 +215,9 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
// save battery by not polling stats while app is closed
|
||||
tunnelService.cancelStatsJob()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user