From 604cfd5202de883091921143790d9df6bc49d2b1 Mon Sep 17 00:00:00 2001
From: Ernir Erlingsson <ernir@ymirmobile.com>
Date: Fri, 8 Apr 2016 12:03:01 +0200
Subject: [PATCH] Fix transport update

---
 .../briarproject/android/BaseActivity.java    |  9 ++++----
 .../briarproject/android/BriarActivity.java   | 16 -------------
 .../android/NavDrawerActivity.java            |  3 ++-
 .../controller/NavDrawerControllerImp.java    | 23 ++++++++-----------
 4 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/briar-android/src/org/briarproject/android/BaseActivity.java b/briar-android/src/org/briarproject/android/BaseActivity.java
index 1bbbc6fdec..7e1b7165a7 100644
--- a/briar-android/src/org/briarproject/android/BaseActivity.java
+++ b/briar-android/src/org/briarproject/android/BaseActivity.java
@@ -4,6 +4,7 @@ import android.os.Bundle;
 import android.os.IBinder;
 import android.os.PersistableBundle;
 import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
 
@@ -46,13 +47,13 @@ public abstract class BaseActivity extends AppCompatActivity {
 	}
 
 	@Override
-	public void onPostCreate(Bundle savedInstanceState,
-			PersistableBundle persistentState) {
-		super.onPostCreate(savedInstanceState, persistentState);
+	public void onPostCreate(Bundle savedInstanceState) {
+		super.onPostCreate(savedInstanceState);
+		// Post call used for controllers to ensure that the onCreate method
+		// override in inherited Activities has finished
 		for (ActivityLifecycleController alc : lifecycleControllers) {
 			alc.onActivityCreate();
 		}
-
 	}
 
 	@Override
diff --git a/briar-android/src/org/briarproject/android/BriarActivity.java b/briar-android/src/org/briarproject/android/BriarActivity.java
index a61e4059dc..9bd1e27dbf 100644
--- a/briar-android/src/org/briarproject/android/BriarActivity.java
+++ b/briar-android/src/org/briarproject/android/BriarActivity.java
@@ -39,21 +39,6 @@ public abstract class BriarActivity extends BaseActivity {
 	private static final Logger LOG =
 			Logger.getLogger(BriarActivity.class.getName());
 
-	/*
-	private final BriarServiceConnection serviceConnection =
-			new BriarServiceConnection();
-
-	@Inject
-	DatabaseConfig databaseConfig;
-	private boolean bound = false;
-
-	// Fields that are accessed from background threads must be volatile
-	@Inject
-	@DatabaseExecutor
-	protected volatile Executor dbExecutor;
-	@Inject
-	protected volatile LifecycleManager lifecycleManager;
-	*/
 	@Inject
 	protected BriarController briarController;
 
@@ -62,7 +47,6 @@ public abstract class BriarActivity extends BaseActivity {
 		super.onCreate(state);
 
 		briarController.startAndBindService();
-//		if (databaseConfig.getEncryptionKey() != null) startAndBindService();
 	}
 
 	@Override
diff --git a/briar-android/src/org/briarproject/android/NavDrawerActivity.java b/briar-android/src/org/briarproject/android/NavDrawerActivity.java
index a5c8f8e290..8545044851 100644
--- a/briar-android/src/org/briarproject/android/NavDrawerActivity.java
+++ b/briar-android/src/org/briarproject/android/NavDrawerActivity.java
@@ -10,6 +10,7 @@ import android.support.v4.view.GravityCompat;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.ActionBarDrawerToggle;
 import android.support.v7.widget.Toolbar;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -203,7 +204,7 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
 	}
 
 	@Override
-	protected void onPostCreate(Bundle savedInstanceState) {
+	public void onPostCreate(Bundle savedInstanceState) {
 		super.onPostCreate(savedInstanceState);
 		drawerToggle.syncState();
 	}
diff --git a/briar-android/src/org/briarproject/android/controller/NavDrawerControllerImp.java b/briar-android/src/org/briarproject/android/controller/NavDrawerControllerImp.java
index a86b7231d7..72e93293c5 100644
--- a/briar-android/src/org/briarproject/android/controller/NavDrawerControllerImp.java
+++ b/briar-android/src/org/briarproject/android/controller/NavDrawerControllerImp.java
@@ -17,7 +17,6 @@ import org.briarproject.api.plugins.PluginManager;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.inject.Inject;
@@ -54,13 +53,13 @@ public class NavDrawerControllerImp extends BriarControllerImp
 	@Override
 	public void onActivityCreate() {
 		super.onActivityCreate();
-		initializeTransports();
 	}
 
 	@Override
 	public void onActivityResume() {
 		super.onActivityResume();
 		eventBus.addListener(this);
+		LOG.info("onActivityResume");
 	}
 
 	@Override
@@ -97,12 +96,12 @@ public class NavDrawerControllerImp extends BriarControllerImp
 		});
 	}
 
-	private void initializeTransports() {
-		transports.clear();
-		transports.add(pluginManager.getPlugin(new TransportId("tor")));
-		transports.add(pluginManager.getPlugin(new TransportId("bt")));
-		transports.add(pluginManager.getPlugin(new TransportId("lan")));
-	}
+//	private void initializeTransports() {
+//		transports.clear();
+//		transports.add(pluginManager.getPlugin(new TransportId("tor")));
+//		transports.add(pluginManager.getPlugin(new TransportId("bt")));
+//		transports.add(pluginManager.getPlugin(new TransportId("lan")));
+//	}
 
 	@Override
 	public void setTransportListener(TransportStateListener transportListener) {
@@ -111,12 +110,8 @@ public class NavDrawerControllerImp extends BriarControllerImp
 
 	@Override
 	public boolean transportRunning(TransportId transportId) {
-		for (Plugin transport : transports) {
-			if (transport.getId().equals(transportId)) {
-				return transport.isRunning();
-			}
-		}
-		return false;
+		Plugin plugin = pluginManager.getPlugin(transportId);
+		return plugin != null && plugin.isRunning();
 	}
 
 	@Override
-- 
GitLab