mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-01 12:54:07 +00:00
Honor manage system apps when notifying on access
This commit is contained in:
parent
de8c09702e
commit
523c3f3327
2 changed files with 15 additions and 3 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue