diff --git a/android/src/network/loki/lokinet/LokiNetActivity.java b/android/src/network/loki/lokinet/LokiNetActivity.java index b299a94fd..8654d676b 100755 --- a/android/src/network/loki/lokinet/LokiNetActivity.java +++ b/android/src/network/loki/lokinet/LokiNetActivity.java @@ -33,20 +33,16 @@ import android.widget.TextView; public class LokiNetActivity extends Activity { private static final String TAG = "lokinet-activity"; private TextView textView; - private static final String DefaultBootstrapURL = "https://i2p.rocks/bootstrap.signed"; + private static final String DefaultBootstrapURL = "https://seed.lokinet.org/bootstrap.signed"; private AsyncBootstrap bootstrapper; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - // copy assets - //String conf = copyFileAsset("daemon.ini"); textView = new TextView(this); setContentView(textView); - - Lokinet_JNI.loadLibraries(); + System.loadLibrary("lokinetandroid"); } diff --git a/android/src/network/loki/lokinet/LokinetService.java b/android/src/network/loki/lokinet/LokinetService.java index 9030a1f21..7dbae6236 100644 --- a/android/src/network/loki/lokinet/LokinetService.java +++ b/android/src/network/loki/lokinet/LokinetService.java @@ -5,4 +5,5 @@ import android.net.VpnService; public class LokinetService extends VpnService { + } diff --git a/android/src/network/loki/lokinet/Lokinet_JNI.java b/android/src/network/loki/lokinet/Lokinet_JNI.java deleted file mode 100644 index a5d3cda40..000000000 --- a/android/src/network/loki/lokinet/Lokinet_JNI.java +++ /dev/null @@ -1,44 +0,0 @@ -package network.loki.lokinet; - -public class Lokinet_JNI { - - public static final String STATUS_OK = "ok"; - - public static native String getABICompiledWith(); - - /** - * returns error info if failed - * returns "ok" if daemon initialized and started okay - */ - public static native String startLokinet(String config); - - /** - * stop daemon if running - */ - public static native void stopLokinet(); - - /** get interface address we want */ - public static native String getIfAddr(); - - /** get interface address range we want */ - public static native int getIfRange(); - - /** - * change network status - */ - public static native void onNetworkStateChanged(boolean isConnected); - - /** - * set vpn network interface fd pair - * @param rfd the file descriptor of read end - * @param wfd the file descriptor of the write end - */ - public static native void setVPNFileDescriptor(int rfd, int wfd); - - /** - * load jni libraries - */ - public static void loadLibraries() { - System.loadLibrary("lokinetandroid"); - } -} diff --git a/jni/lokinet_android.cpp b/jni/lokinet_android.cpp index 2ecc41243..4c4cc0ac4 100644 --- a/jni/lokinet_android.cpp +++ b/jni/lokinet_android.cpp @@ -39,10 +39,10 @@ struct AndroidMain { if(m_impl || m_thread) return true; - m_impl = llarp_main_init(configFile.c_str(), true); + m_impl = llarp_main_default_init(); if(m_impl == nullptr) return false; - if(llarp_main_setup(m_impl, false)) + if(llarp_main_setup(m_impl)) { llarp_main_free(m_impl); m_impl = nullptr; @@ -63,7 +63,8 @@ struct AndroidMain void Run() { - if(llarp_main_run(m_impl)) + llarp_main_runtime_opts opts; + if(llarp_main_run(m_impl, opts)) { // on error llarp::LogError("daemon run fail"); @@ -74,50 +75,6 @@ struct AndroidMain } } - const char* - GetIfAddr() - { - std::string addr; - if(m_impl) - { - auto* ctx = llarp_main_get_context(m_impl); - if(!ctx) - return ""; - - ctx->router->hiddenServiceContext().ForEachService( - [&addr](const std::string&, - const llarp::service::Endpoint_ptr& ep) -> bool { - if(addr.empty()) - { - if(ep->HasIfAddr()) - { - // TODO: v4 - const auto ip = ep->GetIfAddr(); - if(ip.h) - { - addr = ip.ToString(); - return false; - } - } - } - return true; - }); - } - return addr.c_str(); - } - - int - GetIfRange() const - { - if(m_impl) - { - auto* ctx = llarp_main_get_context(m_impl); - if(!ctx) - return -1; - } - return -1; - } - void SetVPN_FD(int rfd, int wfd) { @@ -200,19 +157,13 @@ extern "C" JNIEXPORT jstring JNICALL Java_network_loki_lokinet_Lokinet_1JNI_getIfAddr(JNIEnv* env, jclass) { - if(daemon_ptr) - return env->NewStringUTF(daemon_ptr->GetIfAddr()); - else - return env->NewStringUTF(""); + return env->NewStringUTF(""); } JNIEXPORT jint JNICALL Java_network_loki_lokinet_Lokinet_1JNI_getIfRange(JNIEnv*, jclass) { - if(daemon_ptr) - return daemon_ptr->GetIfRange(); - else - return -1; + return -1; } JNIEXPORT void JNICALL