Honor manage system apps when notifying on access

This commit is contained in:
M66B 2016-01-30 20:25:24 +01:00
parent de8c09702e
commit 523c3f3327
2 changed files with 15 additions and 3 deletions

View File

@ -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);

View File

@ -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();