mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-01-28 16:51:26 -05:00
Replace runtime push-requests expert setting with a compile-time configuration
This partially reverts commit c2d9749105
* 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
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
478b416861
commit
2dbcbff4bf
@@ -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<RepoPushRequest> 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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
19
app/src/main/res/values/config.xml
Normal file
19
app/src/main/res/values/config.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Calyx Institute
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<bool name="config_allowPushRequests">false</bool>
|
||||
</resources>
|
||||
@@ -47,9 +47,6 @@
|
||||
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>
|
||||
<string name="other">Other</string>
|
||||
|
||||
<string name="update_interval">Automatic update interval</string>
|
||||
|
||||
@@ -202,12 +202,6 @@
|
||||
android:key="sendVersionAndUUIDToServers"
|
||||
android:summary="@string/send_version_and_uuid_summary"
|
||||
android:title="@string/send_version_and_uuid" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="expert"
|
||||
android:key="allowPushRequests"
|
||||
android:summary="@string/allow_push_requests_summary"
|
||||
android:title="@string/allow_push_requests" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="expert"
|
||||
|
||||
Reference in New Issue
Block a user