diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-07 04:12:42 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-07 04:12:42 +0200 |
commit | 24605c9c0132135873f7a8c7a966ff2d512edef3 (patch) | |
tree | cba521a2a357e75ed39b64e2b4242e233ebccc8f /app/src/main/java/com/wireguard/android/backend | |
parent | 7b59353910149cdd6f8ba76a19c31c2e2c416611 (diff) |
Give Samuel heart attack by removing Dagger
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/backend')
-rw-r--r-- | app/src/main/java/com/wireguard/android/backend/GoBackend.java | 4 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java | 16 |
2 files changed, 8 insertions, 12 deletions
diff --git a/app/src/main/java/com/wireguard/android/backend/GoBackend.java b/app/src/main/java/com/wireguard/android/backend/GoBackend.java index 21df018e..8c8d593a 100644 --- a/app/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -229,7 +229,7 @@ public final class GoBackend implements Backend { @Override public void onDestroy() { - for (final Tunnel tunnel : Application.getComponent().getTunnelManager().getTunnels()) { + for (final Tunnel tunnel : Application.getTunnelManager().getTunnels()) { if (tunnel != null && tunnel.getState() != State.DOWN) tunnel.setState(State.DOWN); } @@ -242,7 +242,7 @@ public final class GoBackend implements Backend { vpnService.complete(this); if (intent == null || intent.getComponent() == null || !intent.getComponent().getPackageName().equals(getPackageName())) { Log.d(TAG, "Service started by Always-on VPN feature"); - Application.getComponent().getTunnelManager().restoreState(true).whenComplete(ExceptionLoggers.D); + Application.getTunnelManager().restoreState(true).whenComplete(ExceptionLoggers.D); } return super.onStartCommand(intent, flags, startId); } diff --git a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java index e5a5574f..56d62a1f 100644 --- a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java @@ -9,6 +9,7 @@ package com.wireguard.android.backend; import android.content.Context; import android.util.Log; +import com.wireguard.android.Application; import com.wireguard.android.model.Tunnel; import com.wireguard.android.model.Tunnel.State; import com.wireguard.android.model.Tunnel.Statistics; @@ -35,14 +36,9 @@ public final class WgQuickBackend implements Backend { private static final String TAG = "WireGuard/" + WgQuickBackend.class.getSimpleName(); private final File localTemporaryDir; - private final RootShell rootShell; - private final ToolsInstaller toolsInstaller; - public WgQuickBackend(final Context context, final RootShell rootShell, - final ToolsInstaller toolsInstaller) { + public WgQuickBackend(final Context context) { localTemporaryDir = new File(context.getCacheDir(), "tmp"); - this.rootShell = rootShell; - this.toolsInstaller = toolsInstaller; } @Override @@ -66,8 +62,8 @@ public final class WgQuickBackend implements Backend { final List<String> output = new ArrayList<>(); // Don't throw an exception here or nothing will show up in the UI. try { - toolsInstaller.ensureToolsAvailable(); - if (rootShell.run(output, "wg show interfaces") != 0 || output.isEmpty()) + Application.getToolsInstaller().ensureToolsAvailable(); + if (Application.getRootShell().run(output, "wg show interfaces") != 0 || output.isEmpty()) return Collections.emptySet(); } catch (final Exception e) { Log.w(TAG, "Unable to enumerate running tunnels", e); @@ -95,7 +91,7 @@ public final class WgQuickBackend implements Backend { if (state == originalState) return originalState; Log.d(TAG, "Changing tunnel " + tunnel.getName() + " to state " + state); - toolsInstaller.ensureToolsAvailable(); + Application.getToolsInstaller().ensureToolsAvailable(); setStateInternal(tunnel, tunnel.getConfig(), state); return getState(tunnel); } @@ -110,7 +106,7 @@ public final class WgQuickBackend implements Backend { state.toString().toLowerCase(), tempFile.getAbsolutePath()); if (state == State.UP) command = "cat /sys/module/wireguard/version && " + command; - final int result = rootShell.run(null, command); + final int result = Application.getRootShell().run(null, command); // noinspection ResultOfMethodCallIgnored tempFile.delete(); if (result != 0) |