summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-09 09:37:49 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-09 09:37:49 -0600
commitdaacc06a0dcf4e8de371b9e177627ecd82e0ba17 (patch)
treedc476c95ee42bc9e019c1cccc93f295f6e3179af /app/src
parenta1d955ef6264498c6c27569660152dbda7f60392 (diff)
global: Clean up error logging
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/wireguard/android/BootShutdownReceiver.java4
-rw-r--r--app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java3
-rw-r--r--app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java7
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelController.java7
-rw-r--r--app/src/main/java/com/wireguard/android/util/ToolsInstaller.java2
5 files changed, 13 insertions, 10 deletions
diff --git a/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java b/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java
index 153e615d..001c3b55 100644
--- a/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java
+++ b/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java
@@ -18,10 +18,10 @@ public class BootShutdownReceiver extends BroadcastReceiver {
return;
final TunnelManager tunnelManager = Application.getComponent().getTunnelManager();
if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
- Log.d(TAG, "Broadcast receiver restoring state (boot)");
+ Log.i(TAG, "Broadcast receiver restoring state (boot)");
tunnelManager.restoreState().whenComplete(ExceptionLoggers.D);
} else if (Intent.ACTION_SHUTDOWN.equals(action)) {
- Log.d(TAG, "Broadcast receiver saving state (shutdown)");
+ Log.i(TAG, "Broadcast receiver saving state (shutdown)");
tunnelManager.saveState();
}
}
diff --git a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
index 0c6ce595..dec07d7a 100644
--- a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
+++ b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
@@ -64,7 +64,6 @@ public final class WgQuickBackend implements Backend {
@Override
public State getState(final Tunnel tunnel) {
- Log.v(TAG, "Requested state for tunnel " + tunnel.getName());
return enumerate().contains(tunnel.getName()) ? State.UP : State.DOWN;
}
@@ -75,12 +74,12 @@ public final class WgQuickBackend implements Backend {
@Override
public State setState(final Tunnel tunnel, State state) throws Exception {
- Log.v(TAG, "Requested state change to " + state + " for tunnel " + tunnel.getName());
final State originalState = getState(tunnel);
if (state == State.TOGGLE)
state = originalState == State.UP ? State.DOWN : State.UP;
if (state == originalState)
return originalState;
+ Log.d(TAG, "Changing tunnel " + tunnel.getName() + " to state " + state);
toolsInstaller.ensureToolsAvailable();
final int result;
if (state == State.UP) {
diff --git a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
index dd2b434f..2b2e405b 100644
--- a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
+++ b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
@@ -8,6 +8,7 @@ import com.wireguard.config.Config;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -31,6 +32,7 @@ public final class FileConfigStore implements ConfigStore {
@Override
public Config create(final String name, final Config config) throws IOException {
+ Log.d(TAG, "Creating configuration for tunnel " + name);
final File file = fileFor(name);
if (!file.createNewFile()) {
final String message = "Configuration file " + file.getName() + " already exists";
@@ -44,6 +46,7 @@ public final class FileConfigStore implements ConfigStore {
@Override
public void delete(final String name) throws IOException {
+ Log.d(TAG, "Deleting configuration for tunnel " + name);
final File file = fileFor(name);
if (!file.delete())
throw new IOException("Cannot delete configuration file " + file.getName());
@@ -70,11 +73,11 @@ public final class FileConfigStore implements ConfigStore {
@Override
public Config save(final String name, final Config config) throws IOException {
- Log.d(TAG, "Requested save config for tunnel " + name);
+ Log.d(TAG, "Saving configuration for tunnel " + name);
final File file = fileFor(name);
if (!file.isFile()) {
final String message = "Configuration file " + file.getName() + " not found";
- throw new IllegalStateException(message);
+ throw new FileNotFoundException(message);
}
try (FileOutputStream stream = new FileOutputStream(file, false)) {
stream.write(config.toString().getBytes(StandardCharsets.UTF_8));
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelController.java b/app/src/main/java/com/wireguard/android/fragment/TunnelController.java
index fd265d20..1d1dc6b9 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelController.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelController.java
@@ -41,7 +41,7 @@ public final class TunnelController {
else
tunnel = null;
if (tunnel == null) {
- Log.e(TAG, "setChecked() from a null tunnel", new IllegalStateException());
+ Log.e(TAG, "setChecked() from a null tunnel", new IllegalStateException("No tunnel"));
return;
}
tunnel.setState(State.of(checked)).whenComplete((state, throwable) -> {
@@ -51,15 +51,16 @@ public final class TunnelController {
if (throwable instanceof ErrnoException
&& ((ErrnoException) throwable).errno == OsConstants.ENODEV) {
final String message = context.getString(R.string.not_supported_message);
+ final String title = context.getString(R.string.not_supported_title);
final AlertDialog dialog = new AlertDialog.Builder(context)
.setMessage(Html.fromHtml(message))
.setPositiveButton(R.string.ok, null)
- .setTitle(R.string.not_supported_title)
+ .setTitle(title)
.show();
// Make links work.
((TextView) dialog.findViewById(android.R.id.message))
.setMovementMethod(LinkMovementMethod.getInstance());
- Log.e(TAG, "WireGuard not supported");
+ Log.e(TAG, title, throwable);
} else {
final String error = ExceptionLoggers.unwrap(throwable).getMessage();
final int messageResId = checked ? R.string.error_up : R.string.error_down;
diff --git a/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java b/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java
index 6a3d4e05..46dc43a4 100644
--- a/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java
+++ b/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java
@@ -93,7 +93,7 @@ public final class ToolsInstaller {
synchronized (this) {
if (areToolsAvailable == null) {
if (areInstalled() == OsConstants.EALREADY) {
- Log.d(TAG, "Tools are installed to /system");
+ Log.d(TAG, "Tools are installed to the system partition");
areToolsAvailable = true;
} else if (areSymlinked() == OsConstants.EALREADY) {
Log.d(TAG, "Tools were already symlinked into our private binary dir");