IllegalStateException when sharing remote contact link
The following crash happens when sharing a remote contact link from another app while signed out:
java.lang.IllegalStateException
at org.briarproject.bramble.db.H2Database.createConnection(H2Database.java:94)
at org.briarproject.bramble.db.JdbcDatabase.startTransaction(JdbcDatabase.java:547)
at org.briarproject.bramble.db.JdbcDatabase.startTransaction(JdbcDatabase.java:96)
at org.briarproject.bramble.db.DatabaseComponentImpl.startTransaction(DatabaseComponentImpl.java:160)
at org.briarproject.bramble.db.DatabaseComponentImpl.transactionWithResult(DatabaseComponentImpl.java:207)
at org.briarproject.bramble.contact.ContactManagerImpl.getHandshakeLink(ContactManagerImpl.java:138)
at org.briarproject.briar.android.contact.add.remote.AddContactViewModel.lambda$loadHandshakeLink$0$AddContactViewModel(AddContactViewModel.java:62)
The cause is similar to #1482 (closed): we're accessing the DB before knowing whether we're signed in.
The solution we created for #1482 (closed) requires us to defer all database work until onResume(), and check isSignedIn() before doing any database work. The fact that we've seen a second bug so soon after fixing the first may suggest that it's going to be hard to remember those constraints in every case.
Another possible workaround would be for H2Database#createConnection() to throw a DbClosedException rather than an IllegalStateException if there's no DB key.