Avoid deadlock during applyBatch().

We've found evidence that apps performing applyBatch() operations
can cause a deadlock if they attempt to scanFile() while another
scan operation is already in progress.  To solve this, we delay our
blocking scan operations until after we've released any database
transaction held by applyBatch().

Bug: 158293295
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I53cf76af1fdf00a79245ddf6e2a4384841cfab16
2 files changed