Enable write-ahead logging for keystore db.

Write-ahead logging wasn't previously enabled for the keystore2 sqlite
databases out of concern that it might make it impossible to open the
database when the file system is full.  Work to correct that problem,
to ensure that sqlite databases can always be opened in WAL mode even
when the WAL file cannot be created, is in progress, so this CL goes
ahead and puts the database in WAL mode.  The approach is a little
wasteful, since it re-sends the pragma on every connection, but that
ensures that it gets done and shouldn't impose any significant
overhead.

In the event that setting WAL mode fails, we log an error and continue
on.

Test: CtsKeystoreTestCases
Change-Id: I7d5618760019dce68576f72575321c54c3c24415
2 files changed