Commit 3fc61bb7 by tonihei Committed by Ian Baker

Deprecate MediaMetadata folderType and stabilize mediaType+isBrowsable

PiperOrigin-RevId: 522058915
parent e4194fc8
......@@ -52,6 +52,9 @@
`onAudioCapabilitiesChanged` in `AudioSink.Listener` interface, and a
new interface `RendererCapabilities.Listener` which triggers
`onRendererCapabilitiesChanged` events.
* Metadata:
* Deprecate `MediaMetadata.folderType` in favor of `isBrowsable` and
`mediaType`.
* DRM:
* Reduce the visibility of several internal-only methods on
`DefaultDrmSession` that aren't expected to be called from outside the
......
......@@ -30,6 +30,7 @@ public class MediaMetadataTest {
private static final String EXTRAS_KEY = "exampleKey";
private static final String EXTRAS_VALUE = "exampleValue";
@SuppressWarnings("deprecation") // Testing deprecated field.
@Test
public void builder_minimal_correctDefaults() {
MediaMetadata mediaMetadata = new MediaMetadata.Builder().build();
......@@ -134,6 +135,7 @@ public class MediaMetadataTest {
assertThat(mediaMetadataFromBundle.extras.getString(EXTRAS_KEY)).isEqualTo(EXTRAS_VALUE);
}
@SuppressWarnings("deprecation") // Testing deprecated setter.
@Test
public void builderSetFolderType_toNone_setsIsBrowsableToFalse() {
MediaMetadata mediaMetadata =
......@@ -142,6 +144,7 @@ public class MediaMetadataTest {
assertThat(mediaMetadata.isBrowsable).isFalse();
}
@SuppressWarnings("deprecation") // Testing deprecated setter.
@Test
public void builderSetFolderType_toNotNone_setsIsBrowsableToTrueAndMatchingMediaType() {
MediaMetadata mediaMetadata =
......@@ -151,6 +154,7 @@ public class MediaMetadataTest {
assertThat(mediaMetadata.mediaType).isEqualTo(MediaMetadata.MEDIA_TYPE_FOLDER_PLAYLISTS);
}
@SuppressWarnings("deprecation") // Testing deprecated setter.
@Test
public void
builderSetFolderType_toNotNoneWithManualMediaType_setsIsBrowsableToTrueAndDoesNotOverrideMediaType() {
......@@ -164,6 +168,7 @@ public class MediaMetadataTest {
assertThat(mediaMetadata.mediaType).isEqualTo(MediaMetadata.MEDIA_TYPE_FOLDER_PODCASTS);
}
@SuppressWarnings("deprecation") // Testing deprecated field.
@Test
public void builderSetIsBrowsable_toTrueWithoutMediaType_setsFolderTypeToMixed() {
MediaMetadata mediaMetadata = new MediaMetadata.Builder().setIsBrowsable(true).build();
......@@ -171,6 +176,7 @@ public class MediaMetadataTest {
assertThat(mediaMetadata.folderType).isEqualTo(MediaMetadata.FOLDER_TYPE_MIXED);
}
@SuppressWarnings("deprecation") // Testing deprecated field.
@Test
public void builderSetIsBrowsable_toTrueWithMediaType_setsFolderTypeToMatchMediaType() {
MediaMetadata mediaMetadata =
......@@ -182,6 +188,7 @@ public class MediaMetadataTest {
assertThat(mediaMetadata.folderType).isEqualTo(MediaMetadata.FOLDER_TYPE_ARTISTS);
}
@SuppressWarnings("deprecation") // Testing deprecated field.
@Test
public void builderSetFolderType_toFalse_setsFolderTypeToNone() {
MediaMetadata mediaMetadata = new MediaMetadata.Builder().setIsBrowsable(false).build();
......@@ -189,6 +196,7 @@ public class MediaMetadataTest {
assertThat(mediaMetadata.folderType).isEqualTo(MediaMetadata.FOLDER_TYPE_NONE);
}
@SuppressWarnings("deprecation") // Setting deprecated fields.
private static MediaMetadata getFullyPopulatedMediaMetadata() {
Bundle extras = new Bundle();
extras.putString(EXTRAS_KEY, EXTRAS_VALUE);
......
......@@ -176,8 +176,8 @@ public final class LibraryResult<V> implements Bundleable {
/**
* Creates an instance with a media item and {@link #resultCode}{@code ==}{@link #RESULT_SUCCESS}.
*
* <p>The {@link MediaItem#mediaMetadata} must specify {@link MediaMetadata#isBrowsable} (or
* {@link MediaMetadata#folderType}) and {@link MediaMetadata#isPlayable} fields.
* <p>The {@link MediaItem#mediaMetadata} must specify {@link MediaMetadata#isBrowsable} and
* {@link MediaMetadata#isPlayable} fields.
*
* @param item The media item.
* @param params The optional parameters to describe the media item.
......@@ -193,8 +193,7 @@ public final class LibraryResult<V> implements Bundleable {
* #RESULT_SUCCESS}.
*
* <p>The {@link MediaItem#mediaMetadata} of each item in the list must specify {@link
* MediaMetadata#isBrowsable} (or {@link MediaMetadata#folderType}) and {@link
* MediaMetadata#isPlayable} fields.
* MediaMetadata#isBrowsable} and {@link MediaMetadata#isPlayable} fields.
*
* @param items The list of media items.
* @param params The optional parameters to describe the list of media items.
......
......@@ -119,9 +119,8 @@ public abstract class MediaLibraryService extends MediaSessionService {
* An extended {@link MediaSession.Callback} for the {@link MediaLibrarySession}.
*
* <p>When you return {@link LibraryResult} with {@link MediaItem media items}, each item must
* have valid {@link MediaItem#mediaId} and specify {@link MediaMetadata#isBrowsable} (or {@link
* MediaMetadata#folderType}) and {@link MediaMetadata#isPlayable} in its {@link
* MediaItem#mediaMetadata}.
* have valid {@link MediaItem#mediaId} and specify {@link MediaMetadata#isBrowsable} and {@link
* MediaMetadata#isPlayable} in its {@link MediaItem#mediaMetadata}.
*/
public interface Callback extends MediaSession.Callback {
......
......@@ -317,6 +317,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
/** Converts a {@link MediaItem} to a {@link MediaDescriptionCompat} */
@SuppressWarnings("deprecation") // Converting deprecated fields.
public static MediaDescriptionCompat convertToMediaDescriptionCompat(
MediaItem item, @Nullable Bitmap artworkBitmap) {
MediaDescriptionCompat.Builder builder =
......@@ -372,6 +373,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
descriptionCompat, ratingType, /* browsable= */ false, /* playable= */ true);
}
@SuppressWarnings("deprecation") // Populating deprecated fields.
private static MediaMetadata convertToMediaMetadata(
@Nullable MediaDescriptionCompat descriptionCompat,
@RatingCompat.Style int ratingType,
......@@ -425,6 +427,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
/** Creates {@link MediaMetadata} from the {@link MediaMetadataCompat} and rating type. */
@SuppressWarnings("deprecation") // Populating deprecated fields.
public static MediaMetadata convertToMediaMetadata(
@Nullable MediaMetadataCompat metadataCompat, @RatingCompat.Style int ratingType) {
if (metadataCompat == null) {
......@@ -547,6 +550,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
* duration should be included.
* @return An instance of the legacy {@link MediaMetadataCompat}.
*/
@SuppressWarnings("deprecation") // Converting deprecated fields.
public static MediaMetadataCompat convertToMediaMetadataCompat(
MediaMetadata metadata,
String mediaId,
......@@ -629,6 +633,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
return builder.build();
}
@SuppressWarnings("deprecation") // Converting to deprecated constants.
@MediaMetadata.FolderType
private static int convertToFolderType(long extraBtFolderType) {
if (extraBtFolderType == MediaDescriptionCompat.BT_FOLDER_TYPE_MIXED) {
......@@ -650,6 +655,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
}
@SuppressWarnings("deprecation") // Converting from deprecated constants.
private static long convertToExtraBtFolderType(@MediaMetadata.FolderType int folderType) {
switch (folderType) {
case MediaMetadata.FOLDER_TYPE_MIXED:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment