From 523c3f332721f576b3ae3ea6d01224df5856e099 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 30 Jan 2016 20:25:24 +0100 Subject: [PATCH] Honor manage system apps when notifying on access --- .../java/eu/faircode/netguard/SinkholeService.java | 8 +++++--- app/src/main/java/eu/faircode/netguard/Util.java | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 504248ec..c14aad98 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -657,9 +657,11 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS dh.insertLog(packet, rr == null ? null : rr.QName, (last_connected ? last_metered ? 2 : 1 : 0), last_interactive); if (packet.uid > 0) { - if (dh.updateAccess(packet, rr == null ? null : rr.QName) && - prefs.getBoolean("notify_access", false)) - showAccessNotification(packet.uid); + if (dh.updateAccess(packet, rr == null ? null : rr.QName)) + if (prefs.getBoolean("notify_access", false) && + (prefs.getBoolean("manage_system", false) || + !Util.isSystem(packet.uid, SinkholeService.this))) + showAccessNotification(packet.uid); } else if (packet.dport != 53) Log.w(TAG, "Unknown application packet=" + packet); diff --git a/app/src/main/java/eu/faircode/netguard/Util.java b/app/src/main/java/eu/faircode/netguard/Util.java index ddeb814c..093a1d35 100644 --- a/app/src/main/java/eu/faircode/netguard/Util.java +++ b/app/src/main/java/eu/faircode/netguard/Util.java @@ -299,6 +299,16 @@ public class Util { } } + public static boolean isSystem(int uid, Context context) { + PackageManager pm = context.getPackageManager(); + String[] pkgs = pm.getPackagesForUid(uid); + if (pkgs != null) + for (String pkg : pkgs) + if (isSystem(pkg, context)) + return true; + return false; + } + public static boolean isSystem(String packageName, Context context) { try { PackageManager pm = context.getPackageManager();