mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Remove various bits of code whose migration periods have passed.
This commit is contained in:
@@ -27,8 +27,6 @@ public interface TorConstants {
|
|||||||
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
|
|
||||||
int PREF_TOR_NETWORK_NEVER = 3;
|
|
||||||
|
|
||||||
// Default values for local settings
|
// Default values for local settings
|
||||||
boolean DEFAULT_PREF_PLUGIN_ENABLE = true;
|
boolean DEFAULT_PREF_PLUGIN_ENABLE = true;
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
private final long maxLatency;
|
private final long maxLatency;
|
||||||
private final int maxIdleTime;
|
private final int maxIdleTime;
|
||||||
private final int socketTimeout;
|
private final int socketTimeout;
|
||||||
private final File torDirectory, geoIpFile, configFile;
|
private final File torDirectory;
|
||||||
|
private final File configFile;
|
||||||
private final int torSocksPort;
|
private final int torSocksPort;
|
||||||
private final int torControlPort;
|
private final int torControlPort;
|
||||||
private final File doneFile, cookieFile;
|
private final File doneFile, cookieFile;
|
||||||
@@ -195,7 +196,6 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
this.torDirectory = torDirectory;
|
this.torDirectory = torDirectory;
|
||||||
this.torSocksPort = torSocksPort;
|
this.torSocksPort = torSocksPort;
|
||||||
this.torControlPort = torControlPort;
|
this.torControlPort = torControlPort;
|
||||||
geoIpFile = new File(torDirectory, "geoip");
|
|
||||||
configFile = new File(torDirectory, "torrc");
|
configFile = new File(torDirectory, "torrc");
|
||||||
doneFile = new File(torDirectory, "done");
|
doneFile = new File(torDirectory, "done");
|
||||||
cookieFile = new File(torDirectory, ".tor/control_auth_cookie");
|
cookieFile = new File(torDirectory, ".tor/control_auth_cookie");
|
||||||
@@ -332,12 +332,6 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
// The done file may already exist from a previous installation
|
// The done file may already exist from a previous installation
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
doneFile.delete();
|
doneFile.delete();
|
||||||
// The GeoIP file may exist from a previous installation - we can
|
|
||||||
// save some space by deleting it.
|
|
||||||
// TODO: Remove after a reasonable migration period
|
|
||||||
// (added 2022-03-29)
|
|
||||||
//noinspection ResultOfMethodCallIgnored
|
|
||||||
geoIpFile.delete();
|
|
||||||
installTorExecutable();
|
installTorExecutable();
|
||||||
installObfs4Executable();
|
installObfs4Executable();
|
||||||
installSnowflakeExecutable();
|
installSnowflakeExecutable();
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import static org.briarproject.bramble.api.lifecycle.LifecycleManager.StartResul
|
|||||||
import static org.briarproject.bramble.api.lifecycle.LifecycleManager.StartResult.SUCCESS;
|
import static org.briarproject.bramble.api.lifecycle.LifecycleManager.StartResult.SUCCESS;
|
||||||
import static org.briarproject.bramble.util.AndroidUtils.isUiThread;
|
import static org.briarproject.bramble.util.AndroidUtils.isUiThread;
|
||||||
import static org.briarproject.briar.android.BriarApplication.ENTRY_ACTIVITY;
|
import static org.briarproject.briar.android.BriarApplication.ENTRY_ACTIVITY;
|
||||||
import static org.briarproject.briar.api.android.AndroidNotificationManager.FAILURE_CHANNEL_ID;
|
|
||||||
import static org.briarproject.briar.api.android.AndroidNotificationManager.ONGOING_CHANNEL_ID;
|
import static org.briarproject.briar.api.android.AndroidNotificationManager.ONGOING_CHANNEL_ID;
|
||||||
import static org.briarproject.briar.api.android.AndroidNotificationManager.ONGOING_CHANNEL_OLD_ID;
|
import static org.briarproject.briar.api.android.AndroidNotificationManager.ONGOING_CHANNEL_OLD_ID;
|
||||||
import static org.briarproject.briar.api.android.AndroidNotificationManager.ONGOING_NOTIFICATION_ID;
|
import static org.briarproject.briar.api.android.AndroidNotificationManager.ONGOING_NOTIFICATION_ID;
|
||||||
@@ -141,11 +140,6 @@ public class BriarService extends Service {
|
|||||||
ongoingChannel.setLockscreenVisibility(VISIBILITY_SECRET);
|
ongoingChannel.setLockscreenVisibility(VISIBILITY_SECRET);
|
||||||
ongoingChannel.setShowBadge(false);
|
ongoingChannel.setShowBadge(false);
|
||||||
nm.createNotificationChannel(ongoingChannel);
|
nm.createNotificationChannel(ongoingChannel);
|
||||||
// Delete the unused channel previously used for startup
|
|
||||||
// failure notifications
|
|
||||||
// TODO: Remove this ID after a reasonable upgrade period
|
|
||||||
// (added 2021-07-12)
|
|
||||||
nm.deleteNotificationChannel(FAILURE_CHANNEL_ID);
|
|
||||||
}
|
}
|
||||||
Notification foregroundNotification =
|
Notification foregroundNotification =
|
||||||
notificationManager.getForegroundNotification();
|
notificationManager.getForegroundNotification();
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_
|
|||||||
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING;
|
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_NEVER;
|
|
||||||
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_ONLY_WHEN_CHARGING;
|
import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_ONLY_WHEN_CHARGING;
|
||||||
import static org.briarproject.briar.android.settings.SettingsViewModel.BT_NAMESPACE;
|
import static org.briarproject.briar.android.settings.SettingsViewModel.BT_NAMESPACE;
|
||||||
import static org.briarproject.briar.android.settings.SettingsViewModel.TOR_NAMESPACE;
|
import static org.briarproject.briar.android.settings.SettingsViewModel.TOR_NAMESPACE;
|
||||||
@@ -61,32 +60,18 @@ class ConnectionsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateTorSettings(Settings settings) {
|
void updateTorSettings(Settings settings) {
|
||||||
Settings torSettings = migrateTorSettings(settings);
|
torEnabled.postValue(settings.getBoolean(PREF_PLUGIN_ENABLE,
|
||||||
torEnabled.postValue(torSettings.getBoolean(PREF_PLUGIN_ENABLE,
|
|
||||||
TorConstants.DEFAULT_PREF_PLUGIN_ENABLE));
|
TorConstants.DEFAULT_PREF_PLUGIN_ENABLE));
|
||||||
|
|
||||||
int torNetworkSetting = torSettings.getInt(PREF_TOR_NETWORK,
|
int torNetworkSetting = settings.getInt(PREF_TOR_NETWORK,
|
||||||
DEFAULT_PREF_TOR_NETWORK);
|
DEFAULT_PREF_TOR_NETWORK);
|
||||||
torNetwork.postValue(Integer.toString(torNetworkSetting));
|
torNetwork.postValue(Integer.toString(torNetworkSetting));
|
||||||
|
|
||||||
torMobile.postValue(torSettings.getBoolean(PREF_TOR_MOBILE,
|
torMobile.postValue(settings.getBoolean(PREF_TOR_MOBILE,
|
||||||
DEFAULT_PREF_TOR_MOBILE));
|
DEFAULT_PREF_TOR_MOBILE));
|
||||||
torCharging
|
|
||||||
.postValue(torSettings.getBoolean(PREF_TOR_ONLY_WHEN_CHARGING,
|
|
||||||
DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Remove after a reasonable migration period (added 2020-06-25)
|
torCharging.postValue(settings.getBoolean(PREF_TOR_ONLY_WHEN_CHARGING,
|
||||||
private Settings migrateTorSettings(Settings s) {
|
DEFAULT_PREF_TOR_ONLY_WHEN_CHARGING));
|
||||||
int network = s.getInt(PREF_TOR_NETWORK, DEFAULT_PREF_TOR_NETWORK);
|
|
||||||
if (network == PREF_TOR_NETWORK_NEVER) {
|
|
||||||
s.putInt(PREF_TOR_NETWORK, DEFAULT_PREF_TOR_NETWORK);
|
|
||||||
s.putBoolean(PREF_PLUGIN_ENABLE, false);
|
|
||||||
// We don't need to save the migrated settings - the Tor plugin is
|
|
||||||
// responsible for that. This code just handles the case where the
|
|
||||||
// settings are loaded before the plugin migrates them.
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveData<Boolean> btEnabled() {
|
LiveData<Boolean> btEnabled() {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ public interface AndroidNotificationManager {
|
|||||||
|
|
||||||
// Notification IDs
|
// Notification IDs
|
||||||
int ONGOING_NOTIFICATION_ID = 1;
|
int ONGOING_NOTIFICATION_ID = 1;
|
||||||
int FAILURE_NOTIFICATION_ID = 2;
|
|
||||||
int REMINDER_NOTIFICATION_ID = 3;
|
int REMINDER_NOTIFICATION_ID = 3;
|
||||||
int PRIVATE_MESSAGE_NOTIFICATION_ID = 4;
|
int PRIVATE_MESSAGE_NOTIFICATION_ID = 4;
|
||||||
int GROUP_MESSAGE_NOTIFICATION_ID = 5;
|
int GROUP_MESSAGE_NOTIFICATION_ID = 5;
|
||||||
@@ -47,10 +46,6 @@ public interface AndroidNotificationManager {
|
|||||||
String HOTSPOT_CHANNEL_ID = "zHotspot";
|
String HOTSPOT_CHANNEL_ID = "zHotspot";
|
||||||
String MAILBOX_PROBLEM_CHANNEL_ID = "zMailboxProblem";
|
String MAILBOX_PROBLEM_CHANNEL_ID = "zMailboxProblem";
|
||||||
|
|
||||||
// This channel is no longer used - keep the ID so we can remove the
|
|
||||||
// channel from existing installations
|
|
||||||
String FAILURE_CHANNEL_ID = "zStartupFailure";
|
|
||||||
|
|
||||||
// Actions for pending intents
|
// Actions for pending intents
|
||||||
String ACTION_DISMISS_REMINDER = "dismissReminder";
|
String ACTION_DISMISS_REMINDER = "dismissReminder";
|
||||||
String ACTION_STOP_HOTSPOT = "stopHotspot";
|
String ACTION_STOP_HOTSPOT = "stopHotspot";
|
||||||
|
|||||||
@@ -9,16 +9,6 @@ public interface MessagingConstants {
|
|||||||
*/
|
*/
|
||||||
int MAX_PRIVATE_MESSAGE_TEXT_LENGTH = MAX_MESSAGE_BODY_LENGTH - 2048;
|
int MAX_PRIVATE_MESSAGE_TEXT_LENGTH = MAX_MESSAGE_BODY_LENGTH - 2048;
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum length of an incoming private message's text in UTF-8 bytes.
|
|
||||||
* This is higher than MAX_PRIVATE_MESSAGE_TEXT_LENGTH for compatibility
|
|
||||||
* with older peers.
|
|
||||||
* <p>
|
|
||||||
* TODO: Remove after a reasonable migration period (added 2021-03-12).
|
|
||||||
*/
|
|
||||||
int MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH =
|
|
||||||
MAX_MESSAGE_BODY_LENGTH - 1024;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of attachments per private message.
|
* The maximum number of attachments per private message.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_CONTE
|
|||||||
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_DESCRIPTOR_LENGTH;
|
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_DESCRIPTOR_LENGTH;
|
||||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||||
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_ATTACHMENTS_PER_MESSAGE;
|
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_ATTACHMENTS_PER_MESSAGE;
|
||||||
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH;
|
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_TEXT_LENGTH;
|
||||||
import static org.briarproject.briar.client.MessageTrackerConstants.MSG_KEY_READ;
|
import static org.briarproject.briar.client.MessageTrackerConstants.MSG_KEY_READ;
|
||||||
import static org.briarproject.briar.messaging.MessageTypes.ATTACHMENT;
|
import static org.briarproject.briar.messaging.MessageTypes.ATTACHMENT;
|
||||||
import static org.briarproject.briar.messaging.MessageTypes.PRIVATE_MESSAGE;
|
import static org.briarproject.briar.messaging.MessageTypes.PRIVATE_MESSAGE;
|
||||||
@@ -106,7 +106,7 @@ class PrivateMessageValidator implements MessageValidator {
|
|||||||
// Client version 0.0: Private message text
|
// Client version 0.0: Private message text
|
||||||
checkSize(body, 1);
|
checkSize(body, 1);
|
||||||
String text = body.getString(0);
|
String text = body.getString(0);
|
||||||
checkLength(text, 0, MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH);
|
checkLength(text, 0, MAX_PRIVATE_MESSAGE_TEXT_LENGTH);
|
||||||
// Return the metadata
|
// Return the metadata
|
||||||
BdfDictionary meta = new BdfDictionary();
|
BdfDictionary meta = new BdfDictionary();
|
||||||
meta.put(MSG_KEY_TIMESTAMP, m.getTimestamp());
|
meta.put(MSG_KEY_TIMESTAMP, m.getTimestamp());
|
||||||
@@ -123,7 +123,7 @@ class PrivateMessageValidator implements MessageValidator {
|
|||||||
// attachment headers, optional auto-delete timer.
|
// attachment headers, optional auto-delete timer.
|
||||||
checkSize(body, 3, 4);
|
checkSize(body, 3, 4);
|
||||||
String text = body.getOptionalString(1);
|
String text = body.getOptionalString(1);
|
||||||
checkLength(text, 0, MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH);
|
checkLength(text, 0, MAX_PRIVATE_MESSAGE_TEXT_LENGTH);
|
||||||
BdfList headers = body.getList(2);
|
BdfList headers = body.getList(2);
|
||||||
if (text == null) checkSize(headers, 1, MAX_ATTACHMENTS_PER_MESSAGE);
|
if (text == null) checkSize(headers, 1, MAX_ATTACHMENTS_PER_MESSAGE);
|
||||||
else checkSize(headers, 0, MAX_ATTACHMENTS_PER_MESSAGE);
|
else checkSize(headers, 0, MAX_ATTACHMENTS_PER_MESSAGE);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_DESCR
|
|||||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MAX_AUTO_DELETE_TIMER_MS;
|
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MAX_AUTO_DELETE_TIMER_MS;
|
||||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
||||||
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_ATTACHMENTS_PER_MESSAGE;
|
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_ATTACHMENTS_PER_MESSAGE;
|
||||||
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH;
|
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_TEXT_LENGTH;
|
||||||
import static org.briarproject.briar.client.MessageTrackerConstants.MSG_KEY_READ;
|
import static org.briarproject.briar.client.MessageTrackerConstants.MSG_KEY_READ;
|
||||||
import static org.briarproject.briar.messaging.MessageTypes.ATTACHMENT;
|
import static org.briarproject.briar.messaging.MessageTypes.ATTACHMENT;
|
||||||
import static org.briarproject.briar.messaging.MessageTypes.PRIVATE_MESSAGE;
|
import static org.briarproject.briar.messaging.MessageTypes.PRIVATE_MESSAGE;
|
||||||
@@ -58,7 +58,7 @@ public class PrivateMessageValidatorTest extends BrambleMockTestCase {
|
|||||||
private final Message message = getMessage(group.getId());
|
private final Message message = getMessage(group.getId());
|
||||||
private final long now = message.getTimestamp() + 1000;
|
private final long now = message.getTimestamp() + 1000;
|
||||||
private final String text =
|
private final String text =
|
||||||
getRandomString(MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH);
|
getRandomString(MAX_PRIVATE_MESSAGE_TEXT_LENGTH);
|
||||||
private final BdfList attachmentHeader = getAttachmentHeader();
|
private final BdfList attachmentHeader = getAttachmentHeader();
|
||||||
private final MessageId attachmentId = new MessageId(getRandomId());
|
private final MessageId attachmentId = new MessageId(getRandomId());
|
||||||
private final String contentType = getRandomString(MAX_CONTENT_TYPE_BYTES);
|
private final String contentType = getRandomString(MAX_CONTENT_TYPE_BYTES);
|
||||||
@@ -135,7 +135,7 @@ public class PrivateMessageValidatorTest extends BrambleMockTestCase {
|
|||||||
@Test(expected = InvalidMessageException.class)
|
@Test(expected = InvalidMessageException.class)
|
||||||
public void testRejectsTooLongTextForLegacyMessage() throws Exception {
|
public void testRejectsTooLongTextForLegacyMessage() throws Exception {
|
||||||
String invalidText =
|
String invalidText =
|
||||||
getRandomString(MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH + 1);
|
getRandomString(MAX_PRIVATE_MESSAGE_TEXT_LENGTH + 1);
|
||||||
|
|
||||||
testRejectsLegacyMessage(BdfList.of(invalidText));
|
testRejectsLegacyMessage(BdfList.of(invalidText));
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ public class PrivateMessageValidatorTest extends BrambleMockTestCase {
|
|||||||
@Test(expected = InvalidMessageException.class)
|
@Test(expected = InvalidMessageException.class)
|
||||||
public void testRejectsTooLongTextForPrivateMessage() throws Exception {
|
public void testRejectsTooLongTextForPrivateMessage() throws Exception {
|
||||||
String invalidText =
|
String invalidText =
|
||||||
getRandomString(MAX_PRIVATE_MESSAGE_INCOMING_TEXT_LENGTH + 1);
|
getRandomString(MAX_PRIVATE_MESSAGE_TEXT_LENGTH + 1);
|
||||||
|
|
||||||
testRejectsPrivateMessage(
|
testRejectsPrivateMessage(
|
||||||
BdfList.of(PRIVATE_MESSAGE, invalidText, new BdfList()));
|
BdfList.of(PRIVATE_MESSAGE, invalidText, new BdfList()));
|
||||||
|
|||||||
Reference in New Issue
Block a user