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

Commit 6d520a49 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Add QUERY_ARG_RELATED_URI to aid media placement.

We normally have strict rules about where media can be created to
help ensure that the user's content stays organized.  (For example,
"image/jpeg" can only be placed inside DCIM/ or Pictures/.)

However, when inserting an SD card from another device, it's pretty
common to find media outside of these well-defined top-level
directories.  Apps have been able to read and write pre-existing
content in these locations, but this change now provides a way for
apps to create new media "adjacent" to this pre-existing content,
subject to the following rules:

-- The top level MIME type must be in agreement.
-- The relative path on the device must be in agreement.

When a developer wants to perform an insert() which would normally
be blocked, they can provide a QUERY_ARG_RELATED_URI to allow that
operation to succeed, if it meets the rules above.

Bug: 131643582
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I7d678ee733023f5c5b55b5d18cdcde5a20116312
parent 0fa31f69
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -38643,6 +38643,7 @@ package android.provider {
    field public static final String QUERY_ARG_MATCH_FAVORITE = "android:query-arg-match-favorite";
    field public static final String QUERY_ARG_MATCH_PENDING = "android:query-arg-match-pending";
    field public static final String QUERY_ARG_MATCH_TRASHED = "android:query-arg-match-trashed";
    field public static final String QUERY_ARG_RELATED_URI = "android:query-arg-related-uri";
    field public static final String UNKNOWN_STRING = "<unknown>";
    field public static final String VOLUME_EXTERNAL = "external";
    field public static final String VOLUME_EXTERNAL_PRIMARY = "external_primary";
+17 −0
Original line number Diff line number Diff line
@@ -563,6 +563,23 @@ public final class MediaStore {
      */
    public static final String UNKNOWN_STRING = "<unknown>";

    /**
     * Specify a {@link Uri} that is "related" to the current operation being
     * performed.
     * <p>
     * This is typically used to allow an operation that may normally be
     * rejected, such as making a copy of a pre-existing image located under a
     * {@link MediaColumns#RELATIVE_PATH} where new images are not allowed.
     * <p>
     * It's strongly recommended that when making a copy of pre-existing content
     * that you define the "original document ID" GUID as defined by the <em>XMP
     * Media Management</em> standard.
     * <p>
     * This key can be placed in a {@link Bundle} of extras and passed to
     * {@link ContentResolver#insert}.
     */
    public static final String QUERY_ARG_RELATED_URI = "android:query-arg-related-uri";

    /**
     * Specify how {@link MediaColumns#IS_PENDING} items should be filtered when
     * performing a {@link MediaStore} operation.