From 4da63b38007d27f666748748ce904d319a874d46 Mon Sep 17 00:00:00 2001
From: Ernir Erlingsson <ernir@ymirmobile.com>
Date: Sun, 13 Mar 2016 22:31:14 +0100
Subject: [PATCH] Modified the project structure, removed module extension and
 went instead for a non-complete core dependency graph

---
 briar-android/build.gradle                    |   3 +
 .../android/AndroidComponent.java             |  37 ++++++-
 .../briarproject/android/AndroidModule.java   |  72 +++++++++++-
 .../AndroidNotificationManagerImpl.java       |  24 ++--
 .../org/briarproject/android/AppModule.java   |   4 +-
 .../android/ApplicationScope.java             |  11 --
 .../android/BriarApplication.java             |  17 +--
 .../briarproject/android/BriarService.java    |   6 +-
 .../android/NavDrawerActivity.java            |   3 +-
 .../android/ReferenceManagerImpl.java         |   2 +-
 .../briarproject/android/SetupActivity.java   |   2 +-
 .../android/SplashScreenActivity.java         |   3 +-
 .../android/api/AndroidExecutor.java          |   4 +-
 .../api}/AndroidNotificationManager.java      |   2 +-
 .../android/api}/ReferenceManager.java        |   2 +-
 .../android/contact/ConversationActivity.java |   3 +-
 .../android/forum/ForumActivity.java          |   2 +-
 .../invitation/AddContactActivity.java        |   2 +-
 .../android/panic/PanicResponderActivity.java |   5 +-
 .../plugins/AndroidPluginsModule.java         |  61 +++++++++++
 .../plugins/PluginsModuleExtension.java       |  59 ++++------
 .../plugins/droidtooth/DroidtoothPlugin.java  |   2 +-
 .../droidtooth/DroidtoothPluginFactory.java   |   2 +-
 .../system/AndroidExecutorImpl.java           |   6 +-
 .../system/AndroidSystemModule.java           |  29 +++++
 .../system/PlatformModuleExtension.java       |  78 -------------
 .../system/SystemModuleExtension.java         |  32 ------
 .../src/org/briarproject/CoreComponent.java   | 103 ------------------
 .../org/briarproject/CoreEagerSingletons.java |  24 ++--
 .../src/org/briarproject/CoreModule.java      |  45 ++++++++
 .../src/org/briarproject/PlatformModule.java  |  36 ------
 .../briarproject/plugins/PluginsModule.java   |  22 +---
 .../org/briarproject/system/SystemModule.java |   9 --
 33 files changed, 314 insertions(+), 398 deletions(-)
 delete mode 100644 briar-android/src/org/briarproject/android/ApplicationScope.java
 rename briar-api/src/org/briarproject/api/android/PlatformExecutor.java => briar-android/src/org/briarproject/android/api/AndroidExecutor.java (85%)
 rename {briar-api/src/org/briarproject/api/android => briar-android/src/org/briarproject/android/api}/AndroidNotificationManager.java (91%)
 rename {briar-api/src/org/briarproject/api/android => briar-android/src/org/briarproject/android/api}/ReferenceManager.java (95%)
 create mode 100644 briar-android/src/org/briarproject/plugins/AndroidPluginsModule.java
 create mode 100644 briar-android/src/org/briarproject/system/AndroidSystemModule.java
 delete mode 100644 briar-android/src/org/briarproject/system/PlatformModuleExtension.java
 delete mode 100644 briar-android/src/org/briarproject/system/SystemModuleExtension.java
 delete mode 100644 briar-core/src/org/briarproject/CoreComponent.java
 create mode 100644 briar-core/src/org/briarproject/CoreModule.java
 delete mode 100644 briar-core/src/org/briarproject/PlatformModule.java

diff --git a/briar-android/build.gradle b/briar-android/build.gradle
index 81228e9186..ac93551175 100644
--- a/briar-android/build.gradle
+++ b/briar-android/build.gradle
@@ -97,4 +97,7 @@ android {
 	lintOptions {
 		abortOnError false
 	}
+}
+dependencies {
+	compile 'cglib:cglib-nodep:3.1'
 }
\ No newline at end of file
diff --git a/briar-android/src/org/briarproject/android/AndroidComponent.java b/briar-android/src/org/briarproject/android/AndroidComponent.java
index 27f156e915..e182b9a47f 100644
--- a/briar-android/src/org/briarproject/android/AndroidComponent.java
+++ b/briar-android/src/org/briarproject/android/AndroidComponent.java
@@ -1,6 +1,7 @@
 package org.briarproject.android;
 
-import org.briarproject.CoreComponent;
+import org.briarproject.CoreEagerSingletons;
+import org.briarproject.CoreModule;
 import org.briarproject.android.contact.ContactListFragment;
 import org.briarproject.android.contact.ConversationActivity;
 import org.briarproject.android.forum.AvailableForumsActivity;
@@ -15,33 +16,59 @@ import org.briarproject.android.identity.CreateIdentityActivity;
 import org.briarproject.android.invitation.AddContactActivity;
 import org.briarproject.android.panic.PanicPreferencesActivity;
 import org.briarproject.android.panic.PanicResponderActivity;
+import org.briarproject.plugins.AndroidPluginsModule;
+import org.briarproject.system.AndroidSystemModule;
+
+import javax.inject.Singleton;
 
 import dagger.Component;
-@ApplicationScope
+
+@Singleton
 @Component(
-		dependencies = {CoreComponent.class},
-		modules = {AppModule.class, AndroidModule.class})
-public interface AndroidComponent {
+		modules = {CoreModule.class, AppModule.class, AndroidModule.class,
+				AndroidPluginsModule.class, AndroidSystemModule.class})
+public interface AndroidComponent extends CoreEagerSingletons {
+
 	void inject(SplashScreenActivity activity);
+
 	void inject(SetupActivity activity);
+
 	void inject(NavDrawerActivity activity);
+
 	void inject(PasswordActivity activity);
+
 	void inject(BriarService activity);
+
 	void inject(PanicResponderActivity activity);
+
 	void inject(PanicPreferencesActivity activity);
+
 	void inject(AddContactActivity activity);
+
 	void inject(ConversationActivity activity);
+
 	void inject(CreateIdentityActivity activity);
+
 	void inject(TestingActivity activity);
+
 	void inject(AvailableForumsActivity activity);
+
 	void inject(WriteForumPostActivity activity);
+
 	void inject(CreateForumActivity activity);
+
 	void inject(ShareForumActivity activity);
+
 	void inject(ReadForumPostActivity activity);
+
 	void inject(ForumActivity activity);
+
 	void inject(ContactListFragment fragment);
+
 	void inject(SettingsFragment fragment);
+
 	void inject(ForumListFragment fragment);
+
 	// Eager singleton load
 	void inject(AndroidModule.EagerSingletons init);
 
diff --git a/briar-android/src/org/briarproject/android/AndroidModule.java b/briar-android/src/org/briarproject/android/AndroidModule.java
index 53ea73f15b..d3a7d8a4d5 100644
--- a/briar-android/src/org/briarproject/android/AndroidModule.java
+++ b/briar-android/src/org/briarproject/android/AndroidModule.java
@@ -1,11 +1,20 @@
 package org.briarproject.android;
 
-import org.briarproject.api.android.AndroidNotificationManager;
-import org.briarproject.api.android.ReferenceManager;
+import android.app.Application;
+import android.content.Context;
+
+import org.briarproject.android.api.AndroidNotificationManager;
+import org.briarproject.android.api.ReferenceManager;
+import org.briarproject.api.crypto.SecretKey;
+import org.briarproject.api.db.DatabaseConfig;
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.lifecycle.LifecycleManager;
+import org.briarproject.api.ui.UiCallback;
+
+import java.io.File;
 
 import javax.inject.Inject;
+import javax.inject.Singleton;
 
 import dagger.Module;
 import dagger.Provides;
@@ -18,14 +27,69 @@ public class AndroidModule {
 		AndroidNotificationManager androidNotificationManager;
 	}
 
+	private final UiCallback uiCallback;
+
+	public AndroidModule() {
+		// Use a dummy UI callback
+		uiCallback = new UiCallback() {
+
+			public int showChoice(String[] options, String... message) {
+				throw new UnsupportedOperationException();
+			}
+
+			public boolean showConfirmationMessage(String... message) {
+				throw new UnsupportedOperationException();
+			}
+
+			public void showMessage(String... message) {
+				throw new UnsupportedOperationException();
+			}
+		};
+	}
+
+	@Provides
+	public UiCallback provideUICallback() {
+		return uiCallback;
+	}
+
+	@Provides
+	@Singleton
+	public DatabaseConfig provideDatabaseConfig(Application app) {
+		final File dir = app.getApplicationContext().getDir("db", Context.MODE_PRIVATE);
+		return new DatabaseConfig() {
+
+			private volatile SecretKey key = null;
+
+			public boolean databaseExists() {
+				return dir.isDirectory() && dir.listFiles().length > 0;
+			}
+
+			public File getDatabaseDirectory() {
+				return dir;
+			}
+
+			public void setEncryptionKey(SecretKey key) {
+				this.key = key;
+			}
+
+			public SecretKey getEncryptionKey() {
+				return key;
+			}
+
+			public long getMaxSize() {
+				return Long.MAX_VALUE;
+			}
+		};
+	}
+
 	@Provides
-	@ApplicationScope
+	@Singleton
 	ReferenceManager provideReferenceManager() {
 		return new ReferenceManagerImpl();
 	}
 
 	@Provides
-	@ApplicationScope
+	@Singleton
 	AndroidNotificationManager provideAndroidNotificationManager(
 			LifecycleManager lifecycleManager, EventBus eventBus,
 			AndroidNotificationManagerImpl notificationManager) {
diff --git a/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java b/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java
index 64ae4e90e3..172c998d10 100644
--- a/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java
+++ b/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java
@@ -12,8 +12,8 @@ import android.support.v4.app.TaskStackBuilder;
 import org.briarproject.R;
 import org.briarproject.android.contact.ConversationActivity;
 import org.briarproject.android.forum.ForumActivity;
-import org.briarproject.api.android.PlatformExecutor;
-import org.briarproject.api.android.AndroidNotificationManager;
+import org.briarproject.android.api.AndroidExecutor;
+import org.briarproject.android.api.AndroidNotificationManager;
 import org.briarproject.api.db.DatabaseExecutor;
 import org.briarproject.api.db.DbException;
 import org.briarproject.api.event.Event;
@@ -65,7 +65,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	private final SettingsManager settingsManager;
 	private final MessagingManager messagingManager;
 	private final ForumManager forumManager;
-	private final PlatformExecutor platformExecutor;
+	private final AndroidExecutor androidExecutor;
 	private final Context appContext;
 
 	// The following must only be accessed on the main UI thread
@@ -82,13 +82,13 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	@Inject
 	public AndroidNotificationManagerImpl(@DatabaseExecutor Executor dbExecutor,
 			SettingsManager settingsManager, MessagingManager messagingManager,
-			ForumManager forumManager, PlatformExecutor platformExecutor,
+			ForumManager forumManager, AndroidExecutor androidExecutor,
 			Application app) {
 		this.dbExecutor = dbExecutor;
 		this.settingsManager = settingsManager;
 		this.messagingManager = messagingManager;
 		this.forumManager = forumManager;
-		this.platformExecutor = platformExecutor;
+		this.androidExecutor = androidExecutor;
 		appContext = app.getApplicationContext();
 	}
 
@@ -118,7 +118,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	}
 
 	private void clearNotifications() {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				clearPrivateMessageNotification();
 				clearForumPostNotification();
@@ -155,7 +155,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	}
 
 	public void showPrivateMessageNotification(final GroupId g) {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				Integer count = contactCounts.get(g);
 				if (count == null) contactCounts.put(g, 1);
@@ -168,7 +168,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	}
 
 	public void clearPrivateMessageNotification(final GroupId g) {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				Integer count = contactCounts.remove(g);
 				if (count == null) return; // Already cleared
@@ -239,7 +239,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	}
 
 	public void showForumPostNotification(final GroupId g) {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				Integer count = forumCounts.get(g);
 				if (count == null) forumCounts.put(g, 1);
@@ -252,7 +252,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	}
 
 	public void clearForumPostNotification(final GroupId g) {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				Integer count = forumCounts.remove(g);
 				if (count == null) return; // Already cleared
@@ -311,7 +311,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	}
 
 	public void blockNotification(final GroupId g) {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				visibleGroup = g;
 			}
@@ -319,7 +319,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
 	}
 
 	public void unblockNotification(final GroupId g) {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				if (g.equals(visibleGroup)) visibleGroup = null;
 			}
diff --git a/briar-android/src/org/briarproject/android/AppModule.java b/briar-android/src/org/briarproject/android/AppModule.java
index b48d752e34..53631803d5 100644
--- a/briar-android/src/org/briarproject/android/AppModule.java
+++ b/briar-android/src/org/briarproject/android/AppModule.java
@@ -2,6 +2,8 @@ package org.briarproject.android;
 
 import android.app.Application;
 
+import javax.inject.Singleton;
+
 import dagger.Module;
 import dagger.Provides;
 
@@ -15,7 +17,7 @@ public class AppModule {
 	}
 
 	@Provides
-	@ApplicationScope
+	@Singleton
 	Application providesApplication() {
 		return application;
 	}
diff --git a/briar-android/src/org/briarproject/android/ApplicationScope.java b/briar-android/src/org/briarproject/android/ApplicationScope.java
deleted file mode 100644
index ad1fb2a4aa..0000000000
--- a/briar-android/src/org/briarproject/android/ApplicationScope.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.briarproject.android;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-import javax.inject.Scope;
-
-@Scope
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ApplicationScope {
-}
diff --git a/briar-android/src/org/briarproject/android/BriarApplication.java b/briar-android/src/org/briarproject/android/BriarApplication.java
index 6a01e57fb8..a4a34720db 100644
--- a/briar-android/src/org/briarproject/android/BriarApplication.java
+++ b/briar-android/src/org/briarproject/android/BriarApplication.java
@@ -6,12 +6,7 @@ import java.util.logging.Logger;
 import android.app.Application;
 import android.content.Context;
 
-import org.briarproject.CoreComponent;
-import org.briarproject.CoreEagerSingletons;
-import org.briarproject.DaggerCoreComponent;
-import org.briarproject.plugins.PluginsModuleExtension;
-import org.briarproject.system.PlatformModuleExtension;
-import org.briarproject.system.SystemModuleExtension;
+import org.briarproject.CoreModule;
 
 public class BriarApplication extends Application {
 
@@ -30,20 +25,14 @@ public class BriarApplication extends Application {
 		CrashHandler newHandler = new CrashHandler(ctx, oldHandler);
 		Thread.setDefaultUncaughtExceptionHandler(newHandler);
 
-		CoreComponent coreComponent = DaggerCoreComponent.builder()
-				.systemModule(new SystemModuleExtension(this))
-				.platformModule(new PlatformModuleExtension(this))
-				.pluginsModule(new PluginsModuleExtension(this))
-				.build();
-
 		applicationComponent = DaggerAndroidComponent.builder()
 				.appModule(new AppModule(this))
-				.coreComponent(coreComponent)
+				.androidModule(new AndroidModule())
 				.build();
 
 		// We need to load the eager singletons directly after making the
 		// dependency graphs
-		CoreEagerSingletons.initEagerSingletons(coreComponent);
+		CoreModule.initEagerSingletons(applicationComponent);
 		AndroidEagerSingletons.initEagerSingletons(applicationComponent);
 	}
 
diff --git a/briar-android/src/org/briarproject/android/BriarService.java b/briar-android/src/org/briarproject/android/BriarService.java
index 2a2bd6522f..06a09cce19 100644
--- a/briar-android/src/org/briarproject/android/BriarService.java
+++ b/briar-android/src/org/briarproject/android/BriarService.java
@@ -12,7 +12,7 @@ import android.os.IBinder;
 import android.support.v4.app.NotificationCompat;
 
 import org.briarproject.R;
-import org.briarproject.api.android.PlatformExecutor;
+import org.briarproject.android.api.AndroidExecutor;
 import org.briarproject.api.db.DatabaseConfig;
 import org.briarproject.api.lifecycle.LifecycleManager;
 import org.briarproject.api.lifecycle.LifecycleManager.StartResult;
@@ -48,7 +48,7 @@ public class BriarService extends Service {
 
 	// Fields that are accessed from background threads must be volatile
 	@Inject protected volatile LifecycleManager lifecycleManager;
-	@Inject protected volatile PlatformExecutor platformExecutor;
+	@Inject protected volatile AndroidExecutor androidExecutor;
 	private volatile boolean started = false;
 
 	@Override
@@ -106,7 +106,7 @@ public class BriarService extends Service {
 	}
 
 	private void showStartupFailureNotification(final StartResult result) {
-		platformExecutor.execute(new Runnable() {
+		androidExecutor.execute(new Runnable() {
 			public void run() {
 				NotificationCompat.Builder b =
 						new NotificationCompat.Builder(BriarService.this);
diff --git a/briar-android/src/org/briarproject/android/NavDrawerActivity.java b/briar-android/src/org/briarproject/android/NavDrawerActivity.java
index 8342c58379..d3d45e61ed 100644
--- a/briar-android/src/org/briarproject/android/NavDrawerActivity.java
+++ b/briar-android/src/org/briarproject/android/NavDrawerActivity.java
@@ -8,7 +8,6 @@ import android.os.Bundle;
 import android.support.v4.view.GravityCompat;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.ActionBarDrawerToggle;
-import android.support.v7.widget.AppCompatButton;
 import android.support.v7.widget.Toolbar;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -25,7 +24,7 @@ import org.briarproject.android.forum.ForumListFragment;
 import org.briarproject.android.fragment.BaseFragment;
 import org.briarproject.android.util.CustomAnimations;
 import org.briarproject.api.TransportId;
-import org.briarproject.api.android.ReferenceManager;
+import org.briarproject.android.api.ReferenceManager;
 import org.briarproject.api.db.DbException;
 import org.briarproject.api.event.Event;
 import org.briarproject.api.event.EventBus;
diff --git a/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java b/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java
index 7b1b96c2b1..d5959a622e 100644
--- a/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java
+++ b/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java
@@ -8,7 +8,7 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.logging.Logger;
 
-import org.briarproject.api.android.ReferenceManager;
+import org.briarproject.android.api.ReferenceManager;
 
 class ReferenceManagerImpl implements ReferenceManager {
 
diff --git a/briar-android/src/org/briarproject/android/SetupActivity.java b/briar-android/src/org/briarproject/android/SetupActivity.java
index 4aba12d056..6caf20e5ac 100644
--- a/briar-android/src/org/briarproject/android/SetupActivity.java
+++ b/briar-android/src/org/briarproject/android/SetupActivity.java
@@ -17,7 +17,7 @@ import android.widget.TextView.OnEditorActionListener;
 import org.briarproject.R;
 import org.briarproject.android.util.AndroidUtils;
 import org.briarproject.android.util.StrengthMeter;
-import org.briarproject.api.android.ReferenceManager;
+import org.briarproject.android.api.ReferenceManager;
 import org.briarproject.api.crypto.CryptoComponent;
 import org.briarproject.api.crypto.CryptoExecutor;
 import org.briarproject.api.crypto.KeyPair;
diff --git a/briar-android/src/org/briarproject/android/SplashScreenActivity.java b/briar-android/src/org/briarproject/android/SplashScreenActivity.java
index acc0652af6..b79e605e1f 100644
--- a/briar-android/src/org/briarproject/android/SplashScreenActivity.java
+++ b/briar-android/src/org/briarproject/android/SplashScreenActivity.java
@@ -8,11 +8,11 @@ import android.os.StrictMode;
 import android.os.StrictMode.ThreadPolicy;
 import android.os.StrictMode.VmPolicy;
 import android.support.v7.preference.PreferenceManager;
-import android.util.Log;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 
 import org.briarproject.R;
+import org.briarproject.android.util.AndroidUtils;
 import org.briarproject.android.util.LayoutUtils;
 import org.briarproject.api.db.DatabaseConfig;
 import org.briarproject.util.FileUtils;
@@ -91,6 +91,7 @@ public class SplashScreenActivity extends BaseActivity {
 					startActivity(new Intent(this, NavDrawerActivity.class));
 				} else {
 					clearSharedPrefs();
+					AndroidUtils.deleteAppData(this);
 					FileUtils.deleteFileOrDir(
 							dbConfig.getDatabaseDirectory());
 					startActivity(new Intent(this, SetupActivity.class));
diff --git a/briar-api/src/org/briarproject/api/android/PlatformExecutor.java b/briar-android/src/org/briarproject/android/api/AndroidExecutor.java
similarity index 85%
rename from briar-api/src/org/briarproject/api/android/PlatformExecutor.java
rename to briar-android/src/org/briarproject/android/api/AndroidExecutor.java
index 4cd309374f..5ed8ef0f89 100644
--- a/briar-api/src/org/briarproject/api/android/PlatformExecutor.java
+++ b/briar-android/src/org/briarproject/android/api/AndroidExecutor.java
@@ -1,4 +1,4 @@
-package org.briarproject.api.android;
+package org.briarproject.android.api;
 
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
@@ -7,7 +7,7 @@ import java.util.concurrent.Future;
  * Enables background threads to make Android API calls that must be made from
  * a thread with a message queue.
  */
-public interface PlatformExecutor {
+public interface AndroidExecutor {
 
 	/**
 	 * Runs the given task on the main UI thread and returns a Future for
diff --git a/briar-api/src/org/briarproject/api/android/AndroidNotificationManager.java b/briar-android/src/org/briarproject/android/api/AndroidNotificationManager.java
similarity index 91%
rename from briar-api/src/org/briarproject/api/android/AndroidNotificationManager.java
rename to briar-android/src/org/briarproject/android/api/AndroidNotificationManager.java
index 3aad189dc3..33177e1b8c 100644
--- a/briar-api/src/org/briarproject/api/android/AndroidNotificationManager.java
+++ b/briar-android/src/org/briarproject/android/api/AndroidNotificationManager.java
@@ -1,4 +1,4 @@
-package org.briarproject.api.android;
+package org.briarproject.android.api;
 
 import org.briarproject.api.sync.GroupId;
 
diff --git a/briar-api/src/org/briarproject/api/android/ReferenceManager.java b/briar-android/src/org/briarproject/android/api/ReferenceManager.java
similarity index 95%
rename from briar-api/src/org/briarproject/api/android/ReferenceManager.java
rename to briar-android/src/org/briarproject/android/api/ReferenceManager.java
index 2366d9e1cd..8f1cd93b01 100644
--- a/briar-api/src/org/briarproject/api/android/ReferenceManager.java
+++ b/briar-android/src/org/briarproject/android/api/ReferenceManager.java
@@ -1,4 +1,4 @@
-package org.briarproject.api.android;
+package org.briarproject.android.api;
 
 /**
  * Manages mappings between object references and serialisable handles. This
diff --git a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
index 4555d8c9d1..45ebe6eab9 100644
--- a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
+++ b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java
@@ -21,11 +21,10 @@ import org.briarproject.android.AndroidComponent;
 import org.briarproject.android.BriarActivity;
 import org.briarproject.android.util.BriarRecyclerView;
 import org.briarproject.api.FormatException;
-import org.briarproject.api.android.AndroidNotificationManager;
+import org.briarproject.android.api.AndroidNotificationManager;
 import org.briarproject.api.contact.Contact;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.contact.ContactManager;
-import org.briarproject.api.crypto.CryptoComponent;
 import org.briarproject.api.crypto.CryptoExecutor;
 import org.briarproject.api.db.DbException;
 import org.briarproject.api.db.NoSuchContactException;
diff --git a/briar-android/src/org/briarproject/android/forum/ForumActivity.java b/briar-android/src/org/briarproject/android/forum/ForumActivity.java
index 96add7ce47..6b6fcea049 100644
--- a/briar-android/src/org/briarproject/android/forum/ForumActivity.java
+++ b/briar-android/src/org/briarproject/android/forum/ForumActivity.java
@@ -18,7 +18,7 @@ import org.briarproject.android.BriarActivity;
 import org.briarproject.android.util.ElasticHorizontalSpace;
 import org.briarproject.android.util.HorizontalBorder;
 import org.briarproject.android.util.ListLoadingProgressBar;
-import org.briarproject.api.android.AndroidNotificationManager;
+import org.briarproject.android.api.AndroidNotificationManager;
 import org.briarproject.api.db.DbException;
 import org.briarproject.api.db.NoSuchGroupException;
 import org.briarproject.api.db.NoSuchMessageException;
diff --git a/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java b/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java
index 39f2b578eb..1d8b12fe0a 100644
--- a/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java
+++ b/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java
@@ -7,7 +7,7 @@ import android.widget.Toast;
 import org.briarproject.R;
 import org.briarproject.android.AndroidComponent;
 import org.briarproject.android.BriarActivity;
-import org.briarproject.api.android.ReferenceManager;
+import org.briarproject.android.api.ReferenceManager;
 import org.briarproject.api.crypto.CryptoComponent;
 import org.briarproject.api.db.DbException;
 import org.briarproject.api.identity.AuthorId;
diff --git a/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java b/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java
index 5e71c113fe..29f271f0e4 100644
--- a/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java
+++ b/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java
@@ -9,6 +9,7 @@ import android.support.v7.preference.PreferenceManager;
 
 import org.briarproject.android.AndroidComponent;
 import org.briarproject.android.BriarActivity;
+import org.briarproject.android.util.AndroidUtils;
 import org.briarproject.api.db.DatabaseConfig;
 import org.briarproject.util.FileUtils;
 import org.iilab.IilabEngineeringRSA2048Pin;
@@ -111,9 +112,7 @@ public class PanicResponderActivity extends BriarActivity {
 			public void run() {
 				clearSharedPrefs();
 				// TODO somehow delete/shred the database more thoroughly
-				FileUtils
-						.deleteFileOrDir(
-								databaseConfig.getDatabaseDirectory());
+				AndroidUtils.deleteAppData(PanicResponderActivity.this);
 				PanicResponder.deleteAllAppData(PanicResponderActivity.this);
 
 				// nothing left to do after everything is deleted,
diff --git a/briar-android/src/org/briarproject/plugins/AndroidPluginsModule.java b/briar-android/src/org/briarproject/plugins/AndroidPluginsModule.java
new file mode 100644
index 0000000000..7718122f01
--- /dev/null
+++ b/briar-android/src/org/briarproject/plugins/AndroidPluginsModule.java
@@ -0,0 +1,61 @@
+package org.briarproject.plugins;
+
+import android.app.Application;
+import android.content.Context;
+
+import org.briarproject.android.api.AndroidExecutor;
+import org.briarproject.api.event.EventBus;
+import org.briarproject.api.lifecycle.IoExecutor;
+import org.briarproject.api.plugins.BackoffFactory;
+import org.briarproject.api.plugins.duplex.DuplexPluginConfig;
+import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
+import org.briarproject.api.plugins.simplex.SimplexPluginConfig;
+import org.briarproject.api.plugins.simplex.SimplexPluginFactory;
+import org.briarproject.api.system.LocationUtils;
+import org.briarproject.plugins.droidtooth.DroidtoothPluginFactory;
+import org.briarproject.plugins.tcp.AndroidLanTcpPluginFactory;
+import org.briarproject.plugins.tor.TorPluginFactory;
+
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.Executor;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+public class AndroidPluginsModule {
+
+	@Provides
+	SimplexPluginConfig provideSimplexPluginConfig() {
+		return new SimplexPluginConfig() {
+			public Collection<SimplexPluginFactory> getFactories() {
+				return Collections.emptyList();
+			}
+		};
+	}
+
+	@Provides
+	public DuplexPluginConfig provideDuplexPluginConfig(
+			@IoExecutor Executor ioExecutor, AndroidExecutor androidExecutor,
+			SecureRandom random, BackoffFactory backoffFactory, Application app,
+			LocationUtils locationUtils, EventBus eventBus) {
+		Context appContext = app.getApplicationContext();
+		DuplexPluginFactory bluetooth = new DroidtoothPluginFactory(ioExecutor,
+				androidExecutor, appContext, random, backoffFactory);
+		DuplexPluginFactory tor = new TorPluginFactory(ioExecutor, appContext,
+				locationUtils, eventBus);
+		DuplexPluginFactory lan = new AndroidLanTcpPluginFactory(ioExecutor,
+				backoffFactory, appContext);
+		final Collection<DuplexPluginFactory> factories =
+				Arrays.asList(bluetooth, tor, lan);
+		return new DuplexPluginConfig() {
+			public Collection<DuplexPluginFactory> getFactories() {
+				return factories;
+			}
+		};
+	}
+
+}
diff --git a/briar-android/src/org/briarproject/plugins/PluginsModuleExtension.java b/briar-android/src/org/briarproject/plugins/PluginsModuleExtension.java
index b2b408f8d6..14a55180c8 100644
--- a/briar-android/src/org/briarproject/plugins/PluginsModuleExtension.java
+++ b/briar-android/src/org/briarproject/plugins/PluginsModuleExtension.java
@@ -1,50 +1,33 @@
 package org.briarproject.plugins;
 
-import android.app.Application;
-import android.content.Context;
-
-import org.briarproject.api.android.PlatformExecutor;
-import org.briarproject.api.event.EventBus;
-import org.briarproject.api.lifecycle.IoExecutor;
-import org.briarproject.api.plugins.BackoffFactory;
-import org.briarproject.api.plugins.duplex.DuplexPluginConfig;
-import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
-import org.briarproject.api.system.LocationUtils;
-import org.briarproject.plugins.droidtooth.DroidtoothPluginFactory;
-import org.briarproject.plugins.tcp.AndroidLanTcpPluginFactory;
-import org.briarproject.plugins.tor.TorPluginFactory;
-
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.concurrent.Executor;
-
 public class PluginsModuleExtension extends PluginsModule {
 
-	private final Application app;
+//	@Inject @Named("AndroidDuplexPluginConfig")
+//	DuplexPluginConfig duplexPluginConfig;
+
+	public PluginsModuleExtension() {
 
-	public PluginsModuleExtension(Application app) {
-		this.app = app;
 	}
 
+//	@Override
+//	SimplexPluginConfig provideSimplexPluginConfig() {
+//		return new SimplexPluginConfig() {
+//			public Collection<SimplexPluginFactory> getFactories() {
+//				return Collections.emptyList();
+//			}
+//		};
+//	}
+
+/*
 	@Override
 	public DuplexPluginConfig provideDuplexPluginConfig(
-			@IoExecutor Executor ioExecutor, PlatformExecutor platformExecutor,
+			@IoExecutor Executor ioExecutor, AndroidExecutor androidExecutor,
 			SecureRandom random, BackoffFactory backoffFactory,
 			LocationUtils locationUtils, EventBus eventBus) {
-		Context appContext = app.getApplicationContext();
-		DuplexPluginFactory bluetooth = new DroidtoothPluginFactory(ioExecutor,
-				platformExecutor, appContext, random, backoffFactory);
-		DuplexPluginFactory tor = new TorPluginFactory(ioExecutor, appContext,
-				locationUtils, eventBus);
-		DuplexPluginFactory lan = new AndroidLanTcpPluginFactory(ioExecutor,
-				backoffFactory, appContext);
-		final Collection<DuplexPluginFactory> factories =
-				Arrays.asList(bluetooth, tor, lan);
-		return new DuplexPluginConfig() {
-			public Collection<DuplexPluginFactory> getFactories() {
-				return factories;
-			}
-		};
-	}
+//		return duplexPluginConfig;
+//		@Inject @Named("AndroidDuplexPluginConfig")
+//		DuplexPluginConfig andoridDuplexPlugin;
+//		return andoridDuplexPlugin;
+//	}
+*/
 }
diff --git a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPlugin.java b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPlugin.java
index 325a49d74f..2bc7dbe702 100644
--- a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPlugin.java
+++ b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPlugin.java
@@ -11,7 +11,7 @@ import android.content.IntentFilter;
 
 import org.briarproject.android.util.AndroidUtils;
 import org.briarproject.api.TransportId;
-import org.briarproject.api.android.AndroidExecutor;
+import org.briarproject.android.api.AndroidExecutor;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.crypto.PseudoRandom;
 import org.briarproject.api.plugins.Backoff;
diff --git a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java
index db89929a22..229aba2272 100644
--- a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java
+++ b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java
@@ -3,7 +3,7 @@ package org.briarproject.plugins.droidtooth;
 import android.content.Context;
 
 import org.briarproject.api.TransportId;
-import org.briarproject.api.android.AndroidExecutor;
+import org.briarproject.android.api.AndroidExecutor;
 import org.briarproject.api.plugins.Backoff;
 import org.briarproject.api.plugins.BackoffFactory;
 import org.briarproject.api.plugins.duplex.DuplexPlugin;
diff --git a/briar-android/src/org/briarproject/system/AndroidExecutorImpl.java b/briar-android/src/org/briarproject/system/AndroidExecutorImpl.java
index b119fb8c7b..0b9674c252 100644
--- a/briar-android/src/org/briarproject/system/AndroidExecutorImpl.java
+++ b/briar-android/src/org/briarproject/system/AndroidExecutorImpl.java
@@ -6,15 +6,13 @@ import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 
-import org.briarproject.api.android.PlatformExecutor;
+import org.briarproject.android.api.AndroidExecutor;
 
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
 
-import javax.inject.Inject;
-
-class AndroidExecutorImpl implements PlatformExecutor {
+class AndroidExecutorImpl implements AndroidExecutor {
 
 	private final Handler handler;
 
diff --git a/briar-android/src/org/briarproject/system/AndroidSystemModule.java b/briar-android/src/org/briarproject/system/AndroidSystemModule.java
new file mode 100644
index 0000000000..74e39e06af
--- /dev/null
+++ b/briar-android/src/org/briarproject/system/AndroidSystemModule.java
@@ -0,0 +1,29 @@
+package org.briarproject.system;
+
+import android.app.Application;
+
+import org.briarproject.android.api.AndroidExecutor;
+import org.briarproject.api.system.LocationUtils;
+import org.briarproject.api.system.SeedProvider;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+public class AndroidSystemModule {
+
+	@Provides
+	public SeedProvider provideSeedProvider(Application app) {
+		return new AndroidSeedProvider(app);
+	}
+
+	@Provides
+	public LocationUtils provideLocationUtils(Application app) {
+		return new AndroidLocationUtils(app);
+	}
+
+	@Provides
+	public AndroidExecutor providePlatformExecutor(Application app) {
+		return new AndroidExecutorImpl(app);
+	}
+}
diff --git a/briar-android/src/org/briarproject/system/PlatformModuleExtension.java b/briar-android/src/org/briarproject/system/PlatformModuleExtension.java
deleted file mode 100644
index dc2ae6a4ac..0000000000
--- a/briar-android/src/org/briarproject/system/PlatformModuleExtension.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.briarproject.system;
-
-import android.app.Application;
-import android.content.Context;
-
-import org.briarproject.PlatformModule;
-import org.briarproject.android.ApplicationScope;
-import org.briarproject.api.android.PlatformExecutor;
-import org.briarproject.api.crypto.SecretKey;
-import org.briarproject.api.db.DatabaseConfig;
-import org.briarproject.api.ui.UiCallback;
-
-import java.io.File;
-
-public class PlatformModuleExtension extends PlatformModule {
-
-	private final UiCallback uiCallback;
-	private final Application app;
-
-	public PlatformModuleExtension(Application app) {
-		this.app = app;
-		// Use a dummy UI callback
-		uiCallback = new UiCallback() {
-
-			public int showChoice(String[] options, String... message) {
-				throw new UnsupportedOperationException();
-			}
-
-			public boolean showConfirmationMessage(String... message) {
-				throw new UnsupportedOperationException();
-			}
-
-			public void showMessage(String... message) {
-				throw new UnsupportedOperationException();
-			}
-		};
-	}
-
-	@Override
-	public UiCallback provideUICallback() {
-		return uiCallback;
-	}
-
-	@Override
-	@ApplicationScope
-	public DatabaseConfig provideDatabaseConfig() {
-		final File dir = app.getApplicationContext().getDir("db", Context.MODE_PRIVATE);
-		return new DatabaseConfig() {
-
-			private volatile SecretKey key = null;
-
-			public boolean databaseExists() {
-				return dir.isDirectory() && dir.listFiles().length > 0;
-			}
-
-			public File getDatabaseDirectory() {
-				return dir;
-			}
-
-			public void setEncryptionKey(SecretKey key) {
-				this.key = key;
-			}
-
-			public SecretKey getEncryptionKey() {
-				return key;
-			}
-
-			public long getMaxSize() {
-				return Long.MAX_VALUE;
-			}
-		};
-	}
-
-	@Override
-	public PlatformExecutor providePlatformExecutor() {
-		return new AndroidExecutorImpl(app);
-	}
-}
diff --git a/briar-android/src/org/briarproject/system/SystemModuleExtension.java b/briar-android/src/org/briarproject/system/SystemModuleExtension.java
deleted file mode 100644
index 72ea338b44..0000000000
--- a/briar-android/src/org/briarproject/system/SystemModuleExtension.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.briarproject.system;
-
-
-import android.app.Application;
-
-import org.briarproject.api.system.Clock;
-import org.briarproject.api.system.LocationUtils;
-import org.briarproject.api.system.SeedProvider;
-import org.briarproject.api.system.Timer;
-
-import dagger.Module;
-import dagger.Provides;
-
-public class SystemModuleExtension extends SystemModule {
-
-	private final Application app;
-
-	public SystemModuleExtension(final Application app) {
-		this.app = app;
-	}
-
-	@Override
-	public SeedProvider provideSeedProvider() {
-		return new AndroidSeedProvider(app);
-	}
-
-	@Override
-	public LocationUtils provideLocationUtils() {
-		return new AndroidLocationUtils(app);
-	}
-
-}
diff --git a/briar-core/src/org/briarproject/CoreComponent.java b/briar-core/src/org/briarproject/CoreComponent.java
deleted file mode 100644
index 9f7c41df04..0000000000
--- a/briar-core/src/org/briarproject/CoreComponent.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.briarproject;
-
-import org.briarproject.api.android.PlatformExecutor;
-import org.briarproject.api.android.ReferenceManager;
-import org.briarproject.api.contact.ContactManager;
-import org.briarproject.api.crypto.CryptoComponent;
-import org.briarproject.api.crypto.CryptoExecutor;
-import org.briarproject.api.crypto.PasswordStrengthEstimator;
-import org.briarproject.api.db.DatabaseConfig;
-import org.briarproject.api.db.DatabaseExecutor;
-import org.briarproject.api.event.EventBus;
-import org.briarproject.api.forum.ForumManager;
-import org.briarproject.api.forum.ForumPostFactory;
-import org.briarproject.api.forum.ForumSharingManager;
-import org.briarproject.api.identity.AuthorFactory;
-import org.briarproject.api.identity.IdentityManager;
-import org.briarproject.api.invitation.InvitationTaskFactory;
-import org.briarproject.api.lifecycle.IoExecutor;
-import org.briarproject.api.lifecycle.LifecycleManager;
-import org.briarproject.api.messaging.MessagingManager;
-import org.briarproject.api.messaging.PrivateMessageFactory;
-import org.briarproject.api.plugins.ConnectionRegistry;
-import org.briarproject.api.plugins.PluginManager;
-import org.briarproject.api.properties.TransportPropertyManager;
-import org.briarproject.api.settings.SettingsManager;
-import org.briarproject.api.sync.ValidationManager;
-import org.briarproject.api.transport.KeyManager;
-import org.briarproject.clients.ClientsModule;
-import org.briarproject.contact.ContactModule;
-import org.briarproject.crypto.CryptoModule;
-import org.briarproject.data.DataModule;
-import org.briarproject.db.DatabaseModule;
-import org.briarproject.event.EventModule;
-import org.briarproject.forum.ForumModule;
-import org.briarproject.identity.IdentityModule;
-import org.briarproject.invitation.InvitationModule;
-import org.briarproject.lifecycle.LifecycleModule;
-import org.briarproject.messaging.MessagingModule;
-import org.briarproject.messaging.PrivateMessageValidator;
-import org.briarproject.plugins.PluginsModule;
-import org.briarproject.properties.PropertiesModule;
-import org.briarproject.properties.TransportPropertyValidator;
-import org.briarproject.reliability.ReliabilityModule;
-import org.briarproject.settings.SettingsModule;
-import org.briarproject.sync.SyncModule;
-import org.briarproject.system.SystemModule;
-import org.briarproject.transport.TransportModule;
-
-import java.util.concurrent.Executor;
-
-import javax.inject.Singleton;
-
-import dagger.Component;
-
-@Singleton
-@Component(modules = {DatabaseModule.class,
-		CryptoModule.class, LifecycleModule.class, PlatformModule.class,
-		ReliabilityModule.class, MessagingModule.class,
-		InvitationModule.class, ForumModule.class, IdentityModule.class,
-		EventModule.class, DataModule.class, ContactModule.class,
-		PropertiesModule.class, TransportModule.class, SyncModule.class,
-		SettingsModule.class, ClientsModule.class, SystemModule.class,
-		PluginsModule.class})
-public interface CoreComponent {
-	@IoExecutor
-	Executor ioExecutor();
-	ContactManager contactManager();
-	@CryptoExecutor Executor cryptoExecutor();
-	DatabaseConfig databaseConfig();
-	PasswordStrengthEstimator passwordStrengthEstimator();
-	CryptoComponent cryptoComponent();
-	@DatabaseExecutor Executor dbExecutor();
-	LifecycleManager lifecycleManager();
-	AuthorFactory authFactory();
-	EventBus eventBus();
-	KeyManager keyManager();
-	ValidationManager validationManager();
-	ForumManager forumManager();
-	IdentityManager identityManager();
-	PluginManager pluginManager();
-	SettingsManager settingsManater();
-	InvitationTaskFactory invitationTaskFactory();
-	MessagingManager messagingManager();
-	TransportPropertyManager transportPropertyManager();
-	ConnectionRegistry connectionRegistry();
-	ForumSharingManager forumSharingManager();
-	PrivateMessageFactory privateMessageFactory();
-	ForumPostFactory forumPostFactory();
-	PrivateMessageValidator privateMessageValidator();
-	TransportPropertyValidator transportPropertyValidator();
-	PlatformExecutor platformExecutor();
-	// Eager singletons
-	void inject(ContactModule.EagerSingletons init);
-	void inject(CryptoModule.EagerSingletons init);
-	void inject(DatabaseModule.EagerSingletons init);
-	void inject(ForumModule.EagerSingletons init);
-	void inject(LifecycleModule.EagerSingletons init);
-	void inject(MessagingModule.EagerSingletons init);
-	void inject(PluginsModule.EagerSingletons init);
-	void inject(PropertiesModule.EagerSingletons init);
-	void inject(SyncModule.EagerSingletons init);
-	void inject(TransportModule.EagerSingletons init);
-}
diff --git a/briar-core/src/org/briarproject/CoreEagerSingletons.java b/briar-core/src/org/briarproject/CoreEagerSingletons.java
index 8637f71065..00d46b1da7 100644
--- a/briar-core/src/org/briarproject/CoreEagerSingletons.java
+++ b/briar-core/src/org/briarproject/CoreEagerSingletons.java
@@ -11,18 +11,16 @@ import org.briarproject.properties.PropertiesModule;
 import org.briarproject.sync.SyncModule;
 import org.briarproject.transport.TransportModule;
 
-public class CoreEagerSingletons {
+public interface CoreEagerSingletons {
+	void inject(ContactModule.EagerSingletons init);
+	void inject(CryptoModule.EagerSingletons init);
+	void inject(DatabaseModule.EagerSingletons init);
+	void inject(ForumModule.EagerSingletons init);
+	void inject(LifecycleModule.EagerSingletons init);
+	void inject(MessagingModule.EagerSingletons init);
+	void inject(PluginsModule.EagerSingletons init);
+	void inject(PropertiesModule.EagerSingletons init);
+	void inject(SyncModule.EagerSingletons init);
+	void inject(TransportModule.EagerSingletons init);
 
-	public static void initEagerSingletons(CoreComponent c) {
-		c.inject(new ContactModule.EagerSingletons());
-		c.inject(new CryptoModule.EagerSingletons());
-		c.inject(new DatabaseModule.EagerSingletons());
-		c.inject(new ForumModule.EagerSingletons());
-		c.inject(new LifecycleModule.EagerSingletons());
-		c.inject(new MessagingModule.EagerSingletons());
-		c.inject(new PluginsModule.EagerSingletons());
-		c.inject(new PropertiesModule.EagerSingletons());
-		c.inject(new SyncModule.EagerSingletons());
-		c.inject(new TransportModule.EagerSingletons());
-	}
 }
diff --git a/briar-core/src/org/briarproject/CoreModule.java b/briar-core/src/org/briarproject/CoreModule.java
new file mode 100644
index 0000000000..11d6c87b0a
--- /dev/null
+++ b/briar-core/src/org/briarproject/CoreModule.java
@@ -0,0 +1,45 @@
+package org.briarproject;
+
+import org.briarproject.clients.ClientsModule;
+import org.briarproject.contact.ContactModule;
+import org.briarproject.crypto.CryptoModule;
+import org.briarproject.data.DataModule;
+import org.briarproject.db.DatabaseModule;
+import org.briarproject.event.EventModule;
+import org.briarproject.forum.ForumModule;
+import org.briarproject.identity.IdentityModule;
+import org.briarproject.invitation.InvitationModule;
+import org.briarproject.lifecycle.LifecycleModule;
+import org.briarproject.messaging.MessagingModule;
+import org.briarproject.plugins.PluginsModule;
+import org.briarproject.properties.PropertiesModule;
+import org.briarproject.reliability.ReliabilityModule;
+import org.briarproject.settings.SettingsModule;
+import org.briarproject.sync.SyncModule;
+import org.briarproject.system.SystemModule;
+import org.briarproject.transport.TransportModule;
+
+import dagger.Module;
+
+@Module(includes = {DatabaseModule.class,
+		CryptoModule.class, LifecycleModule.class, ReliabilityModule.class,
+		MessagingModule.class, InvitationModule.class, ForumModule.class,
+		IdentityModule.class, EventModule.class, DataModule.class,
+		ContactModule.class, PropertiesModule.class, TransportModule.class,
+		SyncModule.class, SettingsModule.class, ClientsModule.class,
+		SystemModule.class, PluginsModule.class})
+public class CoreModule {
+
+	public static void initEagerSingletons(CoreEagerSingletons c) {
+		c.inject(new ContactModule.EagerSingletons());
+		c.inject(new CryptoModule.EagerSingletons());
+		c.inject(new DatabaseModule.EagerSingletons());
+		c.inject(new ForumModule.EagerSingletons());
+		c.inject(new LifecycleModule.EagerSingletons());
+		c.inject(new MessagingModule.EagerSingletons());
+		c.inject(new PluginsModule.EagerSingletons());
+		c.inject(new PropertiesModule.EagerSingletons());
+		c.inject(new SyncModule.EagerSingletons());
+		c.inject(new TransportModule.EagerSingletons());
+	}
+}
diff --git a/briar-core/src/org/briarproject/PlatformModule.java b/briar-core/src/org/briarproject/PlatformModule.java
deleted file mode 100644
index c4242048a5..0000000000
--- a/briar-core/src/org/briarproject/PlatformModule.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.briarproject;
-
-import org.briarproject.api.android.PlatformExecutor;
-import org.briarproject.api.db.DatabaseConfig;
-import org.briarproject.api.ui.UiCallback;
-
-import javax.inject.Singleton;
-
-import dagger.Module;
-import dagger.Provides;
-
-/**
- * This class contains methods that MUST(!) be overridden in platform specific
- * modules that use the core.
- */
-@Module
-public class PlatformModule {
-
-	@Provides
-	@Singleton
-	public DatabaseConfig provideDatabaseConfig() {
-		return null;
-	}
-
-	@Provides
-	public UiCallback provideUICallback() {
-		return null;
-	}
-
-
-	@Provides
-	public PlatformExecutor providePlatformExecutor() {
-		return null;
-	}
-
-}
diff --git a/briar-core/src/org/briarproject/plugins/PluginsModule.java b/briar-core/src/org/briarproject/plugins/PluginsModule.java
index 0d523c3489..afdb970df2 100644
--- a/briar-core/src/org/briarproject/plugins/PluginsModule.java
+++ b/briar-core/src/org/briarproject/plugins/PluginsModule.java
@@ -3,7 +3,6 @@ package org.briarproject.plugins;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 
-import org.briarproject.api.android.PlatformExecutor;
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.lifecycle.IoExecutor;
 import org.briarproject.api.lifecycle.LifecycleManager;
@@ -11,19 +10,13 @@ import org.briarproject.api.plugins.BackoffFactory;
 import org.briarproject.api.plugins.ConnectionManager;
 import org.briarproject.api.plugins.ConnectionRegistry;
 import org.briarproject.api.plugins.PluginManager;
-import org.briarproject.api.plugins.duplex.DuplexPluginConfig;
-import org.briarproject.api.plugins.simplex.SimplexPluginConfig;
-import org.briarproject.api.plugins.simplex.SimplexPluginFactory;
 import org.briarproject.api.sync.SyncSessionFactory;
-import org.briarproject.api.system.LocationUtils;
 import org.briarproject.api.system.Timer;
 import org.briarproject.api.transport.KeyManager;
 import org.briarproject.api.transport.StreamReaderFactory;
 import org.briarproject.api.transport.StreamWriterFactory;
 
 import java.security.SecureRandom;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.concurrent.Executor;
 
 import dagger.Module;
@@ -68,6 +61,7 @@ public class PluginsModule {
 		return new ConnectionRegistryImpl(eventBus);
 	}
 
+
 	@Provides
 	@Singleton
 	PluginManager getPluginManager(LifecycleManager lifecycleManager,
@@ -75,21 +69,15 @@ public class PluginsModule {
 		lifecycleManager.register(pluginManager);
 		return pluginManager;
 	}
-
+/*
 	@Provides
 	SimplexPluginConfig provideSimplexPluginConfig() {
-		return new SimplexPluginConfig() {
-			public Collection<SimplexPluginFactory> getFactories() {
-				return Collections.emptyList();
-			}
-		};
+		return null;
 	}
 
 	@Provides
-	public DuplexPluginConfig provideDuplexPluginConfig(@IoExecutor Executor ioExecutor,
-			PlatformExecutor platformExecutor, /*Application app,*/
-			SecureRandom random, BackoffFactory backoffFactory,
-			LocationUtils locationUtils, EventBus eventBus) {
+	public DuplexPluginConfig provideDuplexPluginConfig() {
 		return null;
 	}
+	*/
 }
diff --git a/briar-core/src/org/briarproject/system/SystemModule.java b/briar-core/src/org/briarproject/system/SystemModule.java
index 8a2304e2ea..eb2a0d88d2 100644
--- a/briar-core/src/org/briarproject/system/SystemModule.java
+++ b/briar-core/src/org/briarproject/system/SystemModule.java
@@ -20,13 +20,4 @@ public class SystemModule {
 		return new SystemTimer();
 	}
 
-	@Provides
-	public SeedProvider provideSeedProvider() {
-		return null;
-	}
-
-	@Provides
-	public LocationUtils provideLocationUtils() {
-		return null;
-	}
 }
-- 
GitLab