mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Compare commits
2 Commits
release-1.
...
1387-persi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b9955d71f | ||
|
|
719e3c6138 |
@@ -33,7 +33,6 @@ test:
|
||||
stage: test
|
||||
script:
|
||||
- ./gradlew --no-daemon -Djava.security.egd=file:/dev/urandom animalSnifferMain animalSnifferTest
|
||||
- ./gradlew --no-daemon -Djava.security.egd=file:/dev/urandom :briar-headless:linuxJars
|
||||
- ./gradlew --no-daemon -Djava.security.egd=file:/dev/urandom compileOfficialDebugAndroidTestSources compileScreenshotDebugAndroidTestSources check
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||
|
||||
@@ -15,8 +15,8 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 10403
|
||||
versionName "1.4.3"
|
||||
versionCode 10401
|
||||
versionName "1.4.1"
|
||||
consumerProguardFiles 'proguard-rules.txt'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -5,12 +5,15 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.briarproject.bramble.api.FeatureFlags;
|
||||
import org.briarproject.bramble.api.account.AccountManager;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -23,14 +26,18 @@ import javax.inject.Inject;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.getPersistentLogDir;
|
||||
import static org.briarproject.bramble.util.IoUtils.deleteFileOrDir;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.bramble.util.LogUtils.logFileOrDir;
|
||||
|
||||
class AndroidAccountManager extends AccountManagerImpl
|
||||
implements AccountManager {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(AndroidAccountManager.class.getName());
|
||||
getLogger(AndroidAccountManager.class.getName());
|
||||
|
||||
/**
|
||||
* Directories that shouldn't be deleted when deleting the user's account.
|
||||
@@ -40,13 +47,22 @@ class AndroidAccountManager extends AccountManagerImpl
|
||||
|
||||
protected final Context appContext;
|
||||
private final SharedPreferences prefs;
|
||||
private final PersistentLogManager logManager;
|
||||
private final FeatureFlags featureFlags;
|
||||
|
||||
@Inject
|
||||
AndroidAccountManager(DatabaseConfig databaseConfig,
|
||||
CryptoComponent crypto, IdentityManager identityManager,
|
||||
SharedPreferences prefs, Application app) {
|
||||
AndroidAccountManager(
|
||||
DatabaseConfig databaseConfig,
|
||||
CryptoComponent crypto,
|
||||
IdentityManager identityManager,
|
||||
SharedPreferences prefs,
|
||||
PersistentLogManager logManager,
|
||||
FeatureFlags featureFlags,
|
||||
Application app) {
|
||||
super(databaseConfig, crypto, identityManager);
|
||||
this.prefs = prefs;
|
||||
this.logManager = logManager;
|
||||
this.featureFlags = featureFlags;
|
||||
appContext = app.getApplicationContext();
|
||||
}
|
||||
|
||||
@@ -74,6 +90,9 @@ class AndroidAccountManager extends AccountManagerImpl
|
||||
LOG.info("Contents of account directory after deleting:");
|
||||
logFileOrDir(LOG, INFO, getDataDir());
|
||||
}
|
||||
if (featureFlags.shouldEnablePersistentLogs()) {
|
||||
replacePersistentLogger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,4 +153,13 @@ class AndroidAccountManager extends AccountManagerImpl
|
||||
private void addIfNotNull(Set<File> files, @Nullable File file) {
|
||||
if (file != null) files.add(file);
|
||||
}
|
||||
|
||||
private void replacePersistentLogger() {
|
||||
File logDir = getPersistentLogDir(appContext);
|
||||
try {
|
||||
logManager.addLogHandler(logDir, getLogger(""));
|
||||
} catch (IOException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,10 +111,14 @@ public class AndroidUtils {
|
||||
return ctx.getDir(STORED_REPORTS, MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static File getLogcatFile(Context ctx) {
|
||||
public static File getTemporaryLogFile(Context ctx) {
|
||||
return new File(ctx.getFilesDir(), STORED_LOGCAT);
|
||||
}
|
||||
|
||||
public static File getPersistentLogDir(Context ctx) {
|
||||
return ctx.getDir("log", MODE_PRIVATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of supported content types for image attachments.
|
||||
*/
|
||||
|
||||
@@ -4,9 +4,11 @@ import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
|
||||
import org.briarproject.bramble.api.FeatureFlags;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.lib.legacy.ClassImposteriser;
|
||||
@@ -15,7 +17,9 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.briarproject.bramble.test.TestUtils.deleteTestDirectory;
|
||||
@@ -27,6 +31,10 @@ public class AndroidAccountManagerTest extends BrambleMockTestCase {
|
||||
context.mock(SharedPreferences.class, "prefs");
|
||||
private final SharedPreferences defaultPrefs =
|
||||
context.mock(SharedPreferences.class, "defaultPrefs");
|
||||
private final PersistentLogManager logManager =
|
||||
context.mock(PersistentLogManager.class);
|
||||
private final FeatureFlags featureFlags =
|
||||
context.mock(FeatureFlags.class);
|
||||
private final DatabaseConfig databaseConfig =
|
||||
context.mock(DatabaseConfig.class);
|
||||
private final CryptoComponent crypto = context.mock(CryptoComponent.class);
|
||||
@@ -40,6 +48,7 @@ public class AndroidAccountManagerTest extends BrambleMockTestCase {
|
||||
private final File testDir = getTestDirectory();
|
||||
private final File keyDir = new File(testDir, "key");
|
||||
private final File dbDir = new File(testDir, "db");
|
||||
private final File logDir = new File(testDir, "log");
|
||||
|
||||
private AndroidAccountManager accountManager;
|
||||
|
||||
@@ -61,7 +70,7 @@ public class AndroidAccountManagerTest extends BrambleMockTestCase {
|
||||
will(returnValue(app));
|
||||
}});
|
||||
accountManager = new AndroidAccountManager(databaseConfig, crypto,
|
||||
identityManager, prefs, app) {
|
||||
identityManager, prefs, logManager, featureFlags, app) {
|
||||
@Override
|
||||
SharedPreferences getDefaultSharedPreferences() {
|
||||
return defaultPrefs;
|
||||
@@ -109,10 +118,17 @@ public class AndroidAccountManagerTest extends BrambleMockTestCase {
|
||||
will(returnValue(cacheDir));
|
||||
oneOf(app).getExternalCacheDir();
|
||||
will(returnValue(externalCacheDir));
|
||||
oneOf(featureFlags).shouldEnablePersistentLogs();
|
||||
will(returnValue(true));
|
||||
oneOf(app).getDir("log", MODE_PRIVATE);
|
||||
will(returnValue(logDir));
|
||||
oneOf(logManager).addLogHandler(with(logDir),
|
||||
with(any(Logger.class)));
|
||||
}});
|
||||
|
||||
assertTrue(dbDir.mkdirs());
|
||||
assertTrue(keyDir.mkdirs());
|
||||
assertTrue(logDir.mkdirs());
|
||||
assertTrue(codeCacheDir.mkdirs());
|
||||
assertTrue(codeCacheFile.createNewFile());
|
||||
assertTrue(libDir.mkdirs());
|
||||
@@ -130,6 +146,7 @@ public class AndroidAccountManagerTest extends BrambleMockTestCase {
|
||||
|
||||
assertFalse(dbDir.exists());
|
||||
assertFalse(keyDir.exists());
|
||||
assertFalse(logDir.exists());
|
||||
assertTrue(codeCacheDir.exists());
|
||||
assertTrue(codeCacheFile.exists());
|
||||
assertTrue(libDir.exists());
|
||||
|
||||
@@ -10,4 +10,6 @@ public interface FeatureFlags {
|
||||
boolean shouldEnableProfilePictures();
|
||||
|
||||
boolean shouldEnableDisappearingMessages();
|
||||
|
||||
boolean shouldEnablePersistentLogs();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
package org.briarproject.bramble.api;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.briarproject.bramble.util.StringUtils.fromHexString;
|
||||
import static org.briarproject.bramble.util.StringUtils.toHexString;
|
||||
|
||||
@NotNullByDefault
|
||||
public abstract class StringMap extends Hashtable<String, String> {
|
||||
|
||||
protected StringMap(Map<String, String> m) {
|
||||
@@ -52,4 +60,19 @@ public abstract class StringMap extends Hashtable<String, String> {
|
||||
public void putLong(String key, long value) {
|
||||
put(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getBytes(String key) {
|
||||
String s = get(key);
|
||||
if (s == null) return null;
|
||||
try {
|
||||
return fromHexString(s);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void putBytes(String key, byte[] value) {
|
||||
put(key, toHexString(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,12 +107,6 @@ public interface ContactManager {
|
||||
*/
|
||||
String getHandshakeLink() throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the handshake link that needs to be sent to a contact we want
|
||||
* to add.
|
||||
*/
|
||||
String getHandshakeLink(Transaction txn) throws DbException;
|
||||
|
||||
/**
|
||||
* Creates a {@link PendingContact} from the given handshake link and
|
||||
* alias, adds it to the database and returns it.
|
||||
|
||||
@@ -471,14 +471,6 @@ public interface DatabaseComponent extends TransactionManager {
|
||||
Map<MessageId, Integer> getUnackedMessagesToSend(Transaction txn,
|
||||
ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Reset the transmission count, expiry time and ETA of all messages that
|
||||
* are eligible to be sent to the given contact. This includes messages that
|
||||
* have already been sent and are not yet due for retransmission.
|
||||
*/
|
||||
void resetUnackedMessagesToSend(Transaction txn, ContactId c)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the total length, including headers, of all messages that are
|
||||
* eligible to be sent to the given contact. This may include messages
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.briarproject.bramble.api.logging;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.settings.Settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface PersistentLogManager {
|
||||
|
||||
/**
|
||||
* The namespace of the (@link Settings) where the log key is stored.
|
||||
*/
|
||||
String LOG_SETTINGS_NAMESPACE = "log";
|
||||
|
||||
/**
|
||||
* The {@link Settings} key under which the log key is stored.
|
||||
*/
|
||||
String LOG_KEY_KEY = "logKey";
|
||||
|
||||
/**
|
||||
* Creates and returns a persistent log handler that stores its logs in
|
||||
* the given directory.
|
||||
*/
|
||||
Handler createLogHandler(File dir) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a persistent log handler that stores its logs in the given
|
||||
* directory and adds the handler to the given logger, replacing any
|
||||
* existing persistent log handler.
|
||||
*/
|
||||
void addLogHandler(File dir, Logger logger) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a {@link Scanner} for reading the persistent log entries stored
|
||||
* in the given directory.
|
||||
*
|
||||
* @param old True if the previous session's log should be loaded, or false
|
||||
* if the current session's log should be loaded
|
||||
*/
|
||||
Scanner getPersistentLog(File dir, boolean old) throws IOException;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.api.mailbox;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
@@ -24,10 +23,4 @@ public interface MailboxSettingsManager {
|
||||
|
||||
void recordFailedConnectionAttempt(Transaction txn, long now)
|
||||
throws DbException;
|
||||
|
||||
void setPendingUpload(Transaction txn, ContactId id,
|
||||
@Nullable String filename) throws DbException;
|
||||
|
||||
@Nullable
|
||||
String getPendingUpload(Transaction txn, ContactId id) throws DbException;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,24 @@ import java.io.File;
|
||||
@NotNullByDefault
|
||||
public interface DevConfig {
|
||||
|
||||
/**
|
||||
* Returns the public key for encrypting feedback and crash reports.
|
||||
*/
|
||||
PublicKey getDevPublicKey();
|
||||
|
||||
/**
|
||||
* Returns the onion address for submitting feedback and crash reports.
|
||||
*/
|
||||
String getDevOnionAddress();
|
||||
|
||||
/**
|
||||
* Returns the directory for storing unsent feedback and crash reports.
|
||||
*/
|
||||
File getReportDir();
|
||||
|
||||
File getLogcatFile();
|
||||
/**
|
||||
* Returns the temporary file for passing the encrypted app log from the
|
||||
* main process to the crash reporter process.
|
||||
*/
|
||||
File getTemporaryLogFile();
|
||||
}
|
||||
|
||||
@@ -113,25 +113,9 @@ public interface KeyManager {
|
||||
/**
|
||||
* Looks up the given tag and returns a {@link StreamContext} for reading
|
||||
* from the corresponding stream, or null if an error occurs or the tag was
|
||||
* unexpected. Marks the tag as recognised and updates the reordering
|
||||
* window.
|
||||
* unexpected.
|
||||
*/
|
||||
@Nullable
|
||||
StreamContext getStreamContext(TransportId t, byte[] tag)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Looks up the given tag and returns a {@link StreamContext} for reading
|
||||
* from the corresponding stream, or null if an error occurs or the tag was
|
||||
* unexpected. Only returns the StreamContext; does not mark the tag as
|
||||
* recognised.
|
||||
*/
|
||||
@Nullable
|
||||
StreamContext getStreamContextOnly(TransportId t, byte[] tag)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Marks the tag as recognised and updates the reordering window.
|
||||
*/
|
||||
void markTagAsRecognised(TransportId t, byte[] tag) throws DbException;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.briarproject.bramble.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.FINE;
|
||||
@@ -57,4 +60,13 @@ public class LogUtils {
|
||||
String type) {
|
||||
logger.log(level, type + " " + f.getAbsolutePath() + " " + f.length());
|
||||
}
|
||||
|
||||
public static String formatLog(Formatter formatter,
|
||||
Collection<LogRecord> logRecords) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (LogRecord record : logRecords) {
|
||||
sb.append(formatter.format(record)).append('\n');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.briarproject.bramble.identity.IdentityModule;
|
||||
import org.briarproject.bramble.io.IoModule;
|
||||
import org.briarproject.bramble.keyagreement.KeyAgreementModule;
|
||||
import org.briarproject.bramble.lifecycle.LifecycleModule;
|
||||
import org.briarproject.bramble.logging.LoggingModule;
|
||||
import org.briarproject.bramble.mailbox.MailboxModule;
|
||||
import org.briarproject.bramble.plugin.PluginModule;
|
||||
import org.briarproject.bramble.properties.PropertiesModule;
|
||||
@@ -44,6 +45,7 @@ import dagger.Module;
|
||||
IoModule.class,
|
||||
KeyAgreementModule.class,
|
||||
LifecycleModule.class,
|
||||
LoggingModule.class,
|
||||
MailboxModule.class,
|
||||
PluginModule.class,
|
||||
PropertiesModule.class,
|
||||
|
||||
@@ -121,12 +121,8 @@ class ContactManagerImpl implements ContactManager, EventListener {
|
||||
|
||||
@Override
|
||||
public String getHandshakeLink() throws DbException {
|
||||
return db.transactionWithResult(true, this::getHandshakeLink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHandshakeLink(Transaction txn) throws DbException {
|
||||
KeyPair keyPair = identityManager.getHandshakeKeys(txn);
|
||||
KeyPair keyPair = db.transactionWithResult(true,
|
||||
identityManager::getHandshakeKeys);
|
||||
return pendingContactFactory.createHandshakeLink(keyPair.getPublic());
|
||||
}
|
||||
|
||||
|
||||
@@ -757,13 +757,6 @@ interface Database<T> {
|
||||
*/
|
||||
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
||||
|
||||
/**
|
||||
* Resets the transmission count, expiry time and ETA of all messages that
|
||||
* are eligible to be sent to the given contact. This includes messages that
|
||||
* have already been sent and are not yet due for retransmission.
|
||||
*/
|
||||
void resetUnackedMessagesToSend(T txn, ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the cleanup timer duration for the given message. This does not
|
||||
* start the message's cleanup timer.
|
||||
@@ -852,8 +845,8 @@ interface Database<T> {
|
||||
* of the given message with respect to the given contact, using the latency
|
||||
* of the transport over which it was sent.
|
||||
*/
|
||||
void updateExpiryTimeAndEta(T txn, ContactId c, MessageId m,
|
||||
long maxLatency) throws DbException;
|
||||
void updateExpiryTimeAndEta(T txn, ContactId c, MessageId m, long maxLatency)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Stores the given transport keys, deleting any keys they have replaced.
|
||||
|
||||
@@ -750,15 +750,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
return db.getUnackedMessagesToSend(txn, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetUnackedMessagesToSend(Transaction transaction, ContactId c)
|
||||
throws DbException {
|
||||
T txn = unbox(transaction);
|
||||
if (!db.containsContact(txn, c))
|
||||
throw new NoSuchContactException();
|
||||
db.resetUnackedMessagesToSend(txn, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUnackedMessageBytesToSend(Transaction transaction,
|
||||
ContactId c) throws DbException {
|
||||
|
||||
@@ -429,11 +429,8 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
compactAndClose();
|
||||
logDuration(LOG, "Compacting database", start);
|
||||
// Allow the next transaction to reopen the DB
|
||||
connectionsLock.lock();
|
||||
try {
|
||||
synchronized (connectionsLock) {
|
||||
closed = false;
|
||||
} finally {
|
||||
connectionsLock.unlock();
|
||||
}
|
||||
txn = startTransaction();
|
||||
try {
|
||||
@@ -3293,29 +3290,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetUnackedMessagesToSend(Connection txn, ContactId c)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "UPDATE statuses SET expiry = 0, txCount = 0, eta = 0"
|
||||
+ " WHERE contactId = ? AND state = ?"
|
||||
+ " AND groupShared = TRUE AND messageShared = TRUE"
|
||||
+ " AND deleted = FALSE AND seen = FALSE";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setInt(1, c.getInt());
|
||||
ps.setInt(2, DELIVERED.getValue());
|
||||
int affected = ps.executeUpdate();
|
||||
if (affected < 0) {
|
||||
throw new DbStateException();
|
||||
}
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
tryToClose(ps, LOG, WARNING);
|
||||
throw new DbException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCleanupTimerDuration(Connection txn, MessageId m,
|
||||
long duration) throws DbException {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package org.briarproject.briar.android.logging;
|
||||
package org.briarproject.bramble.logging;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import java.util.logging.Formatter;
|
||||
@@ -18,16 +17,6 @@ import static java.util.Locale.US;
|
||||
@NotNullByDefault
|
||||
public class BriefLogFormatter extends Formatter {
|
||||
|
||||
public static String formatLog(Formatter formatter,
|
||||
Collection<LogRecord> logRecords) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (LogRecord record : logRecords) {
|
||||
String formatted = formatter.format(record);
|
||||
sb.append(formatted).append('\n');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private final Object lock = new Object();
|
||||
private final DateFormat dateFormat; // Locking: lock
|
||||
private final Date date; // Locking: lock
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.briarproject.bramble.logging;
|
||||
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.system.TaskScheduler;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.StreamHandler;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
class FlushingStreamHandler extends StreamHandler {
|
||||
|
||||
private static final int FLUSH_DELAY_MS = 5_000;
|
||||
|
||||
private final TaskScheduler scheduler;
|
||||
private final Executor ioExecutor;
|
||||
private final AtomicBoolean flushScheduled = new AtomicBoolean(false);
|
||||
|
||||
FlushingStreamHandler(TaskScheduler scheduler,
|
||||
Executor ioExecutor, OutputStream out, Formatter formatter) {
|
||||
super(out, formatter);
|
||||
this.scheduler = scheduler;
|
||||
this.ioExecutor = ioExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
super.publish(record);
|
||||
if (!flushScheduled.getAndSet(true)) {
|
||||
scheduler.schedule(this::scheduledFlush, ioExecutor,
|
||||
FLUSH_DELAY_MS, MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@IoExecutor
|
||||
private void scheduledFlush() {
|
||||
flushScheduled.set(false);
|
||||
flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.briarproject.bramble.logging;
|
||||
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
|
||||
import java.util.logging.Formatter;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class LoggingModule {
|
||||
|
||||
@Provides
|
||||
Formatter provideFormatter() {
|
||||
return new BriefLogFormatter();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
PersistentLogManager providePersistentLogManager(
|
||||
LifecycleManager lifecycleManager,
|
||||
PersistentLogManagerImpl persistentLogManager) {
|
||||
lifecycleManager.registerOpenDatabaseHook(persistentLogManager);
|
||||
return persistentLogManager;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package org.briarproject.bramble.logging;
|
||||
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager.OpenDatabaseHook;
|
||||
import org.briarproject.bramble.api.lifecycle.ShutdownManager;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.settings.Settings;
|
||||
import org.briarproject.bramble.api.system.TaskScheduler;
|
||||
import org.briarproject.bramble.api.transport.StreamReaderFactory;
|
||||
import org.briarproject.bramble.api.transport.StreamWriter;
|
||||
import org.briarproject.bramble.api.transport.StreamWriterFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.StreamHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
|
||||
@ThreadSafe
|
||||
@NotNullByDefault
|
||||
class PersistentLogManagerImpl implements PersistentLogManager,
|
||||
OpenDatabaseHook {
|
||||
|
||||
private static final Logger LOG =
|
||||
getLogger(PersistentLogManagerImpl.class.getName());
|
||||
|
||||
private static final String LOG_FILE = "briar.log";
|
||||
private static final String OLD_LOG_FILE = "briar.log.old";
|
||||
|
||||
private final TaskScheduler scheduler;
|
||||
private final Executor ioExecutor;
|
||||
private final ShutdownManager shutdownManager;
|
||||
private final DatabaseComponent db;
|
||||
private final StreamReaderFactory streamReaderFactory;
|
||||
private final StreamWriterFactory streamWriterFactory;
|
||||
private final Formatter formatter;
|
||||
private final SecretKey logKey;
|
||||
private final AtomicReference<Integer> shutdownHookHandle =
|
||||
new AtomicReference<>();
|
||||
|
||||
@Nullable
|
||||
private volatile SecretKey oldLogKey = null;
|
||||
|
||||
@Inject
|
||||
PersistentLogManagerImpl(
|
||||
TaskScheduler scheduler,
|
||||
@IoExecutor Executor ioExecutor,
|
||||
ShutdownManager shutdownManager,
|
||||
DatabaseComponent db,
|
||||
StreamReaderFactory streamReaderFactory,
|
||||
StreamWriterFactory streamWriterFactory,
|
||||
Formatter formatter,
|
||||
CryptoComponent crypto) {
|
||||
this.scheduler = scheduler;
|
||||
this.ioExecutor = ioExecutor;
|
||||
this.shutdownManager = shutdownManager;
|
||||
this.db = db;
|
||||
this.streamReaderFactory = streamReaderFactory;
|
||||
this.streamWriterFactory = streamWriterFactory;
|
||||
this.formatter = formatter;
|
||||
logKey = crypto.generateSecretKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseOpened(Transaction txn) throws DbException {
|
||||
Settings s = db.getSettings(txn, LOG_SETTINGS_NAMESPACE);
|
||||
// Load the old log key, if any
|
||||
byte[] oldKeyBytes = s.getBytes(LOG_KEY_KEY);
|
||||
if (oldKeyBytes != null && oldKeyBytes.length == SecretKey.LENGTH) {
|
||||
LOG.info("Loaded old log key");
|
||||
oldLogKey = new SecretKey(oldKeyBytes);
|
||||
}
|
||||
// Store the current log key
|
||||
s.putBytes(LOG_KEY_KEY, logKey.getBytes());
|
||||
db.mergeSettings(txn, s, LOG_SETTINGS_NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Handler createLogHandler(File dir) throws IOException {
|
||||
File logFile = new File(dir, LOG_FILE);
|
||||
File oldLogFile = new File(dir, OLD_LOG_FILE);
|
||||
if (oldLogFile.exists() && !oldLogFile.delete())
|
||||
LOG.warning("Failed to delete old log file");
|
||||
if (logFile.exists() && !logFile.renameTo(oldLogFile))
|
||||
LOG.warning("Failed to rename log file");
|
||||
try {
|
||||
OutputStream out = new FileOutputStream(logFile);
|
||||
StreamWriter writer =
|
||||
streamWriterFactory.createLogStreamWriter(out, logKey);
|
||||
StreamHandler handler = new FlushingStreamHandler(scheduler,
|
||||
ioExecutor, writer.getOutputStream(), formatter);
|
||||
// Flush the log and terminate the stream at shutdown
|
||||
Runnable shutdownHook = () -> {
|
||||
LOG.info("Shutting down");
|
||||
handler.flush();
|
||||
try {
|
||||
writer.sendEndOfStream();
|
||||
} catch (IOException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
}
|
||||
};
|
||||
int handle = shutdownManager.addShutdownHook(shutdownHook);
|
||||
// If a previous handler registered a shutdown hook, remove it
|
||||
Integer oldHandle = shutdownHookHandle.getAndSet(handle);
|
||||
if (oldHandle != null) {
|
||||
shutdownManager.removeShutdownHook(oldHandle);
|
||||
}
|
||||
return handler;
|
||||
} catch (SecurityException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLogHandler(File dir, Logger logger) throws IOException {
|
||||
for (Handler h : logger.getHandlers()) {
|
||||
if (h instanceof FlushingStreamHandler) logger.removeHandler(h);
|
||||
}
|
||||
logger.addHandler(createLogHandler(dir));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scanner getPersistentLog(File dir, boolean old)
|
||||
throws IOException {
|
||||
if (old) {
|
||||
SecretKey oldLogKey = this.oldLogKey;
|
||||
if (oldLogKey == null) {
|
||||
LOG.info("Old log key has not been loaded");
|
||||
return emptyScanner();
|
||||
}
|
||||
return getPersistentLog(new File(dir, OLD_LOG_FILE), oldLogKey);
|
||||
} else {
|
||||
return getPersistentLog(new File(dir, LOG_FILE), logKey);
|
||||
}
|
||||
}
|
||||
|
||||
private Scanner getPersistentLog(File logFile, SecretKey key)
|
||||
throws IOException {
|
||||
if (logFile.exists()) {
|
||||
LOG.info("Reading log file");
|
||||
InputStream in = new FileInputStream(logFile);
|
||||
return new Scanner(streamReaderFactory.createLogStreamReader(in,
|
||||
key));
|
||||
} else {
|
||||
LOG.info("Log file does not exist");
|
||||
return emptyScanner();
|
||||
}
|
||||
}
|
||||
|
||||
private Scanner emptyScanner() {
|
||||
return new Scanner(new ByteArrayInputStream(new byte[0]));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.mailbox;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.mailbox.MailboxProperties;
|
||||
@@ -10,7 +9,6 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.settings.Settings;
|
||||
import org.briarproject.bramble.api.settings.SettingsManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -27,7 +25,6 @@ class MailboxSettingsManagerImpl implements MailboxSettingsManager {
|
||||
static final String SETTINGS_KEY_LAST_ATTEMPT = "lastAttempt";
|
||||
static final String SETTINGS_KEY_LAST_SUCCESS = "lastSuccess";
|
||||
static final String SETTINGS_KEY_ATTEMPTS = "attempts";
|
||||
static final String SETTINGS_UPLOADS_NAMESPACE = "mailbox-uploads";
|
||||
|
||||
private final SettingsManager settingsManager;
|
||||
|
||||
@@ -86,24 +83,4 @@ class MailboxSettingsManagerImpl implements MailboxSettingsManager {
|
||||
newSettings.putInt(SETTINGS_KEY_ATTEMPTS, attempts + 1);
|
||||
settingsManager.mergeSettings(txn, newSettings, SETTINGS_NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPendingUpload(Transaction txn, ContactId id,
|
||||
@Nullable String filename) throws DbException {
|
||||
Settings s = new Settings();
|
||||
String value = filename == null ? "" : filename;
|
||||
s.put(String.valueOf(id.getInt()), value);
|
||||
settingsManager.mergeSettings(txn, s, SETTINGS_UPLOADS_NAMESPACE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPendingUpload(Transaction txn, ContactId id)
|
||||
throws DbException {
|
||||
Settings s =
|
||||
settingsManager.getSettings(txn, SETTINGS_UPLOADS_NAMESPACE);
|
||||
String filename = s.get(String.valueOf(id.getInt()));
|
||||
if (isNullOrEmpty(filename)) return null;
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +1,40 @@
|
||||
package org.briarproject.bramble.plugin.tor;
|
||||
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface CircumventionProvider {
|
||||
// TODO: Create a module for this so it doesn't have to be public
|
||||
|
||||
enum BridgeType {
|
||||
DEFAULT_OBFS4,
|
||||
NON_DEFAULT_OBFS4,
|
||||
MEEK
|
||||
}
|
||||
public interface CircumventionProvider {
|
||||
|
||||
/**
|
||||
* Countries where Tor is blocked, i.e. vanilla Tor connection won't work.
|
||||
* <p>
|
||||
*
|
||||
* See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
||||
* and https://trac.torproject.org/projects/tor/wiki/doc/OONI/censorshipwiki
|
||||
*/
|
||||
String[] BLOCKED = {"CN", "IR", "EG", "BY", "TR", "SY", "VE", "RU"};
|
||||
String[] BLOCKED = {"CN", "IR", "EG", "BY", "TR", "SY", "VE"};
|
||||
|
||||
/**
|
||||
* Countries where obfs4 or meek bridge connections are likely to work.
|
||||
* Should be a subset of {@link #BLOCKED} and the union of
|
||||
* {@link #DEFAULT_OBFS4_BRIDGES}, {@link #NON_DEFAULT_OBFS4_BRIDGES} and
|
||||
* {@link #MEEK_BRIDGES}.
|
||||
* Should be a subset of {@link #BLOCKED}.
|
||||
*/
|
||||
String[] BRIDGES = {"CN", "IR", "EG", "BY", "TR", "SY", "VE", "RU"};
|
||||
|
||||
/**
|
||||
* Countries where default obfs4 bridges are likely to work.
|
||||
* Should be a subset of {@link #BRIDGES}.
|
||||
*/
|
||||
String[] DEFAULT_OBFS4_BRIDGES = {"EG", "BY", "TR", "SY", "VE"};
|
||||
|
||||
/**
|
||||
* Countries where non-default obfs4 bridges are likely to work.
|
||||
* Should be a subset of {@link #BRIDGES}.
|
||||
*/
|
||||
String[] NON_DEFAULT_OBFS4_BRIDGES = {"RU"};
|
||||
String[] BRIDGES = { "CN", "IR", "EG", "BY", "TR", "SY", "VE" };
|
||||
|
||||
/**
|
||||
* Countries where obfs4 bridges won't work and meek is needed.
|
||||
* Should be a subset of {@link #BRIDGES}.
|
||||
*/
|
||||
String[] MEEK_BRIDGES = {"CN", "IR"};
|
||||
String[] NEEDS_MEEK = {"CN", "IR"};
|
||||
|
||||
/**
|
||||
* Returns true if vanilla Tor connections are blocked in the given country.
|
||||
*/
|
||||
boolean isTorProbablyBlocked(String countryCode);
|
||||
|
||||
/**
|
||||
* Returns true if bridge connections of some type work in the given
|
||||
* country.
|
||||
*/
|
||||
boolean doBridgesWork(String countryCode);
|
||||
|
||||
/**
|
||||
* Returns the best type of bridge connection for the given country, or
|
||||
* {@link #DEFAULT_OBFS4_BRIDGES} if no bridge type is known to work.
|
||||
*/
|
||||
BridgeType getBestBridgeType(String countryCode);
|
||||
boolean needsMeek(String countryCode);
|
||||
|
||||
@IoExecutor
|
||||
List<String> getBridges(BridgeType type);
|
||||
List<String> getBridges(boolean meek);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.briarproject.bramble.plugin.tor;
|
||||
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -10,31 +9,24 @@ import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.DEFAULT_OBFS4;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.MEEK;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.NON_DEFAULT_OBFS4;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
class CircumventionProviderImpl implements CircumventionProvider {
|
||||
|
||||
private final static String BRIDGE_FILE_NAME = "bridges";
|
||||
|
||||
private static final Set<String> BLOCKED_IN_COUNTRIES =
|
||||
new HashSet<>(asList(BLOCKED));
|
||||
private static final Set<String> BRIDGE_COUNTRIES =
|
||||
private static final Set<String> BRIDGES_WORK_IN_COUNTRIES =
|
||||
new HashSet<>(asList(BRIDGES));
|
||||
private static final Set<String> DEFAULT_OBFS4_BRIDGE_COUNTRIES =
|
||||
new HashSet<>(asList(DEFAULT_OBFS4_BRIDGES));
|
||||
private static final Set<String> NON_DEFAULT_OBFS4_BRIDGE_COUNTRIES =
|
||||
new HashSet<>(asList(NON_DEFAULT_OBFS4_BRIDGES));
|
||||
private static final Set<String> MEEK_COUNTRIES =
|
||||
new HashSet<>(asList(MEEK_BRIDGES));
|
||||
private static final Set<String> BRIDGES_NEED_MEEK =
|
||||
new HashSet<>(asList(NEEDS_MEEK));
|
||||
|
||||
@Nullable
|
||||
private volatile List<String> bridges = null;
|
||||
|
||||
@Inject
|
||||
CircumventionProviderImpl() {
|
||||
@@ -47,42 +39,33 @@ class CircumventionProviderImpl implements CircumventionProvider {
|
||||
|
||||
@Override
|
||||
public boolean doBridgesWork(String countryCode) {
|
||||
return BRIDGE_COUNTRIES.contains(countryCode);
|
||||
return BRIDGES_WORK_IN_COUNTRIES.contains(countryCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BridgeType getBestBridgeType(String countryCode) {
|
||||
if (DEFAULT_OBFS4_BRIDGE_COUNTRIES.contains(countryCode)) {
|
||||
return DEFAULT_OBFS4;
|
||||
} else if (NON_DEFAULT_OBFS4_BRIDGE_COUNTRIES.contains(countryCode)) {
|
||||
return NON_DEFAULT_OBFS4;
|
||||
} else if (MEEK_COUNTRIES.contains(countryCode)) {
|
||||
return MEEK;
|
||||
} else {
|
||||
return DEFAULT_OBFS4;
|
||||
}
|
||||
public boolean needsMeek(String countryCode) {
|
||||
return BRIDGES_NEED_MEEK.contains(countryCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@IoExecutor
|
||||
public List<String> getBridges(BridgeType type) {
|
||||
InputStream is = requireNonNull(getClass().getClassLoader()
|
||||
.getResourceAsStream(BRIDGE_FILE_NAME));
|
||||
public List<String> getBridges(boolean useMeek) {
|
||||
List<String> bridges = this.bridges;
|
||||
if (bridges != null) return new ArrayList<>(bridges);
|
||||
|
||||
InputStream is = getClass().getClassLoader()
|
||||
.getResourceAsStream(BRIDGE_FILE_NAME);
|
||||
Scanner scanner = new Scanner(is);
|
||||
|
||||
List<String> bridges = new ArrayList<>();
|
||||
bridges = new ArrayList<>();
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
boolean isDefaultObfs4 = line.startsWith("d ");
|
||||
boolean isNonDefaultObfs4 = line.startsWith("n ");
|
||||
boolean isMeek = line.startsWith("m ");
|
||||
if ((type == DEFAULT_OBFS4 && isDefaultObfs4) ||
|
||||
(type == NON_DEFAULT_OBFS4 && isNonDefaultObfs4) ||
|
||||
(type == MEEK && isMeek)) {
|
||||
bridges.add(line.substring(2));
|
||||
}
|
||||
boolean isMeekBridge = line.startsWith("Bridge meek");
|
||||
if (useMeek && !isMeekBridge || !useMeek && isMeekBridge) continue;
|
||||
if (!line.startsWith("#")) bridges.add(line);
|
||||
}
|
||||
scanner.close();
|
||||
this.bridges = bridges;
|
||||
return bridges;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.briarproject.bramble.api.settings.event.SettingsUpdatedEvent;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.system.LocationUtils;
|
||||
import org.briarproject.bramble.api.system.ResourceProvider;
|
||||
import org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.EOFException;
|
||||
@@ -93,7 +92,6 @@ import static org.briarproject.bramble.api.plugin.TorConstants.PROP_ONION_V3;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.REASON_BATTERY;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.REASON_COUNTRY_BLOCKED;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.REASON_MOBILE_DATA;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.MEEK;
|
||||
import static org.briarproject.bramble.plugin.tor.TorRendezvousCrypto.SEED_BYTES;
|
||||
import static org.briarproject.bramble.util.IoUtils.copyAndClose;
|
||||
import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
||||
@@ -544,20 +542,20 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
controlConnection.setConf("DisableNetwork", enable ? "0" : "1");
|
||||
}
|
||||
|
||||
private void enableBridges(boolean enable, BridgeType bridgeType)
|
||||
private void enableBridges(boolean enable, boolean needsMeek)
|
||||
throws IOException {
|
||||
if (enable) {
|
||||
Collection<String> conf = new ArrayList<>();
|
||||
conf.add("UseBridges 1");
|
||||
File obfs4File = getObfs4ExecutableFile();
|
||||
if (bridgeType == MEEK) {
|
||||
if (needsMeek) {
|
||||
conf.add("ClientTransportPlugin meek_lite exec " +
|
||||
obfs4File.getAbsolutePath());
|
||||
} else {
|
||||
conf.add("ClientTransportPlugin obfs4 exec " +
|
||||
obfs4File.getAbsolutePath());
|
||||
}
|
||||
conf.addAll(circumventionProvider.getBridges(bridgeType));
|
||||
conf.addAll(circumventionProvider.getBridges(needsMeek));
|
||||
controlConnection.setConf(conf);
|
||||
} else {
|
||||
controlConnection.setConf("UseBridges", "0");
|
||||
@@ -846,9 +844,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
|
||||
int reasonsDisabled = 0;
|
||||
boolean enableNetwork = false, enableBridges = false;
|
||||
boolean enableConnectionPadding = false;
|
||||
BridgeType bridgeType =
|
||||
circumventionProvider.getBestBridgeType(country);
|
||||
boolean useMeek = false, enableConnectionPadding = false;
|
||||
|
||||
if (!online) {
|
||||
LOG.info("Disabling network, device is offline");
|
||||
@@ -877,10 +873,14 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
enableNetwork = true;
|
||||
if (network == PREF_TOR_NETWORK_WITH_BRIDGES ||
|
||||
(automatic && bridgesWork)) {
|
||||
if (ipv6Only) bridgeType = MEEK;
|
||||
enableBridges = true;
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
LOG.info("Using bridge type " + bridgeType);
|
||||
if (ipv6Only ||
|
||||
circumventionProvider.needsMeek(country)) {
|
||||
LOG.info("Using meek bridges");
|
||||
enableBridges = true;
|
||||
useMeek = true;
|
||||
} else {
|
||||
LOG.info("Using obfs4 bridges");
|
||||
enableBridges = true;
|
||||
}
|
||||
} else {
|
||||
LOG.info("Not using bridges");
|
||||
@@ -898,7 +898,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
||||
|
||||
try {
|
||||
if (enableNetwork) {
|
||||
enableBridges(enableBridges, bridgeType);
|
||||
enableBridges(enableBridges, useMeek);
|
||||
enableConnectionPadding(enableConnectionPadding);
|
||||
useIpv6(ipv6Only);
|
||||
}
|
||||
|
||||
@@ -215,23 +215,6 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
||||
m.getStreamContext(txn, tag)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamContext getStreamContextOnly(TransportId t, byte[] tag)
|
||||
throws DbException {
|
||||
return withManager(t, m ->
|
||||
db.transactionWithNullableResult(false, txn ->
|
||||
m.getStreamContextOnly(txn, tag)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markTagAsRecognised(TransportId t, byte[] tag)
|
||||
throws DbException {
|
||||
withManager(t, m -> {
|
||||
db.transaction(false, txn -> m.markTagAsRecognised(txn, tag));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventOccurred(Event e) {
|
||||
if (e instanceof ContactRemovedEvent) {
|
||||
|
||||
@@ -48,9 +48,4 @@ interface TransportKeyManager {
|
||||
StreamContext getStreamContext(Transaction txn, byte[] tag)
|
||||
throws DbException;
|
||||
|
||||
@Nullable
|
||||
StreamContext getStreamContextOnly(Transaction txn, byte[] tag);
|
||||
|
||||
void markTagAsRecognised(Transaction txn, byte[] tag) throws DbException;
|
||||
|
||||
}
|
||||
|
||||
@@ -393,82 +393,56 @@ class TransportKeyManagerImpl implements TransportKeyManager {
|
||||
throws DbException {
|
||||
lock.lock();
|
||||
try {
|
||||
StreamContext ctx = streamContextFromTag(tag);
|
||||
if (ctx == null) return null;
|
||||
markTagAsRecognised(txn, tag);
|
||||
// Look up the incoming keys for the tag
|
||||
TagContext tagCtx = inContexts.remove(new Bytes(tag));
|
||||
if (tagCtx == null) return null;
|
||||
MutableIncomingKeys inKeys = tagCtx.inKeys;
|
||||
// Create a stream context
|
||||
StreamContext ctx = new StreamContext(tagCtx.contactId,
|
||||
tagCtx.pendingContactId, transportId,
|
||||
inKeys.getTagKey(), inKeys.getHeaderKey(),
|
||||
tagCtx.streamNumber, tagCtx.handshakeMode);
|
||||
// Update the reordering window
|
||||
ReorderingWindow window = inKeys.getWindow();
|
||||
Change change = window.setSeen(tagCtx.streamNumber);
|
||||
// Add tags for any stream numbers added to the window
|
||||
for (long streamNumber : change.getAdded()) {
|
||||
byte[] addTag = new byte[TAG_LENGTH];
|
||||
transportCrypto.encodeTag(addTag, inKeys.getTagKey(),
|
||||
PROTOCOL_VERSION, streamNumber);
|
||||
TagContext tagCtx1 = new TagContext(tagCtx.keySetId,
|
||||
tagCtx.contactId, tagCtx.pendingContactId, inKeys,
|
||||
streamNumber, tagCtx.handshakeMode);
|
||||
inContexts.put(new Bytes(addTag), tagCtx1);
|
||||
}
|
||||
// Remove tags for any stream numbers removed from the window
|
||||
for (long streamNumber : change.getRemoved()) {
|
||||
if (streamNumber == tagCtx.streamNumber) continue;
|
||||
byte[] removeTag = new byte[TAG_LENGTH];
|
||||
transportCrypto.encodeTag(removeTag, inKeys.getTagKey(),
|
||||
PROTOCOL_VERSION, streamNumber);
|
||||
inContexts.remove(new Bytes(removeTag));
|
||||
}
|
||||
// Write the window back to the DB
|
||||
db.setReorderingWindow(txn, tagCtx.keySetId, transportId,
|
||||
inKeys.getTimePeriod(), window.getBase(),
|
||||
window.getBitmap());
|
||||
// If the outgoing keys are inactive, activate them
|
||||
MutableTransportKeySet ks = keys.get(tagCtx.keySetId);
|
||||
MutableOutgoingKeys outKeys =
|
||||
ks.getKeys().getCurrentOutgoingKeys();
|
||||
if (!outKeys.isActive()) {
|
||||
LOG.info("Activating outgoing keys");
|
||||
outKeys.activate();
|
||||
considerReplacingOutgoingKeys(ks);
|
||||
db.setTransportKeysActive(txn, transportId, tagCtx.keySetId);
|
||||
}
|
||||
return ctx;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamContext getStreamContextOnly(Transaction txn, byte[] tag) {
|
||||
lock.lock();
|
||||
try {
|
||||
return streamContextFromTag(tag);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("lock")
|
||||
@Nullable
|
||||
private StreamContext streamContextFromTag(byte[] tag) {
|
||||
// Look up the incoming keys for the tag
|
||||
TagContext tagCtx = inContexts.get(new Bytes(tag));
|
||||
if (tagCtx == null) return null;
|
||||
MutableIncomingKeys inKeys = tagCtx.inKeys;
|
||||
// Create a stream context
|
||||
return new StreamContext(tagCtx.contactId,
|
||||
tagCtx.pendingContactId, transportId,
|
||||
inKeys.getTagKey(), inKeys.getHeaderKey(),
|
||||
tagCtx.streamNumber, tagCtx.handshakeMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markTagAsRecognised(Transaction txn, byte[] tag)
|
||||
throws DbException {
|
||||
TagContext tagCtx = inContexts.remove(new Bytes(tag));
|
||||
if (tagCtx == null) return;
|
||||
MutableIncomingKeys inKeys = tagCtx.inKeys;
|
||||
// Update the reordering window
|
||||
ReorderingWindow window = inKeys.getWindow();
|
||||
Change change = window.setSeen(tagCtx.streamNumber);
|
||||
// Add tags for any stream numbers added to the window
|
||||
for (long streamNumber : change.getAdded()) {
|
||||
byte[] addTag = new byte[TAG_LENGTH];
|
||||
transportCrypto.encodeTag(addTag, inKeys.getTagKey(),
|
||||
PROTOCOL_VERSION, streamNumber);
|
||||
TagContext tagCtx1 = new TagContext(tagCtx.keySetId,
|
||||
tagCtx.contactId, tagCtx.pendingContactId, inKeys,
|
||||
streamNumber, tagCtx.handshakeMode);
|
||||
inContexts.put(new Bytes(addTag), tagCtx1);
|
||||
}
|
||||
// Remove tags for any stream numbers removed from the window
|
||||
for (long streamNumber : change.getRemoved()) {
|
||||
if (streamNumber == tagCtx.streamNumber) continue;
|
||||
byte[] removeTag = new byte[TAG_LENGTH];
|
||||
transportCrypto.encodeTag(removeTag, inKeys.getTagKey(),
|
||||
PROTOCOL_VERSION, streamNumber);
|
||||
inContexts.remove(new Bytes(removeTag));
|
||||
}
|
||||
// Write the window back to the DB
|
||||
db.setReorderingWindow(txn, tagCtx.keySetId, transportId,
|
||||
inKeys.getTimePeriod(), window.getBase(),
|
||||
window.getBitmap());
|
||||
// If the outgoing keys are inactive, activate them
|
||||
MutableTransportKeySet ks = keys.get(tagCtx.keySetId);
|
||||
MutableOutgoingKeys outKeys =
|
||||
ks.getKeys().getCurrentOutgoingKeys();
|
||||
if (!outKeys.isActive()) {
|
||||
LOG.info("Activating outgoing keys");
|
||||
outKeys.activate();
|
||||
considerReplacingOutgoingKeys(ks);
|
||||
db.setTransportKeysActive(txn, transportId, tagCtx.keySetId);
|
||||
}
|
||||
}
|
||||
|
||||
@DatabaseExecutor
|
||||
@Wakeful
|
||||
private void updateKeys(Transaction txn) throws DbException {
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
d Bridge obfs4 38.229.1.78:80 C8CBDB2464FC9804A69531437BCF2BE31FDD2EE4 cert=Hmyfd2ev46gGY7NoVxA9ngrPF2zCZtzskRTzoWXbxNkzeVnGFPWmrTtILRyqCTjHR+s9dg iat-mode=1
|
||||
d Bridge obfs4 37.218.245.14:38224 D9A82D2F9C2F65A18407B1D2B764F130847F8B5D cert=bjRaMrr1BRiAW8IE9U5z27fQaYgOhX1UCmOpg2pFpoMvo6ZgQMzLsaTzzQNTlm7hNcb+Sg iat-mode=0
|
||||
d Bridge obfs4 85.31.186.98:443 011F2599C0E9B27EE74B353155E244813763C3E5 cert=ayq0XzCwhpdysn5o0EyDUbmSOx3X/oTEbzDMvczHOdBJKlvIdHHLJGkZARtT4dcBFArPPg iat-mode=0
|
||||
d Bridge obfs4 85.31.186.26:443 91A6354697E6B02A386312F68D82CF86824D3606 cert=PBwr+S8JTVZo6MPdHnkTwXJPILWADLqfMGoVvhZClMq/Urndyd42BwX9YFJHZnBB3H0XCw iat-mode=0
|
||||
d Bridge obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0
|
||||
d Bridge obfs4 193.11.166.194:27020 86AC7B8D430DAC4117E9F42C9EAED18133863AAF cert=0LDeJH4JzMDtkJJrFphJCiPqKx7loozKN7VNfuukMGfHO0Z8OGdzHVkhVAOfo1mUdv9cMg iat-mode=0
|
||||
d Bridge obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert=ItvYZzW5tn6v3G4UnQa6Qz04Npro6e81AP70YujmK/KXwDFPTs3aHXcHp4n8Vt6w/bv8cA iat-mode=0
|
||||
d Bridge obfs4 209.148.46.65:443 74FAD13168806246602538555B5521A0383A1875 cert=ssH+9rP8dG2NLDN2XuFw63hIO/9MNNinLmxQDpVa+7kTOa9/m+tGWT1SmSYpQ9uTBGa6Hw iat-mode=0
|
||||
d Bridge obfs4 146.57.248.225:22 10A6CD36A537FCE513A322361547444B393989F0 cert=K1gDtDAIcUfeLqbstggjIw2rtgIKqdIhUlHp82XRqNSq/mtAjp1BIC9vHKJ2FAEpGssTPw iat-mode=0
|
||||
d Bridge obfs4 45.145.95.6:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0k6xYHMPW3vJxICfkMZNdkRrb63Zhl5j9dW3iRGiCx0A7mPhe5T2EDzQ35+Zw iat-mode=0
|
||||
d Bridge obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0
|
||||
d Bridge obfs4 185.100.85.3:443 5B403DFE34F4872EB027059CECAE30B0C864B3A2 cert=bWUdFUe8io9U6JkSLoGAvSAUDcB779/shovCYmYAQb/pW/iEAMZtO/lCd94OokOF909TPA iat-mode=2
|
||||
n Bridge obfs4 46.226.107.197:10300 A38FD6BDFD902882F5F5B9B7CCC95602A20B0BC4 cert=t8tA9q2AeGlmp/dO6oW9bkY5RqqmvqjArCEM9wjJoDnk6XtnaejkF0JTA7VamdyOzcvuBg iat-mode=0
|
||||
n Bridge obfs4 74.104.165.202:9002 EF432018A6AA5D970B2F84E39CD30A147030141C cert=PhppfUusY85dHGvWtGTybZ1fED4DtbHmALkNMIOIYrAz1B4xN7/2a5gyiZe1epju1BOHVg iat-mode=0
|
||||
n Bridge obfs4 23.88.49.56:443 1CDA1660823AE2565D7F50DE8EB99DFDDE96074B cert=4bwNXedHutVD0ZqCm6ph90Vik9dRY4n9qnBHiLiqQOSsIvui4iHwuMFQK6oqiK8tyhVcDw iat-mode=0
|
||||
n Bridge obfs4 185.65.206.101:443 8A3E001D4C5105ED41060597DEEB21FF19CDC4D3 cert=Nd6XZ+f00sGKL1u6USmyvfqR34HN/pt7jEVbgMpXPF/yyGaLBiXRH/x0SIjX5TceYnd+Dg iat-mode=0
|
||||
m Bridge meek_lite 192.0.2.2:2 97700DFE9F483596DDA6264C4D7DF7641E1E39CE url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com
|
||||
Bridge obfs4 37.218.245.14:38224 D9A82D2F9C2F65A18407B1D2B764F130847F8B5D cert=bjRaMrr1BRiAW8IE9U5z27fQaYgOhX1UCmOpg2pFpoMvo6ZgQMzLsaTzzQNTlm7hNcb+Sg iat-mode=0
|
||||
Bridge obfs4 85.31.186.26:443 91A6354697E6B02A386312F68D82CF86824D3606 cert=PBwr+S8JTVZo6MPdHnkTwXJPILWADLqfMGoVvhZClMq/Urndyd42BwX9YFJHZnBB3H0XCw iat-mode=0
|
||||
Bridge obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0
|
||||
Bridge obfs4 193.11.166.194:27020 86AC7B8D430DAC4117E9F42C9EAED18133863AAF cert=0LDeJH4JzMDtkJJrFphJCiPqKx7loozKN7VNfuukMGfHO0Z8OGdzHVkhVAOfo1mUdv9cMg iat-mode=0
|
||||
Bridge obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert=ItvYZzW5tn6v3G4UnQa6Qz04Npro6e81AP70YujmK/KXwDFPTs3aHXcHp4n8Vt6w/bv8cA iat-mode=0
|
||||
Bridge obfs4 209.148.46.65:443 74FAD13168806246602538555B5521A0383A1875 cert=ssH+9rP8dG2NLDN2XuFw63hIO/9MNNinLmxQDpVa+7kTOa9/m+tGWT1SmSYpQ9uTBGa6Hw iat-mode=0
|
||||
Bridge obfs4 45.145.95.6:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0k6xYHMPW3vJxICfkMZNdkRrb63Zhl5j9dW3iRGiCx0A7mPhe5T2EDzQ35+Zw iat-mode=0
|
||||
Bridge obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0
|
||||
Bridge obfs4 78.46.188.239:37356 5A2D2F4158D0453E00C7C176978D3F41D69C45DB cert=3c0SwxpOisbohNxEc4tb875RVW8eOu1opRTVXJhafaKA/PNNtI7ElQIVOVZg1AdL5bxGCw iat-mode=0
|
||||
Bridge meek_lite 192.0.2.2:2 97700DFE9F483596DDA6264C4D7DF7641E1E39CE url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com
|
||||
@@ -2197,55 +2197,6 @@ public abstract class JdbcDatabaseTest extends BrambleTestCase {
|
||||
db.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResetRetransmissionTimes() throws Exception {
|
||||
long now = System.currentTimeMillis();
|
||||
AtomicLong time = new AtomicLong(now);
|
||||
Database<Connection> db =
|
||||
open(false, new TestMessageFactory(), new SettableClock(time));
|
||||
Connection txn = db.startTransaction();
|
||||
|
||||
// Add a contact, a shared group and a shared message
|
||||
db.addIdentity(txn, identity);
|
||||
assertEquals(contactId,
|
||||
db.addContact(txn, author, localAuthor.getId(), null, true));
|
||||
db.addGroup(txn, group);
|
||||
db.addGroupVisibility(txn, contactId, groupId, true);
|
||||
db.addMessage(txn, message, DELIVERED, true, false, null);
|
||||
|
||||
// Time: now
|
||||
// Retrieve the message from the database
|
||||
Collection<MessageId> ids = db.getMessagesToSend(txn, contactId,
|
||||
ONE_MEGABYTE, MAX_LATENCY);
|
||||
assertEquals(singletonList(messageId), ids);
|
||||
|
||||
// Time: now
|
||||
// Mark the message as sent
|
||||
db.updateExpiryTimeAndEta(txn, contactId, messageId, MAX_LATENCY);
|
||||
|
||||
// The message should expire after 2 * MAX_LATENCY
|
||||
assertEquals(now + MAX_LATENCY * 2, db.getNextSendTime(txn, contactId));
|
||||
|
||||
// Time: now + MAX_LATENCY * 2 - 1
|
||||
// The message should not yet be sendable
|
||||
time.set(now + MAX_LATENCY * 2 - 1);
|
||||
ids = db.getMessagesToSend(txn, contactId, ONE_MEGABYTE, MAX_LATENCY);
|
||||
assertTrue(ids.isEmpty());
|
||||
|
||||
// Reset the retransmission times
|
||||
db.resetUnackedMessagesToSend(txn, contactId);
|
||||
|
||||
// The message should have infinitely short expiry
|
||||
assertEquals(0, db.getNextSendTime(txn, contactId));
|
||||
|
||||
// The message should be sendable
|
||||
ids = db.getMessagesToSend(txn, contactId, ONE_MEGABYTE, MAX_LATENCY);
|
||||
assertFalse(ids.isEmpty());
|
||||
|
||||
db.commitTransaction(txn);
|
||||
db.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompactionTime() throws Exception {
|
||||
MessageFactory messageFactory = new TestMessageFactory();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.mailbox;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.mailbox.MailboxProperties;
|
||||
import org.briarproject.bramble.api.mailbox.MailboxSettingsManager;
|
||||
@@ -11,15 +10,12 @@ import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static org.briarproject.bramble.mailbox.MailboxSettingsManagerImpl.SETTINGS_KEY_ATTEMPTS;
|
||||
import static org.briarproject.bramble.mailbox.MailboxSettingsManagerImpl.SETTINGS_KEY_LAST_ATTEMPT;
|
||||
import static org.briarproject.bramble.mailbox.MailboxSettingsManagerImpl.SETTINGS_KEY_LAST_SUCCESS;
|
||||
import static org.briarproject.bramble.mailbox.MailboxSettingsManagerImpl.SETTINGS_KEY_ONION;
|
||||
import static org.briarproject.bramble.mailbox.MailboxSettingsManagerImpl.SETTINGS_KEY_TOKEN;
|
||||
import static org.briarproject.bramble.mailbox.MailboxSettingsManagerImpl.SETTINGS_NAMESPACE;
|
||||
import static org.briarproject.bramble.mailbox.MailboxSettingsManagerImpl.SETTINGS_UPLOADS_NAMESPACE;
|
||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -33,12 +29,8 @@ public class MailboxSettingsManagerImplTest extends BrambleMockTestCase {
|
||||
|
||||
private final MailboxSettingsManager manager =
|
||||
new MailboxSettingsManagerImpl(settingsManager);
|
||||
private final Random random = new Random();
|
||||
private final String onion = getRandomString(64);
|
||||
private final String token = getRandomString(64);
|
||||
private final ContactId contactId1 = new ContactId(random.nextInt());
|
||||
private final ContactId contactId2 = new ContactId(random.nextInt());
|
||||
private final ContactId contactId3 = new ContactId(random.nextInt());
|
||||
private final long now = System.currentTimeMillis();
|
||||
private final long lastAttempt = now - 1234;
|
||||
private final long lastSuccess = now - 2345;
|
||||
@@ -174,52 +166,4 @@ public class MailboxSettingsManagerImplTest extends BrambleMockTestCase {
|
||||
|
||||
manager.recordFailedConnectionAttempt(txn, now);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGettingPendingUploads() throws Exception {
|
||||
Transaction txn = new Transaction(null, true);
|
||||
Settings settings = new Settings();
|
||||
settings.put(String.valueOf(contactId1.getInt()), onion);
|
||||
settings.put(String.valueOf(contactId2.getInt()), token);
|
||||
settings.put(String.valueOf(contactId3.getInt()), "");
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
exactly(4).of(settingsManager)
|
||||
.getSettings(txn, SETTINGS_UPLOADS_NAMESPACE);
|
||||
will(returnValue(settings));
|
||||
}});
|
||||
|
||||
String filename1 = manager.getPendingUpload(txn, contactId1);
|
||||
assertEquals(onion, filename1);
|
||||
String filename2 = manager.getPendingUpload(txn, contactId2);
|
||||
assertEquals(token, filename2);
|
||||
String filename3 = manager.getPendingUpload(txn, contactId3);
|
||||
assertNull(filename3);
|
||||
String filename4 =
|
||||
manager.getPendingUpload(txn, new ContactId(random.nextInt()));
|
||||
assertNull(filename4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettingPendingUploads() throws Exception {
|
||||
Transaction txn = new Transaction(null, false);
|
||||
|
||||
// setting a pending upload stores expected settings
|
||||
Settings expectedSettings1 = new Settings();
|
||||
expectedSettings1.put(String.valueOf(contactId1.getInt()), onion);
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(settingsManager).mergeSettings(txn, expectedSettings1,
|
||||
SETTINGS_UPLOADS_NAMESPACE);
|
||||
}});
|
||||
manager.setPendingUpload(txn, contactId1, onion);
|
||||
|
||||
// nulling a pending upload empties stored settings
|
||||
Settings expectedSettings2 = new Settings();
|
||||
expectedSettings2.put(String.valueOf(contactId2.getInt()), "");
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(settingsManager).mergeSettings(txn, expectedSettings2,
|
||||
SETTINGS_UPLOADS_NAMESPACE);
|
||||
}});
|
||||
manager.setPendingUpload(txn, contactId2, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package org.briarproject.bramble.plugin.tor;
|
||||
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BLOCKED;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BRIDGES;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.DEFAULT_OBFS4;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.MEEK;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.NON_DEFAULT_OBFS4;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.DEFAULT_OBFS4_BRIDGES;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.MEEK_BRIDGES;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.NON_DEFAULT_OBFS4_BRIDGES;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CircumventionProviderTest extends BrambleTestCase {
|
||||
|
||||
private final CircumventionProvider provider =
|
||||
new CircumventionProviderImpl();
|
||||
|
||||
@Test
|
||||
public void testInvariants() {
|
||||
Set<String> blocked = new HashSet<>(asList(BLOCKED));
|
||||
Set<String> bridges = new HashSet<>(asList(BRIDGES));
|
||||
Set<String> defaultObfs4Bridges =
|
||||
new HashSet<>(asList(DEFAULT_OBFS4_BRIDGES));
|
||||
Set<String> nonDefaultObfs4Bridges =
|
||||
new HashSet<>(asList(NON_DEFAULT_OBFS4_BRIDGES));
|
||||
Set<String> meekBridges = new HashSet<>(asList(MEEK_BRIDGES));
|
||||
// BRIDGES should be a subset of BLOCKED
|
||||
assertTrue(blocked.containsAll(bridges));
|
||||
// BRIDGES should be the union of the bridge type sets
|
||||
Set<String> union = new HashSet<>(defaultObfs4Bridges);
|
||||
union.addAll(nonDefaultObfs4Bridges);
|
||||
union.addAll(meekBridges);
|
||||
assertEquals(bridges, union);
|
||||
// The bridge type sets should not overlap
|
||||
assertEmptyIntersection(defaultObfs4Bridges, nonDefaultObfs4Bridges);
|
||||
assertEmptyIntersection(defaultObfs4Bridges, meekBridges);
|
||||
assertEmptyIntersection(nonDefaultObfs4Bridges, meekBridges);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBestBridgeType() {
|
||||
for (String country : DEFAULT_OBFS4_BRIDGES) {
|
||||
assertEquals(DEFAULT_OBFS4, provider.getBestBridgeType(country));
|
||||
}
|
||||
for (String country : NON_DEFAULT_OBFS4_BRIDGES) {
|
||||
assertEquals(NON_DEFAULT_OBFS4,
|
||||
provider.getBestBridgeType(country));
|
||||
}
|
||||
for (String country : MEEK_BRIDGES) {
|
||||
assertEquals(MEEK, provider.getBestBridgeType(country));
|
||||
}
|
||||
assertEquals(DEFAULT_OBFS4, provider.getBestBridgeType("ZZ"));
|
||||
}
|
||||
|
||||
private <T> void assertEmptyIntersection(Set<T> a, Set<T> b) {
|
||||
Set<T> intersection = new HashSet<>(a);
|
||||
intersection.retainAll(b);
|
||||
assertTrue(intersection.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,11 @@ public class TestFeatureFlagModule {
|
||||
public boolean shouldEnableDisappearingMessages() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldEnablePersistentLogs() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,76 +393,6 @@ public class TransportKeyManagerImplTest extends BrambleMockTestCase {
|
||||
assertNull(transportKeyManager.getStreamContext(txn, tag));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStreamContextOnlyAndMarkTag() throws Exception {
|
||||
boolean alice = random.nextBoolean();
|
||||
TransportKeys transportKeys = createTransportKeys(1000, 0, true);
|
||||
Transaction txn = new Transaction(null, false);
|
||||
|
||||
// Keep a copy of the tags
|
||||
List<byte[]> tags = new ArrayList<>();
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(transportCrypto).deriveRotationKeys(transportId, rootKey,
|
||||
1000, alice, true);
|
||||
will(returnValue(transportKeys));
|
||||
// Get the current time (the start of time period 1000)
|
||||
oneOf(clock).currentTimeMillis();
|
||||
will(returnValue(timePeriodLength * 1000));
|
||||
// Encode the tags (3 sets)
|
||||
for (long i = 0; i < REORDERING_WINDOW_SIZE; i++) {
|
||||
exactly(3).of(transportCrypto).encodeTag(
|
||||
with(any(byte[].class)), with(tagKey),
|
||||
with(PROTOCOL_VERSION), with(i));
|
||||
will(new EncodeTagAction(tags));
|
||||
}
|
||||
// Updated the transport keys (the keys are unaffected)
|
||||
oneOf(transportCrypto).updateTransportKeys(transportKeys, 1000);
|
||||
will(returnValue(transportKeys));
|
||||
// Save the keys
|
||||
oneOf(db).addTransportKeys(txn, contactId, transportKeys);
|
||||
will(returnValue(keySetId));
|
||||
// Encode a new tag after sliding the window
|
||||
oneOf(transportCrypto).encodeTag(with(any(byte[].class)),
|
||||
with(tagKey), with(PROTOCOL_VERSION),
|
||||
with((long) REORDERING_WINDOW_SIZE));
|
||||
will(new EncodeTagAction(tags));
|
||||
// Save the reordering window (previous time period, base 1)
|
||||
oneOf(db).setReorderingWindow(txn, keySetId, transportId, 999,
|
||||
1, new byte[REORDERING_WINDOW_SIZE / 8]);
|
||||
}});
|
||||
|
||||
// The timestamp is at the start of time period 1000
|
||||
long timestamp = timePeriodLength * 1000;
|
||||
assertEquals(keySetId, transportKeyManager.addRotationKeys(
|
||||
txn, contactId, rootKey, timestamp, alice, true));
|
||||
assertTrue(transportKeyManager.canSendOutgoingStreams(contactId));
|
||||
// Use the first tag (previous time period, stream number 0)
|
||||
assertEquals(REORDERING_WINDOW_SIZE * 3, tags.size());
|
||||
byte[] tag = tags.get(0);
|
||||
// Repeated request should return same stream context
|
||||
StreamContext ctx = transportKeyManager.getStreamContextOnly(txn, tag);
|
||||
assertNotNull(ctx);
|
||||
assertEquals(contactId, ctx.getContactId());
|
||||
assertEquals(transportId, ctx.getTransportId());
|
||||
assertEquals(tagKey, ctx.getTagKey());
|
||||
assertEquals(headerKey, ctx.getHeaderKey());
|
||||
assertEquals(0L, ctx.getStreamNumber());
|
||||
ctx = transportKeyManager.getStreamContextOnly(txn, tag);
|
||||
assertNotNull(ctx);
|
||||
assertEquals(contactId, ctx.getContactId());
|
||||
assertEquals(transportId, ctx.getTransportId());
|
||||
assertEquals(tagKey, ctx.getTagKey());
|
||||
assertEquals(headerKey, ctx.getHeaderKey());
|
||||
assertEquals(0L, ctx.getStreamNumber());
|
||||
// Then mark tag as recognised
|
||||
transportKeyManager.markTagAsRecognised(txn, tag);
|
||||
// Another tag should have been encoded
|
||||
assertEquals(REORDERING_WINDOW_SIZE * 3 + 1, tags.size());
|
||||
// Finally ensure the used tag is not recognised again
|
||||
assertNull(transportKeyManager.getStreamContextOnly(txn, tag));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeysAreUpdatedToCurrentPeriod() throws Exception {
|
||||
TransportKeys transportKeys = createTransportKeys(1000, 0, true);
|
||||
|
||||
@@ -6,14 +6,12 @@ import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.event.EventBus;
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.network.NetworkManager;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.BackoffFactory;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.system.LocationUtils;
|
||||
import org.briarproject.bramble.api.system.ResourceProvider;
|
||||
import org.briarproject.bramble.api.system.WakefulIoExecutor;
|
||||
import org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType;
|
||||
import org.briarproject.bramble.test.BrambleJavaIntegrationTestComponent;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.bramble.test.DaggerBrambleJavaIntegrationTestComponent;
|
||||
@@ -36,14 +34,11 @@ import javax.inject.Inject;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.ACTIVE;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_CONTROL_PORT;
|
||||
import static org.briarproject.bramble.api.plugin.TorConstants.DEFAULT_SOCKS_PORT;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.DEFAULT_OBFS4;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.MEEK;
|
||||
import static org.briarproject.bramble.plugin.tor.CircumventionProvider.BridgeType.NON_DEFAULT_OBFS4;
|
||||
import static org.briarproject.bramble.test.TestUtils.deleteTestDirectory;
|
||||
import static org.briarproject.bramble.test.TestUtils.getTestDirectory;
|
||||
import static org.briarproject.bramble.test.TestUtils.isOptionalTestEnabled;
|
||||
@@ -62,21 +57,14 @@ public class BridgeTest extends BrambleTestCase {
|
||||
.injectEagerSingletons(component);
|
||||
// Share a failure counter among all the test instances
|
||||
AtomicInteger failures = new AtomicInteger(0);
|
||||
CircumventionProvider provider = component.getCircumventionProvider();
|
||||
List<Params> states = new ArrayList<>();
|
||||
for (String bridge : provider.getBridges(DEFAULT_OBFS4)) {
|
||||
states.add(new Params(bridge, DEFAULT_OBFS4, failures, false));
|
||||
}
|
||||
for (String bridge : provider.getBridges(NON_DEFAULT_OBFS4)) {
|
||||
states.add(new Params(bridge, NON_DEFAULT_OBFS4, failures, false));
|
||||
}
|
||||
for (String bridge : provider.getBridges(MEEK)) {
|
||||
states.add(new Params(bridge, MEEK, failures, true));
|
||||
}
|
||||
List<String> bridges =
|
||||
component.getCircumventionProvider().getBridges(false);
|
||||
List<Params> states = new ArrayList<>(bridges.size());
|
||||
for (String bridge : bridges) states.add(new Params(bridge, failures));
|
||||
return states;
|
||||
}
|
||||
|
||||
private final static long TIMEOUT = MINUTES.toMillis(5);
|
||||
private final static long TIMEOUT = SECONDS.toMillis(60);
|
||||
private final static int NUM_FAILURES_ALLOWED = 1;
|
||||
|
||||
private final static Logger LOG = getLogger(BridgeTest.class.getName());
|
||||
@@ -105,12 +93,14 @@ public class BridgeTest extends BrambleTestCase {
|
||||
CryptoComponent crypto;
|
||||
|
||||
private final File torDir = getTestDirectory();
|
||||
private final Params params;
|
||||
private final String bridge;
|
||||
private final AtomicInteger failures;
|
||||
|
||||
private UnixTorPluginFactory factory;
|
||||
|
||||
public BridgeTest(Params params) {
|
||||
this.params = params;
|
||||
bridge = params.bridge;
|
||||
failures = params.failures;
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -130,7 +120,6 @@ public class BridgeTest extends BrambleTestCase {
|
||||
LocationUtils locationUtils = () -> "US";
|
||||
SocketFactory torSocketFactory = SocketFactory.getDefault();
|
||||
|
||||
@NotNullByDefault
|
||||
CircumventionProvider bridgeProvider = new CircumventionProvider() {
|
||||
@Override
|
||||
public boolean isTorProbablyBlocked(String countryCode) {
|
||||
@@ -143,13 +132,13 @@ public class BridgeTest extends BrambleTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BridgeType getBestBridgeType(String countryCode) {
|
||||
return params.bridgeType;
|
||||
public boolean needsMeek(String countryCode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBridges(BridgeType bridgeType) {
|
||||
return singletonList(params.bridge);
|
||||
public List<String> getBridges(boolean useMeek) {
|
||||
return singletonList(bridge);
|
||||
}
|
||||
};
|
||||
factory = new UnixTorPluginFactory(ioExecutor, wakefulIoExecutor,
|
||||
@@ -171,7 +160,7 @@ public class BridgeTest extends BrambleTestCase {
|
||||
assertNotNull(duplexPlugin);
|
||||
UnixTorPlugin plugin = (UnixTorPlugin) duplexPlugin;
|
||||
|
||||
LOG.warning("Testing " + params.bridge);
|
||||
LOG.warning("Testing " + bridge);
|
||||
try {
|
||||
plugin.start();
|
||||
long start = clock.currentTimeMillis();
|
||||
@@ -181,11 +170,8 @@ public class BridgeTest extends BrambleTestCase {
|
||||
}
|
||||
if (plugin.getState() != ACTIVE) {
|
||||
LOG.warning("Could not connect to Tor within timeout");
|
||||
if (params.failures.incrementAndGet() > NUM_FAILURES_ALLOWED) {
|
||||
fail(params.failures.get() + " bridges are unreachable");
|
||||
}
|
||||
if (params.mustSucceed) {
|
||||
fail("essential bridge is unreachable");
|
||||
if (failures.incrementAndGet() > NUM_FAILURES_ALLOWED) {
|
||||
fail(failures.get() + " bridges are unreachable");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -196,16 +182,11 @@ public class BridgeTest extends BrambleTestCase {
|
||||
private static class Params {
|
||||
|
||||
private final String bridge;
|
||||
private final BridgeType bridgeType;
|
||||
private final AtomicInteger failures;
|
||||
private final boolean mustSucceed;
|
||||
|
||||
private Params(String bridge, BridgeType bridgeType,
|
||||
AtomicInteger failures, boolean mustSucceed) {
|
||||
private Params(String bridge, AtomicInteger failures) {
|
||||
this.bridge = bridge;
|
||||
this.bridgeType = bridgeType;
|
||||
this.failures = failures;
|
||||
this.mustSucceed = mustSucceed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 10403
|
||||
versionName "1.4.3"
|
||||
versionCode 10401
|
||||
versionName "1.4.1"
|
||||
applicationId "org.briarproject.briar.android"
|
||||
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
@@ -3,9 +3,11 @@ package org.briarproject.bramble.account;
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.briarproject.bramble.api.FeatureFlags;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.Localizer;
|
||||
import org.briarproject.briar.android.util.UiUtils;
|
||||
@@ -15,10 +17,16 @@ import javax.inject.Inject;
|
||||
class BriarAccountManager extends AndroidAccountManager {
|
||||
|
||||
@Inject
|
||||
BriarAccountManager(DatabaseConfig databaseConfig, CryptoComponent crypto,
|
||||
IdentityManager identityManager, SharedPreferences prefs,
|
||||
BriarAccountManager(
|
||||
DatabaseConfig databaseConfig,
|
||||
CryptoComponent crypto,
|
||||
IdentityManager identityManager,
|
||||
SharedPreferences prefs,
|
||||
PersistentLogManager logManager,
|
||||
FeatureFlags featureFlags,
|
||||
Application app) {
|
||||
super(databaseConfig, crypto, identityManager, prefs, app);
|
||||
super(databaseConfig, crypto, identityManager, prefs, logManager,
|
||||
featureFlags, app);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.briarproject.bramble.api.keyagreement.PayloadEncoder;
|
||||
import org.briarproject.bramble.api.keyagreement.PayloadParser;
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
import org.briarproject.bramble.api.plugin.PluginManager;
|
||||
import org.briarproject.bramble.api.settings.SettingsManager;
|
||||
import org.briarproject.bramble.api.system.AndroidExecutor;
|
||||
@@ -78,6 +79,7 @@ import org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager
|
||||
import org.briarproject.briar.api.test.TestDataCreator;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Formatter;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@@ -204,6 +206,10 @@ public interface AndroidComponent
|
||||
|
||||
AutoDeleteManager autoDeleteManager();
|
||||
|
||||
PersistentLogManager persistentLogManager();
|
||||
|
||||
Formatter formatter();
|
||||
|
||||
void inject(SignInReminderReceiver briarService);
|
||||
|
||||
void inject(BriarService briarService);
|
||||
|
||||
@@ -56,7 +56,6 @@ import org.briarproject.briar.android.viewmodel.ViewModelModule;
|
||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.briar.api.android.DozeWatchdog;
|
||||
import org.briarproject.briar.api.android.LockManager;
|
||||
import org.briarproject.briar.api.android.NetworkUsageMetrics;
|
||||
import org.briarproject.briar.api.android.ScreenFilterMonitor;
|
||||
import org.briarproject.briar.api.test.TestAvatarCreator;
|
||||
|
||||
@@ -115,7 +114,7 @@ public class AppModule {
|
||||
@Inject
|
||||
ScreenFilterMonitor screenFilterMonitor;
|
||||
@Inject
|
||||
NetworkUsageMetrics networkUsageMetrics;
|
||||
NetworkUsageLogger networkUsageLogger;
|
||||
@Inject
|
||||
DozeWatchdog dozeWatchdog;
|
||||
@Inject
|
||||
@@ -246,8 +245,9 @@ public class AppModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLogcatFile() {
|
||||
return AndroidUtils.getLogcatFile(app.getApplicationContext());
|
||||
public File getTemporaryLogFile() {
|
||||
return AndroidUtils
|
||||
.getTemporaryLogFile(app.getApplicationContext());
|
||||
}
|
||||
};
|
||||
return devConfig;
|
||||
@@ -288,12 +288,11 @@ public class AppModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
NetworkUsageMetrics provideNetworkUsageMetrics(
|
||||
NetworkUsageLogger provideNetworkUsageLogger(
|
||||
LifecycleManager lifecycleManager) {
|
||||
NetworkUsageMetrics networkUsageMetrics = new NetworkUsageMetricsImpl();
|
||||
lifecycleManager.registerService(networkUsageMetrics);
|
||||
return networkUsageMetrics;
|
||||
NetworkUsageLogger networkUsageLogger = new NetworkUsageLogger();
|
||||
lifecycleManager.registerService(networkUsageLogger);
|
||||
return networkUsageLogger;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -339,6 +338,11 @@ public class AppModule {
|
||||
public boolean shouldEnableDisappearingMessages() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldEnablePersistentLogs() {
|
||||
return IS_DEBUG_BUILD;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,14 @@ import com.vanniktech.emoji.google.GoogleEmojiProvider;
|
||||
import org.briarproject.bramble.BrambleAndroidEagerSingletons;
|
||||
import org.briarproject.bramble.BrambleAppComponent;
|
||||
import org.briarproject.bramble.BrambleCoreEagerSingletons;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
import org.briarproject.briar.BriarCoreEagerSingletons;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.logging.CachingLogHandler;
|
||||
import org.briarproject.briar.android.util.UiUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Logger;
|
||||
@@ -31,7 +34,10 @@ import androidx.annotation.NonNull;
|
||||
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
|
||||
import static java.util.logging.Level.FINE;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.getPersistentLogDir;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||
|
||||
public class BriarApplicationImpl extends Application
|
||||
@@ -81,6 +87,17 @@ public class BriarApplicationImpl extends Application
|
||||
rootLogger.addHandler(logHandler);
|
||||
rootLogger.setLevel(IS_DEBUG_BUILD ? FINE : INFO);
|
||||
|
||||
if (applicationComponent.featureFlags().shouldEnablePersistentLogs()) {
|
||||
PersistentLogManager logManager =
|
||||
applicationComponent.persistentLogManager();
|
||||
File logDir = getPersistentLogDir(this);
|
||||
try {
|
||||
rootLogger.addHandler(logManager.createLogHandler(logDir));
|
||||
} catch (IOException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
}
|
||||
}
|
||||
|
||||
LOG.info("Created");
|
||||
|
||||
EmojiManager.install(new GoogleEmojiProvider());
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.briarproject.briar.android;
|
||||
|
||||
import android.net.TrafficStats;
|
||||
import android.os.Process;
|
||||
|
||||
import org.briarproject.bramble.api.lifecycle.Service;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static org.briarproject.bramble.util.LogUtils.now;
|
||||
|
||||
class NetworkUsageLogger implements Service {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(NetworkUsageLogger.class.getName());
|
||||
|
||||
private volatile long startTime, rxBytes, txBytes;
|
||||
|
||||
@Override
|
||||
public void startService() {
|
||||
startTime = now();
|
||||
int uid = Process.myUid();
|
||||
rxBytes = TrafficStats.getUidRxBytes(uid);
|
||||
txBytes = TrafficStats.getUidTxBytes(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopService() {
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
long sessionDuration = now() - startTime;
|
||||
int uid = Process.myUid();
|
||||
long rx = TrafficStats.getUidRxBytes(uid) - rxBytes;
|
||||
long tx = TrafficStats.getUidTxBytes(uid) - txBytes;
|
||||
LOG.info("Duration " + (sessionDuration / 1000) + " seconds");
|
||||
LOG.info("Received " + rx + " bytes");
|
||||
LOG.info("Sent " + tx + " bytes");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package org.briarproject.briar.android;
|
||||
|
||||
import android.net.TrafficStats;
|
||||
import android.os.Process;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.android.NetworkUsageMetrics;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static org.briarproject.bramble.util.LogUtils.now;
|
||||
|
||||
@NotNullByDefault
|
||||
class NetworkUsageMetricsImpl implements NetworkUsageMetrics {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(NetworkUsageMetricsImpl.class.getName());
|
||||
|
||||
private volatile long startTime, rxBytes, txBytes;
|
||||
|
||||
@Override
|
||||
public void startService() {
|
||||
startTime = now();
|
||||
int uid = Process.myUid();
|
||||
rxBytes = TrafficStats.getUidRxBytes(uid);
|
||||
txBytes = TrafficStats.getUidTxBytes(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopService() {
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
Metrics metrics = getMetrics();
|
||||
LOG.info("Duration " + (metrics.getSessionDurationMs() / 1000)
|
||||
+ " seconds");
|
||||
LOG.info("Received " + metrics.getRxBytes() + " bytes");
|
||||
LOG.info("Sent " + metrics.getTxBytes() + " bytes");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Metrics getMetrics() {
|
||||
long sessionDurationMs = now() - startTime;
|
||||
int uid = Process.myUid();
|
||||
long rx = TrafficStats.getUidRxBytes(uid) - rxBytes;
|
||||
long tx = TrafficStats.getUidTxBytes(uid) - txBytes;
|
||||
return new Metrics(sessionDurationMs, rx, tx);
|
||||
}
|
||||
}
|
||||
@@ -312,19 +312,12 @@ class HotspotManager {
|
||||
}
|
||||
GroupInfoListener groupListener = group -> {
|
||||
boolean valid = isGroupValid(group);
|
||||
if (valid) {
|
||||
// the group is valid, set the hotspot to started.
|
||||
onHotspotStarted(group);
|
||||
} else if (attempt < MAX_GROUP_INFO_ATTEMPTS) {
|
||||
// we have attempts left, try again
|
||||
retryRequestingGroupInfo(attempt);
|
||||
} else if (group != null) {
|
||||
// no attempts left, but group is not null, try what we got
|
||||
// If the group is valid, set the hotspot to started. If we don't
|
||||
// have any attempts left, we try what we got
|
||||
if (valid || attempt >= MAX_GROUP_INFO_ATTEMPTS) {
|
||||
onHotspotStarted(group);
|
||||
} else {
|
||||
// no attempts left and group is null, fail
|
||||
releaseHotspotWithError(ctx.getString(
|
||||
R.string.hotspot_error_start_callback_no_group_info));
|
||||
retryRequestingGroupInfo(attempt);
|
||||
}
|
||||
};
|
||||
try {
|
||||
@@ -373,8 +366,13 @@ class HotspotManager {
|
||||
private void retryRequestingGroupInfo(int attempt) {
|
||||
LOG.info("retrying to request group info");
|
||||
// On some devices we need to wait for the group info to become available
|
||||
handler.postDelayed(() -> requestGroupInfo(attempt + 1),
|
||||
RETRY_DELAY_MILLIS);
|
||||
if (attempt < MAX_GROUP_INFO_ATTEMPTS) {
|
||||
handler.postDelayed(() -> requestGroupInfo(attempt + 1),
|
||||
RETRY_DELAY_MILLIS);
|
||||
} else {
|
||||
releaseHotspotWithError(ctx.getString(
|
||||
R.string.hotspot_error_start_callback_no_group_info));
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
||||
@@ -8,8 +8,9 @@ import androidx.annotation.Nullable;
|
||||
@NotNullByDefault
|
||||
public interface LogDecrypter {
|
||||
/**
|
||||
* Returns decrypted log records from {@link AndroidUtils#getLogcatFile}
|
||||
* or null if there was an error reading the logs.
|
||||
* Returns decrypted log records from
|
||||
* {@link AndroidUtils#getTemporaryLogFile} or null if there was an error
|
||||
* reading the logs.
|
||||
*/
|
||||
@Nullable
|
||||
String decryptLogs(@Nullable byte[] logKey);
|
||||
|
||||
@@ -41,7 +41,7 @@ class LogDecrypterImpl implements LogDecrypter {
|
||||
public String decryptLogs(@Nullable byte[] logKey) {
|
||||
if (logKey == null) return null;
|
||||
SecretKey key = new SecretKey(logKey);
|
||||
File logFile = devConfig.getLogcatFile();
|
||||
File logFile = devConfig.getTemporaryLogFile();
|
||||
try (InputStream in = new FileInputStream(logFile)) {
|
||||
InputStream reader =
|
||||
streamReaderFactory.createLogStreamReader(in, key);
|
||||
|
||||
@@ -8,7 +8,7 @@ import androidx.annotation.Nullable;
|
||||
@NotNullByDefault
|
||||
public interface LogEncrypter {
|
||||
/**
|
||||
* Writes encrypted log records to {@link AndroidUtils#getLogcatFile}
|
||||
* Writes encrypted log records to {@link AndroidUtils#getTemporaryLogFile}
|
||||
* and returns the encryption key if everything went fine.
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -33,16 +33,19 @@ class LogEncrypterImpl implements LogEncrypter {
|
||||
|
||||
private final DevConfig devConfig;
|
||||
private final CachingLogHandler logHandler;
|
||||
private final Formatter formatter;
|
||||
private final CryptoComponent crypto;
|
||||
private final StreamWriterFactory streamWriterFactory;
|
||||
|
||||
@Inject
|
||||
LogEncrypterImpl(DevConfig devConfig,
|
||||
CachingLogHandler logHandler,
|
||||
Formatter formatter,
|
||||
CryptoComponent crypto,
|
||||
StreamWriterFactory streamWriterFactory) {
|
||||
this.devConfig = devConfig;
|
||||
this.logHandler = logHandler;
|
||||
this.formatter = formatter;
|
||||
this.crypto = crypto;
|
||||
this.streamWriterFactory = streamWriterFactory;
|
||||
}
|
||||
@@ -51,7 +54,7 @@ class LogEncrypterImpl implements LogEncrypter {
|
||||
@Override
|
||||
public byte[] encryptLogs() {
|
||||
SecretKey logKey = crypto.generateSecretKey();
|
||||
File logFile = devConfig.getLogcatFile();
|
||||
File logFile = devConfig.getTemporaryLogFile();
|
||||
try (OutputStream out = new FileOutputStream(logFile)) {
|
||||
StreamWriter streamWriter =
|
||||
streamWriterFactory.createLogStreamWriter(out, logKey);
|
||||
@@ -67,10 +70,8 @@ class LogEncrypterImpl implements LogEncrypter {
|
||||
}
|
||||
|
||||
private void writeLogString(Writer writer) throws IOException {
|
||||
Formatter formatter = new BriefLogFormatter();
|
||||
for (LogRecord record : logHandler.getRecentLogRecords()) {
|
||||
String formatted = formatter.format(record);
|
||||
writer.append(formatted).append('\n');
|
||||
writer.append(formatter.format(record)).append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,9 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.BuildConfig;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.reporting.ReportData.MultiReportInfo;
|
||||
import org.briarproject.briar.android.reporting.ReportData.ReportInfo;
|
||||
import org.briarproject.briar.android.reporting.ReportData.ReportItem;
|
||||
import org.briarproject.briar.android.reporting.ReportData.SingleReportInfo;
|
||||
import org.briarproject.briar.api.android.NetworkUsageMetrics;
|
||||
import org.briarproject.briar.api.android.NetworkUsageMetrics.Metrics;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
@@ -67,15 +66,13 @@ import static org.briarproject.bramble.util.StringUtils.isNullOrEmpty;
|
||||
class BriarReportCollector {
|
||||
|
||||
private final Context ctx;
|
||||
private final NetworkUsageMetrics networkUsageMetrics;
|
||||
|
||||
BriarReportCollector(Context ctx, NetworkUsageMetrics networkUsageMetrics) {
|
||||
BriarReportCollector(Context ctx) {
|
||||
this.ctx = ctx;
|
||||
this.networkUsageMetrics = networkUsageMetrics;
|
||||
}
|
||||
|
||||
ReportData collectReportData(@Nullable Throwable t, long appStartTime,
|
||||
String logs) {
|
||||
ReportInfo logs) {
|
||||
ReportData reportData = new ReportData()
|
||||
.add(getBasicInfo(t))
|
||||
.add(getDeviceInfo());
|
||||
@@ -85,9 +82,8 @@ class BriarReportCollector {
|
||||
.add(getMemory())
|
||||
.add(getStorage())
|
||||
.add(getConnectivity())
|
||||
.add(getNetworkUsage())
|
||||
.add(getBuildConfig())
|
||||
.add(getLogcat(logs))
|
||||
.add(getLogs(logs))
|
||||
.add(getDeviceFeatures());
|
||||
}
|
||||
|
||||
@@ -303,16 +299,6 @@ class BriarReportCollector {
|
||||
connectivityInfo);
|
||||
}
|
||||
|
||||
private ReportItem getNetworkUsage() {
|
||||
Metrics metrics = networkUsageMetrics.getMetrics();
|
||||
MultiReportInfo networkUsage = new MultiReportInfo()
|
||||
.add("SessionDuration", metrics.getSessionDurationMs())
|
||||
.add("BytesReceived", metrics.getRxBytes())
|
||||
.add("BytesSent", metrics.getTxBytes());
|
||||
return new ReportItem("NetworkUsage", R.string.dev_report_network_usage,
|
||||
networkUsage);
|
||||
}
|
||||
|
||||
private ReportItem getBuildConfig() {
|
||||
MultiReportInfo buildConfig = new MultiReportInfo()
|
||||
.add("GitHash", BuildConfig.GitHash)
|
||||
@@ -324,8 +310,8 @@ class BriarReportCollector {
|
||||
buildConfig);
|
||||
}
|
||||
|
||||
private ReportItem getLogcat(String logs) {
|
||||
return new ReportItem("Logcat", R.string.dev_report_logcat, logs);
|
||||
private ReportItem getLogs(ReportInfo logs) {
|
||||
return new ReportItem("Logs", R.string.dev_report_logcat, logs);
|
||||
}
|
||||
|
||||
private ReportItem getDeviceFeatures() {
|
||||
|
||||
@@ -4,6 +4,8 @@ import android.app.Application;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import org.briarproject.bramble.api.FeatureFlags;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.Plugin;
|
||||
import org.briarproject.bramble.api.plugin.PluginManager;
|
||||
@@ -11,18 +13,19 @@ import org.briarproject.bramble.api.plugin.TorConstants;
|
||||
import org.briarproject.bramble.api.reporting.DevReporter;
|
||||
import org.briarproject.bramble.util.AndroidUtils;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.logging.BriefLogFormatter;
|
||||
import org.briarproject.briar.android.logging.CachingLogHandler;
|
||||
import org.briarproject.briar.android.logging.LogDecrypter;
|
||||
import org.briarproject.briar.android.reporting.ReportData.MultiReportInfo;
|
||||
import org.briarproject.briar.android.reporting.ReportData.ReportItem;
|
||||
import org.briarproject.briar.android.viewmodel.LiveEvent;
|
||||
import org.briarproject.briar.android.viewmodel.MutableLiveEvent;
|
||||
import org.briarproject.briar.api.android.NetworkUsageMetrics;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Logger;
|
||||
@@ -40,18 +43,24 @@ import static java.util.Objects.requireNonNull;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.api.plugin.Plugin.State.ACTIVE;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.getPersistentLogDir;
|
||||
import static org.briarproject.bramble.util.LogUtils.formatLog;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.bramble.util.StringUtils.isNullOrEmpty;
|
||||
import static org.briarproject.briar.android.logging.BriefLogFormatter.formatLog;
|
||||
|
||||
@NotNullByDefault
|
||||
class ReportViewModel extends AndroidViewModel {
|
||||
|
||||
private static final int MAX_PERSISTENT_LOG_LINES = 1000;
|
||||
|
||||
private static final Logger LOG =
|
||||
getLogger(ReportViewModel.class.getName());
|
||||
|
||||
private final CachingLogHandler logHandler;
|
||||
private final LogDecrypter logDecrypter;
|
||||
private final Formatter formatter;
|
||||
private final PersistentLogManager logManager;
|
||||
private final FeatureFlags featureFlags;
|
||||
private final BriarReportCollector collector;
|
||||
private final DevReporter reporter;
|
||||
private final PluginManager pluginManager;
|
||||
@@ -70,15 +79,20 @@ class ReportViewModel extends AndroidViewModel {
|
||||
|
||||
@Inject
|
||||
ReportViewModel(@NonNull Application application,
|
||||
NetworkUsageMetrics networkUsageMetrics,
|
||||
CachingLogHandler logHandler,
|
||||
LogDecrypter logDecrypter,
|
||||
Formatter formatter,
|
||||
PersistentLogManager logManager,
|
||||
FeatureFlags featureFlags,
|
||||
DevReporter reporter,
|
||||
PluginManager pluginManager) {
|
||||
super(application);
|
||||
collector = new BriarReportCollector(application, networkUsageMetrics);
|
||||
collector = new BriarReportCollector(application);
|
||||
this.logHandler = logHandler;
|
||||
this.logDecrypter = logDecrypter;
|
||||
this.formatter = formatter;
|
||||
this.logManager = logManager;
|
||||
this.featureFlags = featureFlags;
|
||||
this.reporter = reporter;
|
||||
this.pluginManager = pluginManager;
|
||||
}
|
||||
@@ -88,22 +102,30 @@ class ReportViewModel extends AndroidViewModel {
|
||||
this.initialComment = initialComment;
|
||||
isFeedback = t == null;
|
||||
if (reportData.getValue() == null) new SingleShotAndroidExecutor(() -> {
|
||||
String decryptedLogs;
|
||||
String currentLog;
|
||||
if (isFeedback) {
|
||||
Formatter formatter = new BriefLogFormatter();
|
||||
decryptedLogs =
|
||||
formatLog(formatter, logHandler.getRecentLogRecords());
|
||||
// We're in the main process, so get the log for this process
|
||||
currentLog = formatLog(formatter,
|
||||
logHandler.getRecentLogRecords());
|
||||
} else {
|
||||
decryptedLogs = logDecrypter.decryptLogs(logKey);
|
||||
if (decryptedLogs == null) {
|
||||
// We're in the crash reporter process, so try to load
|
||||
// the encrypted log that was saved by the main process
|
||||
currentLog = logDecrypter.decryptLogs(logKey);
|
||||
if (currentLog == null) {
|
||||
// error decrypting logs, get logs from this process
|
||||
Formatter formatter = new BriefLogFormatter();
|
||||
decryptedLogs = formatLog(formatter,
|
||||
currentLog = formatLog(formatter,
|
||||
logHandler.getRecentLogRecords());
|
||||
}
|
||||
}
|
||||
MultiReportInfo logs = new MultiReportInfo();
|
||||
logs.add("Current", currentLog);
|
||||
if (isFeedback && featureFlags.shouldEnablePersistentLogs()) {
|
||||
// Add persistent logs for the current and previous processes
|
||||
logs.add("Persistent", getPersistentLog(false));
|
||||
logs.add("PersistentOld", getPersistentLog(true));
|
||||
}
|
||||
ReportData data =
|
||||
collector.collectReportData(t, appStartTime, decryptedLogs);
|
||||
collector.collectReportData(t, appStartTime, logs);
|
||||
reportData.postValue(data);
|
||||
}).start();
|
||||
}
|
||||
@@ -228,6 +250,27 @@ class ReportViewModel extends AndroidViewModel {
|
||||
return closeReport;
|
||||
}
|
||||
|
||||
private String getPersistentLog(boolean old) {
|
||||
File logDir = getPersistentLogDir(getApplication());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try {
|
||||
Scanner scanner = logManager.getPersistentLog(logDir, old);
|
||||
LinkedList<String> lines = new LinkedList<>();
|
||||
int numLines = 0;
|
||||
while (scanner.hasNextLine()) {
|
||||
lines.add(scanner.nextLine());
|
||||
// If there are too many lines, return the most recent ones
|
||||
if (numLines == MAX_PERSISTENT_LOG_LINES) lines.pollFirst();
|
||||
else numLines++;
|
||||
}
|
||||
scanner.close();
|
||||
for (String line : lines) sb.append(line).append('\n');
|
||||
} catch (IOException e) {
|
||||
sb.append("Could not recover persistent log: ").append(e);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// Used for a new thread as the Android executor thread may have died
|
||||
private static class SingleShotAndroidExecutor extends Thread {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.View;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.util.ActivityLaunchers.CreateDocumentAdvanced;
|
||||
import org.briarproject.briar.android.util.ActivityLaunchers.GetImageAdvanced;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -21,6 +22,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.briar.android.AppModule.getAndroidComponent;
|
||||
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||
@@ -37,6 +39,10 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
private static final String PREF_KEY_DEV = "pref_key_dev";
|
||||
private static final String PREF_KEY_EXPLODE = "pref_key_explode";
|
||||
private static final String PREF_KEY_SHARE_APP = "pref_key_share_app";
|
||||
private static final String PREF_KEY_EXPORT_LOG = "pref_key_export_log";
|
||||
private static final String PREF_EXPORT_OLD_LOG = "pref_key_export_old_log";
|
||||
|
||||
private static final String LOG_EXPORT_FILENAME = "briar-log.txt";
|
||||
|
||||
@Inject
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
@@ -44,10 +50,18 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
private SettingsViewModel viewModel;
|
||||
private AvatarPreference prefAvatar;
|
||||
|
||||
private final ActivityResultLauncher<String> launcher =
|
||||
private final ActivityResultLauncher<String> imageLauncher =
|
||||
registerForActivityResult(new GetImageAdvanced(),
|
||||
this::onImageSelected);
|
||||
|
||||
private final ActivityResultLauncher<String> logLauncher =
|
||||
registerForActivityResult(new CreateDocumentAdvanced(),
|
||||
uri -> onLogFileSelected(false, uri));
|
||||
|
||||
private final ActivityResultLauncher<String> oldLogLauncher =
|
||||
registerForActivityResult(new CreateDocumentAdvanced(),
|
||||
uri -> onLogFileSelected(true, uri));
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
@@ -63,7 +77,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
prefAvatar = requireNonNull(findPreference(PREF_KEY_AVATAR));
|
||||
if (viewModel.shouldEnableProfilePictures()) {
|
||||
prefAvatar.setOnPreferenceClickListener(preference -> {
|
||||
launcher.launch("image/*");
|
||||
imageLauncher.launch("image/*");
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
@@ -77,11 +91,32 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
|
||||
Preference explode = requireNonNull(findPreference(PREF_KEY_EXPLODE));
|
||||
if (IS_DEBUG_BUILD) {
|
||||
Preference explode =
|
||||
requireNonNull(findPreference(PREF_KEY_EXPLODE));
|
||||
explode.setOnPreferenceClickListener(preference -> {
|
||||
throw new RuntimeException("Boom!");
|
||||
});
|
||||
Preference exportLog =
|
||||
requireNonNull(findPreference(PREF_KEY_EXPORT_LOG));
|
||||
if (SDK_INT >= 19) {
|
||||
exportLog.setOnPreferenceClickListener(preference -> {
|
||||
logLauncher.launch(LOG_EXPORT_FILENAME);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
exportLog.setVisible(false);
|
||||
}
|
||||
Preference exportOldLog =
|
||||
requireNonNull(findPreference(PREF_EXPORT_OLD_LOG));
|
||||
if (SDK_INT >= 19) {
|
||||
exportOldLog.setOnPreferenceClickListener(preference -> {
|
||||
oldLogLauncher.launch(LOG_EXPORT_FILENAME);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
exportOldLog.setVisible(false);
|
||||
}
|
||||
} else {
|
||||
PreferenceGroup dev = requireNonNull(findPreference(PREF_KEY_DEV));
|
||||
dev.setVisible(false);
|
||||
@@ -111,4 +146,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
ConfirmAvatarDialogFragment.TAG);
|
||||
}
|
||||
|
||||
private void onLogFileSelected(boolean old, @Nullable Uri uri) {
|
||||
if (uri != null) viewModel.exportPersistentLog(old, uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.logging.PersistentLogManager;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.BluetoothConstants;
|
||||
@@ -35,8 +36,12 @@ import org.briarproject.briar.api.avatar.AvatarManager;
|
||||
import org.briarproject.briar.api.identity.AuthorInfo;
|
||||
import org.briarproject.briar.api.identity.AuthorManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -50,6 +55,7 @@ import static android.widget.Toast.LENGTH_LONG;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.getPersistentLogDir;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.getSupportedImageContentTypes;
|
||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
@@ -78,6 +84,7 @@ class SettingsViewModel extends DbViewModel implements EventListener {
|
||||
private final ImageCompressor imageCompressor;
|
||||
private final Executor ioExecutor;
|
||||
private final FeatureFlags featureFlags;
|
||||
private final PersistentLogManager logManager;
|
||||
|
||||
final SettingsStore settingsStore;
|
||||
final TorSummaryProvider torSummaryProvider;
|
||||
@@ -108,7 +115,8 @@ class SettingsViewModel extends DbViewModel implements EventListener {
|
||||
LocationUtils locationUtils,
|
||||
CircumventionProvider circumventionProvider,
|
||||
@IoExecutor Executor ioExecutor,
|
||||
FeatureFlags featureFlags) {
|
||||
FeatureFlags featureFlags,
|
||||
PersistentLogManager logManager) {
|
||||
super(application, dbExecutor, lifecycleManager, db, androidExecutor);
|
||||
this.settingsManager = settingsManager;
|
||||
this.identityManager = identityManager;
|
||||
@@ -118,6 +126,7 @@ class SettingsViewModel extends DbViewModel implements EventListener {
|
||||
this.authorManager = authorManager;
|
||||
this.ioExecutor = ioExecutor;
|
||||
this.featureFlags = featureFlags;
|
||||
this.logManager = logManager;
|
||||
settingsStore = new SettingsStore(settingsManager, dbExecutor,
|
||||
SETTINGS_NAMESPACE);
|
||||
torSummaryProvider = new TorSummaryProvider(getApplication(),
|
||||
@@ -262,4 +271,38 @@ class SettingsViewModel extends DbViewModel implements EventListener {
|
||||
return screenLockTimeout;
|
||||
}
|
||||
|
||||
void exportPersistentLog(boolean old, Uri uri) {
|
||||
// We can use untranslated strings here, as this method is only called
|
||||
// in debug builds
|
||||
ioExecutor.execute(() -> {
|
||||
Application app = getApplication();
|
||||
try {
|
||||
OutputStream os =
|
||||
app.getContentResolver().openOutputStream(uri);
|
||||
if (os == null) throw new IOException();
|
||||
File logDir = getPersistentLogDir(app);
|
||||
Scanner scanner = logManager.getPersistentLog(logDir, old);
|
||||
if (!scanner.hasNextLine()) {
|
||||
scanner.close();
|
||||
androidExecutor.runOnUiThread(() ->
|
||||
Toast.makeText(app, "Log is empty",
|
||||
LENGTH_LONG).show());
|
||||
return;
|
||||
}
|
||||
PrintWriter w = new PrintWriter(os);
|
||||
while (scanner.hasNextLine()) w.println(scanner.nextLine());
|
||||
w.flush();
|
||||
w.close();
|
||||
scanner.close();
|
||||
androidExecutor.runOnUiThread(() ->
|
||||
Toast.makeText(app, "Log exported",
|
||||
LENGTH_LONG).show());
|
||||
} catch (IOException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
androidExecutor.runOnUiThread(() ->
|
||||
Toast.makeText(app, "Failed to export log",
|
||||
LENGTH_LONG).show());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package org.briarproject.briar.api.android;
|
||||
|
||||
import org.briarproject.bramble.api.lifecycle.Service;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface NetworkUsageMetrics extends Service {
|
||||
|
||||
Metrics getMetrics();
|
||||
|
||||
class Metrics {
|
||||
|
||||
private final long sessionDurationMs, rxBytes, txBytes;
|
||||
|
||||
public Metrics(long sessionDurationMs, long rxBytes,
|
||||
long txBytes) {
|
||||
this.sessionDurationMs = sessionDurationMs;
|
||||
this.rxBytes = rxBytes;
|
||||
this.txBytes = txBytes;
|
||||
}
|
||||
|
||||
public long getSessionDurationMs() {
|
||||
return sessionDurationMs;
|
||||
}
|
||||
|
||||
public long getRxBytes() {
|
||||
return rxBytes;
|
||||
}
|
||||
|
||||
public long getTxBytes() {
|
||||
return txBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -647,6 +647,8 @@
|
||||
<string name="transports_help_text">Briar може да се свърже с контактите ви през интернет, Wi-Fi или Bluetooth.\n\nЗа повече поверителност цялата връзка към интернет се пренасочва през мрежата на Tor.\n\nАко даден контакт може да бъде достъпен чрез няколко метода Briar ги използва успоредно.</string>
|
||||
<!--Share app offline-->
|
||||
<string name="hotspot_title">Споделяне на приложението извън мрежа</string>
|
||||
<string name="hotspot_intro">Споделете приложението с някого около вас без достъп до интернет с използване на Wi-Fi на устройствата.
|
||||
\n\nВашето устройство създава безжична точка за достъп. Хората около вас биха могли да се свържат към нея и да изтеглят Briar от вашето устройство.</string>
|
||||
<string name="hotspot_button_start_sharing">Включване на безжична точка</string>
|
||||
<string name="hotspot_button_stop_sharing">Спиране на безжична точка</string>
|
||||
<string name="hotspot_progress_text_start">Настройване на безжична точка…</string>
|
||||
|
||||
@@ -692,7 +692,6 @@
|
||||
<string name="hotspot_help_wifi_title">Probleme bei der WLAN-Verbindung:</string>
|
||||
<string name="hotspot_help_wifi_1">Versuche, WLAN auf beiden Telefonen zu deaktivieren und wieder zu aktivieren, und versuche es dann erneut.</string>
|
||||
<string name="hotspot_help_wifi_2">Wenn dein Telefon meldet, dass das WLAN kein Internet hat, sag ihm, dass du trotzdem verbunden bleiben willst.</string>
|
||||
<string name="hotspot_help_wifi_3">Telefon neu starten, auf dem der WLAN-Hotspot läuft, danach Briar starten und erneut teilen.</string>
|
||||
<string name="hotspot_help_site_title">Probleme beim Besuch der lokalen Webseite:</string>
|
||||
<string name="hotspot_help_site_1">Überprüfe unbedingt, ob du die Adresse genau so wie angezeigt eingegeben hast. Ein kleiner Fehler kann dazu führen, dass der Versuch fehlschlägt.</string>
|
||||
<string name="hotspot_help_site_2">Vergewissere dich, dass dein Telefon immer noch mit dem richtigen WLAN verbunden ist (siehe oben), wenn du die Webseite aufrufen willst.</string>
|
||||
|
||||
@@ -609,7 +609,6 @@
|
||||
<string name="dev_report_memory">Memoria</string>
|
||||
<string name="dev_report_storage">Almacenamiento</string>
|
||||
<string name="dev_report_connectivity">Conectividad</string>
|
||||
<string name="dev_report_network_usage">Uso de red</string>
|
||||
<string name="dev_report_build_config">Configuración de compilación</string>
|
||||
<string name="dev_report_logcat">Registro de la aplicación</string>
|
||||
<string name="dev_report_device_features">Características del dispositivo</string>
|
||||
@@ -652,7 +651,7 @@
|
||||
<string name="transports_help_text">Briar puede conectar a tus contactos vía Internet, Wi-Fi o Bluetooth.\n\nTodas las conexiones a Internet van a través de la red Tor por privacidad.\n\nSi un contacto puede ser alcanzado por múltiples métodos, Briar los usa en paralelo.</string>
|
||||
<!--Share app offline-->
|
||||
<string name="hotspot_title">Comparte esta aplicación fuera de línea</string>
|
||||
<string name="hotspot_intro">Comparte esta aplicación con alguien que esté cerca tuyo sin una conexión a Internet, usando el Wi-Fi de tu teléfono.
|
||||
<string name="hotspot_intro">Comparte esta aplicación con alguien que esté cerca tuyo sin conexión a Internet, usando el Wi-Fi de tu teléfono.
|
||||
\n\nTu teléfono iniciará un punto de acceso Wi-Fi. Las personas cercanas a tí pueden conectarse al punto de acceso y descargar la aplicación Briar desde tu teléfono.</string>
|
||||
<string name="hotspot_button_start_sharing">Iniciar punto de acceso</string>
|
||||
<string name="hotspot_button_stop_sharing">Detener punto de acceso</string>
|
||||
|
||||
@@ -45,11 +45,6 @@
|
||||
|
||||
اخطار: هویت های شما، مخاطبان شما و پیام های شما برای همیشه از بین خواهند رفت.</string>
|
||||
<string name="startup_failed_activity_title">خطا در شروع Briar (برایر)</string>
|
||||
<string name="startup_failed_clock_error">Briar به دلیل این که ساعت دستگاه شما غلط است، اجرا نشد.\n\n لطفا ساعت دستگاه خود را تنظیم کرده و دوباره تلاش کنید.</string>
|
||||
<string name="startup_failed_db_error">Briar قادر به باز کردن پایگاه داده حاوی حساب کاربری، مخاطبین و پیامهای شما نشد.\n\n لطفا برنامه را به آخرین نسخه ارتقا داده، و یا هنگام وارد کردن رمز عبور، با انتخاب گزینه «رمز خود را فراموش کردهام» حساب جدیدی ایجاد کنید.</string>
|
||||
<string name="startup_failed_data_too_old_error">حساب کاربری شما با نسخه قدیمی این برنامه ساخته شده و در این نسخه قابل باز شدن نیست.\n\n شما یا باید نسخه قبلی را دوباره نصب کنید و یا هنگام وارد کردن رمز عبور، با انتخاب «رمز خود را فراموش کردهام» حساب جدیدی ایجاد کنید.</string>
|
||||
<string name="startup_failed_data_too_new_error">حساب کاربری شما با نسخه جدیدتر این برنامه ساخته شده و در این نسخه قابل باز شدن نیست.\n\n لطفا به آخرین نسخه ارتقا داده و دوباره امتحان کنید.</string>
|
||||
<string name="startup_failed_service_error">Briar قادر به آغاز اجزای مورد نیاز نیست.\n\n لطفا به آخرین نسخه برنامه ارتقا داده و دوباره امتحان کنید.</string>
|
||||
<plurals name="expiry_warning">
|
||||
<item quantity="one">این یک نسخه آزمایشی از Briar (برایر) می باشد. حساب کاربری شما در %d روز آینده به پایان می رسد و امکان تمدید آن وجود نخواهد داشت.</item>
|
||||
<item quantity="other">این یک نسخه آزمایشی از Briar (برایر) می باشد. حساب کاربری شما در %d روز آینده به پایان می رسد و امکان تمدید آن وجود نخواهد داشت.</item>
|
||||
@@ -334,13 +329,9 @@
|
||||
<!--Connect via Bluetooth-->
|
||||
<string name="menu_item_connect_via_bluetooth">اتصال از طریق بلوتوث</string>
|
||||
<string name="connect_via_bluetooth_title">اتصال از طریق بلوتوث</string>
|
||||
<string name="connect_via_bluetooth_intro">در صورتی که ارتباطات بلوتوث به صورت خودکار کار نکرد، میتوانید از این صفحه برای ارتباط دستی استفاده کنید.\n\n برای کار کردن این امکان، مخاطب شما باید نزدیک باشد.\n\n شما و مخاطبتان باید هر دو گزینه «آغاز» را همزمان بفشارید.</string>
|
||||
<string name="connect_via_bluetooth_already_discovering">در حال تلاش برای اتصال با بلوتوث. لطفا به زودی دوباره امتحان کنید.</string>
|
||||
<string name="connect_via_bluetooth_no_location_permission">امکان ادامه بدون اجازه مکانیابی وجود ندارد</string>
|
||||
<string name="connect_via_bluetooth_start">در حال اتصال از طریق بلوتوث</string>
|
||||
<string name="connect_via_bluetooth_success">ارتباط از طریق بلوتوث با موفقیت انجام شد</string>
|
||||
<string name="connect_via_bluetooth_error">اتصال از طریق بلوتوث امکان پذیر نیست.</string>
|
||||
<string name="connect_via_bluetooth_error_not_supported">بلوتوث توسط دستگاه پشتیبانی نمیشود.</string>
|
||||
<!--Private Groups-->
|
||||
<string name="groups_list_empty">هیچ گروهی برای نمایش وجود ندارد</string>
|
||||
<string name="groups_list_empty_action">برای ایجاد یک گروه روی آیکون + کلیک کنید، یا از مخاطبان خود بخواهید تا گروه های خود را با شما به اشتراک بگذارند</string>
|
||||
@@ -631,7 +622,6 @@
|
||||
<string name="link_warning_open_link">باز کردن پیوند</string>
|
||||
<!--Crash Reporter-->
|
||||
<string name="crash_report_title">گزارش خطای Briar (برایر)</string>
|
||||
<string name="briar_crashed">متاسفانه Briar از کار افتاد</string>
|
||||
<string name="not_your_fault">این تقصیر شما نیست.</string>
|
||||
<string name="please_send_report">لطفا با فرستادن گزارش خطا به ما کمک کنید تا Briar (برایر) را بهتر کنیم.</string>
|
||||
<string name="report_is_encrypted">به شما اطمینان می دهیم که گزارش شما رمزنگاری شده و به صورت امن فرستاده می شود.</string>
|
||||
@@ -649,7 +639,6 @@
|
||||
<string name="dev_report_memory">حافظه</string>
|
||||
<string name="dev_report_storage">حافظه</string>
|
||||
<string name="dev_report_connectivity">اتصال</string>
|
||||
<string name="dev_report_network_usage">استفاده از شبکه</string>
|
||||
<string name="dev_report_build_config">پیکربندی ساخت</string>
|
||||
<string name="dev_report_logcat">لاگ برنامه</string>
|
||||
<string name="dev_report_device_features">ویژگیهای دستگاه</string>
|
||||
@@ -703,89 +692,18 @@ Briar (برایر) موقعیت شما را ذخیره نمیکند و آن
|
||||
<!--Connections Screen-->
|
||||
<string name="transports_help_text">Briar (برایر) میتواند از طریق اینترنت، Wi-Fi و یا بلوتوث به مخاطبین شما متصل گردد.\n\nارتباط با اینترنت از طریق شبکهی تور صورت میپذیرد.\n\nاگر دسترسی به مخاطب شما از روشهای مختلفی ممکن باشد، Briar (برایر) به صورت موازی از آنها استفاده خواهد کرد.</string>
|
||||
<!--Share app offline-->
|
||||
<string name="hotspot_title">این برنامه را به صورت آفلاین به اشتراک بگذارید</string>
|
||||
<string name="hotspot_intro">این برنامه را بدو ارتباط با اینترنت و فقط با Wi-Fi تلفن خود با فردی در نزدیکی خود به اشتراک بگذارید.
|
||||
\n\n تلفن شما با Wi-Fi hotspot آغاز میشود. افراد در نزدیکی شما میتوانند به hotspot متصل شده و برنامه Briar را از تلفن شما دانلود کنند.</string>
|
||||
<string name="hotspot_button_start_sharing">آغاز hotspot</string>
|
||||
<string name="hotspot_button_stop_sharing">توقف hotspot</string>
|
||||
<string name="hotspot_progress_text_start">در حال راه اندازی hotspot...</string>
|
||||
<string name="hotspot_notification_channel_title">Wi-Fi hotspot</string>
|
||||
<string name="hotspot_notification_title">اشتراکگذاری آفلاین Briar</string>
|
||||
<string name="hotspot_button_connected">بعد</string>
|
||||
<string name="permission_hotspot_location_request_body">برای ایجاد Wi-Fi hotspot، Briar به مجوز دسترسی مکانی شما نیاز دارد.\n\n Briar اطلاعات مکانی شما را ذخیره نکرده و با کسی به اشتراک نمیگذارد.</string>
|
||||
<string name="permission_hotspot_location_denied_body">شما دسترسی به مکان خود را رد کردهاید، در صورتی که Briar برای ایجاد Wi-Fi hotspot به این مجوز نیاز دارد.\n\n لطفا اجازه دسترسی را در نظر بگیرید.</string>
|
||||
<string name="wifi_settings_title">تنظیمات Wi-Fi</string>
|
||||
<string name="wifi_settings_request_enable_body">برای ایجاد Wi-Fi hotspot، Briar نیاز به استفاده از Wi-Fi دارد. لطفا آن را فعال کنید.</string>
|
||||
<string name="hotspot_tab_manual">دستی</string>
|
||||
<!--The placeholder to be inserted into the string 'hotspot_manual_wifi': People can connect by %s-->
|
||||
<string name="hotspot_scanning_a_qr_code">کد QR را اسکن کنید</string>
|
||||
<!--Wi-Fi setup-->
|
||||
<!--The %s placeholder will be replaced with the translation of 'hotspot_scanning_a_qr_code'-->
|
||||
<string name="hotspot_manual_wifi">تلفن شما Wi-Fi hotspot ارائه میکند. کسانی که قصد دانلود Briar را دارند، میتوانند با افزودن hotspot در تنظیمات Wi-Fi دستگاه خود، به آن متصل شده و یا %s. هنگامی که به hotspot متصل شدند، دکمه «بعد» را بفشارند.</string>
|
||||
<string name="hotspot_manual_wifi_ssid">نام شبکه</string>
|
||||
<string name="hotspot_qr_wifi">تلفن شما Wi-Fi hotspot ارائه میکند. کسانی که قصد دانلود Briar را دارند، میتوانند با اسکن این کد QR به hotspot متصل شوند. هنگامی که به hotspot متصل شدند، دکمه «بعد» را بفشارند.</string>
|
||||
<string name="hotspot_no_peers_connected">هیچ دستگاهی متصل نیست</string>
|
||||
<plurals name="hotspot_peers_connected">
|
||||
<item quantity="one">%s دستگاه متصل است</item>
|
||||
<item quantity="other">%s دستگاه متصل است</item>
|
||||
</plurals>
|
||||
<!--Download link-->
|
||||
<!--The %s placeholder will be replaced with the translation of 'hotspot_scanning_a_qr_code'-->
|
||||
<string name="hotspot_manual_site">تلفن شما Wi-Fi hotspot ارائه میکند. کسانی که به hotspot متصل هستند، میتوانند Briar را با تایپ لینک زیر در مرورگر خود دانلود کنند و یا %s.</string>
|
||||
<string name="hotspot_manual_site_address">آدرس (URL)</string>
|
||||
<string name="hotspot_qr_site">تلفن شما Wi-Fi hotspot ارائه میکند. کسانی که به hotspot متصل هستند، میتوانند Briar را با اسکن این کد QR دانلود کنند.</string>
|
||||
<!--e.g. Download Briar 1.2.20-->
|
||||
<string name="website_download_title">دانلود %s</string>
|
||||
<string name="website_download_intro">فردی در نزدیکی %s را با شما به اشتراک گذاشته است.</string>
|
||||
<string name="website_download_outro">پس از تکمیل دانلود، فایل دانلود شده را باز کرده و نصب کنید.</string>
|
||||
<string name="website_troubleshooting_title">◾️ عیب یابی</string>
|
||||
<string name="website_troubleshooting_1">اگر قادر به دانلود کردن برنامه نیستید، با مرورگر دیگری امتحان کنید.</string>
|
||||
<string name="website_troubleshooting_2_old">برای نصب برنامه دانلود شده، باید اجازه نصب برنامه از «منابع ناشناخته» را در تنظیمات سیستم بدهید. سپس ممکن است نیاز به دانلود دوباره برنامه داشته باشید. ما توصیه میکنیم که پس از نصب این برنامه، اجازه «منابع ناشناخته» را لغو کنید.</string>
|
||||
<string name="website_troubleshooting_2_new">برای نصب برنامه دانلود شده، ممکن است نیاز به ایجاد مجوز نصب برنامههای ناشناخته در مرورگر را داشته باشید. پس از نصب این برنامه، توصیه میکنیم مجوز نصب برنامههای ناشناخته را لغو کنید.</string>
|
||||
<string name="hotspot_help_wifi_title">مشکلات اتصال به Wi-Fi:</string>
|
||||
<string name="hotspot_help_wifi_1">Wi-Fi را در هر دو تلفن غیرفعال و دوباره فعال کنید.</string>
|
||||
<string name="hotspot_help_wifi_2">اگر تلفن پیامی مبنی بر عدم دسترسی Wi-Fi به اینترنت داد، از گزینه مربوط به متصل ماندن استفاده کنید.</string>
|
||||
<string name="hotspot_help_wifi_3">تلفنی که میزبان Wi-Fi hotspot است را دوباره راهاندازی کنید، سپس Briar را باز کرده و دوباره به اشتراک بگذارید.</string>
|
||||
<string name="hotspot_help_site_title">مشکلات بازدید از وبسایت محلی:</string>
|
||||
<string name="hotspot_help_site_1">مطمئن شوید که آدرسی که وارد میکنید، دقیقا آدرسی باشد که نمایش یافته. خطای کوچک منجر به ناموفق بودن پروسه خواهد شد.</string>
|
||||
<string name="hotspot_help_site_2">مطمئن شوید هنگامی که قصد دسترسی به سایت را دارید، تلفن شما هنوز به Wi-Fi صحیح متصل باشد (بالا را ببینید).</string>
|
||||
<string name="hotspot_help_site_3">اگر از برنامه فایروال استفاده میکنید، مطمئن باشید که دسترسی را مسدود نکرده است.</string>
|
||||
<string name="hotspot_help_site_4">اگر میتوانید سایت را باز کنید، ولی نمیتوانید برنامه Briar را دانلود کنید، از یک مرورگر دیگر استفاده کنید.</string>
|
||||
<string name="hotspot_help_fallback_title">هیچ چیز کار نمیکند؟</string>
|
||||
<string name="hotspot_help_fallback_intro">شما میتوانید با راههایی، برنامه را به صورت فایل .apk ذخیره و به اشتراک بگذارید. هنگامی که فایل به دستگاه دیگری انتقال یافت، میتواند برای نصب Briar مورد استفاده قرار گیرد.
|
||||
\n\nنکته: برای اشتراکگذاری از طریق بلوتوث، ممکن است نیاز به تغییر انتهای نام فایل به .zip داشته باشید.</string>
|
||||
<string name="hotspot_help_fallback_button">ذخیره برنامه</string>
|
||||
<!--error handling-->
|
||||
<string name="hotspot_error_intro">هنگام تلاش برای اشتراکگذاری برنامه از طریق Wi-Fi مشکلی رخ داد:</string>
|
||||
<string name="hotspot_error_no_wifi_direct">دستگاه از Wi-Fi Direct پشتیبانی نمیکند</string>
|
||||
<string name="hotspot_error_start_callback_failed">Hotspot قادر به راهاندازی نبود: خطای %s</string>
|
||||
<string name="hotspot_error_start_callback_failed_unknown">Hotspot با خطایی ناشناخته قادر به راهاندازی نبود، علت %d</string>
|
||||
<string name="hotspot_error_start_callback_no_group_info">Hotspot قادر به راهاندازی نبود: بدون اطلاعات گروه</string>
|
||||
<string name="hotspot_error_web_server_start">خطا در راهاندازی سرور وب</string>
|
||||
<string name="hotspot_error_web_server_serve">خطا در ارائه وبسایت.\n\n لطفا در صورت ادامه مشکل، بازخورد خود را (به همراه دادههای ناشناس) به برنامه Briar ارسال کنید.</string>
|
||||
<string name="hotspot_flag_test">هشدار: این برنامه با Android Studio نصب شده و قادر به نصب بر روی دستگاه دیگری نیست.</string>
|
||||
<string name="hotspot_error_framework_busy">مشکل در راهاندازی hotspot.\n\n اگر hotspot دیگری در دستگاه شما فعال است و اینترنت شما را با اتصال Wi-Fi به اشتراک میگذارد، لطفا آن را متوقف کرده و دوباره امتحان کنید.</string>
|
||||
<!--Transfer Data via Removable Drives-->
|
||||
<string name="removable_drive_menu_title">اتصال ار طریق حافظه قابل جابجایی</string>
|
||||
<string name="removable_drive_intro">اگر از طریق اینترنت، Wi-Fi و یا بلوتوث قادر به ارتباط با مخاطب خود نیستید، Briar قادر به جابجایی پیامها از طریق درایو قابل جابجایی مانند حافظه قلش و یا کارت SD است.</string>
|
||||
<string name="removable_drive_explanation">اگر از طریق اینترنت، Wi-Fi و یا بلوتوث قادر به ارتباط با مخاطب خود نیستید، Briar قادر به جابجایی پیامها از طریق درایو قابل جابجایی مانند حافظه قلش و یا کارت SD است.\n\nهنگامی که از گزینه «ارسال داده» استفاده میکنید، هر دادهای که منتظر ارسال به مخاطب شماست، بر روی حافظه قابل جابجایی ذخیره خواهد شد. این دادهها شامل پیامها، ضمائم، بلاگها، تالارها و گروههای خصوصی است.\n\nهمه دادهها قبل از ذخیره در حافظه قابل جابجایی، رمزگذاری خواهند شد.\n\nهنگامی که مخاطب شما حافظه قابل جابجایی را دریافت میکند، میتواند با استفاده از دکمه «دریافت داده» تمامی پیامها را به Briar وارد کند.</string>
|
||||
<string name="removable_drive_title_send">ارسال داده</string>
|
||||
<string name="removable_drive_title_receive">دریافت داده</string>
|
||||
<string name="removable_drive_send_intro">دکمه زیر را برای ایجاد فایل جدید حاوی پیامهای رمزگذاری شده بفشارید. شما میتوانید محل ذخیره فایل را تعیین کنید.\n\n اگر تمایل به ذخیره فایل بر روی حافظه قابل جابجایی دارید، آن را الآن متصل کنید.</string>
|
||||
<string name="removable_drive_send_no_data">در حال حاظر هیچ پیامی در انتظار ارسال به مخاطب نیست.</string>
|
||||
<string name="removable_drive_send_not_supported">این مخاطب از نسخه قدیمی Briar و یا از دستگاه قدیمی که این قابلیت را پشتیبانی نمیکند، استفاده میکند.</string>
|
||||
<string name="removable_drive_send_button">فایل را برای گرفتن خروجی انتخاب کنید</string>
|
||||
<string name="removable_drive_ongoing">لطفا تا تکمیل کار فعلی منتظر بمانید</string>
|
||||
<string name="removable_drive_receive_intro">برای انتخاب فایلی که مخاطب شما ارسال کرده است، دکمه زیر را بفشارید.\n\nاگر فایل بر روی حافظه قابل جابجایی است، آن را الآن متصل کنید.</string>
|
||||
<string name="removable_drive_receive_button">فایل را برای وارد کردن انتخاب کنید</string>
|
||||
<string name="removable_drive_success_send_title">خروجی با موفقیت گرفته شد</string>
|
||||
<string name="removable_drive_success_send_text">از دادهها با موفقیت خروجی گرفته شد. شما الآن ۲۸ روز تا انتقال فایل به مخاطب خود فرصت دارید.\n\nاگر فایل بر روی حافظه قابل جابجایی است، از پیام در نوار اعلانات برای خارج کردن آن استفاده کنید.</string>
|
||||
<string name="removable_drive_success_receive_title">درون برد موفق بود</string>
|
||||
<string name="removable_drive_success_receive_text">تمامی پیامهای رمزگذاریشده در این فایل دریافت شدند.</string>
|
||||
<string name="removable_drive_error_send_title">خطا حین گرفتن خروجی از داده</string>
|
||||
<string name="removable_drive_error_send_text">خطایی هنگام نوشتن دادهها در فایل رخ داد.\n\nاگر از حافظه قابل جابجایی استفاده میکنید، از اتصال صحیح آن مطمئن شوید.\n\nاگر خطا ادامه یافت، لطفا بازخورد خود را برای اطلاع تیم Briar از مشکل، به ما ارسال کنید.</string>
|
||||
<string name="removable_drive_error_receive_title">خطا حین وارد کردن داده</string>
|
||||
<string name="removable_drive_error_receive_text">فایل انتخاب شده چیز قابل شناسایی توسط Briar نداشت.\n\nلطفا از انتخاب فایل صحبح مطمئن شوید.\n\nاگر مخاطب شما فایل را بیش از ۲۸ روز قبل ساخته است، Briar قادر به شناسایی آن نخواهد بود.</string>
|
||||
<!--Screenshots-->
|
||||
<!--This is a name to be used in screenshots. Feel free to change it to a local name.-->
|
||||
<string name="screenshot_alice">آلیس</string>
|
||||
|
||||
@@ -41,11 +41,6 @@
|
||||
<string name="dialog_title_lost_password">Mot de passe oublié</string>
|
||||
<string name="dialog_message_lost_password">Votre compte Briar est enregistré chiffré sur votre appareil, pas dans le nuage, et nous ne pouvons donc pas réinitialiser votre mot de passe. Voulez-vous supprimer votre compte et recommencer ?\n\nAttention : vos identités, contacts et messages seront perdus irrémédiablement.</string>
|
||||
<string name="startup_failed_activity_title">Échec de démarrage de Briar</string>
|
||||
<string name="startup_failed_clock_error">Briar n’a pas pu démarrer, car l’horloge de votre appareil n’est pas à l’heure.\n\nVeuillez mettre l’horloge de votre appareil à l’heure et réessayer.</string>
|
||||
<string name="startup_failed_db_error">Briar n’a pas pu ouvrir la base de données qui comprend votre compte, vos contacts et messages.\n\nVeuillez mettre l’appli à jour vers la version la plus récente et réessayer, ou créer un nouveau compte en choisissant « J’ai oublié mon mot de passe » à l’invite de mot de passe.</string>
|
||||
<string name="startup_failed_data_too_old_error">Votre compte a été créé avec une ancienne version de cette appli et ne peut pas être ouvert avec cette version.\n\nVous devez soit réinstaller l’ancienne version, soit créer un nouveau compte en choisissant « J’ai oublié mon mot de passe » à l’invite de mot de passe.</string>
|
||||
<string name="startup_failed_data_too_new_error">Votre compte a été créé avec une version plus récente de cette appli et ne peut être ouvert avec cette version.\n\nVeuillez mettre l’appli à jour vers la version la plus récente et réessayer.</string>
|
||||
<string name="startup_failed_service_error">Briar n\'a pas pu lancer un composant essentiel.\n\nVeuillez mettre l’appli à jour vers la version la plus récente et réessayer.</string>
|
||||
<plurals name="expiry_warning">
|
||||
<item quantity="one">Ceci est une version de test de Briar. Votre compte arrivera à expiration dans %d jour et ne peut pas être renouvelé.</item>
|
||||
<item quantity="other">Ceci est une version de test de Briar. Votre compte arrivera à expiration dans %d jours et ne pourra pas être renouvelé.</item>
|
||||
@@ -316,13 +311,9 @@
|
||||
<!--Connect via Bluetooth-->
|
||||
<string name="menu_item_connect_via_bluetooth">Se connecter par Bluetooth</string>
|
||||
<string name="connect_via_bluetooth_title">Se connecter par Bluetooth</string>
|
||||
<string name="connect_via_bluetooth_intro">Au cas où les connexions Bluetooth ne fonctionneraient pas automatiquement, vous pouvez utiliser cet écran pour vous connecter manuellement.\n\nPour que cela fonctionne, votre contact doit être à proximité.\n\nVotre contact et vous devriez appuyer sur « Commencer » en même temps.</string>
|
||||
<string name="connect_via_bluetooth_already_discovering">Une tentative de connexion par Bluetooth est en cours. Veuillez réessayer dans un moment.</string>
|
||||
<string name="connect_via_bluetooth_no_location_permission">Impossible de poursuivre sans autoriser la position.</string>
|
||||
<string name="connect_via_bluetooth_no_location_permission">Impossible de poursuivre sans la permission de position</string>
|
||||
<string name="connect_via_bluetooth_start">Connexion par Bluetooth…</string>
|
||||
<string name="connect_via_bluetooth_success">La connexion par Bluetooth est réussie</string>
|
||||
<string name="connect_via_bluetooth_error">Impossible de se connecter par Bluetooth.</string>
|
||||
<string name="connect_via_bluetooth_error_not_supported">Bluetooth n’est pas pris en charge par l’appareil.</string>
|
||||
<string name="connect_via_bluetooth_success">Connectée par Bluetooth avec succès</string>
|
||||
<!--Private Groups-->
|
||||
<string name="groups_list_empty">Aucun groupe à afficher</string>
|
||||
<string name="groups_list_empty_action">Touchez l’icône + pour créer un groupe ou pour demander à vos contacts de partager des groupes avec vous</string>
|
||||
@@ -593,7 +584,6 @@ copies des messages que vous envoyez.
|
||||
<string name="link_warning_open_link">Ouvrir le lien</string>
|
||||
<!--Crash Reporter-->
|
||||
<string name="crash_report_title">Rapport de plantage de Briar</string>
|
||||
<string name="briar_crashed">Désolé, Briar a planté</string>
|
||||
<string name="not_your_fault">Vous n’y êtes pour rien.</string>
|
||||
<string name="please_send_report">Veuillez nous aider à améliorer Briar en nous envoyant un rapport de plantage.</string>
|
||||
<string name="report_is_encrypted">Nous promettons que le rapport est chiffré et envoyé en toute sécurité. </string>
|
||||
@@ -652,22 +642,10 @@ copies des messages que vous envoyez.
|
||||
<!--Connections Screen-->
|
||||
<string name="transports_help_text">Briar peut se connecter à vos contacts par Internet, Wi-Fi ou Bluetooth.\n\nToutes les connections Internet passent par le réseau Tor afin de protéger les données.\n\nSi un contact peut être joint par plusieurs moyens, Briar les utilisera simultanément.</string>
|
||||
<!--Share app offline-->
|
||||
<string name="hotspot_title">Partager cette appli hors ligne.</string>
|
||||
<string name="hotspot_intro">Partagez cette appli avec une personne à proximité sans connexion Internet en utilisant le Wi-Fi de votre téléphone.
|
||||
\n\nVotre téléphone démarrera un point d’accès Wi-Fi. Les personnes à proximité peuvent se connecter au point d’accès sans fil et télécharger l’appli Briar de votre téléphone.</string>
|
||||
<string name="hotspot_button_start_sharing">Démarrer le point d’accès sans fil</string>
|
||||
<string name="hotspot_button_stop_sharing">Arrêter le point d’accès sans fil</string>
|
||||
<string name="hotspot_progress_text_start">Configuration du point d’accès sans fil…</string>
|
||||
<string name="hotspot_notification_channel_title">Point d’accès Wi-Fi</string>
|
||||
<string name="hotspot_notification_title">Partage hors ligne de Briar</string>
|
||||
<string name="hotspot_button_connected">Suivant</string>
|
||||
<string name="permission_hotspot_location_request_body">Pour créer un point d’accès Wi-Fi, Briar a besoin de l’autorisation Position.\n\nBriar ne stocke pas votre position et ne la partage avec personne.</string>
|
||||
<string name="permission_hotspot_location_denied_body">Vous avez refusé l’accès à votre position, mais Briar en a besoin pour créer un point d’accès Wi-Fi.\n\nNous vous invitons à y accorder l’accès.</string>
|
||||
<string name="wifi_settings_title">Paramètre Wi-Fi</string>
|
||||
<string name="wifi_settings_request_enable_body">Pour créer un point d’accès Wi-Fi, Briar a besoin d’utiliser le Wi-Fi. Veuillez l’activer.</string>
|
||||
<string name="hotspot_tab_manual">Manuel</string>
|
||||
<!--The placeholder to be inserted into the string 'hotspot_manual_wifi': People can connect by %s-->
|
||||
<string name="hotspot_scanning_a_qr_code">balayant un code QR</string>
|
||||
<!--Wi-Fi setup-->
|
||||
<!--The %s placeholder will be replaced with the translation of 'hotspot_scanning_a_qr_code'-->
|
||||
<!--Download link-->
|
||||
|
||||
@@ -609,7 +609,6 @@
|
||||
<string name="dev_report_memory">Memoria</string>
|
||||
<string name="dev_report_storage">Spazio</string>
|
||||
<string name="dev_report_connectivity">Connettività</string>
|
||||
<string name="dev_report_network_usage">Utilizzo della rete</string>
|
||||
<string name="dev_report_build_config">Configurazione build</string>
|
||||
<string name="dev_report_logcat">Registro app</string>
|
||||
<string name="dev_report_device_features">Caratteristiche dispositivo</string>
|
||||
|
||||
@@ -613,6 +613,8 @@
|
||||
<string name="transports_help_text">Briarは、インターネット、Wi-Fi、Bluetoothを介して連絡先に接続することができます。\n\nすべてのインターネット接続は、プライバシー保護のためにTorネットワークを経由します。\n\n複数の方法で連絡が取れる場合、Briarはそれらを並行して使用します。</string>
|
||||
<!--Share app offline-->
|
||||
<string name="hotspot_title">このアプリをオフラインで共有</string>
|
||||
<string name="hotspot_intro">あなたの電話機のWi-Fiを使用して、インターネット接続なしで、近くの誰かとこのアプリを共有します。
|
||||
\n\nあなたの電話機はWi-Fiホットスポットになります。近くの人はホットスポットへ接続し、あなたの電話機からBriarアプリをダウンロードできます。</string>
|
||||
<string name="hotspot_button_start_sharing">ホットスポットを開始</string>
|
||||
<string name="hotspot_button_stop_sharing">ホットスポットを停止</string>
|
||||
<string name="hotspot_progress_text_start">ホットスポットを設定する…</string>
|
||||
@@ -650,8 +652,7 @@
|
||||
<string name="website_troubleshooting_2_new">ダウンロードしたアプリをインストールするには、ブラウザに不明なアプリのインストールを許可する必要がある場合があります。アプリをインストールした後は、ブラウザの不明なアプリのインストール許可を解除することをお勧めします。</string>
|
||||
<string name="hotspot_help_wifi_title">W-Fi接続の問題:</string>
|
||||
<string name="hotspot_help_wifi_1">双方の電話機でWi-Fiを無効にして、再び有効にするのを試してください。</string>
|
||||
<string name="hotspot_help_wifi_2">もし電話機が「Wi-Fiにはインターネットがない」と不満を訴えてきたら、「とにかく接続していたい」と伝えてください。</string>
|
||||
<string name="hotspot_help_wifi_3">Wi-Fiホットスポットが実行中の電話機を再起動して、Briarの起動と共有を再び試してください。</string>
|
||||
<string name="hotspot_help_wifi_2">もし携帯電話が「Wi-Fiにはインターネットがない」と不満を訴えてきたら、「とにかく接続していたい」と伝えてください。</string>
|
||||
<string name="hotspot_help_site_title">ローカルのウェブサイト訪問の問題:</string>
|
||||
<string name="hotspot_help_site_1">表示されている通りにアドレスを入力したかどうかを再確認してください。小さなミスで失敗することがあります。</string>
|
||||
<string name="hotspot_help_site_2">サイトにアクセスする際に、電話機が正しいWi-Fi(上記を参照)に接続されていることを確認してください。</string>
|
||||
|
||||
@@ -635,7 +635,6 @@
|
||||
<string name="dev_report_memory">Atmintis</string>
|
||||
<string name="dev_report_storage">Saugykla</string>
|
||||
<string name="dev_report_connectivity">Jungiamumas</string>
|
||||
<string name="dev_report_network_usage">Tinklo naudojimas</string>
|
||||
<string name="dev_report_build_config">Darinio konfigūracija</string>
|
||||
<string name="dev_report_logcat">Programėlės žurnalas</string>
|
||||
<string name="dev_report_device_features">Įrenginio ypatybės</string>
|
||||
|
||||
@@ -664,8 +664,8 @@ De asemenea, contactul dvs. poate modifica această setare pentru amândoi.</str
|
||||
<string name="transports_help_text">Briar se poate conecta la contactele dumneavoastră prin Internet, Wi-Fi sau Bluetooth.\n\nToate conexiunile la internet trec prin rețeaua Tor din motive de confidențialitate.\n\nDacă un contact poate fi accesat prin metode multiple, Briar le va folosi în mod paralel.</string>
|
||||
<!--Share app offline-->
|
||||
<string name="hotspot_title">Partajează această aplicație fără Internet</string>
|
||||
<string name="hotspot_intro">Împărtășiți acest app cu o persoană din apropiere fără conexiune la internet, utilizând Wi-Fi-ul telefonului dumneavoastră.
|
||||
\n\nTelefonul dumneavoastră va porni un hotspot Wi-Fi. Persoanele din apropiere se pot conecta la hotspot și pot descărca aplicația Briar de pe telefonul vostru.</string>
|
||||
<string name="hotspot_intro">Partajați această aplicație cu cineva din apropiere fără Internet folosind conexiunea Wi-Fi a dispozitivului.
|
||||
\n\nDispozitivul dumneavoastră va porni un hotspot Wi-Fi. Persoanele din apropiere se pot conecta la hotspot și pot descărca aplicația Briar de pe dispozitivul dumneavoastră.</string>
|
||||
<string name="hotspot_button_start_sharing">Pornește hotspot</string>
|
||||
<string name="hotspot_button_stop_sharing">Oprește hotspot</string>
|
||||
<string name="hotspot_progress_text_start">Configurare hotspot...</string>
|
||||
|
||||
@@ -720,7 +720,6 @@
|
||||
<string name="hotspot_help_wifi_title">Проблемы с подключением к Wi-Fi:</string>
|
||||
<string name="hotspot_help_wifi_1">Попробуйте отключить и снова включить Wi-Fi на обоих телефонах и повторить попытку.</string>
|
||||
<string name="hotspot_help_wifi_2">Если ваш телефон сообщит, что в сети Wi-Fi нет доступа к интернету, подтвердите, что вы все равно хотите подключиться к этой сети.</string>
|
||||
<string name="hotspot_help_wifi_3">Перезагрузите телефон, на котором работает точка доступа Wi-Fi, затем запустите Briar и повторите попытку обмена.</string>
|
||||
<string name="hotspot_help_site_title">Проблемы с доступом к локальному веб-сайту:</string>
|
||||
<string name="hotspot_help_site_1">Дважды убедитесь, что вы ввели адрес точно так, как показано. Небольшая ошибка может привести к сбою.</string>
|
||||
<string name="hotspot_help_site_2">Убедитесь, что ваш телефон все еще подключен к правильной сети Wi-Fi (см. выше), прежде чем попытаться зайти на этот сайт.</string>
|
||||
|
||||
@@ -610,7 +610,6 @@ Këtë rregullim mund ta ndryshojë edhe kontakti juaj, për të dy ju.</string>
|
||||
<string name="dev_report_memory">Kujtesë</string>
|
||||
<string name="dev_report_storage">Depozitim</string>
|
||||
<string name="dev_report_connectivity">Aftësi lidhjeje</string>
|
||||
<string name="dev_report_network_usage">Përdorim rrjeti</string>
|
||||
<string name="dev_report_build_config">Formësim montimi</string>
|
||||
<string name="dev_report_logcat">Regjistër aplikacioni</string>
|
||||
<string name="dev_report_device_features">Veçori Pajisjeje</string>
|
||||
|
||||
@@ -609,7 +609,6 @@
|
||||
<string name="dev_report_memory">Bellek</string>
|
||||
<string name="dev_report_storage">Depo</string>
|
||||
<string name="dev_report_connectivity">Bağlanabilirlik</string>
|
||||
<string name="dev_report_network_usage">Ağ Kullanımı</string>
|
||||
<string name="dev_report_build_config">Derleme yapılandırması</string>
|
||||
<string name="dev_report_logcat">Uygulama günlüğü</string>
|
||||
<string name="dev_report_device_features">Aygıt Seçenekleri</string>
|
||||
@@ -693,7 +692,6 @@
|
||||
<string name="hotspot_help_wifi_title">Kablosuz ağa bağlanma sorunları:</string>
|
||||
<string name="hotspot_help_wifi_1">Her iki telefonda da kablosuz ağı devre dışı bırakıp tekrar etkinleştirin ve yeniden deneyin.</string>
|
||||
<string name="hotspot_help_wifi_2">Eğer telefonunuz kablosuz ağda İnternet olmadığını söylüyorsa yine de bağlı kalmasını söyleyin.</string>
|
||||
<string name="hotspot_help_wifi_3">Wi-Fi bağlantı noktasını sağlayan telefonu yeniden başlatın, daha sonra Briar\'ı başlatın ve paylaşmayı yeniden deneyin.</string>
|
||||
<string name="hotspot_help_site_title">Yerel web sitesini ziyaret etme sorunları:</string>
|
||||
<string name="hotspot_help_site_1">Adresi tam gösterildiği şekilde girdiğinizden emin olun. Çok küçük bir hata sorun olabilir.</string>
|
||||
<string name="hotspot_help_site_2">Siteye erişmeye çalışırken telefonunuzun doğru kablosuz ağa bağlı olduğundan emin olun (Bkz. önceki kısım).</string>
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
<string name="setup_xiaomi_text">要在后台运行,需将 Briar 锁定在最近的应用列表中。</string>
|
||||
<string name="setup_xiaomi_button">保护 Briar</string>
|
||||
<string name="setup_xiaomi_help">如果未将 Briar 锁定到最近的应用列表,它将无法在后台运行。</string>
|
||||
<string name="setup_xiaomi_dialog_body_old">1. 打开最近的应用列表(也称为应用切换器)\n\n2. 向下滑动 Briar 的图像,显示挂锁图标\n\n3.如果挂锁没有被锁上,轻按锁定它</string>
|
||||
<string name="setup_xiaomi_dialog_body_new">1. 打开最近的应用列表(也称为应用切换器)\n\n2. 按住 Briar 的图像,直到挂锁按钮出现\n\n3. 如果挂锁没有被锁上,轻按锁定它</string>
|
||||
<string name="setup_xiaomi_dialog_body_old">1. 打开最近的应用列表(也称为应用切换器)\n\n2. 向下滑动Briar的图像,显示挂锁图标\n\n3.如果挂锁没有被锁上,轻敲以锁定它</string>
|
||||
<string name="setup_xiaomi_dialog_body_new">1. 打开最近的应用列表(也称为应用切换器)\n\n2. 按住Briar的图像,直到挂锁按钮出现\n\n3. 如果挂锁没有被锁上,轻敲以锁定它</string>
|
||||
<string name="warning_dozed">%s 无法在后台运行</string>
|
||||
<!--Login-->
|
||||
<string name="enter_password">密码</string>
|
||||
@@ -170,7 +170,7 @@
|
||||
<item quantity="other">%d分钟</item>
|
||||
</plurals>
|
||||
<plurals name="duration_hours">
|
||||
<item quantity="other">%d小时</item>
|
||||
<item quantity="other">%d小时消</item>
|
||||
</plurals>
|
||||
<plurals name="duration_days">
|
||||
<item quantity="other">%d天</item>
|
||||
@@ -596,7 +596,6 @@
|
||||
<string name="dev_report_memory">内存</string>
|
||||
<string name="dev_report_storage">存储</string>
|
||||
<string name="dev_report_connectivity">连通性</string>
|
||||
<string name="dev_report_network_usage">网络使用</string>
|
||||
<string name="dev_report_build_config">编译配置</string>
|
||||
<string name="dev_report_logcat">应用程序日志</string>
|
||||
<string name="dev_report_device_features">设备特性</string>
|
||||
@@ -639,8 +638,8 @@
|
||||
<string name="transports_help_text">Briar 可以通过互联网、Wi-Fi 或蓝牙来连接到您的联系人。\n\n为了保护隐私,本应用会通过 Tor 网络进行所有的互联网连接。\n\n如果一个联系人可以通过多种方法联系到,Briar 会并行地使用它们。</string>
|
||||
<!--Share app offline-->
|
||||
<string name="hotspot_title">离线分享此应用</string>
|
||||
<string name="hotspot_intro">使用手机的 Wi-Fi 与附近没有网络的人分享这款应用。
|
||||
\n\n你的手机将启动一个 Wi-Fi 热点。附近的人可以连接至这个热点,从你的手机下载 Briar 应用。</string>
|
||||
<string name="hotspot_intro">使用手机的Wi-Fi与附近没有网络的人分享这款应用。
|
||||
\n\n你的手机会启动一个 Wi-Fi 热点。附近的人可以连接热点,从你的手机下载 Briar 应用。</string>
|
||||
<string name="hotspot_button_start_sharing">启动热点</string>
|
||||
<string name="hotspot_button_stop_sharing">停止热点</string>
|
||||
<string name="hotspot_progress_text_start">设置热点中…</string>
|
||||
|
||||
@@ -649,7 +649,6 @@
|
||||
<string name="dev_report_memory">Memory</string>
|
||||
<string name="dev_report_storage">Storage</string>
|
||||
<string name="dev_report_connectivity">Connectivity</string>
|
||||
<string name="dev_report_network_usage">Network usage</string>
|
||||
<string name="dev_report_build_config">Build configuration</string>
|
||||
<string name="dev_report_logcat">App log</string>
|
||||
<string name="dev_report_device_features">Device Features</string>
|
||||
|
||||
@@ -58,6 +58,14 @@
|
||||
android:targetPackage="@string/app_package" />
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="pref_key_export_log"
|
||||
android:title="Export current log to SD card" />
|
||||
|
||||
<Preference
|
||||
android:key="pref_key_export_old_log"
|
||||
android:title="Export previous log to SD card" />
|
||||
|
||||
<Preference
|
||||
android:key="pref_key_explode"
|
||||
android:title="Crash" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.briar.android.logging;
|
||||
|
||||
import org.briarproject.bramble.logging.BriefLogFormatter;
|
||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
@@ -15,8 +16,8 @@ import static java.util.logging.Level.FINE;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.SEVERE;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.bramble.util.LogUtils.formatLog;
|
||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
import static org.briarproject.briar.android.logging.BriefLogFormatter.formatLog;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class LogEncryptionDecryptionTest extends BrambleMockTestCase {
|
||||
|
||||
@@ -42,7 +42,7 @@ class LoggingTestModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLogcatFile() {
|
||||
public File getTemporaryLogFile() {
|
||||
return logFile;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,15 +38,6 @@ public interface ConversationManager {
|
||||
Collection<ConversationMessageHeader> getMessageHeaders(ContactId c)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the headers of all messages in the given private conversation.
|
||||
* <p>
|
||||
* Only {@link MessagingManager} returns only headers.
|
||||
* The others also return the message text.
|
||||
*/
|
||||
Collection<ConversationMessageHeader> getMessageHeaders(Transaction txn, ContactId c)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the unified group count for all private conversation messages.
|
||||
*/
|
||||
@@ -81,9 +72,6 @@ public interface ConversationManager {
|
||||
void setReadFlag(GroupId g, MessageId m, boolean read)
|
||||
throws DbException;
|
||||
|
||||
void setReadFlag(Transaction txn, GroupId g, MessageId m, boolean read)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns a timestamp for an outgoing message, which is later than the
|
||||
* timestamp of any message in the conversation with the given contact.
|
||||
|
||||
@@ -74,13 +74,6 @@ public interface MessagingManager extends ConversationClient {
|
||||
@Nullable
|
||||
String getMessageText(MessageId m) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the text of the private message with the given ID, or null if
|
||||
* the private message has no text.
|
||||
*/
|
||||
@Nullable
|
||||
String getMessageText(Transaction txn, MessageId m) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the private message format supported by the given contact.
|
||||
*/
|
||||
|
||||
@@ -58,16 +58,15 @@ class ConversationManagerImpl implements ConversationManager {
|
||||
@Override
|
||||
public Collection<ConversationMessageHeader> getMessageHeaders(ContactId c)
|
||||
throws DbException {
|
||||
return db.transactionWithResult(true,
|
||||
txn -> getMessageHeaders(txn, c));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ConversationMessageHeader> getMessageHeaders(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
List<ConversationMessageHeader> messages = new ArrayList<>();
|
||||
for (ConversationClient client : clients) {
|
||||
messages.addAll(client.getMessageHeaders(txn, c));
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
for (ConversationClient client : clients) {
|
||||
messages.addAll(client.getMessageHeaders(txn, c));
|
||||
}
|
||||
db.commitTransaction(txn);
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
@@ -126,14 +125,10 @@ class ConversationManagerImpl implements ConversationManager {
|
||||
@Override
|
||||
public void setReadFlag(GroupId g, MessageId m, boolean read)
|
||||
throws DbException {
|
||||
db.transaction(false, txn -> setReadFlag(txn, g, m, read));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadFlag(Transaction txn, GroupId g, MessageId m, boolean read)
|
||||
throws DbException {
|
||||
boolean wasRead = messageTracker.setReadFlag(txn, g, m, read);
|
||||
if (read && !wasRead) db.startCleanupTimer(txn, m);
|
||||
db.transaction(false, txn -> {
|
||||
boolean wasRead = messageTracker.setReadFlag(txn, g, m, read);
|
||||
if (read && !wasRead) db.startCleanupTimer(txn, m);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -466,14 +466,8 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
|
||||
@Override
|
||||
public String getMessageText(MessageId m) throws DbException {
|
||||
return db.transactionWithNullableResult(true, txn ->
|
||||
getMessageText(txn, m));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Transaction txn, MessageId m) throws DbException {
|
||||
try {
|
||||
BdfList body = clientHelper.getMessageAsList(txn, m);
|
||||
BdfList body = clientHelper.getMessageAsList(m);
|
||||
if (body.size() == 1) return body.getString(0); // Legacy format
|
||||
else return body.getOptionalString(1);
|
||||
} catch (FormatException e) {
|
||||
|
||||
@@ -58,7 +58,6 @@ void jarFactory(Jar jarTask, jarArchitecture) {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
{
|
||||
it.duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||
String[] architectures = ["linux-aarch64", "linux-armhf", "linux-x86_64"]
|
||||
for (String arch : architectures) {
|
||||
if (arch != jarArchitecture) {
|
||||
@@ -112,10 +111,6 @@ task x86LinuxJar(type: Jar) {
|
||||
jarFactory(it, 'linux-x86_64')
|
||||
}
|
||||
|
||||
task linuxJars {
|
||||
dependsOn(aarch64LinuxJar, armhfLinuxJar, x86LinuxJar)
|
||||
}
|
||||
|
||||
// At the moment for non-Android projects we need to explicitly mark the code generated by kapt
|
||||
// as 'generated source code' for correct highlighting and resolve in IDE.
|
||||
idea {
|
||||
|
||||
@@ -107,5 +107,6 @@ internal class HeadlessModule(private val appDir: File) {
|
||||
override fun shouldEnableImageAttachments() = false
|
||||
override fun shouldEnableProfilePictures() = false
|
||||
override fun shouldEnableDisappearingMessages() = false
|
||||
override fun shouldEnablePersistentLogs() = false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user