diff options
| author | 2025-09-19 20:45:17 +0530 | |
|---|---|---|
| committer | 2025-10-20 18:22:36 +0200 | |
| commit | 3b6ab660a94ef563be25e50804951feda26bc30a (patch) | |
| tree | fd862f4428c938ac97f701eb0b6232a156a5f433 /tunnel/src | |
| parent | tunnel: add isAlwaysOn and isLockdownEnabled (diff) | |
| download | wireguard-android-master.tar.xz wireguard-android-master.zip | |
The difference between the usage of 21 and 24 is not big enough to hold
on to all the baggage from API 21
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
| -rw-r--r-- | tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java | 35 |
1 files changed, 2 insertions, 33 deletions
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 46f68b4b..c9a13b2b 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -24,12 +24,10 @@ import com.wireguard.crypto.KeyFormatException; import com.wireguard.util.NonNullForAll; import java.net.InetAddress; -import java.time.Instant; import java.util.Collections; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; -import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -45,7 +43,7 @@ public final class GoBackend implements Backend { private static final int DNS_RESOLUTION_RETRIES = 10; private static final String TAG = "WireGuard/GoBackend"; @Nullable private static AlwaysOnCallback alwaysOnCallback; - private static GhettoCompletableFuture<VpnService> vpnService = new GhettoCompletableFuture<>(); + private static CompletableFuture<VpnService> vpnService = new CompletableFuture<>(); private final Context context; @Nullable private Config currentConfig; @Nullable private Tunnel currentTunnel; @@ -377,35 +375,6 @@ public final class GoBackend implements Backend { void alwaysOnTriggered(); } - // TODO: When we finally drop API 21 and move to API 24, delete this and replace with the ordinary CompletableFuture. - private static final class GhettoCompletableFuture<V> { - private final LinkedBlockingQueue<V> completion = new LinkedBlockingQueue<>(1); - private final FutureTask<V> result = new FutureTask<>(completion::peek); - - public boolean complete(final V value) { - final boolean offered = completion.offer(value); - if (offered) - result.run(); - return offered; - } - - public V get() throws ExecutionException, InterruptedException { - return result.get(); - } - - public V get(final long timeout, final TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException { - return result.get(timeout, unit); - } - - public boolean isDone() { - return !completion.isEmpty(); - } - - public GhettoCompletableFuture<V> newIncompleteFuture() { - return new GhettoCompletableFuture<>(); - } - } - /** * {@link android.net.VpnService} implementation for {@link GoBackend} */ |
