Revert "Use cached volumes to resolve volume paths"
This reverts commit e186819554827cd3acdddbedc3a74389ae5f2600.
Reason for revert: There's a potential race in SMS between H_VOLUME_BROADCAST and MSG_VOLUME_STATE_CHANGED because they are handled on different Handlers. A better fix will be to only listen for one of these events in the MediaProvider, so for instance stop listening to the MEDIA_ broadcasts and instead only rely only listen to onVolumeStateChanged and update/attach/detach volumes as appropriate there
Change-Id: Iec5f3aa7657a7c2d37dd2453dae8aa3ea4b5fa49
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index a456ebf..7ae3f07 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -274,7 +274,13 @@
}
public static File getVolumePath(String volumeName) throws FileNotFoundException {
- return MediaStore.getVolumePath(sCachedVolumes, volumeName);
+ // TODO(b/144275217): A more performant invocation is
+ // MediaStore#getVolumePath(sCachedVolumes, volumeName) since we avoid a binder
+ // to StorageManagerService to getVolumeList. We need to delay the mount broadcasts
+ // from StorageManagerService so that sCachedVolumes is up to date in
+ // onVolumeStateChanged before we to call this method, otherwise we would crash
+ // when we don't find volumeName yet
+ return MediaStore.getVolumePath(volumeName);
}
public static Set<String> getExternalVolumeNames() {