2016-07-09 23:54:11 +03:00
|
|
|
|
|
|
|
//#include <string.h>
|
|
|
|
#include <jni.h>
|
|
|
|
#include "org_purplei2p_i2pd_I2PD_JNI.h"
|
|
|
|
#include "DaemonAndroid.h"
|
2017-04-21 13:33:45 +03:00
|
|
|
#include "RouterContext.h"
|
|
|
|
#include "Transports.h"
|
2016-07-09 23:54:11 +03:00
|
|
|
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
|
|
|
|
(JNIEnv * env, jclass clazz) {
|
|
|
|
#if defined(__arm__)
|
|
|
|
#if defined(__ARM_ARCH_7A__)
|
|
|
|
#if defined(__ARM_NEON__)
|
|
|
|
#if defined(__ARM_PCS_VFP)
|
|
|
|
#define ABI "armeabi-v7a/NEON (hard-float)"
|
|
|
|
#else
|
|
|
|
#define ABI "armeabi-v7a/NEON"
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#if defined(__ARM_PCS_VFP)
|
|
|
|
#define ABI "armeabi-v7a (hard-float)"
|
|
|
|
#else
|
|
|
|
#define ABI "armeabi-v7a"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define ABI "armeabi"
|
|
|
|
#endif
|
|
|
|
#elif defined(__i386__)
|
|
|
|
#define ABI "x86"
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
#define ABI "x86_64"
|
|
|
|
#elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */
|
|
|
|
#define ABI "mips64"
|
|
|
|
#elif defined(__mips__)
|
|
|
|
#define ABI "mips"
|
|
|
|
#elif defined(__aarch64__)
|
|
|
|
#define ABI "arm64-v8a"
|
|
|
|
#else
|
|
|
|
#define ABI "unknown"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return env->NewStringUTF(ABI);
|
|
|
|
}
|
|
|
|
|
2016-07-10 04:42:42 +03:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon
|
2016-07-09 23:54:11 +03:00
|
|
|
(JNIEnv * env, jclass clazz) {
|
2018-01-07 00:08:07 +03:00
|
|
|
|
2018-01-07 00:40:17 +03:00
|
|
|
int argc=5;
|
|
|
|
static char* argv[]={
|
|
|
|
strdup("i2pd"),
|
|
|
|
strdup("--conf=/sdcard/i2pd/i2pd.conf"),
|
|
|
|
strdup("--tunconf=/sdcard/i2pd/tunnels.conf"),
|
|
|
|
strdup("--datadir=/data/data/org.purplei2p.i2pd/app_data/"),
|
|
|
|
strdup("--service"), strdup("--daemon")
|
|
|
|
};
|
2018-01-07 00:08:07 +03:00
|
|
|
|
|
|
|
return env->NewStringUTF(i2p::android::start(argc,argv).c_str());
|
2016-07-09 23:54:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon
|
|
|
|
(JNIEnv * env, jclass clazz) {
|
|
|
|
i2p::android::stop();
|
|
|
|
}
|
|
|
|
|
2016-07-10 04:42:42 +03:00
|
|
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels
|
|
|
|
(JNIEnv * env, jclass clazz) {
|
|
|
|
i2p::context.SetAcceptsTunnels (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
|
2017-04-21 13:33:45 +03:00
|
|
|
(JNIEnv * env, jclass clazz, jboolean isConnected)
|
2016-07-13 17:09:22 +03:00
|
|
|
{
|
2016-07-10 04:42:42 +03:00
|
|
|
bool isConnectedBool = (bool) isConnected;
|
2017-04-21 13:33:45 +03:00
|
|
|
i2p::transport::transports.SetOnline (isConnectedBool);
|
2016-07-10 04:42:42 +03:00
|
|
|
}
|