Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 630c3083 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Add MediaStore.Downloads.CONTENT_TYPE."

parents 82f028ce a50f1a35
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37830,6 +37830,7 @@ package android.provider {
  public static final class MediaStore.Downloads implements android.provider.MediaStore.DownloadColumns {
    method public static android.net.Uri getContentUri(java.lang.String);
    field public static final java.lang.String CONTENT_TYPE = "vnd.android.cursor.dir/download";
    field public static final android.net.Uri EXTERNAL_CONTENT_URI;
    field public static final android.net.Uri INTERNAL_CONTENT_URI;
  }
+25 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import java.io.OutputStream;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;

/**
 * The Media provider contains meta data for all available media on both internal
@@ -1045,6 +1046,20 @@ public final class MediaStore {
        public static final Uri EXTERNAL_CONTENT_URI =
                getContentUri("external");

        /**
         * The MIME type for this table.
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/download";

        /**
         * Regex that matches paths that needs to be considered part of downloads collection.
         * @hide
         */
        public static final Pattern PATTERN_DOWNLOADS_FILE = Pattern.compile(
                "(?i)^/storage/[^/]+/(?:[0-9]+/)?(?:Android/sandbox/[^/]+/)?Download/.+");
        private static final Pattern PATTERN_DOWNLOADS_DIRECTORY = Pattern.compile(
                "(?i)^/storage/[^/]+/(?:[0-9]+/)?(?:Android/sandbox/[^/]+/)?Download/?");

        /**
         * Get the content:// style URI for the downloads table on the
         * given volume.
@@ -1061,6 +1076,16 @@ public final class MediaStore {
        public static Uri getContentUriForPath(@NonNull String path) {
            return getContentUri(getVolumeNameForPath(path));
        }

        /** @hide */
        public static boolean isDownload(@NonNull String path) {
            return PATTERN_DOWNLOADS_FILE.matcher(path).matches();
        }

        /** @hide */
        public static boolean isDownloadDir(@NonNull String path) {
            return PATTERN_DOWNLOADS_DIRECTORY.matcher(path).matches();
        }
    }

    private static String getVolumeNameForPath(@NonNull String path) {