Improvements for migration of large databases.

When migrating thousands of media items from a legacy provider, we
can't actually fit everything inside a single SQLite transaction,
since it'll fail with SQLITE_NOMEM.

To handle this, we need to shift the migrateFromLegacy() logic to
manage its own transactions, instead of running inside the single
transaction driven by the onUpgrade() flow.  We do this by shifting
to onOpen() which has no automatic transaction.

We also add a "silent" option to the legacy provider to skip creating
thousands of media files during the newly added test; without this
we'd timeout.

Bug: 153842860
Test: atest MediaProviderClientTests:com.android.providers.media.client.LegacyProviderMigrationTest
Change-Id: Ieed9036ed7d308d8b60ce2025e8d43b418dd67a0
4 files changed