I2P Android integration

This commit is contained in:
str4d
2014-06-04 10:28:29 +00:00
parent c0f69852b2
commit ea4a1f5f9f
6 changed files with 246 additions and 9 deletions

View File

@@ -6,20 +6,21 @@ import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.RouterLaunch;
import i2p.bote.I2PBote;
import i2p.bote.android.service.Init.RouterChoice;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
public class BoteService extends Service {
boolean mUseInternalRouter;
public static final String ROUTER_CHOICE = "router_choice";
RouterChoice mRouterChoice;
RouterContext mRouterContext;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Init from settings
Init init = new Init(this);
mUseInternalRouter = init.initialize();
if (mUseInternalRouter)
mRouterChoice = (RouterChoice) intent.getSerializableExtra(ROUTER_CHOICE);
if (mRouterChoice == RouterChoice.INTERNAL)
new Thread(new RouterStarter()).start();
I2PBote.getInstance().startUp();
return START_STICKY;
@@ -33,10 +34,15 @@ public class BoteService extends Service {
@Override
public void onDestroy() {
I2PBote.getInstance().shutDown();
if (mUseInternalRouter)
if (mRouterChoice == RouterChoice.INTERNAL)
new Thread(new RouterStopper()).start();
}
//
// Internal router helpers
//
private class RouterStarter implements Runnable {
public void run() {
RouterLaunch.main(null);