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