summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-07 03:27:06 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-07 03:27:06 +0200
commit7b59353910149cdd6f8ba76a19c31c2e2c416611 (patch)
tree998f8c45ba7bcdba573eb850e4d3e49496328274 /app/src/main/java/com
parentca7f4e5be959f322ca652208f97195d5df46e619 (diff)
VersionPreference: account for checking state and move away from tools installer
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/wireguard/android/Application.java2
-rw-r--r--app/src/main/java/com/wireguard/android/preference/VersionPreference.java19
-rw-r--r--app/src/main/java/com/wireguard/android/util/ToolsInstaller.java9
3 files changed, 19 insertions, 11 deletions
diff --git a/app/src/main/java/com/wireguard/android/Application.java b/app/src/main/java/com/wireguard/android/Application.java
index 74cb07cf..eaf2d75c 100644
--- a/app/src/main/java/com/wireguard/android/Application.java
+++ b/app/src/main/java/com/wireguard/android/Application.java
@@ -67,6 +67,8 @@ public class Application extends android.app.Application {
ToolsInstaller getToolsInstaller();
TunnelManager getTunnelManager();
+
+ RootShell getRootShell();
}
@Qualifier
diff --git a/app/src/main/java/com/wireguard/android/preference/VersionPreference.java b/app/src/main/java/com/wireguard/android/preference/VersionPreference.java
index b1a1cf49..2cce769d 100644
--- a/app/src/main/java/com/wireguard/android/preference/VersionPreference.java
+++ b/app/src/main/java/com/wireguard/android/preference/VersionPreference.java
@@ -16,6 +16,14 @@ import com.wireguard.android.BuildConfig;
import com.wireguard.android.R;
import com.wireguard.android.backend.GoBackend;
import com.wireguard.android.backend.WgQuickBackend;
+import com.wireguard.android.util.RootShell;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import java9.util.concurrent.CompletionStage;
public class VersionPreference extends Preference {
private String versionSummary;
@@ -26,10 +34,17 @@ public class VersionPreference extends Preference {
if (Application.getComponent().getBackendType() == GoBackend.class) {
versionSummary = getContext().getString(R.string.version_userspace_summary, GoBackend.getVersion());
} else if (Application.getComponent().getBackendType() == WgQuickBackend.class) {
- Application.getComponent().getToolsInstaller().getVersion().whenComplete((version, exception) -> {
+ versionSummary = getContext().getString(R.string.version_kernel_summary_checking);
+ Application.getComponent().getAsyncWorker().supplyAsync(() -> {
+ final List<String> output = new ArrayList<>();
+ if (Application.getComponent().getRootShell()
+ .run(output, "cat /sys/module/wireguard/version") != 0 || output.isEmpty())
+ throw new RuntimeException("Unable to determine kernel module version");
+ return output.get(0);
+ }).whenComplete((version, exception) -> {
versionSummary = exception == null
? getContext().getString(R.string.version_kernel_summary, version)
- : getContext().getString(R.string.version_kernel_unknown_summary);
+ : getContext().getString(R.string.version_kernel_summary_unknown);
notifyChanged();
});
}
diff --git a/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java b/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java
index 2b8280cc..d4a96f84 100644
--- a/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java
+++ b/app/src/main/java/com/wireguard/android/util/ToolsInstaller.java
@@ -58,15 +58,6 @@ public final class ToolsInstaller {
this.rootShell = rootShell;
}
- public CompletionStage<String> getVersion() {
- return Application.getComponent().getAsyncWorker().supplyAsync(() -> {
- final List<String> output = new ArrayList<>();
- if (rootShell.run(output, "cat /sys/module/wireguard/version") != 0 || output.isEmpty())
- throw new RuntimeException("Unable to determine kernel module version");
- return output.get(0);
- });
- }
-
private static File getInstallDir() {
final String path = System.getenv("PATH");
if (path == null)