diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-07-17 20:17:19 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-07-17 20:17:19 +0200 |
commit | aadf9c06d74fbb41af7be39661055fd367b4c643 (patch) | |
tree | 3d4625d3721b42f7fdfcede0c0ce069d09f1c0d5 | |
parent | 7fe13897bf2ba07ac553b3a47cb5cf66c766f67d (diff) |
Implementier modprobe tun for more braindead images
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | res/xml/general_settings.xml | 18 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/GeneralSettings.java | 13 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/LaunchVPN.java | 29 |
5 files changed, 48 insertions, 18 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0adf7b44..980e8903 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -17,8 +17,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.blinkt.openvpn" - android:versionCode="38" - android:versionName="0.5.12a" > + android:versionCode="39" + android:versionName="0.5.13" > <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index d3493fd2..d4604db7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -237,4 +237,6 @@ <string name="dns_add_error">Could not add DNS Server \"%1$s\", rejected by the system: %2$s</string> <string name="faq_howto"><p>Get a working config (tested on your computer or download from your provider/organisation)</p><p>If it is a single file no with no extra pem/pks12 files you can email the file yourself and open the attachment. If you have multiple files put them on your sd card.</p><p>Click on the email attachment/Use the folder icon in the vpn list to import the config file</p><p>If there are errors about missing files put the missing files on your sd card.</p><p>Click on the save symbol to add the imported VPN to your VPN list</p><p>Connect the VPN by clicking on the name of the VPN</p><p>If there are error or warnings in the log try to understand the warnings/error and try to fix them</p> </string> <string name="faq_howto_title">Quick Start</string> + <string name="setting_loadtun_summary">Try to load the tun.ko kernel module before trying to connect. Needs rooted devices.</string> + <string name="setting_loadtun">Load tun module</string> </resources> diff --git a/res/xml/general_settings.xml b/res/xml/general_settings.xml index 69316d18..73b66b00 100644 --- a/res/xml/general_settings.xml +++ b/res/xml/general_settings.xml @@ -7,11 +7,6 @@ android:summary="@string/netchange_summary" android:title="@string/netchange" /> <CheckBoxPreference - android:defaultValue="false" - android:key="useCM9Fix" - android:summary="@string/owner_fix_summary" - android:title="@string/owner_fix" /> - <CheckBoxPreference android:defaultValue="true" android:key="showlogwindow" android:summary="@string/show_log_summary" @@ -22,4 +17,17 @@ android:summary="@string/keppstatus_summary" android:title="@string/keepstatus" /> + <PreferenceCategory android:title="Device specifics Hacks" > + <CheckBoxPreference + android:defaultValue="false" + android:key="useCM9Fix" + android:summary="@string/owner_fix_summary" + android:title="@string/owner_fix" /> + <CheckBoxPreference + android:defaultValue="false" + android:key="loadTunModule" + android:summary="@string/setting_loadtun_summary" + android:title="@string/setting_loadtun" /> + </PreferenceCategory> + </PreferenceScreen>
\ No newline at end of file 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 |