Merge "Handle _ and % in paths" into jb-dev
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index d23b90d..83fb8d0 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -19,7 +19,7 @@
import static android.Manifest.permission.ACCESS_CACHE_FILESYSTEM;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
-import static android.os.ParcelFileDescriptor.MODE_READ_WRITE;
+import static android.os.ParcelFileDescriptor.MODE_READ_ONLY;
import static android.os.ParcelFileDescriptor.MODE_WRITE_ONLY;
import android.app.SearchManager;
@@ -4319,7 +4319,7 @@
final int modeBits = ContentResolver.modeToMode(uri, mode);
final boolean isWrite = (modeBits & MODE_WRITE_ONLY) != 0;
- final File file = queryForDataFile(uri);
+ File file = queryForDataFile(uri);
final String path;
try {
path = file.getCanonicalPath();
@@ -4335,6 +4335,13 @@
getContext().enforceCallingOrSelfPermission(
WRITE_EXTERNAL_STORAGE, "External path: " + path);
}
+
+ // bypass emulation layer when file is opened for reading
+ if (modeBits == MODE_READ_ONLY && Environment.isExternalStorageEmulated()) {
+ file = new File(Environment.getMediaStorageDirectory(), path.substring(
+ sExternalPath.length()));
+ }
+
} else if (path.startsWith(sCachePath)) {
getContext().enforceCallingOrSelfPermission(
ACCESS_CACHE_FILESYSTEM, "Cache path: " + path);