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. 17
      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 {
} }
} }
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
options.deprecation = true
}
task zipCerts(type:Zip) { task zipCerts(type:Zip) {
from (files('../contrib/')) from (files('../contrib/'))
include 'certificates/**/*.crt' include 'certificates/**/*.crt'

2
android/gradle.properties

@ -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

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

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

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

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

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

@ -66,7 +66,7 @@ public class I2PD extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
//install certs every time //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); textView = new TextView(this);
setContentView(textView); setContentView(textView);

Loading…
Cancel
Save