mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Merge branch 'default-plugin-settings' into 'master'
Enable LAN plugin by default, move default settings to constants See merge request briar/briar!1256
This commit is contained in:
@@ -42,6 +42,7 @@ import static java.util.Collections.list;
|
|||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
import static org.briarproject.bramble.api.plugin.LanTcpConstants.DEFAULT_PREF_PLUGIN_ENABLE;
|
||||||
import static org.briarproject.bramble.api.plugin.Plugin.State.ACTIVE;
|
import static org.briarproject.bramble.api.plugin.Plugin.State.ACTIVE;
|
||||||
import static org.briarproject.bramble.api.plugin.Plugin.State.INACTIVE;
|
import static org.briarproject.bramble.api.plugin.Plugin.State.INACTIVE;
|
||||||
import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
||||||
@@ -82,7 +83,8 @@ class AndroidLanTcpPlugin extends LanTcpPlugin {
|
|||||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||||
initialisePortProperty();
|
initialisePortProperty();
|
||||||
Settings settings = callback.getSettings();
|
Settings settings = callback.getSettings();
|
||||||
state.setStarted(settings.getBoolean(PREF_PLUGIN_ENABLE, false));
|
state.setStarted(settings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
|
DEFAULT_PREF_PLUGIN_ENABLE));
|
||||||
updateConnectionStatus();
|
updateConnectionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ public interface BluetoothConstants {
|
|||||||
|
|
||||||
int UUID_BYTES = 16;
|
int UUID_BYTES = 16;
|
||||||
|
|
||||||
|
// Transport properties
|
||||||
String PROP_ADDRESS = "address";
|
String PROP_ADDRESS = "address";
|
||||||
String PROP_UUID = "uuid";
|
String PROP_UUID = "uuid";
|
||||||
|
|
||||||
|
// Default value for PREF_PLUGIN_ENABLE
|
||||||
|
boolean DEFAULT_PREF_PLUGIN_ENABLE = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,7 @@ public interface LanTcpConstants {
|
|||||||
// Local settings (not shared with contacts)
|
// Local settings (not shared with contacts)
|
||||||
String PREF_LAN_IP_PORTS = "ipPorts";
|
String PREF_LAN_IP_PORTS = "ipPorts";
|
||||||
String PREF_IPV6 = "ipv6";
|
String PREF_IPV6 = "ipv6";
|
||||||
|
|
||||||
|
// Default value for PREF_PLUGIN_ENABLE
|
||||||
|
boolean DEFAULT_PREF_PLUGIN_ENABLE = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ public interface TorConstants {
|
|||||||
|
|
||||||
TransportId ID = new TransportId("org.briarproject.bramble.tor");
|
TransportId ID = new TransportId("org.briarproject.bramble.tor");
|
||||||
|
|
||||||
|
// Transport properties
|
||||||
String PROP_ONION_V2 = "onion";
|
String PROP_ONION_V2 = "onion";
|
||||||
String PROP_ONION_V3 = "onion3";
|
String PROP_ONION_V3 = "onion3";
|
||||||
|
|
||||||
@@ -13,17 +14,25 @@ public interface TorConstants {
|
|||||||
int CONNECT_TO_PROXY_TIMEOUT = 5000; // Milliseconds
|
int CONNECT_TO_PROXY_TIMEOUT = 5000; // Milliseconds
|
||||||
int EXTRA_SOCKET_TIMEOUT = 30000; // Milliseconds
|
int EXTRA_SOCKET_TIMEOUT = 30000; // Milliseconds
|
||||||
|
|
||||||
|
// Local settings (not shared with contacts)
|
||||||
String PREF_TOR_NETWORK = "network2";
|
String PREF_TOR_NETWORK = "network2";
|
||||||
String PREF_TOR_PORT = "port";
|
String PREF_TOR_PORT = "port";
|
||||||
String PREF_TOR_MOBILE = "useMobileData";
|
String PREF_TOR_MOBILE = "useMobileData";
|
||||||
String PREF_TOR_ONLY_WHEN_CHARGING = "onlyWhenCharging";
|
String PREF_TOR_ONLY_WHEN_CHARGING = "onlyWhenCharging";
|
||||||
|
|
||||||
|
// Values for PREF_TOR_NETWORK
|
||||||
int PREF_TOR_NETWORK_AUTOMATIC = 0;
|
int PREF_TOR_NETWORK_AUTOMATIC = 0;
|
||||||
int PREF_TOR_NETWORK_WITHOUT_BRIDGES = 1;
|
int PREF_TOR_NETWORK_WITHOUT_BRIDGES = 1;
|
||||||
int PREF_TOR_NETWORK_WITH_BRIDGES = 2;
|
int PREF_TOR_NETWORK_WITH_BRIDGES = 2;
|
||||||
// TODO: Remove when settings migration code is removed
|
// TODO: Remove when settings migration code is removed
|
||||||
int PREF_TOR_NETWORK_NEVER = 3;
|
int PREF_TOR_NETWORK_NEVER = 3;
|
||||||
|
|
||||||
|
// Default values for local settings
|
||||||
|
boolean DEFAULT_PREF_PLUGIN_ENABLE = true;
|
||||||
|
int DEFAULT_PREF_TOR_NETWORK = PREF_TOR_NETWORK_AUTOMATIC;
|
||||||
|
boolean DEFAULT_PREF_TOR_MOBILE = true;
|
||||||
|
boolean DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reason flag returned by {@link Plugin#getReasonsDisabled()}.
|
* Reason flag returned by {@link Plugin#getReasonsDisabled()}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,4 +4,7 @@ public interface WanTcpConstants {
|
|||||||
|
|
||||||
TransportId ID = new TransportId("org.briarproject.bramble.wan");
|
TransportId ID = new TransportId("org.briarproject.bramble.wan");
|
||||||
|
|
||||||
|
// Default value for PREF_PLUGIN_ENABLE
|
||||||
|
boolean DEFAULT_PREF_PLUGIN_ENABLE = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import static java.util.logging.Level.INFO;
|
|||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.api.keyagreement.KeyAgreementConstants.TRANSPORT_ID_BLUETOOTH;
|
import static org.briarproject.bramble.api.keyagreement.KeyAgreementConstants.TRANSPORT_ID_BLUETOOTH;
|
||||||
|
import static org.briarproject.bramble.api.plugin.BluetoothConstants.DEFAULT_PREF_PLUGIN_ENABLE;
|
||||||
import static org.briarproject.bramble.api.plugin.BluetoothConstants.ID;
|
import static org.briarproject.bramble.api.plugin.BluetoothConstants.ID;
|
||||||
import static org.briarproject.bramble.api.plugin.BluetoothConstants.PROP_ADDRESS;
|
import static org.briarproject.bramble.api.plugin.BluetoothConstants.PROP_ADDRESS;
|
||||||
import static org.briarproject.bramble.api.plugin.BluetoothConstants.PROP_UUID;
|
import static org.briarproject.bramble.api.plugin.BluetoothConstants.PROP_UUID;
|
||||||
@@ -164,7 +165,8 @@ abstract class BluetoothPlugin<SS> implements DuplexPlugin, EventListener {
|
|||||||
public void start() throws PluginException {
|
public void start() throws PluginException {
|
||||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||||
Settings settings = callback.getSettings();
|
Settings settings = callback.getSettings();
|
||||||
boolean enabledByUser = settings.getBoolean(PREF_PLUGIN_ENABLE, false);
|
boolean enabledByUser = settings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
|
DEFAULT_PREF_PLUGIN_ENABLE);
|
||||||
state.setStarted(enabledByUser);
|
state.setStarted(enabledByUser);
|
||||||
try {
|
try {
|
||||||
initialiseAdapter();
|
initialiseAdapter();
|
||||||
@@ -432,7 +434,8 @@ abstract class BluetoothPlugin<SS> implements DuplexPlugin, EventListener {
|
|||||||
|
|
||||||
@IoExecutor
|
@IoExecutor
|
||||||
private void onSettingsUpdated(Settings settings) {
|
private void onSettingsUpdated(Settings settings) {
|
||||||
boolean enabledByUser = settings.getBoolean(PREF_PLUGIN_ENABLE, false);
|
boolean enabledByUser = settings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
|
DEFAULT_PREF_PLUGIN_ENABLE);
|
||||||
SS ss = state.setEnabledByUser(enabledByUser);
|
SS ss = state.setEnabledByUser(enabledByUser);
|
||||||
State s = getState();
|
State s = getState();
|
||||||
if (ss != null) {
|
if (ss != null) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import static java.util.logging.Level.INFO;
|
|||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.api.keyagreement.KeyAgreementConstants.TRANSPORT_ID_LAN;
|
import static org.briarproject.bramble.api.keyagreement.KeyAgreementConstants.TRANSPORT_ID_LAN;
|
||||||
|
import static org.briarproject.bramble.api.plugin.LanTcpConstants.DEFAULT_PREF_PLUGIN_ENABLE;
|
||||||
import static org.briarproject.bramble.api.plugin.LanTcpConstants.ID;
|
import static org.briarproject.bramble.api.plugin.LanTcpConstants.ID;
|
||||||
import static org.briarproject.bramble.api.plugin.LanTcpConstants.PREF_IPV6;
|
import static org.briarproject.bramble.api.plugin.LanTcpConstants.PREF_IPV6;
|
||||||
import static org.briarproject.bramble.api.plugin.LanTcpConstants.PREF_LAN_IP_PORTS;
|
import static org.briarproject.bramble.api.plugin.LanTcpConstants.PREF_LAN_IP_PORTS;
|
||||||
@@ -103,7 +104,8 @@ class LanTcpPlugin extends TcpPlugin {
|
|||||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||||
initialisePortProperty();
|
initialisePortProperty();
|
||||||
Settings settings = callback.getSettings();
|
Settings settings = callback.getSettings();
|
||||||
state.setStarted(settings.getBoolean(PREF_PLUGIN_ENABLE, false));
|
state.setStarted(settings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
|
DEFAULT_PREF_PLUGIN_ENABLE));
|
||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,6 +118,11 @@ class LanTcpPlugin extends TcpPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isEnabledByDefault() {
|
||||||
|
return DEFAULT_PREF_PLUGIN_ENABLE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<InetSocketAddress> getLocalSocketAddresses(boolean ipv4) {
|
protected List<InetSocketAddress> getLocalSocketAddresses(boolean ipv4) {
|
||||||
TransportProperties p = callback.getLocalProperties();
|
TransportProperties p = callback.getLocalProperties();
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ abstract class TcpPlugin implements DuplexPlugin, EventListener {
|
|||||||
protected abstract boolean isConnectable(InterfaceAddress local,
|
protected abstract boolean isConnectable(InterfaceAddress local,
|
||||||
InetSocketAddress remote);
|
InetSocketAddress remote);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the plugin is enabled by default.
|
||||||
|
*/
|
||||||
|
protected abstract boolean isEnabledByDefault();
|
||||||
|
|
||||||
TcpPlugin(Executor ioExecutor, Backoff backoff, PluginCallback callback,
|
TcpPlugin(Executor ioExecutor, Backoff backoff, PluginCallback callback,
|
||||||
int maxLatency, int maxIdleTime, int connectionTimeout) {
|
int maxLatency, int maxIdleTime, int connectionTimeout) {
|
||||||
this.ioExecutor = ioExecutor;
|
this.ioExecutor = ioExecutor;
|
||||||
@@ -131,7 +136,8 @@ abstract class TcpPlugin implements DuplexPlugin, EventListener {
|
|||||||
public void start() {
|
public void start() {
|
||||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||||
Settings settings = callback.getSettings();
|
Settings settings = callback.getSettings();
|
||||||
state.setStarted(settings.getBoolean(PREF_PLUGIN_ENABLE, false));
|
state.setStarted(
|
||||||
|
settings.getBoolean(PREF_PLUGIN_ENABLE, isEnabledByDefault()));
|
||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +408,8 @@ abstract class TcpPlugin implements DuplexPlugin, EventListener {
|
|||||||
|
|
||||||
@IoExecutor
|
@IoExecutor
|
||||||
private void onSettingsUpdated(Settings settings) {
|
private void onSettingsUpdated(Settings settings) {
|
||||||
boolean enabledByUser = settings.getBoolean(PREF_PLUGIN_ENABLE, false);
|
boolean enabledByUser =
|
||||||
|
settings.getBoolean(PREF_PLUGIN_ENABLE, isEnabledByDefault());
|
||||||
List<ServerSocket> toClose = state.setEnabledByUser(enabledByUser);
|
List<ServerSocket> toClose = state.setEnabledByUser(enabledByUser);
|
||||||
State s = getState();
|
State s = getState();
|
||||||
if (!toClose.isEmpty()) {
|
if (!toClose.isEmpty()) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
|
import static org.briarproject.bramble.api.plugin.WanTcpConstants.DEFAULT_PREF_PLUGIN_ENABLE;
|
||||||
import static org.briarproject.bramble.api.plugin.WanTcpConstants.ID;
|
import static org.briarproject.bramble.api.plugin.WanTcpConstants.ID;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@@ -42,6 +43,11 @@ class WanTcpPlugin extends TcpPlugin {
|
|||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isEnabledByDefault() {
|
||||||
|
return DEFAULT_PREF_PLUGIN_ENABLE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<InetSocketAddress> getLocalSocketAddresses(boolean ipv4) {
|
protected List<InetSocketAddress> getLocalSocketAddresses(boolean ipv4) {
|
||||||
if (!ipv4) return emptyList();
|
if (!ipv4) return emptyList();
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ import static org.briarproject.bramble.api.plugin.Plugin.State.ENABLING;
|
|||||||
import static org.briarproject.bramble.api.plugin.Plugin.State.INACTIVE;
|
import static org.briarproject.bramble.api.plugin.Plugin.State.INACTIVE;
|
||||||
import static org.briarproject.bramble.api.plugin.Plugin.State.STARTING_STOPPING;
|
import static org.briarproject.bramble.api.plugin.Plugin.State.STARTING_STOPPING;
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.CONTROL_PORT;
|
import static org.briarproject.bramble.api.plugin.TorConstants.CONTROL_PORT;
|
||||||
|
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_PLUGIN_ENABLE;
|
||||||
|
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_MOBILE;
|
||||||
|
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_NETWORK;
|
||||||
|
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING;
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.ID;
|
import static org.briarproject.bramble.api.plugin.TorConstants.ID;
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_MOBILE;
|
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_MOBILE;
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK;
|
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK;
|
||||||
@@ -290,9 +294,9 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
// TODO: Remove after a reasonable migration period (added 2020-06-25)
|
// TODO: Remove after a reasonable migration period (added 2020-06-25)
|
||||||
private Settings migrateSettings(Settings settings) {
|
private Settings migrateSettings(Settings settings) {
|
||||||
int network = settings.getInt(PREF_TOR_NETWORK,
|
int network = settings.getInt(PREF_TOR_NETWORK,
|
||||||
PREF_TOR_NETWORK_AUTOMATIC);
|
DEFAULT_PREF_TOR_NETWORK);
|
||||||
if (network == PREF_TOR_NETWORK_NEVER) {
|
if (network == PREF_TOR_NETWORK_NEVER) {
|
||||||
settings.putInt(PREF_TOR_NETWORK, PREF_TOR_NETWORK_AUTOMATIC);
|
settings.putInt(PREF_TOR_NETWORK, DEFAULT_PREF_TOR_NETWORK);
|
||||||
settings.putBoolean(PREF_PLUGIN_ENABLE, false);
|
settings.putBoolean(PREF_PLUGIN_ENABLE, false);
|
||||||
callback.mergeSettings(settings);
|
callback.mergeSettings(settings);
|
||||||
}
|
}
|
||||||
@@ -774,13 +778,15 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
String country = locationUtils.getCurrentCountry();
|
String country = locationUtils.getCurrentCountry();
|
||||||
boolean blocked =
|
boolean blocked =
|
||||||
circumventionProvider.isTorProbablyBlocked(country);
|
circumventionProvider.isTorProbablyBlocked(country);
|
||||||
boolean enabledByUser =
|
boolean enabledByUser = settings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
settings.getBoolean(PREF_PLUGIN_ENABLE, true);
|
DEFAULT_PREF_PLUGIN_ENABLE);
|
||||||
int network = settings.getInt(PREF_TOR_NETWORK,
|
int network = settings.getInt(PREF_TOR_NETWORK,
|
||||||
PREF_TOR_NETWORK_AUTOMATIC);
|
DEFAULT_PREF_TOR_NETWORK);
|
||||||
boolean useMobile = settings.getBoolean(PREF_TOR_MOBILE, true);
|
boolean useMobile = settings.getBoolean(PREF_TOR_MOBILE,
|
||||||
|
DEFAULT_PREF_TOR_MOBILE);
|
||||||
boolean onlyWhenCharging =
|
boolean onlyWhenCharging =
|
||||||
settings.getBoolean(PREF_TOR_ONLY_WHEN_CHARGING, false);
|
settings.getBoolean(PREF_TOR_ONLY_WHEN_CHARGING,
|
||||||
|
DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING);
|
||||||
boolean bridgesWork = circumventionProvider.doBridgesWork(country);
|
boolean bridgesWork = circumventionProvider.doBridgesWork(country);
|
||||||
boolean automatic = network == PREF_TOR_NETWORK_AUTOMATIC;
|
boolean automatic = network == PREF_TOR_NETWORK_AUTOMATIC;
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ import static androidx.core.view.ViewCompat.LAYOUT_DIRECTION_LTR;
|
|||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.bramble.api.plugin.Plugin.PREF_PLUGIN_ENABLE;
|
import static org.briarproject.bramble.api.plugin.Plugin.PREF_PLUGIN_ENABLE;
|
||||||
|
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_MOBILE;
|
||||||
|
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_NETWORK;
|
||||||
|
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING;
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_MOBILE;
|
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_MOBILE;
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK;
|
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK;
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK_AUTOMATIC;
|
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK_AUTOMATIC;
|
||||||
@@ -372,9 +375,9 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
|
|
||||||
// TODO: Remove after a reasonable migration period (added 2020-06-25)
|
// TODO: Remove after a reasonable migration period (added 2020-06-25)
|
||||||
private Settings migrateTorSettings(Settings s) {
|
private Settings migrateTorSettings(Settings s) {
|
||||||
int network = s.getInt(PREF_TOR_NETWORK, PREF_TOR_NETWORK_AUTOMATIC);
|
int network = s.getInt(PREF_TOR_NETWORK, DEFAULT_PREF_TOR_NETWORK);
|
||||||
if (network == PREF_TOR_NETWORK_NEVER) {
|
if (network == PREF_TOR_NETWORK_NEVER) {
|
||||||
s.putInt(PREF_TOR_NETWORK, PREF_TOR_NETWORK_AUTOMATIC);
|
s.putInt(PREF_TOR_NETWORK, DEFAULT_PREF_TOR_NETWORK);
|
||||||
s.putBoolean(PREF_PLUGIN_ENABLE, false);
|
s.putBoolean(PREF_PLUGIN_ENABLE, false);
|
||||||
// We don't need to save the migrated settings - the Tor plugin is
|
// We don't need to save the migrated settings - the Tor plugin is
|
||||||
// responsible for that. This code just handles the case where the
|
// responsible for that. This code just handles the case where the
|
||||||
@@ -388,29 +391,32 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
// due to events, we might try to display before a load completed
|
// due to events, we might try to display before a load completed
|
||||||
if (!settingsLoaded) return;
|
if (!settingsLoaded) return;
|
||||||
|
|
||||||
boolean btEnabledSetting =
|
boolean btEnabledSetting = btSettings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
btSettings.getBoolean(PREF_PLUGIN_ENABLE, false);
|
BluetoothConstants.DEFAULT_PREF_PLUGIN_ENABLE);
|
||||||
enableBluetooth.setChecked(btEnabledSetting);
|
enableBluetooth.setChecked(btEnabledSetting);
|
||||||
|
|
||||||
boolean wifiEnabledSetting =
|
boolean wifiEnabledSetting =
|
||||||
wifiSettings.getBoolean(PREF_PLUGIN_ENABLE, false);
|
wifiSettings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
|
LanTcpConstants.DEFAULT_PREF_PLUGIN_ENABLE);
|
||||||
enableWifi.setChecked(wifiEnabledSetting);
|
enableWifi.setChecked(wifiEnabledSetting);
|
||||||
|
|
||||||
boolean torEnabledSetting =
|
boolean torEnabledSetting =
|
||||||
torSettings.getBoolean(PREF_PLUGIN_ENABLE, true);
|
torSettings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
|
TorConstants.DEFAULT_PREF_PLUGIN_ENABLE);
|
||||||
enableTor.setChecked(torEnabledSetting);
|
enableTor.setChecked(torEnabledSetting);
|
||||||
|
|
||||||
int torNetworkSetting = torSettings.getInt(PREF_TOR_NETWORK,
|
int torNetworkSetting = torSettings.getInt(PREF_TOR_NETWORK,
|
||||||
PREF_TOR_NETWORK_AUTOMATIC);
|
DEFAULT_PREF_TOR_NETWORK);
|
||||||
torNetwork.setValue(Integer.toString(torNetworkSetting));
|
torNetwork.setValue(Integer.toString(torNetworkSetting));
|
||||||
setTorNetworkSummary(torNetworkSetting);
|
setTorNetworkSummary(torNetworkSetting);
|
||||||
|
|
||||||
boolean torMobileSetting =
|
boolean torMobileSetting = torSettings.getBoolean(PREF_TOR_MOBILE,
|
||||||
torSettings.getBoolean(PREF_TOR_MOBILE, true);
|
DEFAULT_PREF_TOR_MOBILE);
|
||||||
torMobile.setChecked(torMobileSetting);
|
torMobile.setChecked(torMobileSetting);
|
||||||
|
|
||||||
boolean torChargingSetting =
|
boolean torChargingSetting =
|
||||||
torSettings.getBoolean(PREF_TOR_ONLY_WHEN_CHARGING, false);
|
torSettings.getBoolean(PREF_TOR_ONLY_WHEN_CHARGING,
|
||||||
|
DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING);
|
||||||
torOnlyWhenCharging.setChecked(torChargingSetting);
|
torOnlyWhenCharging.setChecked(torChargingSetting);
|
||||||
|
|
||||||
displayScreenLockSetting();
|
displayScreenLockSetting();
|
||||||
|
|||||||
Reference in New Issue
Block a user