From 2dbcbff4bfd61d2b1fc2ca908764586082904f1d Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Wed, 13 Oct 2021 20:00:41 +0530 Subject: [PATCH] Replace runtime push-requests expert setting with a compile-time configuration This partially reverts commit c2d9749105a8e5018307a3d57ff292de3b53005f * This feature let repos automatically install / uninstall apps. * It does not make sense to have as a user-facing option. * Change this to a compile-time option to allow whitelabel builds to easily enable this while securely keeping it disabled for everyone else who doesn't need it. * For more background, see: https://gitlab.com/fdroid/fdroidclient/-/merge_requests/1063#note_702867355 https://gitlab.com/fdroid/fdroid-website/-/merge_requests/721 Change-Id: Id5113816accaade2813b1ef053bf57afd5144ddb --- .../java/org/fdroid/fdroid/IndexUpdater.java | 11 ++++++++--- .../java/org/fdroid/fdroid/Preferences.java | 11 ----------- app/src/main/res/values/config.xml | 19 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 --- app/src/main/res/xml/preferences.xml | 6 ------ 5 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 app/src/main/res/values/config.xml diff --git a/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java b/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java index 614cd6e7e..9ce0d6278 100644 --- a/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java @@ -26,6 +26,7 @@ package org.fdroid.fdroid; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; +import android.content.res.Resources.NotFoundException; import android.content.pm.PackageInfo; import android.text.TextUtils; import android.util.Log; @@ -453,12 +454,16 @@ public class IndexUpdater { * Server index XML can include optional {@code install} and {@code uninstall} * requests. This processes those requests, figuring out whether the client * should always accept, prompt the user, or ignore those requests on a - * per repo basis. There is also a global preference as a failsafe. + * per repo basis. There is also a compile-time option as a failsafe. * - * @see Preferences#allowPushRequests() */ void processRepoPushRequests(List requestEntries) { - if (!Preferences.get().allowPushRequests()) { + try { + if (!context.getResources().getBoolean(R.bool.config_allowPushRequests)) { + return; + } + } catch (NotFoundException e) { + Utils.debugLog(TAG, "allowPushRequests configuration not found, defaulting to false"); return; } for (RepoPushRequest repoPushRequest : requestEntries) { diff --git a/app/src/main/java/org/fdroid/fdroid/Preferences.java b/app/src/main/java/org/fdroid/fdroid/Preferences.java index 5bf1fd0fe..a3e33b265 100644 --- a/app/src/main/java/org/fdroid/fdroid/Preferences.java +++ b/app/src/main/java/org/fdroid/fdroid/Preferences.java @@ -121,7 +121,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh public static final String PREF_HIDE_ON_LONG_PRESS_SEARCH = "hideOnLongPressSearch"; public static final String PREF_HIDE_ALL_NOTIFICATIONS = "hideAllNotifications"; public static final String PREF_SEND_VERSION_AND_UUID_TO_SERVERS = "sendVersionAndUUIDToServers"; - public static final String PREF_ALLOW_PUSH_REQUESTS = "allowPushRequests"; public static final int OVER_NETWORK_NEVER = 0; public static final int OVER_NETWORK_ON_DEMAND = 1; @@ -572,16 +571,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh return preferences.getBoolean(PREF_SEND_VERSION_AND_UUID_TO_SERVERS, IGNORED_B); } - /** - * Whether push requests are globally enabled or disabled. - * - * @see org.fdroid.fdroid.data.RepoPushRequest - * @see IndexUpdater#processRepoPushRequests(List) - */ - public boolean allowPushRequests() { - return preferences.getBoolean(PREF_ALLOW_PUSH_REQUESTS, IGNORED_B); - } - /** * This is cached as it is called several times inside app list adapters. * Providing it here means the shared preferences file only needs to be diff --git a/app/src/main/res/values/config.xml b/app/src/main/res/values/config.xml new file mode 100644 index 000000000..ae7dcb488 --- /dev/null +++ b/app/src/main/res/values/config.xml @@ -0,0 +1,19 @@ + + + + false + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0d8664129..2bcc70950 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -47,9 +47,6 @@ downloading, takes affect next app restart. Force old index format In case there are bugs or compatibility issues, use the XML app index - Allow repos to install/uninstall apps - Repo metadata can include "push requests" to install or uninstall apps - Other Automatic update interval diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 71251c3e3..bdfad323a 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -202,12 +202,6 @@ android:key="sendVersionAndUUIDToServers" android:summary="@string/send_version_and_uuid_summary" android:title="@string/send_version_and_uuid" /> -