summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml7
-rw-r--r--res/xml/main_headers.xml7
-rw-r--r--src/de/blinkt/openvpn/GeneralSettings.java17
-rw-r--r--src/de/blinkt/openvpn/LaunchVPN.java25
4 files changed, 47 insertions, 9 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bea7220c..a40c5830 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -125,7 +125,7 @@
<string name="custom_options_title">Custom Options</string>
<string name="edit_vpn">Edit VPN Settings</string>
<string name="remove_vpn_query">Remove the VPN Profile %s?</string>
- <string name="tun_error_helpful">" On some custom ICS images the permission on /dev/tun might be wrong, or the tun module might be missing completly"</string>
+ <string name="tun_error_helpful">" On some custom ICS images the permission on /dev/tun might be wrong, or the tun module might be missing completly. For CM9 images try the fix ownership option under general settings"</string>
<string name="tun_open_error">Opening tun interface failed badly.</string>
<string name="error">"Error: "</string>
<string name="clear">Clear</string>
@@ -194,10 +194,13 @@
<string name="converted_profile">imported profile</string>
<string name="converted_profile_i">imported profile %d</string>
<string name="broken_images">Broken Images</string>
- <string name="broken_images_faq">&lt;p>Offical HTC images are known to have a strange routing problem causing traffic not to flow through the tunnel (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\">Issue 18&lt;/a> in the bug tracker.)&lt;/p>&lt;p>The offical SONY images from Xperia arc S and Xperia Ray have been reported to be missing the VPNService completly from the image. Other Sony images may be affected as well. (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\">Issue 29&lt;/a> in the bug tracker.)&lt;/p>&lt;p>On custom build images the tun module might be missing or the rights of /dev/tun might be wrong. On the experimental CM9 Defy image a &lt;i>chown system /dev/tun&lt;/i> is needed to make the VPNService API work.&lt;/p></string>
+ <string name="broken_images_faq">&lt;p>Offical HTC images are known to have a strange routing problem causing traffic not to flow through the tunnel (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\">Issue 18&lt;/a> in the bug tracker.)&lt;/p>&lt;p>The offical SONY images from Xperia arc S and Xperia Ray have been reported to be missing the VPNService completly from the image. Other Sony images may be affected as well. (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\">Issue 29&lt;/a> in the bug tracker.)&lt;/p>&lt;p>On custom build images the tun module might be missing or the rights of /dev/tun might be wrong. Some CM9 images need the fix ownership option under general settings.&lt;/p></string>
<string name="error_empty_username">The username must not be empty.</string>
<string name="pkcs12_file_encryption_key">PKCS12 File Encryption Key</string>
<string name="private_key_password">Private Key Password</string>
<string name="password">Password</string>
+ <string name="generalsettings">General Settings</string>
+ <string name="owner_fix_summary">Tries to set the owner of /dev/tun to system. Some CM9 images need this to make the VPNService API work. Requires root.</string>
+ <string name="owner_fix">Fix owner of /dev/tun</string>
</resources> \ No newline at end of file
diff --git a/res/xml/main_headers.xml b/res/xml/main_headers.xml
index 030b5488..92740382 100644
--- a/res/xml/main_headers.xml
+++ b/res/xml/main_headers.xml
@@ -5,14 +5,9 @@
android:fragment="de.blinkt.openvpn.VPNProfileList"
android:summary="@string/vpn_list_summary"
android:title="@string/vpn_list_title" />
-
- <!--
- <header
-
+ <header
android:fragment="de.blinkt.openvpn.GeneralSettings"
android:title="@string/generalsettings" />
- -->
-
<header
android:fragment="de.blinkt.openvpn.FaqFragment"
android:summary="@string/faq_summary"
diff --git a/src/de/blinkt/openvpn/GeneralSettings.java b/src/de/blinkt/openvpn/GeneralSettings.java
new file mode 100644
index 00000000..24bf2616
--- /dev/null
+++ b/src/de/blinkt/openvpn/GeneralSettings.java
@@ -0,0 +1,17 @@
+package de.blinkt.openvpn;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+public class GeneralSettings extends PreferenceFragment {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.general_settings);
+ }
+
+
+ } \ No newline at end of file
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java
index 5d17e6b3..b7b010a4 100644
--- a/src/de/blinkt/openvpn/LaunchVPN.java
+++ b/src/de/blinkt/openvpn/LaunchVPN.java
@@ -30,9 +30,11 @@ import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.net.VpnService;
import android.os.Bundle;
import android.os.Parcelable;
+import android.preference.PreferenceManager;
import android.text.InputType;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
@@ -76,7 +78,9 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
private ProfileManager mPM;
private VpnProfile mSelectedProfile;
-
+
+
+ private boolean mCmfixed=false;
static boolean minivpnwritten=false;
@Override
@@ -326,6 +330,25 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
}
Intent intent = VpnService.prepare(this);
+ // Check if we want to fix /dev/tun
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ boolean usecm9fix = prefs.getBoolean("useCM9Fix", 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();
+ }
+ }
+
+
if (intent != null) {
// Start the query