Permalink
Browse files

MediaProvider: read real mount point for removable storage

*Note: must give media_rw group access to /mnt/media_rw (770)

Change-Id: Ia6e80c5a13a3da5d9ca43aca055c494bc1957c68
  • Loading branch information...
drewis committed Dec 3, 2013
1 parent 5ad6b18 commit 5c067577fe4757cb2d744c4674934c4810cd2589
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/com/android/providers/media/MediaProvider.java
@@ -5244,8 +5244,18 @@ private Uri attachVolume(String volume) {
} else if (EXTERNAL_VOLUME.equals(volume)) {
if (Environment.isExternalStorageRemovable()) {
String path = mExternalStoragePaths[0];
// For Kitkat we know this will fail but check anyway.
int volumeID = FileUtils.getFatVolumeId(path);
if (LOCAL_LOGV) Log.v(TAG, path + " volume ID: " + volumeID);
//if (LOCAL_LOGV)
Log.d(TAG, path + " volume ID: " + volumeID);
if (volumeID == -1) {
// HACK: build the real mount point (NOTE: /mnt/media_rw must be 770)
String realPath = "/mnt/media_rw/" + path.substring(path.lastIndexOf('/')+1);
volumeID = FileUtils.getFatVolumeId(realPath);
Log.d(TAG, realPath + " volume ID: " + volumeID);
}
// Must check for failure!
// If the volume is not (yet) mounted, this will create a new

0 comments on commit 5c06757

Please sign in to comment.