From 4a0adc143e107f140deaf77edd4af482a1808dbe Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 11 Jan 2016 18:42:50 +0100 Subject: [PATCH] Give service on background time to stop --- .../main/java/eu/faircode/netguard/SinkholeService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 1b4cca7c..b9961529 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -800,8 +800,15 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS if (user_foreground) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SinkholeService.this); - if (prefs.getBoolean("enabled", false)) + if (prefs.getBoolean("enabled", false)) { + // Allow service of background user to stop + try { + Thread.sleep(3000); + } catch (InterruptedException ignored) { + } + start("foreground", SinkholeService.this); + } } else stop("background", SinkholeService.this); }