From 13bc0e237d9ca8abab4d5fa0a193ee090776d7cd Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 12 Feb 2016 08:35:37 +0100 Subject: [PATCH] Show NetGuard in the application list again Fixes #312 --- .../main/java/eu/faircode/netguard/Rule.java | 28 +++++++++---------- .../eu/faircode/netguard/SinkholeService.java | 4 --- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/Rule.java b/app/src/main/java/eu/faircode/netguard/Rule.java index cc193c19..e568d016 100644 --- a/app/src/main/java/eu/faircode/netguard/Rule.java +++ b/app/src/main/java/eu/faircode/netguard/Rule.java @@ -226,27 +226,25 @@ public class Rule { if (pre_system.containsKey(info.packageName)) rule.system = pre_system.get(info.packageName); + if (info.applicationInfo.uid == Process.myUid()) + rule.system = true; if (all || ((rule.system ? show_system : show_user) && (show_nointernet || rule.internet) && - (show_disabled || rule.enabled) && - info.applicationInfo.uid != Process.myUid())) { + (show_disabled || rule.enabled))) { - // Internet access is needed to resolve host names - if (info.applicationInfo.uid != Process.myUid()) { - rule.wifi_default = (pre_wifi_blocked.containsKey(info.packageName) ? pre_wifi_blocked.get(info.packageName) : default_wifi); - rule.other_default = (pre_other_blocked.containsKey(info.packageName) ? pre_other_blocked.get(info.packageName) : default_other); - rule.screen_wifi_default = default_screen_wifi; - rule.screen_other_default = default_screen_other; - rule.roaming_default = (pre_roaming.containsKey(info.packageName) ? pre_roaming.get(info.packageName) : default_roaming); + rule.wifi_default = (pre_wifi_blocked.containsKey(info.packageName) ? pre_wifi_blocked.get(info.packageName) : default_wifi); + rule.other_default = (pre_other_blocked.containsKey(info.packageName) ? pre_other_blocked.get(info.packageName) : default_other); + rule.screen_wifi_default = default_screen_wifi; + rule.screen_other_default = default_screen_other; + rule.roaming_default = (pre_roaming.containsKey(info.packageName) ? pre_roaming.get(info.packageName) : default_roaming); - rule.wifi_blocked = (!(rule.system && !manage_system) && wifi.getBoolean(info.packageName, rule.wifi_default)); - rule.other_blocked = (!(rule.system && !manage_system) && other.getBoolean(info.packageName, rule.other_default)); - rule.screen_wifi = screen_wifi.getBoolean(info.packageName, rule.screen_wifi_default); - rule.screen_other = screen_other.getBoolean(info.packageName, rule.screen_other_default); - rule.roaming = roaming.getBoolean(info.packageName, rule.roaming_default); - } + rule.wifi_blocked = (!(rule.system && !manage_system) && wifi.getBoolean(info.packageName, rule.wifi_default)); + rule.other_blocked = (!(rule.system && !manage_system) && other.getBoolean(info.packageName, rule.other_default)); + rule.screen_wifi = screen_wifi.getBoolean(info.packageName, rule.screen_wifi_default); + rule.screen_other = screen_other.getBoolean(info.packageName, rule.screen_other_default); + rule.roaming = roaming.getBoolean(info.packageName, rule.roaming_default); List listPkg = new ArrayList<>(); if (pre_related.containsKey(info.packageName)) diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 269ea4d6..5e0c94bd 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -1189,10 +1189,6 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS private Allowed isAddressAllowed(Packet packet) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - // Allow name resolving - if (packet.uid == Process.myUid()) - return new Allowed(); - packet.allowed = false; if (prefs.getBoolean("filter", false)) { if (packet.uid < 0) // unknown