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

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

Respond to API feedback for directory names.

We have public APIs to set "primary" and "secondary" directory names
when contributing new media, but we don't have a way to read out that
information once an app targets Q.  So define columns to provide API
symmetry.

Also, since these are called "primary" and "secondary", it's
confusing to have a "secondary bucket ID" defined, so rename that to
be a "group ID" instead.

Since this is a major schema change, recalculate all columns that
are derived from file paths.

Fix bugs where we tried dropping SQLite internals when wiping the
schema of a database, which would have always failed.

Bug: 115377970
Test: atest MediaProviderTests
Test: atest cts/tests/tests/media/src/android/media/cts/MediaScanner*
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: I7b7b7e03bfdae6f94a1d70ac1d9e80776a2171b8
parent 7e8bd1e0
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -38455,13 +38455,13 @@ package android.provider {
    field public static final String BUCKET_ID = "bucket_id";
    field public static final String DATE_TAKEN = "datetaken";
    field public static final String DESCRIPTION = "description";
    field public static final String GROUP_ID = "group_id";
    field public static final String IS_PRIVATE = "isprivate";
    field @Deprecated public static final String LATITUDE = "latitude";
    field @Deprecated public static final String LONGITUDE = "longitude";
    field @Deprecated public static final String MINI_THUMB_MAGIC = "mini_thumb_magic";
    field public static final String ORIENTATION = "orientation";
    field @Deprecated public static final String PICASA_ID = "picasa_id";
    field public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
  }
  public static final class MediaStore.Images.Media implements android.provider.MediaStore.Images.ImageColumns {
@@ -38515,6 +38515,8 @@ package android.provider {
    field public static final String IS_TRASHED = "is_trashed";
    field public static final String MIME_TYPE = "mime_type";
    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 SECONDARY_DIRECTORY = "secondary_directory";
    field public static final String SIZE = "_size";
    field public static final String TITLE = "title";
    field public static final String WIDTH = "width";
@@ -38582,13 +38584,13 @@ package android.provider {
    field public static final String DATE_TAKEN = "datetaken";
    field public static final String DESCRIPTION = "description";
    field public static final String DURATION = "duration";
    field public static final String GROUP_ID = "group_id";
    field public static final String IS_PRIVATE = "isprivate";
    field public static final String LANGUAGE = "language";
    field @Deprecated public static final String LATITUDE = "latitude";
    field @Deprecated public static final String LONGITUDE = "longitude";
    field @Deprecated public static final String MINI_THUMB_MAGIC = "mini_thumb_magic";
    field public static final String RESOLUTION = "resolution";
    field public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
    field public static final String TAGS = "tags";
  }
+46 −8
Original line number Diff line number Diff line
@@ -641,6 +641,8 @@ public final class MediaStore {
         * location. For example, when this value is left undefined, pending
         * {@link MediaStore.Audio.Media} items are stored under
         * {@link Environment#DIRECTORY_MUSIC}.
         *
         * @see MediaColumns#PRIMARY_DIRECTORY
         */
        public void setPrimaryDirectory(@Nullable String primaryDirectory) {
            this.primaryDirectory = primaryDirectory;
@@ -652,6 +654,8 @@ public final class MediaStore {
         * <p>
         * You may leave this value undefined to store the media as a direct
         * descendant of the {@link #setPrimaryDirectory(String)} location.
         *
         * @see MediaColumns#SECONDARY_DIRECTORY
         */
        public void setSecondaryDirectory(@Nullable String secondaryDirectory) {
            this.secondaryDirectory = secondaryDirectory;
@@ -980,6 +984,26 @@ public final class MediaStore {
         * Type: TEXT
         */
        public static final String OWNER_PACKAGE_NAME = "owner_package_name";

        /**
         * The primary directory name this media exists under. The value may be
         * {@code NULL} if the media doesn't have a primary directory name.
         * <p>
         * Type: TEXT
         *
         * @see PendingParams#setPrimaryDirectory(String)
         */
        public static final String PRIMARY_DIRECTORY = "primary_directory";

        /**
         * The secondary directory name this media exists under. The value may
         * be {@code NULL} if the media doesn't have a secondary directory name.
         * <p>
         * Type: TEXT
         *
         * @see PendingParams#setSecondaryDirectory(String)
         */
        public static final String SECONDARY_DIRECTORY = "secondary_directory";
    }

    /**
@@ -1428,13 +1452,20 @@ public final class MediaStore {
            public static final String BUCKET_DISPLAY_NAME = "bucket_display_name";

            /**
             * The secondary bucket ID of this media item. This can be useful to
             * present the user a second-level clustering of related media
             * items. This is a read-only column that is automatically computed.
             * The group ID of this media item. This can be useful to present
             * the user a grouping of related media items, such a burst of
             * images, or a {@code JPG} and {@code DNG} version of the same
             * image.
             * <p>
             * This is a read-only column that is automatically computed based
             * on the first portion of the filename. For example,
             * {@code IMG1024.BURST001.JPG} and {@code IMG1024.BURST002.JPG}
             * will have the same {@link #GROUP_ID} because the first portion of
             * their filenames is identical.
             * <p>
             * Type: INTEGER
             */
            public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
            public static final String GROUP_ID = "group_id";
        }

        public static final class Media implements ImageColumns {
@@ -2697,13 +2728,20 @@ public final class MediaStore {
            public static final String BUCKET_DISPLAY_NAME = "bucket_display_name";

            /**
             * The secondary bucket ID of this media item. This can be useful to
             * present the user a second-level clustering of related media
             * items. This is a read-only column that is automatically computed.
             * The group ID of this media item. This can be useful to present
             * the user a grouping of related media items, such a burst of
             * images, or a {@code JPG} and {@code DNG} version of the same
             * image.
             * <p>
             * This is a read-only column that is automatically computed based
             * on the first portion of the filename. For example,
             * {@code IMG1024.BURST001.JPG} and {@code IMG1024.BURST002.JPG}
             * will have the same {@link #GROUP_ID} because the first portion of
             * their filenames is identical.
             * <p>
             * Type: INTEGER
             */
            public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
            public static final String GROUP_ID = "group_id";

            /**
             * The bookmark for the video. Time in ms. Represents the location in the video that the