android: Load JNI libraries in Application class
authorTobias Brunner <tobias@strongswan.org>
Fri, 17 Nov 2017 15:41:52 +0000 (16:41 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 17 Nov 2017 17:05:35 +0000 (18:05 +0100)
This way they are also loaded when we don't use CharonVpnService.

src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java
src/frontends/android/app/src/main/java/org/strongswan/android/logic/StrongSwanApplication.java

index 95c2ccd..b6e7e2d 100644 (file)
@@ -1073,28 +1073,4 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
        {
                return Build.MODEL + " - " + Build.BRAND + "/" + Build.PRODUCT + "/" + Build.MANUFACTURER;
        }
-
-       /*
-        * The libraries are extracted to /data/data/org.strongswan.android/...
-        * during installation.  On newer releases most are loaded in JNI_OnLoad.
-        */
-       static
-       {
-               if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
-               {
-                       System.loadLibrary("strongswan");
-
-                       if (MainActivity.USE_BYOD)
-                       {
-                               System.loadLibrary("tpmtss");
-                               System.loadLibrary("tncif");
-                               System.loadLibrary("tnccs");
-                               System.loadLibrary("imcv");
-                       }
-
-                       System.loadLibrary("charon");
-                       System.loadLibrary("ipsec");
-               }
-               System.loadLibrary("androidbridge");
-       }
 }
index d642b67..19711e4 100644 (file)
@@ -18,9 +18,11 @@ package org.strongswan.android.logic;
 import java.security.Security;
 
 import org.strongswan.android.security.LocalCertificateKeyStoreProvider;
+import org.strongswan.android.ui.MainActivity;
 
 import android.app.Application;
 import android.content.Context;
+import android.os.Build;
 
 public class StrongSwanApplication extends Application
 {
@@ -45,4 +47,28 @@ public class StrongSwanApplication extends Application
        {
                return StrongSwanApplication.mContext;
        }
+
+       /*
+        * The libraries are extracted to /data/data/org.strongswan.android/...
+        * during installation.  On newer releases most are loaded in JNI_OnLoad.
+        */
+       static
+       {
+               if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
+               {
+                       System.loadLibrary("strongswan");
+
+                       if (MainActivity.USE_BYOD)
+                       {
+                               System.loadLibrary("tpmtss");
+                               System.loadLibrary("tncif");
+                               System.loadLibrary("tnccs");
+                               System.loadLibrary("imcv");
+                       }
+
+                       System.loadLibrary("charon");
+                       System.loadLibrary("ipsec");
+               }
+               System.loadLibrary("androidbridge");
+       }
 }