diff options
Diffstat (limited to 'apex')
-rw-r--r-- | apex/framework/java/android/provider/MediaStore.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/apex/framework/java/android/provider/MediaStore.java b/apex/framework/java/android/provider/MediaStore.java index c9ee81196..b528bf649 100644 --- a/apex/framework/java/android/provider/MediaStore.java +++ b/apex/framework/java/android/provider/MediaStore.java @@ -32,6 +32,7 @@ import android.annotation.WorkerThread; import android.app.Activity; import android.app.AppOpsManager; import android.app.PendingIntent; +import android.app.compat.CompatChanges; import android.compat.annotation.UnsupportedAppUsage; import android.content.ClipData; import android.content.ContentProvider; @@ -61,6 +62,7 @@ import android.os.Bundle; import android.os.CancellationSignal; import android.os.Environment; import android.os.OperationCanceledException; +import android.os.Parcel; import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.os.RemoteException; @@ -663,6 +665,11 @@ public final class MediaStore { public static final String INTENT_ACTION_VIDEO_CAMERA = "android.media.action.VIDEO_CAMERA"; /** + * This is a copy of the flag that exists in MediaProvider. + */ + static final long EXCLUDE_UNRELIABLE_STORAGE_VOLUMES = 391360514L; + + /** * Standard Intent action that can be sent to have the camera application * capture an image and return it. * <p> @@ -4734,7 +4741,15 @@ public final class MediaStore { case Environment.MEDIA_MOUNTED_READ_ONLY: { final String volumeName = sv.getMediaStoreVolumeName(); if (volumeName != null) { - res.add(volumeName); + File directory = sv.getDirectory(); + if (shouldExcludeUnReliableStorageVolumes(context) + && directory != null + && directory.getAbsolutePath() != null + && directory.getAbsolutePath().startsWith("/mnt/")) { + Log.d(TAG, "skipping unreliable volume : " + volumeName); + } else { + res.add(volumeName); + } } break; } @@ -4744,6 +4759,15 @@ public final class MediaStore { } /** + * Checks if the EXCLUDE_UNRELIABLE_STORAGE_VOLUMES appcompat flag is enabled. + */ + private static boolean shouldExcludeUnReliableStorageVolumes(Context context) { + return Flags.excludeUnreliableVolumes() + && CompatChanges.isChangeEnabled( + EXCLUDE_UNRELIABLE_STORAGE_VOLUMES, context.getApplicationInfo().uid); + } + + /** * Works exactly the same as * {@link ContentResolver#openFileDescriptor(Uri, String, CancellationSignal)}, but only works * for {@link Uri} whose scheme is {@link ContentResolver#SCHEME_CONTENT} and its authority is |