mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-07-21 22:20:34 +02:00
Cancel Graceful Stop
This commit is contained in:
parent
71e57717c2
commit
7c1961d4ef
6 changed files with 54 additions and 5 deletions
|
@ -33,6 +33,13 @@ public class DaemonSingleton {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void startAcceptingTunnels() {
|
||||
if(isStartedOkay()){
|
||||
setState(State.startedOkay);
|
||||
I2PD_JNI.startAcceptingTunnels();
|
||||
}
|
||||
}
|
||||
|
||||
private volatile boolean startedOkay;
|
||||
|
||||
public enum State {
|
||||
|
|
|
@ -144,14 +144,10 @@ public class I2PDActivity extends Activity {
|
|||
case MY_PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE:
|
||||
{
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
Log.e(TAG, "Memory permission granted");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e(TAG, "Memory permission declined");
|
||||
// TODO: terminate
|
||||
}
|
||||
return;
|
||||
}
|
||||
default: ;
|
||||
|
@ -244,7 +240,16 @@ public class I2PDActivity extends Activity {
|
|||
i2pdStop();
|
||||
return true;
|
||||
case R.id.action_graceful_stop:
|
||||
i2pdGracefulStop();
|
||||
if (getGracefulQuitTimer()!= null)
|
||||
{
|
||||
item.setTitle(R.string.action_graceful_stop);
|
||||
i2pdCancelGracefulStop ();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setTitle(R.string.action_cancel_graceful_stop);
|
||||
i2pdGracefulStop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -307,6 +312,32 @@ public class I2PDActivity extends Activity {
|
|||
|
||||
},"gracInit").start();
|
||||
}
|
||||
|
||||
private void i2pdCancelGracefulStop()
|
||||
{
|
||||
cancelGracefulStop();
|
||||
Toast.makeText(this, R.string.startedOkay, Toast.LENGTH_SHORT).show();
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.d(TAG, "grac stopping cancel");
|
||||
if(daemon.isStartedOkay())
|
||||
daemon.startAcceptingTunnels();
|
||||
else
|
||||
i2pdStop();
|
||||
}
|
||||
catch(Throwable tr)
|
||||
{
|
||||
Log.e(TAG,"",tr);
|
||||
}
|
||||
}
|
||||
|
||||
},"gracCancel").start();
|
||||
}
|
||||
|
||||
private void rescheduleGraceStop(Timer gracefulQuitTimerOld, long gracefulStopAtMillis) {
|
||||
if(gracefulQuitTimerOld!=null)gracefulQuitTimerOld.cancel();
|
||||
|
|
|
@ -12,6 +12,8 @@ public class I2PD_JNI {
|
|||
|
||||
public static native void stopAcceptingTunnels();
|
||||
|
||||
public static native void startAcceptingTunnels();
|
||||
|
||||
public static native void onNetworkStateChanged(boolean isConnected);
|
||||
|
||||
public static void loadLibraries() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue