global: get rid of nonnull gradle hack
Hacking things up via gradle is not right, and package-info.java poses problems with two modules, so instead we just apply it manually to every class. Remember to add this to new classes! Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
c00a0b12e4
commit
8e8643122e
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,4 +15,3 @@ build/
|
||||
*.iml
|
||||
*.jks
|
||||
keystore.properties
|
||||
package-info.java
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2017-2019 WireGuard LLC. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
task generateNonNullJavaFiles(dependsOn: "assembleDebug", type: Copy) {
|
||||
group = "Copying"
|
||||
description = "Generate package-info.java classes"
|
||||
|
||||
def basePackage = "com" + File.separatorChar + "wireguard"
|
||||
def mainSrcPhrase = "src" + File.separatorChar + "main" + File.separatorChar +
|
||||
"java" + File.separatorChar
|
||||
def mainTestSrcPhrase = "src" + File.separatorChar + "test" + File.separatorChar +
|
||||
"java" + File.separatorChar
|
||||
def mainAndroidTestSrcPhrase = "src" + File.separatorChar + "androidTest" + File.separatorChar +
|
||||
"java" + File.separatorChar
|
||||
|
||||
def sourceDir = file( "${projectDir}" + File.separatorChar + "src" + File.separatorChar +
|
||||
"main" + File.separatorChar + "java" + File.separatorChar +
|
||||
basePackage )
|
||||
def testSourceDir = file( "${projectDir}" + File.separatorChar + "src" + File.separatorChar +
|
||||
"test" + File.separatorChar + "java" + File.separatorChar +
|
||||
basePackage)
|
||||
def androidTestSourceDir = file( "${projectDir}" + File.separatorChar + "src" + File
|
||||
.separatorChar +
|
||||
"androidTest" + File.separatorChar + "java" + File.separatorChar +
|
||||
basePackage )
|
||||
|
||||
generateInfoFiles(sourceDir, mainSrcPhrase)
|
||||
sourceDir.eachDirRecurse { dir ->
|
||||
generateInfoFiles(dir, mainSrcPhrase)
|
||||
}
|
||||
if (file(testSourceDir).exists()) {
|
||||
generateInfoFiles(testSourceDir, mainTestSrcPhrase)
|
||||
testSourceDir.eachDirRecurse { dir ->
|
||||
generateInfoFiles(dir, mainTestSrcPhrase)
|
||||
}
|
||||
}
|
||||
if (file(androidTestSourceDir).exists()) {
|
||||
generateInfoFiles(androidTestSourceDir, mainAndroidTestSrcPhrase)
|
||||
androidTestSourceDir.eachDirRecurse { dir ->
|
||||
generateInfoFiles(dir, mainAndroidTestSrcPhrase)
|
||||
}
|
||||
}
|
||||
println "[SUCCESS] NonNull generator: package-info.java files checked"
|
||||
}
|
||||
|
||||
private void generateInfoFiles(File dir, String mainSrcPhrase) {
|
||||
def infoFileContentHeader = getFileContentHeader()
|
||||
def infoFileContentFooter = getFileContentFooter()
|
||||
def infoFilePath = dir.getAbsolutePath() + File.separatorChar + "package-info.java"
|
||||
|
||||
//file(infoFilePath).delete(); //do not use in production code
|
||||
if (!file(infoFilePath).exists()) {
|
||||
def infoFileContentPackage = getFileContentPackage(dir.getAbsolutePath(), mainSrcPhrase)
|
||||
new File(infoFilePath).write(infoFileContentHeader +
|
||||
infoFileContentPackage + infoFileContentFooter)
|
||||
println "[dir] " + infoFilePath + " created"
|
||||
}
|
||||
}
|
||||
|
||||
static def getFileContentPackage(String path, String mainSrcPhrase) {
|
||||
def mainSrcPhraseIndex = path.indexOf(mainSrcPhrase)
|
||||
def output = path.substring(mainSrcPhraseIndex)
|
||||
|
||||
// Win hotfix
|
||||
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||
output = output.replace("\\", "/")
|
||||
mainSrcPhrase = mainSrcPhrase.replace("\\", "/")
|
||||
}
|
||||
|
||||
return "package " + output.replaceAll(mainSrcPhrase, "").replaceAll(
|
||||
"/", ".") + ";\n"
|
||||
}
|
||||
|
||||
static def getFileContentHeader() {
|
||||
return "/**\n" +
|
||||
" * Make all method parameters @NonNull by default.\n" +
|
||||
" */\n" +
|
||||
"@NonNullForAll\n"
|
||||
}
|
||||
|
||||
static def getFileContentFooter() {
|
||||
return "\n" +
|
||||
"import com.wireguard.util.NonNullForAll;\n"
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply from: rootProject.file('nonnull.gradle')
|
||||
|
||||
android {
|
||||
buildToolsVersion '29.0.3'
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.backend;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import com.wireguard.config.Config;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -16,6 +18,7 @@ import androidx.annotation.Nullable;
|
||||
* Interface for implementations of the WireGuard secure network tunnel.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface Backend {
|
||||
/**
|
||||
* Enumerate names of currently-running tunnels.
|
||||
|
@ -5,6 +5,9 @@
|
||||
|
||||
package com.wireguard.android.backend;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
@NonNullForAll
|
||||
public final class BackendException extends Exception {
|
||||
public enum Reason {
|
||||
UNKNOWN_KERNEL_MODULE_NAME,
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.backend;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
@ -30,6 +32,7 @@ import java.util.concurrent.TimeoutException;
|
||||
|
||||
import java9.util.concurrent.CompletableFuture;
|
||||
|
||||
@NonNullForAll
|
||||
public final class GoBackend implements Backend {
|
||||
private static final String TAG = "WireGuard/" + GoBackend.class.getSimpleName();
|
||||
private static CompletableFuture<VpnService> vpnService = new CompletableFuture<>();
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.backend;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.util.Pair;
|
||||
|
||||
@ -13,6 +15,7 @@ import com.wireguard.crypto.Key;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@NonNullForAll
|
||||
public class Statistics {
|
||||
private long lastTouched = SystemClock.elapsedRealtime();
|
||||
private final Map<Key, Pair<Long, Long>> peerBytes = new HashMap<>();
|
||||
|
@ -5,12 +5,15 @@
|
||||
|
||||
package com.wireguard.android.backend;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Represents a WireGuard tunnel.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface Tunnel {
|
||||
enum State {
|
||||
DOWN,
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.backend;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.content.Context;
|
||||
@ -39,6 +41,7 @@ import java9.util.stream.Stream;
|
||||
* WireGuard backend that uses {@code wg-quick} to implement tunnel configuration.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public final class WgQuickBackend implements Backend {
|
||||
private static final String TAG = "WireGuard/" + WgQuickBackend.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.system.OsConstants;
|
||||
import android.util.Base64;
|
||||
@ -36,6 +38,7 @@ import java.util.Map;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@NonNullForAll
|
||||
public class ModuleLoader {
|
||||
private static final String MODULE_PUBLIC_KEY_BASE64 = "RWRmHuT9PSqtwfsLtEx+QS06BJtLgFYteL9WCNjH7yuyu5Y1DieSN7If";
|
||||
private static final String MODULE_LIST_URL = "https://download.wireguard.com/android-module/modules.txt.sig";
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
@ -24,6 +26,7 @@ import java.util.UUID;
|
||||
* Helper class for running commands as root.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class RootShell {
|
||||
private static final String SU = "su";
|
||||
private static final String TAG = "WireGuard/" + RootShell.class.getSimpleName();
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
@ -19,6 +21,7 @@ import java.util.HashSet;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@NonNullForAll
|
||||
public final class SharedLibraryLoader {
|
||||
private static final String TAG = "WireGuard/" + SharedLibraryLoader.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.system.OsConstants;
|
||||
@ -22,6 +24,7 @@ import java.util.List;
|
||||
* Helper to install WireGuard tools to the system partition.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public final class ToolsInstaller {
|
||||
public static final int ERROR = 0x0;
|
||||
public static final int MAGISK = 0x4;
|
||||
|
@ -5,12 +5,15 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import java9.util.Optional;
|
||||
|
||||
@NonNullForAll
|
||||
public final class Attribute {
|
||||
private static final Pattern LINE_PATTERN = Pattern.compile("(\\w+)\\s*=\\s*([^\\s#][^#]*)");
|
||||
private static final Pattern LIST_SEPARATOR = Pattern.compile("\\s*,\\s*");
|
||||
|
@ -5,10 +5,13 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.wireguard.crypto.KeyFormatException;
|
||||
|
||||
@NonNullForAll
|
||||
public class BadConfigException extends Exception {
|
||||
private final Location location;
|
||||
private final Reason reason;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.wireguard.config.BadConfigException.Location;
|
||||
@ -29,6 +31,7 @@ import java.util.Set;
|
||||
* <p>
|
||||
* Instances of this class are immutable.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public final class Config {
|
||||
private final Interface interfaze;
|
||||
private final List<Peer> peers;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
@ -17,6 +19,7 @@ import androidx.annotation.Nullable;
|
||||
/**
|
||||
* Utility methods for creating instances of {@link InetAddress}.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public final class InetAddresses {
|
||||
@Nullable private static final Method PARSER_METHOD;
|
||||
private static final Pattern WONT_TOUCH_RESOLVER = Pattern.compile("^(((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?)|((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))$");
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.threeten.bp.Duration;
|
||||
@ -25,6 +27,7 @@ import java9.util.Optional;
|
||||
* <p>
|
||||
* Instances of this class are externally immutable.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public final class InetEndpoint {
|
||||
private static final Pattern BARE_IPV6 = Pattern.compile("^[^\\[\\]]*:[^\\[\\]]*");
|
||||
private static final Pattern FORBIDDEN_CHARACTERS = Pattern.compile("[/?#]");
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
|
||||
@ -13,6 +15,7 @@ import java.net.InetAddress;
|
||||
* <p>
|
||||
* Instances of this class are immutable.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public final class InetNetwork {
|
||||
private final InetAddress address;
|
||||
private final int mask;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.wireguard.config.BadConfigException.Location;
|
||||
@ -35,6 +37,7 @@ import java9.util.stream.StreamSupport;
|
||||
* <p>
|
||||
* Instances of this class are immutable.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public final class Interface {
|
||||
private static final int MAX_UDP_PORT = 65535;
|
||||
private static final int MIN_UDP_PORT = 0;
|
||||
|
@ -5,10 +5,13 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@NonNullForAll
|
||||
public class ParseException extends Exception {
|
||||
private final Class<?> parsingClass;
|
||||
private final CharSequence text;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.config;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.wireguard.config.BadConfigException.Location;
|
||||
@ -28,6 +30,7 @@ import java9.util.Optional;
|
||||
* <p>
|
||||
* Instances of this class are immutable.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public final class Peer {
|
||||
private final Set<InetNetwork> allowedIps;
|
||||
private final Optional<InetEndpoint> endpoint;
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
package com.wireguard.crypto;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -25,6 +27,7 @@ import java.util.Arrays;
|
||||
* References: http://cr.yp.to/ecdh.html, RFC 7748
|
||||
*/
|
||||
@SuppressWarnings({"MagicNumber", "NonConstantFieldWithUpperCaseName", "SuspiciousNameCombination"})
|
||||
@NonNullForAll
|
||||
public final class Curve25519 {
|
||||
// Numbers modulo 2^255 - 19 are broken up into ten 26-bit words.
|
||||
private static final int NUM_LIMBS_255BIT = 10;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.crypto;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import com.wireguard.crypto.KeyFormatException.Type;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
@ -18,6 +20,7 @@ import java.util.Arrays;
|
||||
* Instances of this class are immutable.
|
||||
*/
|
||||
@SuppressWarnings("MagicNumber")
|
||||
@NonNullForAll
|
||||
public final class Key {
|
||||
private final byte[] key;
|
||||
|
||||
|
@ -5,11 +5,14 @@
|
||||
|
||||
package com.wireguard.crypto;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
/**
|
||||
* An exception thrown when attempting to parse an invalid key (too short, too long, or byte
|
||||
* data inappropriate for the format). The format being parsed can be accessed with the
|
||||
* {@link #getFormat} method.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public final class KeyFormatException extends Exception {
|
||||
private final Key.Format format;
|
||||
private final Type type;
|
||||
|
@ -5,11 +5,14 @@
|
||||
|
||||
package com.wireguard.crypto;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
/**
|
||||
* Represents a Curve25519 key pair as used by WireGuard.
|
||||
* <p>
|
||||
* Instances of this class are immutable.
|
||||
*/
|
||||
@NonNullForAll
|
||||
public class KeyPair {
|
||||
private final Key privateKey;
|
||||
private final Key publicKey;
|
||||
|
@ -22,5 +22,6 @@ import javax.annotation.meta.TypeQualifierDefault;
|
||||
@Nonnull
|
||||
@TypeQualifierDefault({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
public @interface NonNullForAll {
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply from: rootProject.file('nonnull.gradle')
|
||||
|
||||
// Create a variable called keystorePropertiesFile, and initialize it to your
|
||||
// keystore.properties file, in the rootProject folder.
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@ -35,6 +37,7 @@ import java.util.Locale;
|
||||
|
||||
import java9.util.concurrent.CompletableFuture;
|
||||
|
||||
@NonNullForAll
|
||||
public class Application extends android.app.Application implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = "WireGuard/" + Application.class.getSimpleName();
|
||||
public static final String USER_AGENT = String.format(Locale.ENGLISH, "WireGuard/%s (Android %d; %s; %s; %s %s; %s)", BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT, Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "unknown ABI", Build.BOARD, Build.MANUFACTURER, Build.MODEL, Build.FINGERPRINT);
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -14,6 +16,7 @@ import com.wireguard.android.backend.WgQuickBackend;
|
||||
import com.wireguard.android.model.TunnelManager;
|
||||
import com.wireguard.android.util.ExceptionLoggers;
|
||||
|
||||
@NonNullForAll
|
||||
public class BootShutdownReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "WireGuard/" + BootShutdownReceiver.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Intent;
|
||||
import androidx.databinding.Observable;
|
||||
import androidx.databinding.Observable.OnPropertyChangedCallback;
|
||||
@ -34,6 +36,7 @@ import java.util.Objects;
|
||||
*/
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@NonNullForAll
|
||||
public class QuickTileService extends TileService {
|
||||
private static final String TAG = "WireGuard/" + QuickTileService.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.activity;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.CallbackRegistry;
|
||||
import androidx.databinding.CallbackRegistry.NotifierCallback;
|
||||
import android.os.Bundle;
|
||||
@ -19,6 +21,7 @@ import java.util.Objects;
|
||||
* Base class for activities that need to remember the currently-selected tunnel.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public abstract class BaseActivity extends ThemeChangeAwareActivity {
|
||||
private static final String KEY_SELECTED_TUNNEL = "selected_tunnel";
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.activity;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@ -31,6 +33,7 @@ import java.util.List;
|
||||
* editing the configuration and interface state of WireGuard tunnels.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class MainActivity extends BaseActivity
|
||||
implements FragmentManager.OnBackStackChangedListener {
|
||||
@Nullable private ActionBar actionBar;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.activity;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@ -30,6 +32,7 @@ import java.util.List;
|
||||
* Interface for changing application-global persistent settings.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class SettingsActivity extends ThemeChangeAwareActivity {
|
||||
private final SparseArray<PermissionRequestCallback> permissionRequestCallbacks = new SparseArray<>();
|
||||
private int permissionRequestCounter;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.activity;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
@ -18,6 +20,7 @@ import com.wireguard.android.Application;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@NonNullForAll
|
||||
public abstract class ThemeChangeAwareActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = "WireGuard/" + ThemeChangeAwareActivity.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.activity;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@ -15,6 +17,7 @@ import com.wireguard.android.model.ObservableTunnel;
|
||||
* Standalone activity for creating tunnels.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class TunnelCreatorActivity extends BaseActivity {
|
||||
@Override
|
||||
@SuppressWarnings("UnnecessaryFullyQualifiedName")
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.activity;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -24,6 +26,7 @@ import com.wireguard.android.backend.Tunnel.State;
|
||||
import com.wireguard.android.util.ErrorMessages;
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@NonNullForAll
|
||||
public class TunnelToggleActivity extends AppCompatActivity {
|
||||
private static final String TAG = "WireGuard/" + TunnelToggleActivity.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.configStore;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import com.wireguard.config.Config;
|
||||
|
||||
import java.util.Set;
|
||||
@ -13,6 +15,7 @@ import java.util.Set;
|
||||
* Interface for persistent storage providers for WireGuard configurations.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface ConfigStore {
|
||||
/**
|
||||
* Create a persistent tunnel, which must have a unique name within the persistent storage
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.configStore;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
@ -27,6 +29,7 @@ import java9.util.stream.Stream;
|
||||
* Configuration store that uses a {@code wg-quick}-style file for each configured tunnel.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public final class FileConfigStore implements ConfigStore {
|
||||
private static final String TAG = "WireGuard/" + FileConfigStore.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.databinding;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.BindingAdapter;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableList;
|
||||
@ -35,6 +37,7 @@ import java9.util.Optional;
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@NonNullForAll
|
||||
public final class BindingAdapters {
|
||||
private BindingAdapters() {
|
||||
// Prevent instantiation.
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.databinding;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableList;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
@ -22,6 +24,7 @@ import java.util.Objects;
|
||||
* Helper class for binding an ObservableList to the children of a ViewGroup.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
class ItemChangeListener<T> {
|
||||
private final OnListChangedCallback<T> callback = new OnListChangedCallback<>(this);
|
||||
private final ViewGroup container;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.databinding;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableList;
|
||||
@ -25,6 +27,7 @@ import java.lang.ref.WeakReference;
|
||||
* A generic {@code RecyclerView.Adapter} backed by a {@code ObservableKeyedList}.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class ObservableKeyedRecyclerViewAdapter<K, E extends Keyed<? extends K>> extends Adapter<ObservableKeyedRecyclerViewAdapter.ViewHolder> {
|
||||
|
||||
private final OnListChangedCallback<E> callback = new OnListChangedCallback<>(this);
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.fragment;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
@ -34,6 +36,7 @@ import java9.util.Comparators;
|
||||
import java9.util.stream.Collectors;
|
||||
import java9.util.stream.StreamSupport;
|
||||
|
||||
@NonNullForAll
|
||||
public class AppListDialogFragment extends DialogFragment {
|
||||
|
||||
private static final String KEY_EXCLUDED_APPS = "excludedApps";
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.fragment;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
@ -32,6 +34,7 @@ import com.wireguard.android.util.ErrorMessages;
|
||||
* attached to a {@code BaseActivity}.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public abstract class BaseFragment extends Fragment implements OnSelectedTunnelChangedListener {
|
||||
private static final int REQUEST_CODE_VPN_PERMISSION = 23491;
|
||||
private static final String TAG = "WireGuard/" + BaseFragment.class.getSimpleName();
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.fragment;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
@ -26,6 +28,7 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
@NonNullForAll
|
||||
public class ConfigNamingDialogFragment extends DialogFragment {
|
||||
private static final String KEY_CONFIG_TEXT = "config_text";
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.fragment;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
@ -30,6 +32,7 @@ import java.util.TimerTask;
|
||||
* Fragment that shows details about a specific tunnel.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class TunnelDetailFragment extends BaseFragment {
|
||||
@Nullable private TunnelDetailFragmentBinding binding;
|
||||
@Nullable private Timer timer;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.fragment;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import androidx.databinding.ObservableList;
|
||||
@ -41,6 +43,7 @@ import java.util.Objects;
|
||||
* Fragment for editing a WireGuard configuration.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class TunnelEditorFragment extends BaseFragment implements AppExclusionListener {
|
||||
private static final String KEY_LOCAL_CONFIG = "local_config";
|
||||
private static final String KEY_ORIGINAL_NAME = "original_name";
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.fragment;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
@ -64,6 +66,7 @@ import java9.util.stream.StreamSupport;
|
||||
* Fragment containing a list of known WireGuard tunnels. It allows creating and deleting tunnels.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class TunnelListFragment extends BaseFragment {
|
||||
public static final int REQUEST_IMPORT = 1;
|
||||
private static final int REQUEST_TARGET_FRAGMENT = 2;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.model;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.BaseObservable;
|
||||
import androidx.databinding.Bindable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -12,6 +14,7 @@ import android.graphics.drawable.Drawable;
|
||||
import com.wireguard.android.BR;
|
||||
import com.wireguard.util.Keyed;
|
||||
|
||||
@NonNullForAll
|
||||
public class ApplicationData extends BaseObservable implements Keyed<String> {
|
||||
private final Drawable icon;
|
||||
private final String name;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.model;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.BaseObservable;
|
||||
import androidx.databinding.Bindable;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -23,6 +25,7 @@ import java9.util.concurrent.CompletionStage;
|
||||
* Encapsulates the volatile and nonvolatile state of a WireGuard tunnel.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class ObservableTunnel extends BaseObservable implements Keyed<String>, Tunnel {
|
||||
private final TunnelManager manager;
|
||||
@Nullable private Config config;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.model;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -39,6 +41,7 @@ import java9.util.stream.StreamSupport;
|
||||
* Maintains and mediates changes to the set of available WireGuard tunnels,
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public final class TunnelManager extends BaseObservable {
|
||||
private static final Comparator<String> COMPARATOR = Comparators.<String>thenComparing(
|
||||
String.CASE_INSENSITIVE_ORDER, Comparators.naturalOrder());
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.preference;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
@ -29,6 +31,7 @@ import java.io.InputStreamReader;
|
||||
* Preference implementing a button that asynchronously exports logs.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class LogExporterPreference extends Preference {
|
||||
private static final String TAG = "WireGuard/" + LogExporterPreference.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.preference;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.system.OsConstants;
|
||||
@ -18,6 +20,7 @@ import com.wireguard.android.util.ErrorMessages;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@NonNullForAll
|
||||
public class ModuleDownloaderPreference extends Preference {
|
||||
private State state = State.INITIAL;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.preference;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
@ -19,6 +21,7 @@ import com.wireguard.android.util.ToolsInstaller;
|
||||
* result as the preference summary.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class ToolsInstallerPreference extends Preference {
|
||||
private State state = State.INITIAL;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.preference;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -22,6 +24,7 @@ import com.wireguard.android.backend.WgQuickBackend;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@NonNullForAll
|
||||
public class VersionPreference extends Preference {
|
||||
@Nullable private String versionSummary;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.preference;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
@ -35,6 +37,7 @@ import java9.util.concurrent.CompletableFuture;
|
||||
* Preference implementing a button that asynchronously exports config zips.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class ZipExporterPreference extends Preference {
|
||||
private static final String TAG = "WireGuard/" + ZipExporterPreference.class.getSimpleName();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
@ -16,6 +18,7 @@ import java9.util.concurrent.CompletionStage;
|
||||
* Helper class for running asynchronous tasks and ensuring they are completed on the main thread.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class AsyncWorker {
|
||||
private final Executor executor;
|
||||
private final Handler handler;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
@ -16,6 +18,7 @@ import android.widget.TextView;
|
||||
* Standalone utilities for interacting with the system clipboard.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public final class ClipboardUtils {
|
||||
private ClipboardUtils() {
|
||||
// Prevent instantiation
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
@ -22,6 +24,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@NonNullForAll
|
||||
public class DownloadsFileSaver {
|
||||
|
||||
public static class DownloadsFile {
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.RemoteException;
|
||||
|
||||
@ -29,6 +31,7 @@ import java.util.Map;
|
||||
|
||||
import java9.util.Maps;
|
||||
|
||||
@NonNullForAll
|
||||
public final class ErrorMessages {
|
||||
private static final Map<BadConfigException.Reason, Integer> BCE_REASON_MAP = new EnumMap<>(Maps.of(
|
||||
BadConfigException.Reason.INVALID_KEY, R.string.bad_config_reason_invalid_key,
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
|
@ -4,12 +4,15 @@
|
||||
*/
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
||||
import com.wireguard.android.activity.SettingsActivity;
|
||||
|
||||
@NonNullForAll
|
||||
public final class FragmentUtils {
|
||||
private FragmentUtils() {
|
||||
// Prevent instantiation
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@ -21,6 +23,7 @@ import java.util.Objects;
|
||||
* operations, require O(n) time.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class ObservableKeyedArrayList<K, E extends Keyed<? extends K>>
|
||||
extends ObservableArrayList<E> implements ObservableKeyedList<K, E> {
|
||||
@Override
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.ObservableList;
|
||||
|
||||
import com.wireguard.util.Keyed;
|
||||
@ -14,6 +16,7 @@ import com.wireguard.util.KeyedList;
|
||||
* A list that is both keyed and observable.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface ObservableKeyedList<K, E extends Keyed<? extends K>>
|
||||
extends KeyedList<K, E>, ObservableList<E> {
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.wireguard.util.Keyed;
|
||||
@ -26,6 +28,7 @@ import java.util.Spliterator;
|
||||
* key still require O(n) time.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class ObservableSortedKeyedArrayList<K, E extends Keyed<? extends K>>
|
||||
extends ObservableKeyedArrayList<K, E> implements ObservableSortedKeyedList<K, E> {
|
||||
@Nullable private final Comparator<? super K> comparator;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import com.wireguard.util.Keyed;
|
||||
import com.wireguard.util.SortedKeyedList;
|
||||
|
||||
@ -12,6 +14,7 @@ import com.wireguard.util.SortedKeyedList;
|
||||
* A list that is both sorted/keyed and observable.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface ObservableSortedKeyedList<K, E extends Keyed<? extends K>>
|
||||
extends ObservableKeyedList<K, E>, SortedKeyedList<K, E> {
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.viewmodel;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.databinding.ObservableList;
|
||||
import android.os.Parcel;
|
||||
@ -17,6 +19,7 @@ import com.wireguard.config.Peer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@NonNullForAll
|
||||
public class ConfigProxy implements Parcelable {
|
||||
public static final Parcelable.Creator<ConfigProxy> CREATOR = new ConfigProxyCreator();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.viewmodel;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.BaseObservable;
|
||||
import androidx.databinding.Bindable;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
@ -26,6 +28,7 @@ import java.util.List;
|
||||
import java9.util.stream.Collectors;
|
||||
import java9.util.stream.StreamSupport;
|
||||
|
||||
@NonNullForAll
|
||||
public class InterfaceProxy extends BaseObservable implements Parcelable {
|
||||
public static final Parcelable.Creator<InterfaceProxy> CREATOR = new InterfaceProxyCreator();
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.viewmodel;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.databinding.BaseObservable;
|
||||
import androidx.databinding.Bindable;
|
||||
import androidx.databinding.Observable;
|
||||
@ -32,6 +34,7 @@ import java9.util.Sets;
|
||||
import java9.util.stream.Collectors;
|
||||
import java9.util.stream.Stream;
|
||||
|
||||
@NonNullForAll
|
||||
public class PeerProxy extends BaseObservable implements Parcelable {
|
||||
public static final Parcelable.Creator<PeerProxy> CREATOR = new PeerProxyCreator();
|
||||
private static final Set<String> IPV4_PUBLIC_NETWORKS = new LinkedHashSet<>(Lists.of(
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.widget;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@ -16,6 +18,7 @@ import com.wireguard.crypto.Key;
|
||||
* InputFilter for entering WireGuard private/public keys encoded with base64.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class KeyInputFilter implements InputFilter {
|
||||
private static boolean isAllowed(final char c) {
|
||||
return Character.isLetterOrDigit(c) || c == '+' || c == '/';
|
||||
|
@ -5,12 +5,15 @@
|
||||
|
||||
package com.wireguard.android.widget;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.wireguard.android.R;
|
||||
|
||||
@NonNullForAll
|
||||
public class MultiselectableRelativeLayout extends RelativeLayout {
|
||||
private static final int[] STATE_MULTISELECTED = {R.attr.state_multiselected};
|
||||
private boolean multiselected;
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.android.widget;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@ -16,6 +18,7 @@ import com.wireguard.android.backend.Tunnel;
|
||||
* InputFilter for entering WireGuard configuration names (Linux interface names).
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public class NameInputFilter implements InputFilter {
|
||||
private static boolean isAllowed(final char c) {
|
||||
return Character.isLetterOrDigit(c) || "_=+.-".indexOf(c) >= 0;
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
package com.wireguard.android.widget;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.res.ColorStateList;
|
||||
@ -29,6 +31,7 @@ import androidx.annotation.RequiresApi;
|
||||
import android.util.FloatProperty;
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@NonNullForAll
|
||||
public class SlashDrawable extends Drawable {
|
||||
|
||||
private static final float CENTER_X = 10.65f;
|
||||
|
@ -6,12 +6,15 @@
|
||||
|
||||
package com.wireguard.android.widget;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Switch;
|
||||
|
||||
@NonNullForAll
|
||||
public class ToggleSwitch extends Switch {
|
||||
private boolean isRestoringState;
|
||||
@Nullable private OnBeforeCheckedChangeListener listener;
|
||||
|
@ -5,10 +5,13 @@
|
||||
|
||||
package com.wireguard.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
/**
|
||||
* Interface for objects that have a identifying key of the given type.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface Keyed<K> {
|
||||
K getKey();
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -15,6 +17,7 @@ import java.util.List;
|
||||
* {@code null} elements.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface KeyedList<K, E extends Keyed<? extends K>> extends List<E> {
|
||||
boolean containsAllKeys(Collection<K> keys);
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package com.wireguard.util;
|
||||
|
||||
import com.wireguard.util.NonNullForAll;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -16,6 +18,7 @@ import java.util.Set;
|
||||
* applied to their keys.
|
||||
*/
|
||||
|
||||
@NonNullForAll
|
||||
public interface SortedKeyedList<K, E extends Keyed<? extends K>> extends KeyedList<K, E> {
|
||||
Comparator<? super K> comparator();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user