mirror of
https://github.com/PurpleI2P/i2pd-android.git
synced 2025-02-09 05:14:24 +00:00
get webconsole address from daemon
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
404cb804bc
commit
f23335b1c1
@ -15,7 +15,7 @@ android {
|
|||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
versionCode 23500
|
versionCode 23500
|
||||||
versionName "2.35.0-113-g01df1647"
|
versionName "2.35.0-121-gaa206d03"
|
||||||
setProperty("archivesBaseName", archivesBaseName + "-" + versionName)
|
setProperty("archivesBaseName", archivesBaseName + "-" + versionName)
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 01df1647bcfe7a9b92a90b457fdf2683e338a4f9
|
Subproject commit aa206d034dfb744d9be28c5f0911061ebc33ead9
|
@ -1,114 +1,123 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2020, The PurpleI2P Project
|
* Copyright (c) 2013-2020, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
* See full license text in LICENSE file at top of project tree
|
* See full license text in LICENSE file at top of project tree
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include "org_purplei2p_i2pd_I2PD_JNI.h"
|
#include "org_purplei2p_i2pd_I2PD_JNI.h"
|
||||||
#include "DaemonAndroid.h"
|
#include "DaemonAndroid.h"
|
||||||
#include "RouterContext.h"
|
#include "Config.h"
|
||||||
#include "ClientContext.h"
|
#include "RouterContext.h"
|
||||||
#include "Transports.h"
|
#include "ClientContext.h"
|
||||||
#include "Tunnel.h"
|
#include "Transports.h"
|
||||||
|
#include "Tunnel.h"
|
||||||
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
|
||||||
#if defined(__arm__)
|
(JNIEnv *env, jclass clazz) {
|
||||||
#if defined(__ARM_ARCH_7A__)
|
#if defined(__arm__)
|
||||||
#if defined(__ARM_NEON__)
|
#if defined(__ARM_ARCH_7A__)
|
||||||
#if defined(__ARM_PCS_VFP)
|
#if defined(__ARM_NEON__)
|
||||||
#define ABI "armeabi-v7a/NEON (hard-float)"
|
#if defined(__ARM_PCS_VFP)
|
||||||
#else
|
#define ABI "armeabi-v7a/NEON (hard-float)"
|
||||||
#define ABI "armeabi-v7a/NEON"
|
#else
|
||||||
#endif
|
#define ABI "armeabi-v7a/NEON"
|
||||||
#else
|
#endif
|
||||||
#if defined(__ARM_PCS_VFP)
|
#else
|
||||||
#define ABI "armeabi-v7a (hard-float)"
|
#if defined(__ARM_PCS_VFP)
|
||||||
#else
|
#define ABI "armeabi-v7a (hard-float)"
|
||||||
#define ABI "armeabi-v7a"
|
#else
|
||||||
#endif
|
#define ABI "armeabi-v7a"
|
||||||
#endif
|
#endif
|
||||||
#else
|
#endif
|
||||||
#define ABI "armeabi"
|
#else
|
||||||
#endif
|
#define ABI "armeabi"
|
||||||
#elif defined(__i386__)
|
#endif
|
||||||
#define ABI "x86"
|
#elif defined(__i386__)
|
||||||
#elif defined(__x86_64__)
|
#define ABI "x86"
|
||||||
#define ABI "x86_64"
|
#elif defined(__x86_64__)
|
||||||
#elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */
|
#define ABI "x86_64"
|
||||||
#define ABI "mips64"
|
#elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */
|
||||||
#elif defined(__mips__)
|
#define ABI "mips64"
|
||||||
#define ABI "mips"
|
#elif defined(__mips__)
|
||||||
#elif defined(__aarch64__)
|
#define ABI "mips"
|
||||||
#define ABI "arm64-v8a"
|
#elif defined(__aarch64__)
|
||||||
#else
|
#define ABI "arm64-v8a"
|
||||||
#define ABI "unknown"
|
#else
|
||||||
#endif
|
#define ABI "unknown"
|
||||||
|
#endif
|
||||||
return env->NewStringUTF(ABI);
|
|
||||||
}
|
return env->NewStringUTF(ABI);
|
||||||
|
}
|
||||||
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon
|
||||||
return env->NewStringUTF(i2p::android::start().c_str());
|
(JNIEnv *env, jclass clazz) {
|
||||||
}
|
return env->NewStringUTF(i2p::android::start().c_str());
|
||||||
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon
|
||||||
i2p::android::stop();
|
(JNIEnv *env, jclass clazz) {
|
||||||
}
|
i2p::android::stop();
|
||||||
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels
|
||||||
i2p::context.SetAcceptsTunnels (false);
|
(JNIEnv *env, jclass clazz) {
|
||||||
}
|
i2p::context.SetAcceptsTunnels (false);
|
||||||
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startAcceptingTunnels
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startAcceptingTunnels
|
||||||
i2p::context.SetAcceptsTunnels (true);
|
(JNIEnv *env, jclass clazz) {
|
||||||
}
|
i2p::context.SetAcceptsTunnels (true);
|
||||||
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_reloadTunnelsConfigs
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_reloadTunnelsConfigs
|
||||||
i2p::client::context.ReloadConfig();
|
(JNIEnv *env, jclass clazz) {
|
||||||
}
|
i2p::client::context.ReloadConfig();
|
||||||
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
|
|
||||||
(JNIEnv *env, jclass clazz, jboolean isConnected) {
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
|
||||||
bool isConnectedBool = (bool) isConnected;
|
(JNIEnv *env, jclass clazz, jboolean isConnected) {
|
||||||
i2p::transport::transports.SetOnline (isConnectedBool);
|
bool isConnectedBool = (bool) isConnected;
|
||||||
}
|
i2p::transport::transports.SetOnline (isConnectedBool);
|
||||||
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
|
|
||||||
(JNIEnv *env, jclass clazz, jstring jdataDir) {
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
|
||||||
|
(JNIEnv *env, jclass clazz, jstring jdataDir) {
|
||||||
/*
|
|
||||||
// Method 1: convert UTF-16 jstring to std::string (https://stackoverflow.com/a/41820336)
|
/*
|
||||||
const jclass stringClass = env->GetObjectClass(jdataDir);
|
// Method 1: convert UTF-16 jstring to std::string (https://stackoverflow.com/a/41820336)
|
||||||
const jmethodID getBytes = env->GetMethodID(stringClass, "getBytes", "(Ljava/lang/String;)[B");
|
const jclass stringClass = env->GetObjectClass(jdataDir);
|
||||||
const jbyteArray stringJbytes = (jbyteArray) env->CallObjectMethod(jdataDir, getBytes, env->NewStringUTF("UTF-8"));
|
const jmethodID getBytes = env->GetMethodID(stringClass, "getBytes", "(Ljava/lang/String;)[B");
|
||||||
|
const jbyteArray stringJbytes = (jbyteArray) env->CallObjectMethod(jdataDir, getBytes, env->NewStringUTF("UTF-8"));
|
||||||
size_t length = (size_t) env->GetArrayLength(stringJbytes);
|
|
||||||
jbyte* pBytes = env->GetByteArrayElements(stringJbytes, NULL);
|
size_t length = (size_t) env->GetArrayLength(stringJbytes);
|
||||||
|
jbyte* pBytes = env->GetByteArrayElements(stringJbytes, NULL);
|
||||||
std::string dataDir = std::string((char *)pBytes, length);
|
|
||||||
env->ReleaseByteArrayElements(stringJbytes, pBytes, JNI_ABORT);
|
std::string dataDir = std::string((char *)pBytes, length);
|
||||||
|
env->ReleaseByteArrayElements(stringJbytes, pBytes, JNI_ABORT);
|
||||||
env->DeleteLocalRef(stringJbytes);
|
|
||||||
env->DeleteLocalRef(stringClass); */
|
env->DeleteLocalRef(stringJbytes);
|
||||||
|
env->DeleteLocalRef(stringClass); */
|
||||||
// Method 2: get string chars and make char array.
|
|
||||||
auto dataDir = env->GetStringUTFChars(jdataDir, NULL);
|
// Method 2: get string chars and make char array.
|
||||||
env->ReleaseStringUTFChars(jdataDir, dataDir);
|
auto dataDir = env->GetStringUTFChars(jdataDir, NULL);
|
||||||
|
env->ReleaseStringUTFChars(jdataDir, dataDir);
|
||||||
// Set DataDir
|
|
||||||
i2p::android::SetDataDir(dataDir);
|
// Set DataDir
|
||||||
}
|
i2p::android::SetDataDir(dataDir);
|
||||||
|
}
|
||||||
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
|
||||||
return i2p::tunnel::tunnels.CountTransitTunnels();
|
(JNIEnv *env, jclass clazz) {
|
||||||
}
|
return i2p::tunnel::tunnels.CountTransitTunnels();
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr
|
||||||
|
(JNIEnv *env, jclass clazz) {
|
||||||
|
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
|
||||||
|
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
|
||||||
|
std::string result = "http://" + httpAddr + ":" + std::to_string(httpPort) + "/";
|
||||||
|
return env->NewStringUTF(result.c_str());
|
||||||
|
}
|
||||||
|
@ -47,6 +47,9 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
|
|||||||
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
|
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
|
||||||
(JNIEnv *, jclass);
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,8 @@ public class I2PD_JNI {
|
|||||||
|
|
||||||
public static native int GetTransitTunnelsCount();
|
public static native int GetTransitTunnelsCount();
|
||||||
|
|
||||||
|
public static native String getWebConsAddr();
|
||||||
|
|
||||||
public static void loadLibraries() {
|
public static void loadLibraries() {
|
||||||
//System.loadLibrary("c++_shared");
|
//System.loadLibrary("c++_shared");
|
||||||
System.loadLibrary("i2pd");
|
System.loadLibrary("i2pd");
|
||||||
|
@ -28,7 +28,7 @@ public class WebConsoleActivity extends Activity {
|
|||||||
final WebSettings webSettings = webView.getSettings();
|
final WebSettings webSettings = webView.getSettings();
|
||||||
webSettings.setBuiltInZoomControls(true);
|
webSettings.setBuiltInZoomControls(true);
|
||||||
webSettings.setJavaScriptEnabled(false);
|
webSettings.setJavaScriptEnabled(false);
|
||||||
webView.loadUrl("http://127.0.0.1:7070"); // TODO: instead 7070 I2Pd....HttpPort
|
webView.loadUrl(I2PD_JNI.getWebConsAddr());
|
||||||
|
|
||||||
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
|
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
|
||||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user