diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index b98c33f7..c102d834 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -255,7 +255,7 @@ public class SinkholeService extends VpnService { private void startStats() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SinkholeService.this); - boolean enabled = prefs.getBoolean("show_stats", false); + boolean enabled = (!stats && prefs.getBoolean("show_stats", false)); Log.i(TAG, "Stats start enabled=" + enabled); if (enabled) { t = -1; @@ -272,14 +272,13 @@ public class SinkholeService extends VpnService { private void stopStats() { Log.i(TAG, "Stats stop"); stats = false; + mServiceHandler.removeMessages(MSG_STATS_START); + mServiceHandler.removeMessages(MSG_STATS_STOP); mServiceHandler.removeMessages(MSG_STATS_UPDATE); NotificationManagerCompat.from(SinkholeService.this).cancel(NOTIFY_TRAFFIC); } private void updateStats() { - if (!stats) - return; - // Schedule next update mServiceHandler.sendEmptyMessageDelayed(MSG_STATS_UPDATE, 1000);