responsiveness improvements for connectbot

Hello developers of connectbot,

I'm a Ph.D. student and I'm doing research related to Android apps'
responsiveness. I found there are some cases in connectbot that the
database is accessed/queried by UI thread. Does this affect the
performance/responsiveness of the app? An optimization could be
extracting the DB operations into AsyncTask.

For example, in PubkeyListActivity.java, the "pubkeydb" is
queried/inserted/deleted at several places in UI thread: line 334,
408, 453, 468 and so on. How about put them into AsyncTask? I send a
sample patch here. Note that in the patch, in order to avoid data
races on "pubkeydb", I also add synchronization when UI thread and
AsyncTask tries to access "pubkeydb" (e.g., without synchronization,
races on "pubkeydb" appear between "UpdateListTask" and
"onStart"/"onStop").

Similarly, I also transformed HostListActivity.java and
HostEditorActivity.java for field "hostdb". TerminalManager.java
for "hostdb" and "pubkeydb".

Also, TerminalKeyListener.java invokes "bridge.transport.write" which
writes to IO. This also lead to a potential responsiveness issue. Thus, I
tried to move it into AsyncTask. In order to keep the original
semantics, I add a method "getResult()" in the AsyncTask. If the
written throws IOException or takes more than 5 seconds (i.e., the app
is not responsive anymore), "onKey" method will return false.

There should be some other places that can be improved. What do you think
about these improvements? My thought is we can improve the responsiveness if we try
to avoid the access to IO/Database in UI thread.

Thanks,
Yu