summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/de/blinkt/openvpn/GeneralSettings.java13
-rw-r--r--src/de/blinkt/openvpn/LaunchVPN.java29
2 files changed, 31 insertions, 11 deletions
diff --git a/src/de/blinkt/openvpn/GeneralSettings.java b/src/de/blinkt/openvpn/GeneralSettings.java
index 24bf2616..b9c412c0 100644
--- a/src/de/blinkt/openvpn/GeneralSettings.java
+++ b/src/de/blinkt/openvpn/GeneralSettings.java
@@ -1,5 +1,8 @@
package de.blinkt.openvpn;
+import java.io.File;
+
import android.os.Bundle;
+import android.preference.Preference;
import android.preference.PreferenceFragment;
public class GeneralSettings extends PreferenceFragment {
@@ -11,6 +14,16 @@ public class GeneralSettings extends PreferenceFragment {
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.general_settings);
+ Preference loadtun = findPreference("loadTunModule");
+ if(!isTunModuleAvailable())
+ loadtun.setEnabled(false);
+ }
+
+ private boolean isTunModuleAvailable() {
+ // Check if the tun module exists on the file system
+ if(new File("/system/lib/modules/tun.ko").length() > 10)
+ return true;
+ return false;
}
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java
index b057a392..7b1c6cce 100644
--- a/src/de/blinkt/openvpn/LaunchVPN.java
+++ b/src/de/blinkt/openvpn/LaunchVPN.java
@@ -350,21 +350,14 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
// Check if we want to fix /dev/tun
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean usecm9fix = prefs.getBoolean("useCM9Fix", false);
+ boolean loadTunModule = prefs.getBoolean("loadTunModule", false);
if(usecm9fix && !mCmfixed ) {
- ProcessBuilder pb = new ProcessBuilder(new String[] {"su","-c","chown system /dev/tun"});
- try {
- Process p = pb.start();
- int ret = p.waitFor();
- if(ret ==0)
- mCmfixed=true;
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ execeuteSUcmd("chown system /dev/tun");
}
+ if(loadTunModule)
+ execeuteSUcmd("modprobe tun");
if (intent != null) {
@@ -383,6 +376,20 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
}
+ private void execeuteSUcmd(String command) {
+ ProcessBuilder pb = new ProcessBuilder(new String[] {"su","-c",command});
+ try {
+ Process p = pb.start();
+ int ret = p.waitFor();
+ if(ret ==0)
+ mCmfixed=true;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
private class startOpenVpnThread extends Thread {
@Override