Compare commits

..

7 Commits

Author SHA1 Message Date
akwizgran
196df05df9 Bump version numbers for 1.0.7 release. 2018-06-07 12:12:39 +01:00
akwizgran
44f07c8d76 Merge branch '1293-tor-cookie-file' into 'master'
Watch for creation rather than updating of Tor cookie file

See merge request akwizgran/briar!825
2018-06-07 11:07:30 +00:00
akwizgran
d4a9c41cf5 Watch for creation rather than updating of Tor cookie file.
Tor writes to a temporary file and then renames it over the old
file, if any, so CLOSE_WRITE never occurs. The old code was
working in most cases because it received IGNORED when the old
file was unlinked and didn't check the event type.
2018-06-07 09:19:52 +01:00
akwizgran
624e03a2c9 Merge branch 'default-build-timestamp' into 'master'
Add default build timestamp in case Git command fails

See merge request akwizgran/briar!826
2018-06-07 08:15:08 +00:00
akwizgran
a24e0482c9 Add default build timestamp in case Git command fails. 2018-06-06 14:34:40 +01:00
Torsten Grote
8fc8333451 Merge branch '1294-log-stack-traces' into 'master'
Log exception stacktraces

Closes #1294

See merge request akwizgran/briar!824
2018-06-03 02:28:17 +00:00
akwizgran
c2154c81f4 Log exception stacktraces. 2018-06-01 16:43:10 +01:00
4 changed files with 49 additions and 31 deletions

View File

@@ -8,8 +8,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 26 targetSdkVersion 26
versionCode 10006 versionCode 10007
versionName "1.0.6" versionName "1.0.7"
consumerProguardFiles 'proguard-rules.txt' consumerProguardFiles 'proguard-rules.txt'
} }

View File

@@ -185,18 +185,15 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
if (used.getAndSet(true)) throw new IllegalStateException(); if (used.getAndSet(true)) throw new IllegalStateException();
// Install or update the assets if necessary // Install or update the assets if necessary
if (!assetsAreUpToDate()) installAssets(); if (!assetsAreUpToDate()) installAssets();
LOG.info("Starting Tor"); // Watch for the auth cookie file being created
// Watch for the auth cookie file being updated if (cookieFile.getParentFile().mkdirs())
try { LOG.info("Created directory for cookie file");
cookieFile.getParentFile().mkdirs(); if (cookieFile.delete()) LOG.info("Deleted old cookie file");
cookieFile.createNewFile();
} catch (IOException e) {
throw new PluginException(e);
}
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
FileObserver obs = new WriteObserver(cookieFile, latch); FileObserver obs = new CreateObserver(cookieFile, latch);
obs.startWatching(); obs.startWatching();
// Start a new Tor process // Start a new Tor process
LOG.info("Starting Tor");
String torPath = torFile.getAbsolutePath(); String torPath = torFile.getAbsolutePath();
String configPath = configFile.getAbsolutePath(); String configPath = configFile.getAbsolutePath();
String pid = String.valueOf(android.os.Process.myPid()); String pid = String.valueOf(android.os.Process.myPid());
@@ -364,7 +361,7 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
File[] children = f.listFiles(); File[] children = f.listFiles();
if (children != null) for (File child : children) listFiles(child); if (children != null) for (File child : children) listFiles(child);
} else { } else {
LOG.info(f.getAbsolutePath()); LOG.info(f.getAbsolutePath() + " " + f.length());
} }
} }
@@ -641,22 +638,6 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
LOG.info("Descriptor uploaded"); LOG.info("Descriptor uploaded");
} }
private static class WriteObserver extends FileObserver {
private final CountDownLatch latch;
private WriteObserver(File file, CountDownLatch latch) {
super(file.getAbsolutePath(), CLOSE_WRITE);
this.latch = latch;
}
@Override
public void onEvent(int event, @Nullable String path) {
stopWatching();
latch.countDown();
}
}
@Override @Override
public void eventOccurred(Event e) { public void eventOccurred(Event e) {
if (e instanceof SettingsUpdatedEvent) { if (e instanceof SettingsUpdatedEvent) {
@@ -717,6 +698,26 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
if (oldConnectivityCheck != null) oldConnectivityCheck.cancel(false); if (oldConnectivityCheck != null) oldConnectivityCheck.cancel(false);
} }
private static class CreateObserver extends FileObserver {
private final File file;
private final CountDownLatch latch;
private CreateObserver(File file, CountDownLatch latch) {
super(file.getParentFile().getAbsolutePath(), CREATE | MOVED_TO);
this.file = file;
this.latch = latch;
}
@Override
public void onEvent(int event, @Nullable String path) {
if (file.exists()) {
stopWatching();
latch.countDown();
}
}
}
private class NetworkStateReceiver extends BroadcastReceiver { private class NetworkStateReceiver extends BroadcastReceiver {
@Override @Override

View File

@@ -238,15 +238,16 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 26 targetSdkVersion 26
versionCode 10006 versionCode 10007
versionName "1.0.6" versionName "1.0.7"
applicationId "org.briarproject.briar.android" applicationId "org.briarproject.briar.android"
resValue "string", "app_package", "org.briarproject.briar.android" resValue "string", "app_package", "org.briarproject.briar.android"
resValue "string", "app_name", "Briar" resValue "string", "app_name", "Briar"
buildConfigField "String", "GitHash", buildConfigField "String", "GitHash",
"\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\"" "\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
def now = (long) (System.currentTimeMillis() / 1000)
buildConfigField "Long", "BuildTimestamp", buildConfigField "Long", "BuildTimestamp",
"${getStdout(['git', 'log', '-n', '1', '--format=%ct'], 0)}000L" "${getStdout(['git', 'log', '-n', '1', '--format=%ct'], now)}000L"
} }
buildTypes { buildTypes {

View File

@@ -42,6 +42,22 @@ public class BriefLogFormatter extends Formatter {
tag = tag.substring(tag.lastIndexOf('.') + 1); tag = tag.substring(tag.lastIndexOf('.') + 1);
sb.append(tag).append(": "); sb.append(tag).append(": ");
sb.append(record.getMessage()); sb.append(record.getMessage());
Throwable t = record.getThrown();
if (t != null) {
sb.append('\n');
appendThrowable(sb, t);
}
return sb.toString(); return sb.toString();
} }
private void appendThrowable(StringBuilder sb, Throwable t) {
sb.append(t);
for (StackTraceElement e : t.getStackTrace())
sb.append("\n at ").append(e);
Throwable cause = t.getCause();
if (cause != null) {
sb.append("\n Caused by: ");
appendThrowable(sb, cause);
}
}
} }