Forget volumes that have been freshly formatted.

When the user formats an existing volume, the old partition will never
appear again, so we can immediately clean up any VolumeRecord
information.

This change ensures that the next MediaProvider idle maintenance pass
will see the UUID has been removed via getRecentStorageVolumes(),
and will clean up stale metadata, instead of waiting an entire week
for the volume to appear stale.

Bug: 157164840
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: Ia60440a423d980de141a87e957cfe03f91a6d9ff
This commit is contained in:
Jeff Sharkey
2020-06-16 10:12:54 -06:00
parent c744ad246e
commit e56dab21a5

View File

@@ -2252,8 +2252,15 @@ class StorageManagerService extends IStorageManager.Stub
enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);
final VolumeInfo vol = findVolumeByIdOrThrow(volId);
final String fsUuid = vol.fsUuid;
try {
mVold.format(vol.id, "auto");
// After a successful format above, we should forget about any
// records for the old partition, since it'll never appear again
if (!TextUtils.isEmpty(fsUuid)) {
forgetVolume(fsUuid);
}
} catch (Exception e) {
Slog.wtf(TAG, e);
}