Skip to content
Snippets Groups Projects
Commit 765340c3 authored by akwizgran's avatar akwizgran
Browse files

Clear all activities when showing startup failure notification.

parent cd492545
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import static java.util.logging.Level.INFO; ...@@ -7,6 +7,7 @@ import static java.util.logging.Level.INFO;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.inject.Inject; import javax.inject.Inject;
...@@ -37,6 +38,7 @@ public class BriarService extends RoboService { ...@@ -37,6 +38,7 @@ public class BriarService extends RoboService {
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(BriarService.class.getName()); Logger.getLogger(BriarService.class.getName());
private final AtomicBoolean created = new AtomicBoolean(false);
private final Binder binder = new BriarBinder(); private final Binder binder = new BriarBinder();
@Inject private DatabaseConfig databaseConfig; @Inject private DatabaseConfig databaseConfig;
...@@ -52,6 +54,11 @@ public class BriarService extends RoboService { ...@@ -52,6 +54,11 @@ public class BriarService extends RoboService {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
if(LOG.isLoggable(INFO)) LOG.info("Created"); if(LOG.isLoggable(INFO)) LOG.info("Created");
if(created.getAndSet(true)) {
if(LOG.isLoggable(INFO)) LOG.info("Already created");
stopSelf();
return;
}
if(databaseConfig.getEncryptionKey() == null) { if(databaseConfig.getEncryptionKey() == null) {
if(LOG.isLoggable(INFO)) LOG.info("No database key"); if(LOG.isLoggable(INFO)) LOG.info("No database key");
stopSelf(); stopSelf();
...@@ -92,6 +99,11 @@ public class BriarService extends RoboService { ...@@ -92,6 +99,11 @@ public class BriarService extends RoboService {
Object o = getSystemService(Context.NOTIFICATION_SERVICE); Object o = getSystemService(Context.NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o; NotificationManager nm = (NotificationManager) o;
nm.notify(FAILURE_NOTIFICATION_ID, b.build()); nm.notify(FAILURE_NOTIFICATION_ID, b.build());
// Bring HomeScreenActivity to the front to clear all other activities
Intent i = new Intent(this, HomeScreenActivity.class);
i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra("briar.STARTUP_FAILED", true);
startActivity(i);
} }
@Override @Override
......
...@@ -53,8 +53,14 @@ public class HomeScreenActivity extends BriarActivity { ...@@ -53,8 +53,14 @@ public class HomeScreenActivity extends BriarActivity {
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
super.onCreate(state); super.onCreate(state);
long handle = getIntent().getLongExtra("briar.LOCAL_AUTHOR_HANDLE", -1); Intent i = getIntent();
if(handle == -1) { boolean failed = i.getBooleanExtra("briar.STARTUP_FAILED", false);
long handle = i.getLongExtra("briar.LOCAL_AUTHOR_HANDLE", -1);
if(failed) {
finish();
if(LOG.isLoggable(INFO)) LOG.info("Exiting");
System.exit(0);
} else if(handle == -1) {
// The activity has been launched before // The activity has been launched before
showButtons(); showButtons();
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment