From b26f40d3918f44a24ed9e20c93f325585a34fd76 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 16 Aug 2017 10:01:20 +0200 Subject: [PATCH] Android O fix --- .../main/java/eu/faircode/netguard/ServiceSinkhole.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java index bf34bc68..0ec24e12 100644 --- a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java +++ b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java @@ -2138,9 +2138,6 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS @Override public void onCreate() { - startForeground(NOTIFY_WAITING, getWaitingNotification()); - state = State.waiting; - Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this)); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -2314,6 +2311,11 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS @Override public int onStartCommand(Intent intent, int flags, int startId) { + if (state == State.enforcing) + startForeground(NOTIFY_ENFORCING, getEnforcingNotification(0, 0, 0)); + else + startForeground(NOTIFY_WAITING, getWaitingNotification()); + Log.i(TAG, "Received " + intent); Util.logExtras(intent);