Fix recomputeMediaTypeValues to accumulate all updates and update later

recomputeMediaTypeValues iterates over database rows with
MEDIA_TYPE=MEDIA_TYPE_NONE. If MEDIA_TYPE of the file matches subtitle
or document, we update the MEDIA_TYPE of that database row with
corresponding value.
If the number of database rows with MEDIA_TYPE_NONE exceeds cursor
window size, we may run into issue where next cursor window will see
the new database updates and may miscalculate the database rows for
next cursor window.
This will finally result in an exception, and we will not be able to
migrate database contents from legacy MediaProvider's database.

To fix the issue, we now accumulate all MEDIA_TYPE updates in an
ArrayMap and update the MEDIA_TYPE values once we have iterated over
the entire cursor.

Reordered isSubtitleMimeType and isDocumentMimeType check to check for
subtitle mime types first as some of the mimeTypes like text/vtt can be
categorised under both subtitle and document.

Bug: 171659403
Test: Manual
Merged-In: Id334dd8bee95fd3d841b53be90fb50bb541e7e28
Change-Id: Id334dd8bee95fd3d841b53be90fb50bb541e7e28
1 file changed