Browse Source

Merge pull request #1100 from PurpleI2P/revert-1099-revert-1090-openssl

Revert "Revert "quit features replaced by stop; gradle upgraded; i2pd version name updated at build.gradle""
pull/1101/head
orignal 7 years ago committed by GitHub
parent
commit
b6d838731f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      android/AndroidManifest.xml
  2. 4
      android/build.gradle
  3. 10
      android/res/menu/options_main.xml
  4. 9
      android/res/values/strings.xml
  5. 6
      android/src/org/purplei2p/i2pd/DaemonSingleton.java
  6. 2
      android/src/org/purplei2p/i2pd/ForegroundService.java
  7. 56
      android/src/org/purplei2p/i2pd/I2PDActivity.java

6
android/AndroidManifest.xml

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.purplei2p.i2pd" package="org.purplei2p.i2pd"
android:installLocation="auto"
android:versionCode="1" 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-sdk android:minSdkVersion="14" android:targetSdkVersion="25"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
@ -14,7 +14,7 @@
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/> <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<activity android:name=".I2PD" <activity android:name=".I2PDActivity"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

4
android/build.gradle

@ -4,7 +4,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.android.tools.build:gradle:2.3.3'
} }
} }
@ -18,7 +18,7 @@ android {
targetSdkVersion 25 targetSdkVersion 25
minSdkVersion 14 minSdkVersion 14
versionCode 1 versionCode 1
versionName "2.17.1" versionName "2.18.0"
} }
sourceSets { sourceSets {
main { main {

10
android/res/menu/options_main.xml

@ -2,15 +2,15 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context=".I2PD"> tools:context=".I2PDActivity">
<item <item
android:id="@+id/action_graceful_quit" android:id="@+id/action_graceful_stop"
android:title="@string/action_graceful_quit" android:title="@string/action_graceful_stop"
android:orderInCategory="98" android:orderInCategory="98"
/> />
<item <item
android:id="@+id/action_quit" android:id="@+id/action_stop"
android:title="@string/action_quit" android:title="@string/action_stop"
android:orderInCategory="99" android:orderInCategory="99"
/> />
</menu> </menu>

9
android/res/values/strings.xml

@ -4,8 +4,9 @@
<string name="i2pd_started">i2pd started</string> <string name="i2pd_started">i2pd started</string>
<string name="i2pd_service_started">i2pd service started</string> <string name="i2pd_service_started">i2pd service started</string>
<string name="i2pd_service_stopped">i2pd service stopped</string> <string name="i2pd_service_stopped">i2pd service stopped</string>
<string name="action_quit">Quit</string> <string name="action_stop">Stop</string>
<string name="action_graceful_quit">Graceful Quit</string> <string name="action_graceful_stop">Graceful Stop</string>
<string name="graceful_quit_is_already_in_progress">Graceful quit is already in progress</string> <string name="graceful_stop_is_already_in_progress">Graceful stop is already in progress</string>
<string name="graceful_quit_is_in_progress">Graceful quit is in progress</string> <string name="graceful_stop_is_in_progress">Graceful stop is in progress</string>
<string name="already_stopped">Already stopped</string>
</resources> </resources>

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

@ -32,7 +32,7 @@ public class DaemonSingleton {
private boolean startedOkay; private boolean startedOkay;
public static enum State {uninitialized,starting,jniLibraryLoaded,startedOkay,startFailed,gracefulShutdownInProgress}; public static enum State {uninitialized,starting,jniLibraryLoaded,startedOkay,startFailed,gracefulShutdownInProgress,stopped};
private State state = State.uninitialized; private State state = State.uninitialized;
@ -121,6 +121,10 @@ public class DaemonSingleton {
if(isStartedOkay()){ if(isStartedOkay()){
try {I2PD_JNI.stopDaemon();}catch(Throwable tr){Log.e(TAG, "", tr);} try {I2PD_JNI.stopDaemon();}catch(Throwable tr){Log.e(TAG, "", tr);}
setStartedOkay(false); setStartedOkay(false);
synchronized (DaemonSingleton.this) {
state = State.stopped;
fireStateUpdate();
}
} }
} }
} }

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

@ -75,7 +75,7 @@ public class ForegroundService extends Service {
// The PendingIntent to launch our activity if the user selects this notification // The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, I2PD.class), 0); new Intent(this, I2PDActivity.class), 0);
// Set the info for the views that show in the notification panel. // Set the info for the views that show in the notification panel.
Notification notification = new Notification.Builder(this) Notification notification = new Notification.Builder(this)

56
android/src/org/purplei2p/i2pd/I2PD.java → android/src/org/purplei2p/i2pd/I2PDActivity.java

@ -5,13 +5,11 @@ import java.io.StringWriter;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log; import android.util.Log;
@ -20,7 +18,7 @@ import android.view.MenuItem;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
public class I2PD extends Activity { public class I2PDActivity extends Activity {
private static final String TAG = "i2pd"; private static final String TAG = "i2pd";
private TextView textView; private TextView textView;
@ -81,11 +79,11 @@ public class I2PD extends Activity {
gracefulQuitTimer.cancel(); gracefulQuitTimer.cancel();
setGracefulQuitTimer(null); setGracefulQuitTimer(null);
} }
try{ // try{
doUnbindService(); // doUnbindService();
}catch(Throwable tr){ // }catch(Throwable tr){
Log.e(TAG, "", tr); // Log.e(TAG, "", tr);
} // }
} }
private CharSequence throwableToString(Throwable tr) { private CharSequence throwableToString(Throwable tr) {
@ -126,7 +124,8 @@ public class I2PD extends Activity {
private boolean mIsBound; private boolean mIsBound;
private void doBindService() { private synchronized void doBindService() {
if(mIsBound)return;
// Establish a connection with the service. We use an explicit // Establish a connection with the service. We use an explicit
// class name because we want a specific service implementation that // class name because we want a specific service implementation that
// we know will be running in our own process (and thus won't be // we know will be running in our own process (and thus won't be
@ -159,48 +158,39 @@ public class I2PD extends Activity {
int id = item.getItemId(); int id = item.getItemId();
switch(id){ switch(id){
case R.id.action_quit: case R.id.action_stop:
quit(); i2pdStop();
return true; return true;
case R.id.action_graceful_quit: case R.id.action_graceful_stop:
gracefulQuit(); i2pdGracefulStop();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@SuppressLint("NewApi") private void i2pdStop() {
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{ try{
daemon.stopDaemon(); daemon.stopDaemon();
}catch (Throwable tr) { }catch (Throwable tr) {
Log.e(TAG, "", tr); Log.e(TAG, "", tr);
} }
System.exit(0);
} }
private Timer gracefulQuitTimer; private Timer gracefulQuitTimer;
private final Object gracefulQuitTimerLock = new Object(); private final Object gracefulQuitTimerLock = new Object();
private void gracefulQuit() { private synchronized void i2pdGracefulStop() {
if(daemon.getState()==DaemonSingleton.State.stopped){
Toast.makeText(this, R.string.already_stopped,
Toast.LENGTH_SHORT).show();
return;
}
if(getGracefulQuitTimer()!=null){ if(getGracefulQuitTimer()!=null){
Toast.makeText(this, R.string.graceful_quit_is_already_in_progress, Toast.makeText(this, R.string.graceful_stop_is_already_in_progress,
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
return; return;
} }
Toast.makeText(this, R.string.graceful_quit_is_in_progress, Toast.makeText(this, R.string.graceful_stop_is_in_progress,
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
new Thread(new Runnable(){ new Thread(new Runnable(){
@ -216,12 +206,12 @@ public class I2PD extends Activity {
@Override @Override
public void run() { public void run() {
quit(); i2pdStop();
} }
}, 10*60*1000/*milliseconds*/); }, 10*60*1000/*milliseconds*/);
}else{ }else{
quit(); i2pdStop();
} }
} catch(Throwable tr) { } catch(Throwable tr) {
Log.e(TAG,"",tr); Log.e(TAG,"",tr);
Loading…
Cancel
Save