summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/main/java/com/wireguard/android/QuickTileService.java4
-rw-r--r--app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java3
-rw-r--r--app/src/main/java/com/wireguard/android/backend/Backend.java2
-rw-r--r--app/src/main/java/com/wireguard/android/configStore/ConfigStore.java2
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java3
-rw-r--r--app/src/main/java/com/wireguard/android/model/TunnelManager.java7
-rw-r--r--app/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java4
-rw-r--r--app/src/main/java/com/wireguard/android/util/ClipboardUtils.java2
-rw-r--r--app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java2
-rw-r--r--app/src/main/java/com/wireguard/android/util/RootShell.java15
-rw-r--r--app/src/main/java/com/wireguard/android/widget/KeyInputFilter.java10
-rw-r--r--app/src/main/java/com/wireguard/android/widget/NameInputFilter.java10
-rw-r--r--app/src/main/java/com/wireguard/android/widget/ToggleSwitch.java1
-rw-r--r--app/src/main/java/com/wireguard/crypto/KeyEncoding.java7
-rw-r--r--app/src/main/java/com/wireguard/crypto/Keypair.java1
-rw-r--r--app/src/main/res/drawable/ic_action_add.xml9
-rw-r--r--app/src/main/res/layout/main_activity.xml4
18 files changed, 47 insertions, 40 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 41fe05c0..94360927 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -39,7 +39,6 @@ dependencies {
implementation 'com.google.dagger:dagger:2.14.1'
implementation 'net.sourceforge.streamsupport:android-retrofuture:1.6.0'
implementation 'net.sourceforge.streamsupport:android-retrostreams:1.6.0'
- implementation fileTree(dir: 'libs', include: ['*.jar'])
}
repositories {
diff --git a/app/src/main/java/com/wireguard/android/QuickTileService.java b/app/src/main/java/com/wireguard/android/QuickTileService.java
index 7cbcf559..20883a41 100644
--- a/app/src/main/java/com/wireguard/android/QuickTileService.java
+++ b/app/src/main/java/com/wireguard/android/QuickTileService.java
@@ -28,6 +28,7 @@ import java.util.Objects;
@TargetApi(Build.VERSION_CODES.N)
public class QuickTileService extends TileService {
private static final String TAG = "WireGuard/" + QuickTileService.class.getSimpleName();
+
private final OnStateChangedCallback onStateChangedCallback = new OnStateChangedCallback();
private final OnTunnelChangedCallback onTunnelChangedCallback = new OnTunnelChangedCallback();
private Tunnel tunnel;
@@ -62,7 +63,8 @@ public class QuickTileService extends TileService {
tunnelManager.removeOnPropertyChangedCallback(onTunnelChangedCallback);
}
- private void onToggleFinished(final State state, final Throwable throwable) {
+ private void onToggleFinished(@SuppressWarnings("unused") final State state,
+ final Throwable throwable) {
if (throwable == null)
return;
final String error = ExceptionLoggers.unwrap(throwable).getMessage();
diff --git a/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java b/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
index 986054df..c5e024b1 100644
--- a/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
+++ b/app/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
@@ -6,11 +6,12 @@ import com.wireguard.android.fragment.TunnelEditorFragment;
import com.wireguard.android.model.Tunnel;
/**
- * Created by samuel on 12/29/17.
+ * Standalone activity for creating tunnels.
*/
public class TunnelCreatorActivity extends BaseActivity {
@Override
+ @SuppressWarnings("UnnecessaryFullyQualifiedName")
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
diff --git a/app/src/main/java/com/wireguard/android/backend/Backend.java b/app/src/main/java/com/wireguard/android/backend/Backend.java
index fb71a3d3..3f0e19ca 100644
--- a/app/src/main/java/com/wireguard/android/backend/Backend.java
+++ b/app/src/main/java/com/wireguard/android/backend/Backend.java
@@ -28,7 +28,7 @@ public interface Backend {
*
* @return The set of running tunnel names.
*/
- Set<String> enumerate() throws Exception;
+ Set<String> enumerate();
/**
* Get the actual state of a tunnel.
diff --git a/app/src/main/java/com/wireguard/android/configStore/ConfigStore.java b/app/src/main/java/com/wireguard/android/configStore/ConfigStore.java
index c1f5b4e3..1d6d29ea 100644
--- a/app/src/main/java/com/wireguard/android/configStore/ConfigStore.java
+++ b/app/src/main/java/com/wireguard/android/configStore/ConfigStore.java
@@ -31,7 +31,7 @@ public interface ConfigStore {
*
* @return The set of present tunnel names.
*/
- Set<String> enumerate() throws Exception;
+ Set<String> enumerate();
/**
* Load the configuration for the tunnel given by {@code name}.
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
index f72a6aea..d3114c89 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
@@ -59,7 +59,8 @@ public class TunnelEditorFragment extends BaseFragment {
binding.setConfig(localConfig);
}
- private void onConfigSaved(final Config config, final Throwable throwable) {
+ private void onConfigSaved(@SuppressWarnings("unused") final Config config,
+ final Throwable throwable) {
final String message;
if (throwable == null) {
message = getString(R.string.config_save_success, localTunnel.getName());
diff --git a/app/src/main/java/com/wireguard/android/model/TunnelManager.java b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
index 9aa96103..1916ab74 100644
--- a/app/src/main/java/com/wireguard/android/model/TunnelManager.java
+++ b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
@@ -15,8 +15,10 @@ import com.wireguard.android.util.AsyncWorker;
import com.wireguard.android.util.ExceptionLoggers;
import com.wireguard.android.util.ObservableKeyedList;
import com.wireguard.android.util.ObservableSortedKeyedArrayList;
+import com.wireguard.android.util.ObservableSortedKeyedList;
import com.wireguard.config.Config;
+import java.util.Collection;
import java.util.Comparator;
import java.util.Set;
@@ -39,13 +41,12 @@ public final class TunnelManager extends BaseObservable {
private static final String KEY_LAST_USED_TUNNEL = "last_used_tunnel";
private static final String KEY_RESTORE_ON_BOOT = "restore_on_boot";
private static final String KEY_RUNNING_TUNNELS = "enabled_configs";
- private static final String TAG = "WireGuard/" + TunnelManager.class.getSimpleName();
private final AsyncWorker asyncWorker;
private final Backend backend;
private final ConfigStore configStore;
private final SharedPreferences preferences;
- private final ObservableKeyedList<String, Tunnel> tunnels =
+ private final ObservableSortedKeyedList<String, Tunnel> tunnels =
new ObservableSortedKeyedArrayList<>(COMPARATOR);
private Tunnel lastUsedTunnel;
@@ -139,7 +140,7 @@ public final class TunnelManager extends BaseObservable {
.whenComplete(ExceptionLoggers.E);
}
- private void onTunnelsLoaded(final Set<String> present, final Set<String> running) {
+ private void onTunnelsLoaded(final Iterable<String> present, final Collection<String> running) {
for (final String name : present)
addToList(name, null, running.contains(name) ? State.UP : State.DOWN);
final String lastUsedName = preferences.getString(KEY_LAST_USED_TUNNEL, null);
diff --git a/app/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java b/app/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java
index c9dfa7b7..15a8ab6a 100644
--- a/app/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java
+++ b/app/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java
@@ -2,6 +2,7 @@ package com.wireguard.android.preference;
import android.content.Context;
import android.preference.Preference;
+import android.support.annotation.NonNull;
import android.system.OsConstants;
import android.util.AttributeSet;
@@ -21,6 +22,7 @@ public class ToolsInstallerPreference extends Preference {
private final ToolsInstaller toolsInstaller;
private State state = State.INITIAL;
+ @SuppressWarnings({"SameParameterValue", "WeakerAccess"})
public ToolsInstallerPreference(final Context context, final AttributeSet attrs) {
super(context, attrs);
final ApplicationComponent applicationComponent = Application.getComponent();
@@ -64,7 +66,7 @@ public class ToolsInstallerPreference extends Preference {
.thenAccept(this::setState);
}
- private void setState(final State state) {
+ private void setState(@NonNull final State state) {
if (this.state == state)
return;
this.state = state;
diff --git a/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java b/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java
index 20aeffff..ea0001e4 100644
--- a/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java
+++ b/app/src/main/java/com/wireguard/android/util/ClipboardUtils.java
@@ -9,7 +9,7 @@ import android.widget.TextView;
import com.commonsware.cwac.crossport.design.widget.Snackbar;
/**
- * Created by samuel on 12/30/17.
+ * Standalone utilities for interacting with the system clipboard.
*/
public final class ClipboardUtils {
diff --git a/app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java b/app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
index d4dff389..7ffffc4c 100644
--- a/app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
+++ b/app/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
@@ -23,6 +23,7 @@ public class ObservableSortedKeyedArrayList<K, E extends Keyed<? extends K>>
private final Comparator<? super K> comparator;
private final transient KeyList<K, E> keyList = new KeyList<>(this);
+ @SuppressWarnings("WeakerAccess")
public ObservableSortedKeyedArrayList() {
comparator = null;
}
@@ -178,6 +179,7 @@ public class ObservableSortedKeyedArrayList<K, E extends Keyed<? extends K>>
}
@Override
+ @SuppressWarnings("EmptyMethod")
public Spliterator<K> spliterator() {
return super.spliterator();
}
diff --git a/app/src/main/java/com/wireguard/android/util/RootShell.java b/app/src/main/java/com/wireguard/android/util/RootShell.java
index 2c498131..6dda2d8f 100644
--- a/app/src/main/java/com/wireguard/android/util/RootShell.java
+++ b/app/src/main/java/com/wireguard/android/util/RootShell.java
@@ -9,14 +9,14 @@ import com.wireguard.android.Application.ApplicationContext;
import com.wireguard.android.Application.ApplicationScope;
import com.wireguard.android.R;
-import java.io.BufferedWriter;
import java.io.BufferedReader;
-import java.io.OutputStreamWriter;
-import java.io.InputStreamReader;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
-import java.util.List;
+import java.util.Collection;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -38,11 +38,10 @@ public class RootShell {
private final String exceptionMessage;
private final String preamble;
-
+ private Process process;
+ private BufferedReader stderr;
private BufferedWriter stdin;
private BufferedReader stdout;
- private BufferedReader stderr;
- private Process process;
@Inject
public RootShell(@ApplicationContext final Context context) {
@@ -141,7 +140,7 @@ public class RootShell {
* @param command Command to run as root.
* @return The exit value of the last command run, or -1 if there was an internal error.
*/
- public int run(final List<String> output, final String command)
+ public int run(final Collection<String> output, final String command)
throws ErrnoException, IOException, NoRootException {
ensureRoot();
diff --git a/app/src/main/java/com/wireguard/android/widget/KeyInputFilter.java b/app/src/main/java/com/wireguard/android/widget/KeyInputFilter.java
index 45652ed5..5fe48ce9 100644
--- a/app/src/main/java/com/wireguard/android/widget/KeyInputFilter.java
+++ b/app/src/main/java/com/wireguard/android/widget/KeyInputFilter.java
@@ -11,7 +11,11 @@ import com.wireguard.crypto.KeyEncoding;
*/
public class KeyInputFilter implements InputFilter {
- public static KeyInputFilter newInstance() {
+ private static boolean isAllowed(final char c) {
+ return Character.isLetterOrDigit(c) || c == '+' || c == '/';
+ }
+
+ public static InputFilter newInstance() {
return new KeyInputFilter();
}
@@ -40,8 +44,4 @@ public class KeyInputFilter implements InputFilter {
}
return replacement;
}
-
- private boolean isAllowed(final char c) {
- return Character.isLetterOrDigit(c) || c == '+' || c == '/';
- }
}
diff --git a/app/src/main/java/com/wireguard/android/widget/NameInputFilter.java b/app/src/main/java/com/wireguard/android/widget/NameInputFilter.java
index 8c91e682..458f4fb9 100644
--- a/app/src/main/java/com/wireguard/android/widget/NameInputFilter.java
+++ b/app/src/main/java/com/wireguard/android/widget/NameInputFilter.java
@@ -11,7 +11,11 @@ import com.wireguard.android.model.Tunnel;
*/
public class NameInputFilter implements InputFilter {
- public static NameInputFilter newInstance() {
+ private static boolean isAllowed(final char c) {
+ return Character.isLetterOrDigit(c) || "_=+.-".indexOf(c) >= 0;
+ }
+
+ public static InputFilter newInstance() {
return new NameInputFilter();
}
@@ -39,8 +43,4 @@ public class NameInputFilter implements InputFilter {
}
return replacement;
}
-
- private boolean isAllowed(final char c) {
- return Character.isLetterOrDigit(c) || "_=+.-".indexOf(c) >= 0;
- }
}
diff --git a/app/src/main/java/com/wireguard/android/widget/ToggleSwitch.java b/app/src/main/java/com/wireguard/android/widget/ToggleSwitch.java
index a8e4e263..83bf5274 100644
--- a/app/src/main/java/com/wireguard/android/widget/ToggleSwitch.java
+++ b/app/src/main/java/com/wireguard/android/widget/ToggleSwitch.java
@@ -25,6 +25,7 @@ public class ToggleSwitch extends Switch {
private boolean isRestoringState;
private OnBeforeCheckedChangeListener listener;
+ @SuppressWarnings({"SameParameterValue", "WeakerAccess"})
public ToggleSwitch(final Context context, final AttributeSet attrs) {
super(context, attrs);
}
diff --git a/app/src/main/java/com/wireguard/crypto/KeyEncoding.java b/app/src/main/java/com/wireguard/crypto/KeyEncoding.java
index f83fd0b1..99ff0ee9 100644
--- a/app/src/main/java/com/wireguard/crypto/KeyEncoding.java
+++ b/app/src/main/java/com/wireguard/crypto/KeyEncoding.java
@@ -6,12 +6,17 @@ package com.wireguard.crypto;
* This is a specialized constant-time base64 implementation that resists side-channel attacks.
*/
-public class KeyEncoding {
+@SuppressWarnings("MagicNumber")
+public final class KeyEncoding {
public static final int KEY_LENGTH = 32;
public static final int KEY_LENGTH_BASE64 = 44;
private static final String KEY_LENGTH_BASE64_EXCEPTION_MESSAGE =
"WireGuard base64 keys must be 44 characters encoding 32 bytes";
+ private KeyEncoding() {
+ // Prevent instantiation.
+ }
+
private static int decodeBase64(final char[] src, final int src_offset) {
int val = 0;
for (int i = 0; i < 4; ++i) {
diff --git a/app/src/main/java/com/wireguard/crypto/Keypair.java b/app/src/main/java/com/wireguard/crypto/Keypair.java
index 25327182..0fc08508 100644
--- a/app/src/main/java/com/wireguard/crypto/Keypair.java
+++ b/app/src/main/java/com/wireguard/crypto/Keypair.java
@@ -6,6 +6,7 @@ import java.security.SecureRandom;
* Represents a Curve25519 keypair as used by WireGuard.
*/
+@SuppressWarnings("MagicNumber")
public class Keypair {
private final byte[] privateKey;
private final byte[] publicKey;
diff --git a/app/src/main/res/drawable/ic_action_add.xml b/app/src/main/res/drawable/ic_action_add.xml
deleted file mode 100644
index d4e66388..00000000
--- a/app/src/main/res/drawable/ic_action_add.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportHeight="24"
- android:viewportWidth="24">
- <path
- android:fillColor="#FFFFFF"
- android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
-</vector>
diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml
index d67e64bc..0f21e2e8 100644
--- a/app/src/main/res/layout/main_activity.xml
+++ b/app/src/main/res/layout/main_activity.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/master_fragment"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ tools:ignore="MergeRootFrame" />