Commit c2d97491 authored by Hans-Christoph Steiner's avatar Hans-Christoph Steiner
Browse files

add Expert Pref to enable Push Requests

Since !705 will allow OEMs, ROM makers, etc. to add repos, there needs to
be a way for the user to prevent those from automatically installing or
uninstalling apps for users of the full F-Droid app, which guarantees user
parent 1fe0d8f4
......@@ -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
* @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
......@@ -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<RepoPushRequest> requestEntries) {
if (!Preferences.get().allowPushRequests()) {
for (RepoPushRequest repoPushRequest : requestEntries) {
String packageName = repoPushRequest.packageName;
PackageInfo packageInfo = Utils.getPackageInfo(context, packageName);
......@@ -33,6 +33,9 @@
downloading, takes affect next app restart.</string>
<string name="force_old_index">Force old index format</string>
<string name="force_old_index_summary">In case there are bugs or compatibility issues, use the XML app index</string>
<string name="allow_push_requests">Allow repos to install/uninstall apps</string>
<string name="allow_push_requests_summary">Repo metadata can include "push requests" to install or uninstall apps
<string name="other">Other</string>
<string name="update_interval">Automatic update interval</string>
......@@ -190,6 +190,12 @@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment