Clean up database access operations

Bug: 33251173

Move write and erase operations to a background thread.

Fix interrupt handling during database initialization. Simplify
initialization synchronization.

Initialize a Cursor at startup and use it for most read operations.
Continue to perform accesses on negative indices directly, if they
would miss the CursorWindow. This avoids a somewhat likely situation
in which we're bounding between windows.

Add some code to gracefully degrade in the event of a database failure.
This is currently disabled.

Test: The alternate direct read path was minimally tested by temporarily
modifying the code. Manual tests were run.

Change-Id: I2112f73ca43cc5f855da98d7f9b1c3beaed3f610
3 files changed