mirror of https://github.com/M66B/NetGuard.git
Added predefined rules to mark user applications
This commit is contained in:
parent
0e53973839
commit
62564e2190
|
@ -125,6 +125,7 @@ public class Rule {
|
||||||
Map<String, Boolean> pre_blocked = new HashMap<>();
|
Map<String, Boolean> pre_blocked = new HashMap<>();
|
||||||
Map<String, Boolean> pre_roaming = new HashMap<>();
|
Map<String, Boolean> pre_roaming = new HashMap<>();
|
||||||
Map<String, String[]> pre_related = new HashMap<>();
|
Map<String, String[]> pre_related = new HashMap<>();
|
||||||
|
Map<String, Boolean> pre_system = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
XmlResourceParser xml = context.getResources().getXml(R.xml.predefined);
|
XmlResourceParser xml = context.getResources().getXml(R.xml.predefined);
|
||||||
int eventType = xml.getEventType();
|
int eventType = xml.getEventType();
|
||||||
|
@ -142,10 +143,16 @@ public class Rule {
|
||||||
String pkg = xml.getAttributeValue(null, "package");
|
String pkg = xml.getAttributeValue(null, "package");
|
||||||
String[] rel = xml.getAttributeValue(null, "related").split(",");
|
String[] rel = xml.getAttributeValue(null, "related").split(",");
|
||||||
pre_related.put(pkg, rel);
|
pre_related.put(pkg, rel);
|
||||||
|
|
||||||
Log.d(tag, "Relation " + pkg + " related=" + TextUtils.join(",", 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
eventType = xml.next();
|
eventType = xml.next();
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
@ -157,6 +164,8 @@ public class Rule {
|
||||||
List<Rule> listRules = new ArrayList<>();
|
List<Rule> listRules = new ArrayList<>();
|
||||||
for (PackageInfo info : context.getPackageManager().getInstalledPackages(0)) {
|
for (PackageInfo info : context.getPackageManager().getInstalledPackages(0)) {
|
||||||
Rule rule = new Rule(info, context);
|
Rule rule = new Rule(info, context);
|
||||||
|
if (pre_system.containsKey(info.packageName))
|
||||||
|
rule.system = pre_system.get(info.packageName);
|
||||||
if (all ||
|
if (all ||
|
||||||
((rule.system ? show_system : show_user) &&
|
((rule.system ? show_system : show_user) &&
|
||||||
(show_nointernet ? true : rule.internet) &&
|
(show_nointernet ? true : rule.internet) &&
|
||||||
|
|
|
@ -13,4 +13,10 @@
|
||||||
package="com.android.chrome"
|
package="com.android.chrome"
|
||||||
related="com.android.providers.downloads"
|
related="com.android.providers.downloads"
|
||||||
title="Chrome" />
|
title="Chrome" />
|
||||||
|
<type
|
||||||
|
package="com.facebook.katana"
|
||||||
|
system="false" />
|
||||||
|
<type
|
||||||
|
package="com.google.android.youtube"
|
||||||
|
system="false" />
|
||||||
</predefined>
|
</predefined>
|
||||||
|
|
Loading…
Reference in New Issue