summaryrefslogtreecommitdiff
path: root/src/de/blinkt
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-07-17 20:17:19 +0200
committerArne Schwabe <arne@rfc2549.org>2012-07-17 20:17:19 +0200
commitf622fbfbf3a6f8985f681c268c64d07e7dcd3eb7 (patch)
treeed870475bbbcb01a50330485ea505a63302d6cd5 /src/de/blinkt
parent2097538559ca82d4c2336da63a5e45e10ca53af0 (diff)
Implementier modprobe tun for more braindead images
Diffstat (limited to 'src/de/blinkt')
-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