ModuleLoader: Staticize isModuleLoaded

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-02-28 13:16:31 +05:30
parent 44fc0228a9
commit 5e94adc73a
3 changed files with 5 additions and 4 deletions

View File

@ -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();

View File

@ -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) -> {

View File

@ -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();
}