mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	Revert "quit features replaced by stop; gradle upgraded; i2pd version name updated at build.gradle"
This commit is contained in:
		
							parent
							
								
									e5fdced4ac
								
							
						
					
					
						commit
						31df49a884
					
				
					 7 changed files with 50 additions and 45 deletions
				
			
		| 
						 | 
				
			
			@ -1,20 +1,20 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
      package="org.purplei2p.i2pd"
 | 
			
		||||
	  android:installLocation="auto"
 | 
			
		||||
      android:versionCode="1"
 | 
			
		||||
      android:versionName="2.18.0">
 | 
			
		||||
      android:versionName="2.18.0"
 | 
			
		||||
	  android:installLocation="auto">
 | 
			
		||||
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25"/>
 | 
			
		||||
	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 | 
			
		||||
    <uses-permission android:name="android.permission.INTERNET"/>
 | 
			
		||||
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 | 
			
		||||
	<application android:label="@string/app_name" android:allowBackup="true" android:icon="@drawable/icon" >
 | 
			
		||||
	<application android:label="@string/app_name" android:allowBackup="true" android:icon="@drawable/icon">
 | 
			
		||||
	    <receiver android:name=".NetworkStateChangeReceiver">
 | 
			
		||||
	        <intent-filter>
 | 
			
		||||
	            <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
 | 
			
		||||
	        </intent-filter>
 | 
			
		||||
	    </receiver>
 | 
			
		||||
	    <activity android:name=".I2PDActivity"
 | 
			
		||||
	    <activity android:name=".I2PD"
 | 
			
		||||
                  android:label="@string/app_name">
 | 
			
		||||
            <intent-filter>
 | 
			
		||||
                <action android:name="android.intent.action.MAIN" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ buildscript {
 | 
			
		|||
                jcenter()
 | 
			
		||||
        }
 | 
			
		||||
        dependencies {
 | 
			
		||||
                classpath 'com.android.tools.build:gradle:2.3.3'
 | 
			
		||||
                classpath 'com.android.tools.build:gradle:2.1.2'
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ android {
 | 
			
		|||
                targetSdkVersion 25
 | 
			
		||||
                minSdkVersion 14
 | 
			
		||||
                versionCode 1
 | 
			
		||||
                versionName "2.18.0"
 | 
			
		||||
                versionName "2.17.1"
 | 
			
		||||
        }
 | 
			
		||||
    sourceSets {
 | 
			
		||||
        main {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,15 +2,15 @@
 | 
			
		|||
    xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
    xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
			
		||||
    xmlns:tools="http://schemas.android.com/tools"
 | 
			
		||||
    tools:context=".I2PDActivity">
 | 
			
		||||
    tools:context=".I2PD">
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/action_graceful_stop"
 | 
			
		||||
        android:title="@string/action_graceful_stop"
 | 
			
		||||
        android:id="@+id/action_graceful_quit"
 | 
			
		||||
        android:title="@string/action_graceful_quit"
 | 
			
		||||
        android:orderInCategory="98"
 | 
			
		||||
        />
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/action_stop"
 | 
			
		||||
        android:title="@string/action_stop"
 | 
			
		||||
        android:id="@+id/action_quit"
 | 
			
		||||
        android:title="@string/action_quit"
 | 
			
		||||
        android:orderInCategory="99"
 | 
			
		||||
        />
 | 
			
		||||
</menu>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,9 +4,8 @@
 | 
			
		|||
    <string name="i2pd_started">i2pd started</string>
 | 
			
		||||
    <string name="i2pd_service_started">i2pd service started</string>
 | 
			
		||||
    <string name="i2pd_service_stopped">i2pd service stopped</string>
 | 
			
		||||
    <string name="action_stop">Stop</string>
 | 
			
		||||
    <string name="action_graceful_stop">Graceful Stop</string>
 | 
			
		||||
    <string name="graceful_stop_is_already_in_progress">Graceful stop is already in progress</string>
 | 
			
		||||
    <string name="graceful_stop_is_in_progress">Graceful stop is in progress</string>
 | 
			
		||||
    <string name="already_stopped">Already stopped</string>
 | 
			
		||||
    <string name="action_quit">Quit</string>
 | 
			
		||||
    <string name="action_graceful_quit">Graceful Quit</string>
 | 
			
		||||
    <string name="graceful_quit_is_already_in_progress">Graceful quit is already in progress</string>
 | 
			
		||||
    <string name="graceful_quit_is_in_progress">Graceful quit is in progress</string>
 | 
			
		||||
</resources>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ public class DaemonSingleton {
 | 
			
		|||
 | 
			
		||||
	private boolean startedOkay;
 | 
			
		||||
 | 
			
		||||
	public static enum State {uninitialized,starting,jniLibraryLoaded,startedOkay,startFailed,gracefulShutdownInProgress,stopped};
 | 
			
		||||
	public static enum State {uninitialized,starting,jniLibraryLoaded,startedOkay,startFailed,gracefulShutdownInProgress};
 | 
			
		||||
 | 
			
		||||
	private State state = State.uninitialized;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -121,10 +121,6 @@ public class DaemonSingleton {
 | 
			
		|||
		if(isStartedOkay()){
 | 
			
		||||
			try {I2PD_JNI.stopDaemon();}catch(Throwable tr){Log.e(TAG, "", tr);}
 | 
			
		||||
			setStartedOkay(false);
 | 
			
		||||
			synchronized (DaemonSingleton.this) {
 | 
			
		||||
				state = State.stopped;
 | 
			
		||||
				fireStateUpdate();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,7 +75,7 @@ public class ForegroundService extends Service {
 | 
			
		|||
 | 
			
		||||
        // The PendingIntent to launch our activity if the user selects this notification
 | 
			
		||||
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
 | 
			
		||||
                new Intent(this, I2PDActivity.class), 0);
 | 
			
		||||
                new Intent(this, I2PD.class), 0);
 | 
			
		||||
 | 
			
		||||
        // Set the info for the views that show in the notification panel.
 | 
			
		||||
        Notification notification = new Notification.Builder(this)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,11 +5,13 @@ import java.io.StringWriter;
 | 
			
		|||
import java.util.Timer;
 | 
			
		||||
import java.util.TimerTask;
 | 
			
		||||
 | 
			
		||||
import android.annotation.SuppressLint;
 | 
			
		||||
import android.app.Activity;
 | 
			
		||||
import android.content.ComponentName;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.content.ServiceConnection;
 | 
			
		||||
import android.os.Build;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.os.IBinder;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +20,7 @@ import android.view.MenuItem;
 | 
			
		|||
import android.widget.TextView;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
public class I2PDActivity extends Activity {
 | 
			
		||||
public class I2PD extends Activity {
 | 
			
		||||
	private static final String TAG = "i2pd";
 | 
			
		||||
 | 
			
		||||
	private TextView textView;
 | 
			
		||||
| 
						 | 
				
			
			@ -79,11 +81,11 @@ public class I2PDActivity extends Activity {
 | 
			
		|||
			gracefulQuitTimer.cancel();
 | 
			
		||||
			setGracefulQuitTimer(null);
 | 
			
		||||
		}
 | 
			
		||||
//		try{
 | 
			
		||||
//            doUnbindService();
 | 
			
		||||
//		}catch(Throwable tr){
 | 
			
		||||
//			Log.e(TAG, "", tr);
 | 
			
		||||
//		}
 | 
			
		||||
		try{
 | 
			
		||||
            doUnbindService();
 | 
			
		||||
		}catch(Throwable tr){
 | 
			
		||||
			Log.e(TAG, "", tr);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private CharSequence throwableToString(Throwable tr) {
 | 
			
		||||
| 
						 | 
				
			
			@ -124,8 +126,7 @@ public class I2PDActivity extends Activity {
 | 
			
		|||
 | 
			
		||||
    private boolean mIsBound;
 | 
			
		||||
 | 
			
		||||
    private synchronized void doBindService() {
 | 
			
		||||
		if(mIsBound)return;
 | 
			
		||||
    private void doBindService() {
 | 
			
		||||
        // Establish a connection with the service.  We use an explicit
 | 
			
		||||
        // class name because we want a specific service implementation that
 | 
			
		||||
        // we know will be running in our own process (and thus won't be
 | 
			
		||||
| 
						 | 
				
			
			@ -158,39 +159,48 @@ public class I2PDActivity extends Activity {
 | 
			
		|||
		int id = item.getItemId();
 | 
			
		||||
 | 
			
		||||
		switch(id){
 | 
			
		||||
        case R.id.action_stop:
 | 
			
		||||
            i2pdStop();
 | 
			
		||||
        case R.id.action_quit:
 | 
			
		||||
            quit();
 | 
			
		||||
            return true;
 | 
			
		||||
        case R.id.action_graceful_stop:
 | 
			
		||||
            i2pdGracefulStop();
 | 
			
		||||
        case R.id.action_graceful_quit:
 | 
			
		||||
            gracefulQuit();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		return super.onOptionsItemSelected(item);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void i2pdStop() {
 | 
			
		||||
    @SuppressLint("NewApi")
 | 
			
		||||
	private void quit() {
 | 
			
		||||
        try {
 | 
			
		||||
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
 | 
			
		||||
                finishAndRemoveTask();
 | 
			
		||||
            } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
 | 
			
		||||
                finishAffinity();
 | 
			
		||||
            } else {
 | 
			
		||||
                //moveTaskToBack(true);
 | 
			
		||||
                finish();
 | 
			
		||||
            }
 | 
			
		||||
        }catch (Throwable tr) {
 | 
			
		||||
            Log.e(TAG, "", tr);
 | 
			
		||||
        }
 | 
			
		||||
        try{
 | 
			
		||||
            daemon.stopDaemon();
 | 
			
		||||
	    }catch (Throwable tr) {
 | 
			
		||||
	        Log.e(TAG, "", tr);
 | 
			
		||||
	    }
 | 
			
		||||
        System.exit(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Timer gracefulQuitTimer;
 | 
			
		||||
    private final Object gracefulQuitTimerLock = new Object();
 | 
			
		||||
    private synchronized void i2pdGracefulStop() {
 | 
			
		||||
        if(daemon.getState()==DaemonSingleton.State.stopped){
 | 
			
		||||
            Toast.makeText(this, R.string.already_stopped,
 | 
			
		||||
                    Toast.LENGTH_SHORT).show();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    private void gracefulQuit() {
 | 
			
		||||
    	if(getGracefulQuitTimer()!=null){
 | 
			
		||||
	        Toast.makeText(this, R.string.graceful_stop_is_already_in_progress,
 | 
			
		||||
	        Toast.makeText(this, R.string.graceful_quit_is_already_in_progress,
 | 
			
		||||
	        		Toast.LENGTH_SHORT).show();
 | 
			
		||||
    		return;
 | 
			
		||||
    	}
 | 
			
		||||
        Toast.makeText(this, R.string.graceful_stop_is_in_progress,
 | 
			
		||||
        Toast.makeText(this, R.string.graceful_quit_is_in_progress,
 | 
			
		||||
        		Toast.LENGTH_SHORT).show();
 | 
			
		||||
        new Thread(new Runnable(){
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -206,12 +216,12 @@ public class I2PDActivity extends Activity {
 | 
			
		|||
 | 
			
		||||
			    			@Override
 | 
			
		||||
			    			public void run() {
 | 
			
		||||
			    				i2pdStop();
 | 
			
		||||
			    				quit();
 | 
			
		||||
			    			}
 | 
			
		||||
 | 
			
		||||
			            }, 10*60*1000/*milliseconds*/);
 | 
			
		||||
			        }else{
 | 
			
		||||
			        	i2pdStop();
 | 
			
		||||
			        	quit();
 | 
			
		||||
			        }
 | 
			
		||||
				} catch(Throwable tr) {
 | 
			
		||||
					Log.e(TAG,"",tr);
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue