summaryrefslogtreecommitdiff
path: root/src/se/leap/openvpn/VPNLaunchHelper.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-04-07 20:43:34 +0200
committerParménides GV <parmegv@sdf.org>2014-04-08 11:43:27 +0200
commitc206a91d320995f37f8abb33188bfd384249da3d (patch)
tree10a7d8a9dd7f24437ac4851b8d01edbd5dd3ee3b /src/se/leap/openvpn/VPNLaunchHelper.java
parent910b0e1746ab3f63e63808b198ad51fec5b635e5 (diff)
Next step: compile jni sources correctly.
Diffstat (limited to 'src/se/leap/openvpn/VPNLaunchHelper.java')
-rw-r--r--src/se/leap/openvpn/VPNLaunchHelper.java76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/se/leap/openvpn/VPNLaunchHelper.java b/src/se/leap/openvpn/VPNLaunchHelper.java
deleted file mode 100644
index 418cf7e9..00000000
--- a/src/se/leap/openvpn/VPNLaunchHelper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package se.leap.openvpn;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import se.leap.bitmaskclient.R;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Build;
-
-public class VPNLaunchHelper {
- static private boolean writeMiniVPN(Context context) {
- File mvpnout = new File(context.getCacheDir(),VpnProfile.MINIVPN);
- if (mvpnout.exists() && mvpnout.canExecute())
- return true;
-
- IOException e2 = null;
-
- try {
- InputStream mvpn;
-
- try {
- mvpn = context.getAssets().open("minivpn." + Build.CPU_ABI);
- }
- catch (IOException errabi) {
- OpenVPN.logInfo("Failed getting assets for archicture " + Build.CPU_ABI);
- e2=errabi;
- mvpn = context.getAssets().open("minivpn." + Build.CPU_ABI2);
-
- }
-
-
- FileOutputStream fout = new FileOutputStream(mvpnout);
-
- byte buf[]= new byte[4096];
-
- int lenread = mvpn.read(buf);
- while(lenread> 0) {
- fout.write(buf, 0, lenread);
- lenread = mvpn.read(buf);
- }
- fout.close();
-
- if(!mvpnout.setExecutable(true)) {
- OpenVPN.logMessage(0, "","Failed to set minivpn executable");
- return false;
- }
-
-
- return true;
- } catch (IOException e) {
- if(e2!=null)
- OpenVPN.logMessage(0, "",e2.getLocalizedMessage());
- OpenVPN.logMessage(0, "",e.getLocalizedMessage());
- e.printStackTrace();
- return false;
- }
- }
-
-
- public static void startOpenVpn(VpnProfile startprofile, Context context) {
- if(!writeMiniVPN(context)) {
- OpenVPN.logMessage(0, "", "Error writing minivpn binary");
- return;
- }
- OpenVPN.logMessage(0, "", context.getString(R.string.building_configration));
-
- Intent startVPN = startprofile.prepareIntent(context);
- if(startVPN!=null)
- context.startService(startVPN);
-
- }
-}