Extract volume_name from path for NULL volume_name in legacy database

1) VOLUME_NAME column was introduced in Q, and value of this column was
updated in recomputeDataValues during database upgrade.
2) We skip DatabaseHelper#recomputeDataValues for legacy database
because they are recomputed during the migration anyways.
3) During migration, we migrate VOLUME_NAME as it is from legacy
database.

All these together caused empty/null values for VOLUME_NAME column in
MediaProvider database after OS upgrade from P->R.
Because of empty volume names, MediaProvider#query skips all rows of
files and directories that existed before OS upgrade. This made gallery
to not show any files.
Since query doesn't return these rows, ModernMediaScanner will not able
to update volume_name for these database rows. Hence, even reboot will
not be able to fix this issue, only deleting database can solve this
problem.

To fix this issue, if volume_name is empty/NULL during migration, we
extract the volume_name from path(i.e., value of MediaColumns.DATA)

Bug: 182137498
Test: Verified that gallery shows photos after OS upgrade from P->R
Test:
com.android.providers.media.client.LegacyProviderMigrationTest#testMigrateNullVolumeName

Merged-In: I18c3b75d3b082c018efe96d770641f109582061c
Change-Id: I18c3b75d3b082c018efe96d770641f109582061c
(cherry picked from commit 2f28999fb42a40e07cba0a19ad97798af3d02712)
2 files changed