Browse Source

code cleanup

pull/1064/head^2
unlnown542a 7 years ago
parent
commit
4c6988e3bc
  1. 5
      android/build.gradle
  2. 2
      android/gradle.properties
  3. 15
      android/src/org/purplei2p/i2pd/DaemonSingleton.java
  4. 13
      android/src/org/purplei2p/i2pd/ForegroundService.java
  5. 2
      android/src/org/purplei2p/i2pd/I2PD.java

5
android/build.gradle

@ -46,6 +46,11 @@ android { @@ -46,6 +46,11 @@ android {
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
options.deprecation = true
}
task zipCerts(type:Zip) {
from (files('../contrib/'))
include 'certificates/**/*.crt'

2
android/gradle.properties

@ -1 +1 @@ @@ -1 +1 @@
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048M -XX:MaxPermSize=256M -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

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

@ -38,7 +38,7 @@ public class DaemonSingleton { @@ -38,7 +38,7 @@ public class DaemonSingleton {
public State getState() { return state; }
public synchronized void start() {
public synchronized void start(final String confDir, final String dataDir) {
if(state != State.uninitialized)return;
state = State.starting;
fireStateUpdate();
@ -62,13 +62,12 @@ public class DaemonSingleton { @@ -62,13 +62,12 @@ public class DaemonSingleton {
}
try {
synchronized (DaemonSingleton.this) {
String args[] = {
"i2pd",
"--conf=/sdcard/i2pd/i2pd.conf",
"--tunconf=/sdcard/i2pd/tunnels.conf",
"--datadir=/data/data/org.purplei2p.i2pd/app_data/",
"--service",
"--daemon"
String args[] = new String[] {
"i2pd", "--service", "--daemon",
"--datadir=" + dataDir,
"--conf=" + confDir + "/i2pd.conf",
"--tunconf=" + confDir + "/tunnels.conf"
};
daemonStartResult = I2PD_JNI.startDaemon(args);

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

@ -5,6 +5,8 @@ import android.app.NotificationManager; @@ -5,6 +5,8 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.Context;
import android.os.Environment;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
@ -28,13 +30,20 @@ public class ForegroundService extends Service { @@ -28,13 +30,20 @@ public class ForegroundService extends Service {
}
}
private String dataDir;
private String confDir;
@Override
public void onCreate() {
notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
dataDir = this.getDir("data", Context.MODE_PRIVATE).toString();
confDir = Environment.getExternalStoragePublicDirectory("i2pd").toString();
// Display a notification about us starting. We put an icon in the status bar.
showNotification();
daemon.start();
Log.i("ForegroundService", "About to start daemon with dataDir: " + dataDir + ", confDir: " + confDir);
daemon.start(confDir, dataDir);
// Tell the user we started.
Toast.makeText(this, R.string.i2pd_service_started, Toast.LENGTH_SHORT).show();
}
@ -42,7 +51,7 @@ public class ForegroundService extends Service { @@ -42,7 +51,7 @@ public class ForegroundService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("ForegroundService", "Received start id " + startId + ": " + intent);
daemon.start();
daemon.start(confDir, dataDir);
return START_STICKY;
}

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

@ -66,7 +66,7 @@ public class I2PD extends Activity { @@ -66,7 +66,7 @@ public class I2PD extends Activity {
super.onCreate(savedInstanceState);
//install certs every time
Decompress.unzipFromAssets(this, "certificates.zip", "/data/data/org.purplei2p.i2pd/app_data/");
Decompress.unzipFromAssets(this, "certificates.zip", this.getDir("data", Context.MODE_PRIVATE).toString() + "/" );
textView = new TextView(this);
setContentView(textView);

Loading…
Cancel
Save