global: Fix or suppress most lints/warnings
Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
parent
dd69a2e778
commit
4f02817ef0
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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}.
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 == '/';
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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>
|
@ -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" />
|
||||
|
Loading…
Reference in New Issue
Block a user