Merge branch 'replicant-fsdg-compliance' into 'master'

Skip non-FSDG-compliant apps on Replicant during repo data parsing

See merge request !452
This commit is contained in:
Peter Serwylo 2017-04-10 22:30:47 +00:00
commit 8e7096b2a8

View File

@ -303,7 +303,9 @@ public class RepoXMLHandler extends DefaultHandler {
} }
private void onApplicationParsed() { private void onApplicationParsed() {
receiver.receiveApp(curapp, apksList); if (!replicantFSDGviolation()) {
receiver.receiveApp(curapp, apksList);
}
curapp = null; curapp = null;
apksList = new ArrayList<>(); apksList = new ArrayList<>();
// If the app packageName is already present in this apps list, then it // If the app packageName is already present in this apps list, then it
@ -402,4 +404,27 @@ public class RepoXMLHandler extends DefaultHandler {
} }
return result; return result;
} }
private final String osVersion = System.getProperty("os.version");
/**
* Checks if an app fails to comply with the GNU Free System Distribution
* Guidelines in the case that F-Droid is installed on Replicant.
* Currently, all apps that have at least one of the following anti-features
* violate the guidelines: Tracking, NonFreeAdd, NonFreeDep and NonFreeAssets.
*/
private boolean replicantFSDGviolation() {
if (osVersion == null || !osVersion.contains("replicant")) {
return false;
}
if (curapp.antiFeatures != null && curapp.antiFeatures.length > 0) {
for (String af : curapp.antiFeatures) {
if ("Tracking".equals(af) || "NonFreeAdd".equals(af)
|| "NonFreeDep".equals(af) || "NonFreeAssets".equals(af)) {
return true;
}
}
}
return false;
}
} }