1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-03-10 01:01:02 +00:00

code cleanup

This commit is contained in:
unlnown542a 2018-01-18 19:35:37 +03:00
parent 0bd4db4cc7
commit 4c6988e3bc
5 changed files with 26 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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