diff --git a/app/src/main/java/org/fdroid/fdroid/Preferences.java b/app/src/main/java/org/fdroid/fdroid/Preferences.java index 3fa6dec15..aa4f1f6d6 100644 --- a/app/src/main/java/org/fdroid/fdroid/Preferences.java +++ b/app/src/main/java/org/fdroid/fdroid/Preferences.java @@ -108,6 +108,7 @@ 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; @@ -512,6 +513,16 @@ 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 RepoUpdater#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/java/org/fdroid/fdroid/RepoUpdater.java b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java index 08e25cd41..566a77124 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java @@ -442,9 +442,14 @@ public class RepoUpdater { * 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. + * per repo basis. There is also a global preference as a failsafe. + * + * @see Preferences#allowPushRequests() */ void processRepoPushRequests(List requestEntries) { + if (!Preferences.get().allowPushRequests()) { + return; + } for (RepoPushRequest repoPushRequest : requestEntries) { String packageName = repoPushRequest.packageName; PackageInfo packageInfo = Utils.getPackageInfo(context, packageName); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f2fa3367d..0520b5e25 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,6 +33,9 @@ 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 8d49dc77b..07748c8e4 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -190,6 +190,12 @@ android:summary="@string/send_version_and_uuid_summary" android:defaultValue="false" android:dependency="expert"/> +