From 8f8afdb10d28506c4308cd3251b1774b12731613 Mon Sep 17 00:00:00 2001 From: Wolfgang Wiedmeyer Date: Tue, 21 Mar 2017 21:03:52 +0100 Subject: [PATCH] Skip non-FSDG-compliant apps on Replicant during repo data parsing Replicant is committed to follow the GNU Free System Distribution Guidelines (FSDG)[1]. Apps with certain anti-feature flags in F-Droid violate these guidelines and thus shouldn't be available in the F-Droid client on Replicant[2]. Issue #564 discusses this, although only the case of having apps with anti-features optionally filtered. To be compliant with the FSDG guidelines, all violating apps must not be accessible and there shouldn't be a setting to make them visible. Not all anti-features in F-Droid violate the FSDG guidelines, so no need to filter all of them. Signed-off-by: Wolfgang Wiedmeyer [1] https://www.gnu.org/distros/free-system-distribution-guidelines.html [2] https://redmine.replicant.us/issues/1629 --- .../org/fdroid/fdroid/RepoXMLHandler.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java b/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java index 345b0d890..fc9d39687 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java @@ -303,7 +303,9 @@ public class RepoXMLHandler extends DefaultHandler { } private void onApplicationParsed() { - receiver.receiveApp(curapp, apksList); + if (!replicantFSDGviolation()) { + receiver.receiveApp(curapp, apksList); + } curapp = null; apksList = new ArrayList<>(); // If the app packageName is already present in this apps list, then it @@ -402,4 +404,27 @@ public class RepoXMLHandler extends DefaultHandler { } 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; + } }