Browse Source

[android] stop immediatly if no transit tunnels available while graceful shutdown

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1515/head
R4SAS 5 years ago
parent
commit
c0de9455bb
  1. 6
      android/jni/i2pd_android.cpp
  2. 3
      android/jni/org_purplei2p_i2pd_I2PD_JNI.h
  3. 4
      android/src/org/purplei2p/i2pd/DaemonSingleton.java
  4. 5
      android/src/org/purplei2p/i2pd/I2PDActivity.java
  5. 2
      android/src/org/purplei2p/i2pd/I2PD_JNI.java

6
android/jni/i2pd_android.cpp

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "RouterContext.h"
#include "ClientContext.h"
#include "Transports.h"
#include "Tunnel.h"
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
(JNIEnv *env, jclass clazz) {
@ -98,3 +99,8 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir @@ -98,3 +99,8 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
// Set DataDir
i2p::android::SetDataDir(dataDir);
}
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
(JNIEnv *env, jclass clazz) {
return i2p::tunnel::tunnels.CountTransitTunnels();
}

3
android/jni/org_purplei2p_i2pd_I2PD_JNI.h

@ -36,6 +36,9 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged @@ -36,6 +36,9 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
(JNIEnv *env, jclass clazz, jstring jdataDir);
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif

4
android/src/org/purplei2p/i2pd/DaemonSingleton.java

@ -65,6 +65,10 @@ public class DaemonSingleton { @@ -65,6 +65,10 @@ public class DaemonSingleton {
}
}
public synchronized int GetTransitTunnelsCount() {
return I2PD_JNI.GetTransitTunnelsCount();
}
private volatile boolean startedOkay;
public enum State {

5
android/src/org/purplei2p/i2pd/I2PDActivity.java

@ -373,6 +373,11 @@ public class I2PDActivity extends Activity { @@ -373,6 +373,11 @@ public class I2PDActivity extends Activity {
if (gracefulQuitTimerOld != null)
gracefulQuitTimerOld.cancel();
if(daemon.GetTransitTunnelsCount() <= 0) { // no tunnels left
Log.d(TAG, "no transit tunnels left, stopping");
i2pdStop();
}
final Timer gracefulQuitTimer = new Timer(true);
setGracefulQuitTimer(gracefulQuitTimer);
gracefulQuitTimer.schedule(new TimerTask() {

2
android/src/org/purplei2p/i2pd/I2PD_JNI.java

@ -22,6 +22,8 @@ public class I2PD_JNI { @@ -22,6 +22,8 @@ public class I2PD_JNI {
public static native void setDataDir(String jdataDir);
public static native int GetTransitTunnelsCount();
public static void loadLibraries() {
//System.loadLibrary("c++_shared");
System.loadLibrary("i2pd");

Loading…
Cancel
Save