summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/de')
-rw-r--r--src/de/blinkt/openvpn/core/OpenVPNThread.java43
-rw-r--r--src/de/blinkt/openvpn/core/OpenVpnService.java14
2 files changed, 41 insertions, 16 deletions
diff --git a/src/de/blinkt/openvpn/core/OpenVPNThread.java b/src/de/blinkt/openvpn/core/OpenVPNThread.java
index 9d6d8e77..d8fff1dd 100644
--- a/src/de/blinkt/openvpn/core/OpenVPNThread.java
+++ b/src/de/blinkt/openvpn/core/OpenVPNThread.java
@@ -10,6 +10,8 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
import android.util.Log;
import de.blinkt.openvpn.R;
@@ -25,8 +27,9 @@ public class OpenVPNThread implements Runnable {
private String mNativeDir;
private OpenVpnService mService;
private String mDumpPath;
+ private Map<String, String> mProcessEnv;
- public OpenVPNThread(OpenVpnService service,String[] argv, String nativelibdir)
+ public OpenVPNThread(OpenVpnService service,String[] argv, Map<String,String> processEnv, String nativelibdir)
{
mArgv = argv;
mNativeDir = nativelibdir;
@@ -43,7 +46,7 @@ public class OpenVPNThread implements Runnable {
public void run() {
try {
Log.i(TAG, "Starting openvpn");
- startOpenVPNThreadArgs(mArgv);
+ startOpenVPNThreadArgs(mArgv, mProcessEnv);
Log.i(TAG, "Giving up");
} catch (Exception e) {
e.printStackTrace();
@@ -81,7 +84,7 @@ public class OpenVPNThread implements Runnable {
}
}
- private void startOpenVPNThreadArgs(String[] argv) {
+ private void startOpenVPNThreadArgs(String[] argv,Map<String, String> env) {
LinkedList<String> argvlist = new LinkedList<String>();
for(String arg:argv)
@@ -90,20 +93,14 @@ public class OpenVPNThread implements Runnable {
ProcessBuilder pb = new ProcessBuilder(argvlist);
// Hack O rama
- // Hack until I find a good way to get the real library path
- String applibpath = argv[0].replace("/cache/" + VpnProfile.MINIVPN , "/lib");
-
- String lbpath = pb.environment().get("LD_LIBRARY_PATH");
- if(lbpath==null)
- lbpath = applibpath;
- else
- lbpath = lbpath + ":" + applibpath;
-
- if (!applibpath.equals(mNativeDir)) {
- lbpath = lbpath + ":" + mNativeDir;
- }
+ String lbpath = genLibraryPath(argv, pb);
pb.environment().put("LD_LIBRARY_PATH", lbpath);
+
+ // Add extra variables
+ for(Entry<String,String> e:env.entrySet()){
+ pb.environment().put(e.getKey(), e.getValue());
+ }
pb.redirectErrorStream(true);
try {
mProcess = pb.start();
@@ -133,4 +130,20 @@ public class OpenVPNThread implements Runnable {
}
+
+ private String genLibraryPath(String[] argv, ProcessBuilder pb) {
+ // Hack until I find a good way to get the real library path
+ String applibpath = argv[0].replace("/cache/" + VpnProfile.MINIVPN , "/lib");
+
+ String lbpath = pb.environment().get("LD_LIBRARY_PATH");
+ if(lbpath==null)
+ lbpath = applibpath;
+ else
+ lbpath = lbpath + ":" + applibpath;
+
+ if (!applibpath.equals(mNativeDir)) {
+ lbpath = lbpath + ":" + mNativeDir;
+ }
+ return lbpath;
+ }
}
diff --git a/src/de/blinkt/openvpn/core/OpenVpnService.java b/src/de/blinkt/openvpn/core/OpenVpnService.java
index d86ae92b..eb6e98d2 100644
--- a/src/de/blinkt/openvpn/core/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/core/OpenVpnService.java
@@ -3,7 +3,9 @@ package de.blinkt.openvpn.core;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.Map;
import java.util.Vector;
import android.Manifest.permission;
@@ -15,6 +17,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.net.LocalServerSocket;
import android.net.LocalSocket;
@@ -323,7 +327,15 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
} else {
- processThread = new OpenVPNThread(this, argv,nativelibdir);
+ HashMap<String, String> env = new HashMap<String, String>();
+ String version="unknown";
+ try {
+ PackageInfo packageinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
+ version = packageinfo.versionName;
+ } catch (NameNotFoundException e) {
+ }
+ env.put("UV_ICSOPENVPN_VERSION", version);
+ processThread = new OpenVPNThread(this, argv, env, nativelibdir);
}
mProcessThread = new Thread(processThread, "OpenVPNProcessThread");