summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--nonnull.gradle86
-rw-r--r--tunnel/build.gradle1
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/Backend.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/BackendException.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/Statistics.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/util/RootShell.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/Attribute.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/BadConfigException.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/Config.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/InetAddresses.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/InetEndpoint.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/InetNetwork.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/Interface.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/ParseException.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/config/Peer.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/crypto/Curve25519.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/crypto/Key.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/crypto/KeyFormatException.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/crypto/KeyPair.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/util/NonNullForAll.java1
-rw-r--r--ui/build.gradle1
-rw-r--r--ui/src/main/java/com/wireguard/android/Application.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/QuickTileService.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/BaseActivity.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/MainActivity.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/model/ApplicationData.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/model/TunnelManager.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/preference/VersionPreference.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/AsyncWorker.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ErrorMessages.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java2
-rw-r--r--ui/src/main/java/com/wireguard/android/util/FragmentUtils.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java3
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java3
-rw-r--r--ui/src/main/java/com/wireguard/util/Keyed.java3
-rw-r--r--ui/src/main/java/com/wireguard/util/KeyedList.java3
-rw-r--r--ui/src/main/java/com/wireguard/util/SortedKeyedList.java3
77 files changed, 216 insertions, 89 deletions
diff --git a/.gitignore b/.gitignore
index a9e2ddae..0c99626a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,3 @@ build/
*.iml
*.jks
keystore.properties
-package-info.java
diff --git a/nonnull.gradle b/nonnull.gradle
deleted file mode 100644
index 7fc9b25d..00000000
--- a/nonnull.gradle
+++ /dev/null
@@ -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"
-}
diff --git a/tunnel/build.gradle b/tunnel/build.gradle
index 10494823..deff4b15 100644
--- a/tunnel/build.gradle
+++ b/tunnel/build.gradle
@@ -1,5 +1,4 @@
apply plugin: 'com.android.library'
-apply from: rootProject.file('nonnull.gradle')
android {
buildToolsVersion '29.0.3'
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Backend.java b/tunnel/src/main/java/com/wireguard/android/backend/Backend.java
index ed3a5ebd..853802d2 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/Backend.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/Backend.java
@@ -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.
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java b/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java
index e1e8eaa9..0f60701b 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java
@@ -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,
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
index 6ad5afa4..bf434cf5 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
@@ -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<>();
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java
index 2ca87d23..f878a1f0 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java
@@ -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<>();
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java b/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java
index af2f59f7..fccda84f 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java
@@ -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,
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
index 53fe3d42..c4434e4d 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
@@ -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();
diff --git a/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java b/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java
index f09d9a87..40645a43 100644
--- a/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java
+++ b/tunnel/src/main/java/com/wireguard/android/util/ModuleLoader.java
@@ -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";
diff --git a/tunnel/src/main/java/com/wireguard/android/util/RootShell.java b/tunnel/src/main/java/com/wireguard/android/util/RootShell.java
index 1fc2c9f2..eccc61cb 100644
--- a/tunnel/src/main/java/com/wireguard/android/util/RootShell.java
+++ b/tunnel/src/main/java/com/wireguard/android/util/RootShell.java
@@ -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();
diff --git a/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java b/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java
index 93e44b64..3c2448fe 100644
--- a/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java
+++ b/tunnel/src/main/java/com/wireguard/android/util/SharedLibraryLoader.java
@@ -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();
diff --git a/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java b/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java
index ac18cabf..1ce3fe80 100644
--- a/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java
+++ b/tunnel/src/main/java/com/wireguard/android/util/ToolsInstaller.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/config/Attribute.java b/tunnel/src/main/java/com/wireguard/config/Attribute.java
index 1e9e25f0..659f7cf4 100644
--- a/tunnel/src/main/java/com/wireguard/config/Attribute.java
+++ b/tunnel/src/main/java/com/wireguard/config/Attribute.java
@@ -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*");
diff --git a/tunnel/src/main/java/com/wireguard/config/BadConfigException.java b/tunnel/src/main/java/com/wireguard/config/BadConfigException.java
index 6d41b065..89b3af2c 100644
--- a/tunnel/src/main/java/com/wireguard/config/BadConfigException.java
+++ b/tunnel/src/main/java/com/wireguard/config/BadConfigException.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/config/Config.java b/tunnel/src/main/java/com/wireguard/config/Config.java
index 62651b08..f86eb6fd 100644
--- a/tunnel/src/main/java/com/wireguard/config/Config.java
+++ b/tunnel/src/main/java/com/wireguard/config/Config.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/config/InetAddresses.java b/tunnel/src/main/java/com/wireguard/config/InetAddresses.java
index 1479b5ff..9b0ab965 100644
--- a/tunnel/src/main/java/com/wireguard/config/InetAddresses.java
+++ b/tunnel/src/main/java/com/wireguard/config/InetAddresses.java
@@ -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]?))$");
diff --git a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java
index a442258e..69c60806 100644
--- a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java
+++ b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java
@@ -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("[/?#]");
diff --git a/tunnel/src/main/java/com/wireguard/config/InetNetwork.java b/tunnel/src/main/java/com/wireguard/config/InetNetwork.java
index f89322fd..0c993fc8 100644
--- a/tunnel/src/main/java/com/wireguard/config/InetNetwork.java
+++ b/tunnel/src/main/java/com/wireguard/config/InetNetwork.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/config/Interface.java b/tunnel/src/main/java/com/wireguard/config/Interface.java
index 54944424..efe00ce7 100644
--- a/tunnel/src/main/java/com/wireguard/config/Interface.java
+++ b/tunnel/src/main/java/com/wireguard/config/Interface.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/config/ParseException.java b/tunnel/src/main/java/com/wireguard/config/ParseException.java
index c79d1fa1..f4da7ccd 100644
--- a/tunnel/src/main/java/com/wireguard/config/ParseException.java
+++ b/tunnel/src/main/java/com/wireguard/config/ParseException.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/config/Peer.java b/tunnel/src/main/java/com/wireguard/config/Peer.java
index 37fcfa69..ef91a306 100644
--- a/tunnel/src/main/java/com/wireguard/config/Peer.java
+++ b/tunnel/src/main/java/com/wireguard/config/Peer.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java b/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java
index 5622fc5f..7628c566 100644
--- a/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java
+++ b/tunnel/src/main/java/com/wireguard/crypto/Curve25519.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/crypto/Key.java b/tunnel/src/main/java/com/wireguard/crypto/Key.java
index 6648a5f3..e46150bd 100644
--- a/tunnel/src/main/java/com/wireguard/crypto/Key.java
+++ b/tunnel/src/main/java/com/wireguard/crypto/Key.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/crypto/KeyFormatException.java b/tunnel/src/main/java/com/wireguard/crypto/KeyFormatException.java
index 5818b4d4..8608fc36 100644
--- a/tunnel/src/main/java/com/wireguard/crypto/KeyFormatException.java
+++ b/tunnel/src/main/java/com/wireguard/crypto/KeyFormatException.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/crypto/KeyPair.java b/tunnel/src/main/java/com/wireguard/crypto/KeyPair.java
index f8238e91..22c21734 100644
--- a/tunnel/src/main/java/com/wireguard/crypto/KeyPair.java
+++ b/tunnel/src/main/java/com/wireguard/crypto/KeyPair.java
@@ -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;
diff --git a/tunnel/src/main/java/com/wireguard/util/NonNullForAll.java b/tunnel/src/main/java/com/wireguard/util/NonNullForAll.java
index f179fa49..2c2d9400 100644
--- a/tunnel/src/main/java/com/wireguard/util/NonNullForAll.java
+++ b/tunnel/src/main/java/com/wireguard/util/NonNullForAll.java
@@ -22,5 +22,6 @@ import javax.annotation.meta.TypeQualifierDefault;
@Nonnull
@TypeQualifierDefault({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
+
public @interface NonNullForAll {
}
diff --git a/ui/build.gradle b/ui/build.gradle
index 7fe8a722..4b17a217 100644
--- a/ui/build.gradle
+++ b/ui/build.gradle
@@ -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.
diff --git a/ui/src/main/java/com/wireguard/android/Application.java b/ui/src/main/java/com/wireguard/android/Application.java
index e32c3755..d3e0aa5f 100644
--- a/ui/src/main/java/com/wireguard/android/Application.java
+++ b/ui/src/main/java/com/wireguard/android/Application.java
@@ -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);
diff --git a/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java b/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java
index e3ffce7a..f5232d50 100644
--- a/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java
+++ b/ui/src/main/java/com/wireguard/android/BootShutdownReceiver.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/QuickTileService.java b/ui/src/main/java/com/wireguard/android/QuickTileService.java
index 66aecec3..f18d01b1 100644
--- a/ui/src/main/java/com/wireguard/android/QuickTileService.java
+++ b/ui/src/main/java/com/wireguard/android/QuickTileService.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java
index 8ec58ee8..6c849412 100644
--- a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.java
@@ -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";
diff --git a/ui/src/main/java/com/wireguard/android/activity/MainActivity.java b/ui/src/main/java/com/wireguard/android/activity/MainActivity.java
index 4c33f000..1e098809 100644
--- a/ui/src/main/java/com/wireguard/android/activity/MainActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/MainActivity.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java
index b597a9b1..02f6b29a 100644
--- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java b/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
index c553e417..114d6f13 100644
--- a/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java b/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
index c87ec537..3149988f 100644
--- a/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.java
@@ -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")
diff --git a/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java b/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java
index 09a34bf7..dbf156b8 100644
--- a/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java
+++ b/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java b/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java
index d4761464..c4db4047 100644
--- a/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java
+++ b/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.java
@@ -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
diff --git a/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java b/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
index 45f2f759..9eb56bde 100644
--- a/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
+++ b/ui/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
index ee216d4c..616f665d 100644
--- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
+++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.java
@@ -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.
diff --git a/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java b/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java
index e7303eae..284f73b4 100644
--- a/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java
+++ b/ui/src/main/java/com/wireguard/android/databinding/ItemChangeListener.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java b/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java
index 8b40dd91..36d1917a 100644
--- a/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java
+++ b/ui/src/main/java/com/wireguard/android/databinding/ObservableKeyedRecyclerViewAdapter.java
@@ -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);
diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
index 43178665..e806615c 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
@@ -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";
diff --git a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java
index 23bf44e7..6fc6d25b 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java
index effa0593..113af0ab 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java
@@ -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";
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
index 8d90fa7e..a7ebb5d1 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
index 92aeb52a..397882d1 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
@@ -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";
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
index 21618e60..747f69fa 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/model/ApplicationData.java b/ui/src/main/java/com/wireguard/android/model/ApplicationData.java
index 65edff90..a64d9d71 100644
--- a/ui/src/main/java/com/wireguard/android/model/ApplicationData.java
+++ b/ui/src/main/java/com/wireguard/android/model/ApplicationData.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java
index edd8bd68..70e3bac9 100644
--- a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java
+++ b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/model/TunnelManager.java b/ui/src/main/java/com/wireguard/android/model/TunnelManager.java
index 35d56c81..77304091 100644
--- a/ui/src/main/java/com/wireguard/android/model/TunnelManager.java
+++ b/ui/src/main/java/com/wireguard/android/model/TunnelManager.java
@@ -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());
diff --git a/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java b/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java
index 565854b4..69608e4d 100644
--- a/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java
+++ b/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java b/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java
index 5c83f1dc..8858c725 100644
--- a/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java
+++ b/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java b/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java
index 78a7497b..61752598 100644
--- a/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java
+++ b/ui/src/main/java/com/wireguard/android/preference/ToolsInstallerPreference.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java b/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java
index 7e95a8ae..542fe2d2 100644
--- a/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java
+++ b/ui/src/main/java/com/wireguard/android/preference/VersionPreference.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java
index 3af412a5..8f86fec7 100644
--- a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java
+++ b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java b/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java
index 1d041851..f8341976 100644
--- a/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java
+++ b/ui/src/main/java/com/wireguard/android/util/AsyncWorker.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java b/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java
index 0df5e96a..649fe261 100644
--- a/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java
+++ b/ui/src/main/java/com/wireguard/android/util/ClipboardUtils.java
@@ -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
diff --git a/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java b/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java
index 7db46fa9..3f80a562 100644
--- a/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java
+++ b/ui/src/main/java/com/wireguard/android/util/DownloadsFileSaver.java
@@ -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 {
diff --git a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java
index 481a6ffb..3b818251 100644
--- a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java
+++ b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.java
@@ -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,
diff --git a/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java b/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java
index 5c7a38c0..3e56bd55 100644
--- a/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java
+++ b/ui/src/main/java/com/wireguard/android/util/ExceptionLoggers.java
@@ -5,6 +5,8 @@
package com.wireguard.android.util;
+import com.wireguard.util.NonNullForAll;
+
import androidx.annotation.Nullable;
import android.util.Log;
diff --git a/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java b/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java
index 5fb9a3bc..50a49fa1 100644
--- a/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java
+++ b/ui/src/main/java/com/wireguard/android/util/FragmentUtils.java
@@ -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
diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java
index 0ba02184..bf16d921 100644
--- a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java
+++ b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedArrayList.java
@@ -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
diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java
index be8ceb9b..1c430493 100644
--- a/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java
+++ b/ui/src/main/java/com/wireguard/android/util/ObservableKeyedList.java
@@ -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> {
}
diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
index 1d585856..77d6bbf3 100644
--- a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
+++ b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedArrayList.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java
index d796704e..59531408 100644
--- a/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java
+++ b/ui/src/main/java/com/wireguard/android/util/ObservableSortedKeyedList.java
@@ -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> {
}
diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java b/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java
index bcfe14e3..cc7bc082 100644
--- a/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java
+++ b/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java
index cc9f2dd8..da9c4f10 100644
--- a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java
+++ b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java
@@ -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();
diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java b/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java
index 7dc50f09..7fc614a1 100644
--- a/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java
+++ b/ui/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java
@@ -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(
diff --git a/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java b/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java
index 79572aa3..c91b12ff 100644
--- a/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java
+++ b/ui/src/main/java/com/wireguard/android/widget/KeyInputFilter.java
@@ -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 == '/';
diff --git a/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java b/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java
index 2fe9c924..16742ae8 100644
--- a/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java
+++ b/ui/src/main/java/com/wireguard/android/widget/MultiselectableRelativeLayout.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java b/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java
index 030be25a..1ec14ac0 100644
--- a/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java
+++ b/ui/src/main/java/com/wireguard/android/widget/NameInputFilter.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java b/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java
index e020aa81..4a3142ea 100644
--- a/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java
+++ b/ui/src/main/java/com/wireguard/android/widget/SlashDrawable.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java b/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java
index dcb9aceb..3aec3329 100644
--- a/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java
+++ b/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.java
@@ -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;
diff --git a/ui/src/main/java/com/wireguard/util/Keyed.java b/ui/src/main/java/com/wireguard/util/Keyed.java
index f31a43a2..b4dc40cd 100644
--- a/ui/src/main/java/com/wireguard/util/Keyed.java
+++ b/ui/src/main/java/com/wireguard/util/Keyed.java
@@ -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();
}
diff --git a/ui/src/main/java/com/wireguard/util/KeyedList.java b/ui/src/main/java/com/wireguard/util/KeyedList.java
index c116c1da..e0d06dbb 100644
--- a/ui/src/main/java/com/wireguard/util/KeyedList.java
+++ b/ui/src/main/java/com/wireguard/util/KeyedList.java
@@ -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);
diff --git a/ui/src/main/java/com/wireguard/util/SortedKeyedList.java b/ui/src/main/java/com/wireguard/util/SortedKeyedList.java
index b144fc85..7afc919e 100644
--- a/ui/src/main/java/com/wireguard/util/SortedKeyedList.java
+++ b/ui/src/main/java/com/wireguard/util/SortedKeyedList.java
@@ -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();