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

Commit f9986700 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Respond to API feedback on DIRECTORY columns.

Internal feedback asked for more documentation, and feedback from
external teams (at least Photos and Camera) was the ability to store
files at arbitrary directory depths.

We now offer a single PATH column, which gives callers more precise
control over file placement.  The old DIRECTORY columns remain
intact for now, and are temporarily accepted to support apps
developing against the preview SDKs.

Bug: 127657692, 123967243
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: Icd90d7c89d066d4ab68aa2f543ccc6fbc3b4f596
parent d4b81682
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -38765,8 +38765,7 @@ package android.provider {
    field public static final String MIME_TYPE = "mime_type";
    field public static final String MIME_TYPE = "mime_type";
    field public static final String ORIGINAL_DOCUMENT_ID = "original_document_id";
    field public static final String ORIGINAL_DOCUMENT_ID = "original_document_id";
    field public static final String OWNER_PACKAGE_NAME = "owner_package_name";
    field public static final String OWNER_PACKAGE_NAME = "owner_package_name";
    field public static final String PRIMARY_DIRECTORY = "primary_directory";
    field public static final String RELATIVE_PATH = "relative_path";
    field public static final String SECONDARY_DIRECTORY = "secondary_directory";
    field public static final String SIZE = "_size";
    field public static final String SIZE = "_size";
    field public static final String TITLE = "title";
    field public static final String TITLE = "title";
    field public static final String WIDTH = "width";
    field public static final String WIDTH = "width";
+2 −0
Original line number Original line Diff line number Diff line
@@ -524,6 +524,8 @@ package android.provider {
  public static interface MediaStore.MediaColumns extends android.provider.BaseColumns {
  public static interface MediaStore.MediaColumns extends android.provider.BaseColumns {
    field @Deprecated public static final String HASH = "_hash";
    field @Deprecated public static final String HASH = "_hash";
    field @Deprecated public static final String IS_TRASHED = "is_trashed";
    field @Deprecated public static final String IS_TRASHED = "is_trashed";
    field @Deprecated public static final String PRIMARY_DIRECTORY = "primary_directory";
    field @Deprecated public static final String SECONDARY_DIRECTORY = "secondary_directory";
  }
  }


  @Deprecated public static class MediaStore.PendingParams {
  @Deprecated public static class MediaStore.PendingParams {
+43 −2
Original line number Original line Diff line number Diff line
@@ -873,7 +873,7 @@ public final class MediaStore {
     */
     */
    public interface MediaColumns extends BaseColumns {
    public interface MediaColumns extends BaseColumns {
        /**
        /**
         * Path to the media item on disk.
         * Absolute filesystem path to the media item on disk.
         * <p>
         * <p>
         * Note that apps may not have filesystem permissions to directly access
         * Note that apps may not have filesystem permissions to directly access
         * this path. Instead of trying to open this path directly, apps should
         * this path. Instead of trying to open this path directly, apps should
@@ -920,6 +920,10 @@ public final class MediaStore {


        /**
        /**
         * The display name of the media item.
         * The display name of the media item.
         * <p>
         * For example, an item stored at
         * {@code /storage/0000-0000/DCIM/Vacation/IMG1024.JPG} would have a
         * display name of {@code IMG1024.JPG}.
         */
         */
        @Column(Cursor.FIELD_TYPE_STRING)
        @Column(Cursor.FIELD_TYPE_STRING)
        public static final String DISPLAY_NAME = "_display_name";
        public static final String DISPLAY_NAME = "_display_name";
@@ -985,7 +989,8 @@ public final class MediaStore {


        /**
        /**
         * Flag indicating if a media item is pending, and still being inserted
         * Flag indicating if a media item is pending, and still being inserted
         * by its owner.
         * by its owner. While this flag is set, only the owner of the item can
         * open the underlying file; requests from other apps will be rejected.
         *
         *
         * @see MediaStore#setIncludePending(Uri)
         * @see MediaStore#setIncludePending(Uri)
         */
         */
@@ -1032,18 +1037,54 @@ public final class MediaStore {
        @Column(value = Cursor.FIELD_TYPE_STRING, readOnly = true)
        @Column(value = Cursor.FIELD_TYPE_STRING, readOnly = true)
        public static final String OWNER_PACKAGE_NAME = "owner_package_name";
        public static final String OWNER_PACKAGE_NAME = "owner_package_name";


        /**
         * Relative path of this media item within the storage device where it
         * is persisted. For example, an item stored at
         * {@code /storage/0000-0000/DCIM/Vacation/IMG1024.JPG} would have a
         * path of {@code DCIM/Vacation}.
         * <p>
         * This value should only be used for organizational purposes, and you
         * should not attempt to construct or access a raw filesystem path using
         * this value. If you need to open a media item, use an API like
         * {@link ContentResolver#openFileDescriptor(Uri, String)}.
         * <p>
         * When this value is set to {@code NULL} during an
         * {@link ContentResolver#insert} operation, the newly created item will
         * be placed in a relevant default location based on the type of media
         * being inserted. For example, a {@code image/jpeg} item will be placed
         * under {@link Environment#DIRECTORY_PICTURES}.
         * <p>
         * You can modify this column during an {@link ContentResolver#update}
         * call, which will move the underlying file on disk.
         * <p>
         * In both cases above, content must be placed under a top-level
         * directory that is relevant to the media type. For example, attempting
         * to place a {@code audio/mpeg} file under
         * {@link Environment#DIRECTORY_PICTURES} will be rejected.
         */
        @Column(Cursor.FIELD_TYPE_STRING)
        public static final String RELATIVE_PATH = "relative_path";

        /**
        /**
         * The primary directory name this media exists under. The value may be
         * The primary directory name this media exists under. The value may be
         * {@code NULL} if the media doesn't have a primary directory name.
         * {@code NULL} if the media doesn't have a primary directory name.
         *
         * @removed
         * @deprecated Replaced by {@link #RELATIVE_PATH}.
         */
         */
        @Column(Cursor.FIELD_TYPE_STRING)
        @Column(Cursor.FIELD_TYPE_STRING)
        @Deprecated
        public static final String PRIMARY_DIRECTORY = "primary_directory";
        public static final String PRIMARY_DIRECTORY = "primary_directory";


        /**
        /**
         * The secondary directory name this media exists under. The value may
         * The secondary directory name this media exists under. The value may
         * be {@code NULL} if the media doesn't have a secondary directory name.
         * be {@code NULL} if the media doesn't have a secondary directory name.
         *
         * @removed
         * @deprecated Replaced by {@link #RELATIVE_PATH}.
         */
         */
        @Column(Cursor.FIELD_TYPE_STRING)
        @Column(Cursor.FIELD_TYPE_STRING)
        @Deprecated
        public static final String SECONDARY_DIRECTORY = "secondary_directory";
        public static final String SECONDARY_DIRECTORY = "secondary_directory";


        /**
        /**