android: Load JNI libraries in Application class

This way they are also loaded when we don't use CharonVpnService.
This commit is contained in:
Tobias Brunner 2017-11-17 16:41:52 +01:00
parent 2d1f65feb3
commit 92c1b52487
2 changed files with 26 additions and 24 deletions

View 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");
}
}

View 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");
}
}