mirror of https://github.com/M66B/NetGuard.git
Fixed checking for system applications
This commit is contained in:
parent
f1e2924f22
commit
a65e56e218
|
@ -127,6 +127,7 @@ public class Rule {
|
|||
Map<String, Boolean> pre_other_blocked = new HashMap<>();
|
||||
Map<String, Boolean> pre_roaming = new HashMap<>();
|
||||
Map<String, String[]> pre_related = new HashMap<>();
|
||||
Map<String, Boolean> pre_system = new HashMap<>();
|
||||
try {
|
||||
XmlResourceParser xml = context.getResources().getXml(R.xml.predefined);
|
||||
int eventType = xml.getEventType();
|
||||
|
@ -152,6 +153,11 @@ public class Rule {
|
|||
pre_related.put(pkg, rel);
|
||||
Log.d(tag, "Relation " + pkg + " related=" + TextUtils.join(",", rel));
|
||||
|
||||
} else if ("type".equals(xml.getName())) {
|
||||
String pkg = xml.getAttributeValue(null, "package");
|
||||
boolean system = xml.getAttributeBooleanValue(null, "system", true);
|
||||
pre_system.put(pkg, system);
|
||||
Log.d(tag, "Type " + pkg + " system=" + system);
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,6 +177,10 @@ public class Rule {
|
|||
continue;
|
||||
|
||||
Rule rule = new Rule(info, context);
|
||||
|
||||
if (pre_system.containsKey(info.packageName))
|
||||
rule.system = pre_system.get(info.packageName);
|
||||
|
||||
if (all ||
|
||||
((rule.system ? show_system : show_user) &&
|
||||
(show_nointernet ? true : rule.internet) &&
|
||||
|
|
|
@ -312,10 +312,14 @@ public class Util {
|
|||
public static boolean isSystem(String packageName, Context context) {
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
PackageInfo info = pm.getPackageInfo(packageName, 0);
|
||||
return ((info.applicationInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0);
|
||||
/*
|
||||
PackageInfo pkg = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
|
||||
PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
|
||||
return (pkg != null && pkg.signatures != null && pkg.signatures.length > 0 &&
|
||||
sys.signatures.length > 0 && sys.signatures[0].equals(pkg.signatures[0]));
|
||||
*/
|
||||
} catch (PackageManager.NameNotFoundException ignore) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,4 +26,23 @@
|
|||
<relation
|
||||
package="com.android.chrome"
|
||||
related="com.android.providers.downloads" />
|
||||
|
||||
<type
|
||||
package="com.facebook.katana"
|
||||
system="false" />
|
||||
<type
|
||||
package="com.facebook.orca"
|
||||
system="false" />
|
||||
<type
|
||||
package="com.google.android.youtube"
|
||||
system="false" />
|
||||
<type
|
||||
package="com.skype.raider"
|
||||
system="false" />
|
||||
<type
|
||||
package="com.twitter.android"
|
||||
system="false" />
|
||||
<type
|
||||
package="com.whatsapp"
|
||||
system="false" />
|
||||
</predefined>
|
||||
|
|
Loading…
Reference in New Issue