From f622fbfbf3a6f8985f681c268c64d07e7dcd3eb7 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 17 Jul 2012 20:17:19 +0200 Subject: Implementier modprobe tun for more braindead images --- AndroidManifest.xml | 4 ++-- res/values/strings.xml | 2 ++ res/xml/general_settings.xml | 18 +++++++++++++----- src/de/blinkt/openvpn/GeneralSettings.java | 13 +++++++++++++ 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 @@ + android:versionCode="39" + android:versionName="0.5.13" > 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 @@ Could not add DNS Server \"%1$s\", rejected by the system: %2$s <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> Quick Start + Try to load the tun.ko kernel module before trying to connect. Needs rooted devices. + Load tun module 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 @@ -6,11 +6,6 @@ android:key="netchangereconnect" android:summary="@string/netchange_summary" android:title="@string/netchange" /> - + + + + + \ 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 -- cgit v1.2.3