summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-02-28 13:16:31 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-02-28 13:16:31 +0530
commit5e94adc73a302eff41e63b133d2a3bc14dc14028 (patch)
treeb20574133c9d361abd3de296800db8d547da7fac /app
parent44fc0228a9dadda781e5e604632a703d73c2d5bd (diff)
ModuleLoader: Staticize isModuleLoaded
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/Application.java4
-rw-r--r--app/src/main/java/com/wireguard/android/activity/SettingsActivity.java3
-rw-r--r--app/src/main/java/com/wireguard/android/util/ModuleLoader.java2
3 files changed, 5 insertions, 4 deletions
diff --git a/app/src/main/java/com/wireguard/android/Application.java b/app/src/main/java/com/wireguard/android/Application.java
index bd848e66..9b40fcd6 100644
--- a/app/src/main/java/com/wireguard/android/Application.java
+++ b/app/src/main/java/com/wireguard/android/Application.java
@@ -73,7 +73,7 @@ public class Application extends android.app.Application {
if (app.backend == null) {
Backend backend = null;
boolean didStartRootShell = false;
- if (!app.moduleLoader.isModuleLoaded() && app.moduleLoader.moduleMightExist()) {
+ if (!ModuleLoader.isModuleLoaded() && app.moduleLoader.moduleMightExist()) {
try {
app.rootShell.start();
didStartRootShell = true;
@@ -81,7 +81,7 @@ public class Application extends android.app.Application {
} catch (final Exception ignored) {
}
}
- if (app.moduleLoader.isModuleLoaded()) {
+ if (ModuleLoader.isModuleLoaded()) {
try {
if (!didStartRootShell)
app.rootShell.start();
diff --git a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java
index 442c93e6..f545c371 100644
--- a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java
+++ b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java
@@ -20,6 +20,7 @@ import android.view.MenuItem;
import com.wireguard.android.Application;
import com.wireguard.android.R;
import com.wireguard.android.backend.WgQuickBackend;
+import com.wireguard.android.util.ModuleLoader;
import java.util.ArrayList;
import java.util.Arrays;
@@ -113,7 +114,7 @@ public class SettingsActivity extends ThemeChangeAwareActivity {
final Preference moduleInstaller = getPreferenceManager().findPreference("module_downloader");
moduleInstaller.setVisible(false);
- if (Application.getModuleLoader().isModuleLoaded()) {
+ if (ModuleLoader.isModuleLoaded()) {
screen.removePreference(moduleInstaller);
} else {
Application.getAsyncWorker().runAsync(Application.getRootShell()::start).whenComplete((v, e) -> {
diff --git a/app/src/main/java/com/wireguard/android/util/ModuleLoader.java b/app/src/main/java/com/wireguard/android/util/ModuleLoader.java
index f5bca0f2..7794dd5c 100644
--- a/app/src/main/java/com/wireguard/android/util/ModuleLoader.java
+++ b/app/src/main/java/com/wireguard/android/util/ModuleLoader.java
@@ -59,7 +59,7 @@ public class ModuleLoader {
Application.getRootShell().run(null, String.format("insmod \"%s/wireguard-$(sha256sum /proc/version|cut -d ' ' -f 1).ko\"", moduleDir.getAbsolutePath()));
}
- public boolean isModuleLoaded() {
+ public static boolean isModuleLoaded() {
return new File("/sys/module/wireguard").exists();
}