Add bluetooth folder type to MediaDescriptionCompat and MediaMetadataCompat
Bug: 28210080
Change-Id: I5f2ff2ec1ff857088e6114d731d426ebe645477d
diff --git a/api/current.txt b/api/current.txt
index 3a09475..a18ba8f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4976,7 +4976,15 @@
method public java.lang.CharSequence getSubtitle();
method public java.lang.CharSequence getTitle();
method public void writeToParcel(android.os.Parcel, int);
+ field public static final long BT_FOLDER_TYPE_ALBUMS = 2L; // 0x2L
+ field public static final long BT_FOLDER_TYPE_ARTISTS = 3L; // 0x3L
+ field public static final long BT_FOLDER_TYPE_GENRES = 4L; // 0x4L
+ field public static final long BT_FOLDER_TYPE_MIXED = 0L; // 0x0L
+ field public static final long BT_FOLDER_TYPE_PLAYLISTS = 5L; // 0x5L
+ field public static final long BT_FOLDER_TYPE_TITLES = 1L; // 0x1L
+ field public static final long BT_FOLDER_TYPE_YEARS = 6L; // 0x6L
field public static final android.os.Parcelable.Creator<android.support.v4.media.MediaDescriptionCompat> CREATOR;
+ field public static final java.lang.String EXTRA_BT_FOLDER_TYPE = "android.media.extra.BT_FOLDER_TYPE";
}
public static final class MediaDescriptionCompat.Builder {
@@ -5016,6 +5024,7 @@
field public static final java.lang.String METADATA_KEY_ARTIST = "android.media.metadata.ARTIST";
field public static final java.lang.String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI";
field public static final java.lang.String METADATA_KEY_AUTHOR = "android.media.metadata.AUTHOR";
+ field public static final java.lang.String METADATA_KEY_BT_FOLDER_TYPE = "android.media.metadata.BT_FOLDER_TYPE";
field public static final java.lang.String METADATA_KEY_COMPILATION = "android.media.metadata.COMPILATION";
field public static final java.lang.String METADATA_KEY_COMPOSER = "android.media.metadata.COMPOSER";
field public static final java.lang.String METADATA_KEY_DATE = "android.media.metadata.DATE";
diff --git a/media-compat/java/android/support/v4/media/MediaDescriptionCompat.java b/media-compat/java/android/support/v4/media/MediaDescriptionCompat.java
index c9b627f..a9c5819 100644
--- a/media-compat/java/android/support/v4/media/MediaDescriptionCompat.java
+++ b/media-compat/java/android/support/v4/media/MediaDescriptionCompat.java
@@ -31,6 +31,68 @@
*/
public final class MediaDescriptionCompat implements Parcelable {
/**
+ * Used as a long extra field to indicate the bluetooth folder type of the media item as
+ * specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5. This is valid only for
+ * {@link MediaBrowserCompat.MediaItem} with
+ * {@link MediaBrowserCompat.MediaItem#FLAG_BROWSABLE}. The value should be one of the
+ * following:
+ * <ul>
+ * <li>{@link #BT_FOLDER_TYPE_MIXED}</li>
+ * <li>{@link #BT_FOLDER_TYPE_TITLES}</li>
+ * <li>{@link #BT_FOLDER_TYPE_ALBUMS}</li>
+ * <li>{@link #BT_FOLDER_TYPE_ARTISTS}</li>
+ * <li>{@link #BT_FOLDER_TYPE_GENRES}</li>
+ * <li>{@link #BT_FOLDER_TYPE_PLAYLISTS}</li>
+ * <li>{@link #BT_FOLDER_TYPE_YEARS}</li>
+ * </ul>
+ *
+ * @see #getExtras()
+ */
+ public static final String EXTRA_BT_FOLDER_TYPE = "android.media.extra.BT_FOLDER_TYPE";
+
+ /**
+ * The type of folder that is unknown or contains media elements of mixed types as specified in
+ * the section 6.10.2.2 of the Bluetooth AVRCP 1.5.
+ */
+ public static final long BT_FOLDER_TYPE_MIXED = 0;
+
+ /**
+ * The type of folder that contains media elements only as specified in the section 6.10.2.2 of
+ * the Bluetooth AVRCP 1.5.
+ */
+ public static final long BT_FOLDER_TYPE_TITLES = 1;
+
+ /**
+ * The type of folder that contains folders categorized by album as specified in the section
+ * 6.10.2.2 of the Bluetooth AVRCP 1.5.
+ */
+ public static final long BT_FOLDER_TYPE_ALBUMS = 2;
+
+ /**
+ * The type of folder that contains folders categorized by artist as specified in the section
+ * 6.10.2.2 of the Bluetooth AVRCP 1.5.
+ */
+ public static final long BT_FOLDER_TYPE_ARTISTS = 3;
+
+ /**
+ * The type of folder that contains folders categorized by genre as specified in the section
+ * 6.10.2.2 of the Bluetooth AVRCP 1.5.
+ */
+ public static final long BT_FOLDER_TYPE_GENRES = 4;
+
+ /**
+ * The type of folder that contains folders categorized by playlist as specified in the section
+ * 6.10.2.2 of the Bluetooth AVRCP 1.5.
+ */
+ public static final long BT_FOLDER_TYPE_PLAYLISTS = 5;
+
+ /**
+ * The type of folder that contains folders categorized by year as specified in the section
+ * 6.10.2.2 of the Bluetooth AVRCP 1.5.
+ */
+ public static final long BT_FOLDER_TYPE_YEARS = 6;
+
+ /**
* Custom key to store a media URI on API 21-22 devices (before it became part of the
* framework class) when parceling/converting to and from framework objects.
*
diff --git a/media-compat/java/android/support/v4/media/MediaMetadataCompat.java b/media-compat/java/android/support/v4/media/MediaMetadataCompat.java
index 4cb2c65..dcf34e1 100644
--- a/media-compat/java/android/support/v4/media/MediaMetadataCompat.java
+++ b/media-compat/java/android/support/v4/media/MediaMetadataCompat.java
@@ -198,6 +198,22 @@
public static final String METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID";
/**
+ * The bluetooth folder type of the media specified in the section 6.10.2.2 of the Bluetooth
+ * AVRCP 1.5. It should be one of the following:
+ * <ul>
+ * <li>{@link MediaDescriptionCompat#BT_FOLDER_TYPE_MIXED}</li>
+ * <li>{@link MediaDescriptionCompat#BT_FOLDER_TYPE_TITLES}</li>
+ * <li>{@link MediaDescriptionCompat#BT_FOLDER_TYPE_ALBUMS}</li>
+ * <li>{@link MediaDescriptionCompat#BT_FOLDER_TYPE_ARTISTS}</li>
+ * <li>{@link MediaDescriptionCompat#BT_FOLDER_TYPE_GENRES}</li>
+ * <li>{@link MediaDescriptionCompat#BT_FOLDER_TYPE_PLAYLISTS}</li>
+ * <li>{@link MediaDescriptionCompat#BT_FOLDER_TYPE_YEARS}</li>
+ * </ul>
+ */
+ public static final String METADATA_KEY_BT_FOLDER_TYPE
+ = "android.media.metadata.BT_FOLDER_TYPE";
+
+ /**
* @hide
*/
@StringDef({METADATA_KEY_TITLE, METADATA_KEY_ARTIST, METADATA_KEY_ALBUM, METADATA_KEY_AUTHOR,
@@ -213,7 +229,7 @@
* @hide
*/
@StringDef({METADATA_KEY_DURATION, METADATA_KEY_YEAR, METADATA_KEY_TRACK_NUMBER,
- METADATA_KEY_NUM_TRACKS, METADATA_KEY_DISC_NUMBER})
+ METADATA_KEY_NUM_TRACKS, METADATA_KEY_DISC_NUMBER, METADATA_KEY_BT_FOLDER_TYPE})
@Retention(RetentionPolicy.SOURCE)
public @interface LongKey {}
@@ -266,6 +282,7 @@
METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_ICON, METADATA_TYPE_BITMAP);
METADATA_KEYS_TYPE.put(METADATA_KEY_DISPLAY_ICON_URI, METADATA_TYPE_TEXT);
METADATA_KEYS_TYPE.put(METADATA_KEY_MEDIA_ID, METADATA_TYPE_TEXT);
+ METADATA_KEYS_TYPE.put(METADATA_KEY_BT_FOLDER_TYPE, METADATA_TYPE_LONG);
}
private static final @TextKey String[] PREFERRED_DESCRIPTION_ORDER = {
@@ -455,6 +472,12 @@
bob.setDescription(text[2]);
bob.setIconBitmap(icon);
bob.setIconUri(iconUri);
+ if (mBundle.containsKey(METADATA_KEY_BT_FOLDER_TYPE)) {
+ Bundle bundle = new Bundle();
+ bundle.putLong(MediaDescriptionCompat.EXTRA_BT_FOLDER_TYPE,
+ getLong(METADATA_KEY_BT_FOLDER_TYPE));
+ bob.setExtras(bundle);
+ }
mDescription = bob.build();
return mDescription;