Ensure only one thread does database migration

Previously, we were using mSchemaLock.writeLock to ensure only one
thread does the migration. That resulted in
SQLiteDatabaseLockedException. Now, we add a synchronized block for
database migration. This ensures only one thread does the migration at
any given point, other thread trying to enter the migration will be
blocked until current thread completes the migration.

Bug: 171683776
Test: Manual
Change-Id: I58c8bb245a2f084e910a0f9a24cc5c80fc8a4a0e
(cherry picked from commit cef7d1087894e76ef7ddd3847f52a427cf2b9d7d)
1 file changed