Optional change for apps to run scan as non-blocking task

Blocking ScanFile in {@link ContentResolver#update} takes long time to
scan the file and update the metadata. This could make some apps lag
due to applyBatch() taking a lot of time for clearing IS_PENDING for 100
files.

In this CL, we provide an option for apps to indicate
{@link ModernMediaScanner#scanFile} triggered from
{@link ContentResolver#update} should run in the background thread.
This flag is typically false for all apps. Note that moving ScanFile
to background thread may make other apps see partial metadata while
file is still being scanned. Apps should update the right metadata in
{@link ContentResolver#update} so that metadata values before
and after the scan remain the same.

Test: Manual. Tested that with the new flag, applyBatch() takes ~200ms.
Bug: 169634969
Change-Id: Ic061d8262eaa4dabbbe5bc09d2ef7f3911a672f9
(cherry picked from commit 9d3711e5418311241ed5bc72b1779a3b4e45d14a)
2 files changed