summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-03-18 17:20:30 +0100
committerArne Schwabe <arne@rfc2549.org>2013-03-18 17:20:30 +0100
commit6ba818e5c9e1d7d50478cf161fe819597499477d (patch)
tree2fcd13e8cd3c0e61821e4c5486f0e9d8ae231a00
parent098204e653c958da12ae864d3b6c183e716c2a9b (diff)
Move native functions into own class.
This way the Gui will not always load the native libraries when showing profiles and allows some GUI modifications without compiling ndk code
-rw-r--r--jni/jbcrypto.cpp2
-rw-r--r--jni/jniglue.c2
-rw-r--r--src/de/blinkt/openvpn/VpnProfile.java9
-rw-r--r--src/de/blinkt/openvpn/core/NativeUtils.java12
-rw-r--r--src/de/blinkt/openvpn/core/OpenVpnManagementThread.java7
5 files changed, 17 insertions, 15 deletions
diff --git a/jni/jbcrypto.cpp b/jni/jbcrypto.cpp
index 77382fb9..97bc5e70 100644
--- a/jni/jbcrypto.cpp
+++ b/jni/jbcrypto.cpp
@@ -17,7 +17,7 @@
extern "C" {
-jbyteArray Java_de_blinkt_openvpn_VpnProfile_rsasign(JNIEnv* env, jclass, jbyteArray from, jint pkeyRef);
+jbyteArray Java_de_blinkt_openvpn_core_NativeUtils_rsasign(JNIEnv* env, jclass, jbyteArray from, jint pkeyRef);
}
int jniThrowException(JNIEnv* env, const char* className, const char* msg) {
diff --git a/jni/jniglue.c b/jni/jniglue.c
index 15b78014..c3b4bf3b 100644
--- a/jni/jniglue.c
+++ b/jni/jniglue.c
@@ -16,7 +16,7 @@ void android_openvpn_log(int level,const char* prefix,const char* prefix_sep,con
__android_log_print(ANDROID_LOG_DEBUG,"openvpn","%s%s%s",prefix,prefix_sep,m1);
}
-void Java_de_blinkt_openvpn_core_OpenVpnManagementThread_jniclose(JNIEnv *env,jclass jo, jint fd) {
+void Java_de_blinkt_openvpn_core_NativeUtils_jniclose(JNIEnv *env,jclass jo, jint fd) {
int ret = close(fd);
}
diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java
index 67a2a142..9d183897 100644
--- a/src/de/blinkt/openvpn/VpnProfile.java
+++ b/src/de/blinkt/openvpn/VpnProfile.java
@@ -42,6 +42,7 @@ import android.security.KeyChain;
import android.security.KeyChainException;
import android.util.Base64;
import de.blinkt.openvpn.R;
+import de.blinkt.openvpn.core.NativeUtils;
import de.blinkt.openvpn.core.OpenVPN;
import de.blinkt.openvpn.core.OpenVpnService;
@@ -140,12 +141,6 @@ public class VpnProfile implements Serializable{
public static final String MINIVPN = "miniopenvpn";
-
- static private native byte[] rsasign(byte[] input,int pkey) throws InvalidKeyException;
- static {
- System.loadLibrary("opvpnutil");
- }
-
public void clearDefaults() {
mServerName="unkown";
mUsePull=false;
@@ -868,7 +863,7 @@ public class VpnProfile implements Serializable{
int pkey = (Integer) getPkeyContext.invoke(opensslkey);
getPkeyContext.setAccessible(false);
- byte[] signed_bytes = rsasign(data, pkey);
+ byte[] signed_bytes = NativeUtils.rsasign(data, pkey);
return Base64.encodeToString(signed_bytes, Base64.NO_WRAP);
} catch (NoSuchMethodException e) {
diff --git a/src/de/blinkt/openvpn/core/NativeUtils.java b/src/de/blinkt/openvpn/core/NativeUtils.java
new file mode 100644
index 00000000..42d0b583
--- /dev/null
+++ b/src/de/blinkt/openvpn/core/NativeUtils.java
@@ -0,0 +1,12 @@
+package de.blinkt.openvpn.core;
+
+import java.security.InvalidKeyException;
+
+public class NativeUtils {
+ public static native byte[] rsasign(byte[] input,int pkey) throws InvalidKeyException;
+ static native void jniclose(int fdint);
+
+ static {
+ System.loadLibrary("opvpnutil");
+ }
+}
diff --git a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
index a44f744e..5b465973 100644
--- a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
+++ b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
@@ -35,8 +35,6 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNMangement {
private static Vector<OpenVpnManagementThread> active=new Vector<OpenVpnManagementThread>();
- static private native void jniclose(int fdint);
-
public OpenVpnManagementThread(VpnProfile profile, LocalServerSocket mgmtsocket, OpenVpnService openVpnService) {
mProfile = profile;
mServerSocket = mgmtsocket;
@@ -128,7 +126,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNMangement {
//ParcelFileDescriptor pfd = ParcelFileDescriptor.fromFd(fdint);
//pfd.close();
- jniclose(fdint);
+ NativeUtils.jniclose(fdint);
return;
} catch (NoSuchMethodException e) {
exp =e;
@@ -426,9 +424,6 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNMangement {
private void proccessPWFailed(String needed, String args) {
OpenVPN.updateStateString("AUTH_FAILED", needed + args,R.string.state_auth_failed,ConnectionStatus.LEVEL_AUTH_FAILED);
}
- private void logStatusMessage(String command) {
- OpenVPN.logMessage(0,"MGMT:", command);
- }
private static boolean stopOpenVPN() {