Remove `Bundleable` type & `Bundleable.Creator<Foo> CREATOR` fields

This interface is not used in the library. Callers can use the
`Bundle toBundle()` and `static Foo fromBundle(Bundle)` methods
defined directly on each type instead.

PiperOrigin-RevId: 642271609
This commit is contained in:
ibaker 2024-06-11 08:02:51 -07:00 committed by Copybara-Service
parent efff1ee2f1
commit f554c12099
45 changed files with 85 additions and 854 deletions

View File

@ -42,6 +42,10 @@
* Cast Extension:
* Test Utilities:
* Remove deprecated symbols:
* Remove `Bundleable` interface. This includes removing all
`Bundleable.Creator<Foo> CREATOR` constant fields. Callers should use
the `Bundle toBundle()` and `static Foo fromBundle(Bundle)` methods on
each type instead.
## 1.4

View File

@ -49,7 +49,7 @@ import java.util.Arrays;
* required changes.
*/
@UnstableApi
public final class AdPlaybackState implements Bundleable {
public final class AdPlaybackState {
/**
* Represents a group of ads, with information about their states.
@ -57,7 +57,7 @@ public final class AdPlaybackState implements Bundleable {
* <p>Instances are immutable. Call the {@code with*} methods to get new instances that have the
* required changes.
*/
public static final class AdGroup implements Bundleable {
public static final class AdGroup {
/**
* The time of the ad group in the {@link Timeline.Period}, in microseconds, or {@link
@ -491,8 +491,6 @@ public final class AdPlaybackState implements Bundleable {
return durationsUs;
}
// Bundleable implementation.
private static final String FIELD_TIME_US = Util.intToStringMaxRadix(0);
private static final String FIELD_COUNT = Util.intToStringMaxRadix(1);
private static final String FIELD_URIS = Util.intToStringMaxRadix(2);
@ -506,7 +504,6 @@ public final class AdPlaybackState implements Bundleable {
// Intentionally assigning deprecated field.
// putParcelableArrayList actually supports null elements.
@SuppressWarnings({"deprecation", "nullness:argument"})
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putLong(FIELD_TIME_US, timeUs);
@ -522,15 +519,6 @@ public final class AdPlaybackState implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link AdGroup} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<AdGroup> CREATOR = AdGroup::fromBundle;
/** Restores a {@code AdGroup} from a {@link Bundle}. */
// getParcelableArrayList may have null elements.
@SuppressWarnings("nullness:type.argument")
@ -1244,21 +1232,18 @@ public final class AdPlaybackState implements Bundleable {
return positionUs < adGroupPositionUs;
}
// Bundleable implementation.
private static final String FIELD_AD_GROUPS = Util.intToStringMaxRadix(1);
private static final String FIELD_AD_RESUME_POSITION_US = Util.intToStringMaxRadix(2);
private static final String FIELD_CONTENT_DURATION_US = Util.intToStringMaxRadix(3);
private static final String FIELD_REMOVED_AD_GROUP_COUNT = Util.intToStringMaxRadix(4);
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #adsId} field so the {@link #adsId} of instances restored by {@link
* #CREATOR} will always be {@code null}.
* #fromBundle(Bundle)} will always be {@code null}.
*/
// TODO(b/166765820): See if missing adsId would be okay and add adsId to the Bundle otherwise.
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
ArrayList<Bundle> adGroupBundleList = new ArrayList<>();
@ -1280,17 +1265,6 @@ public final class AdPlaybackState implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link AdPlaybackState} from a {@link Bundle}.
*
* <p>The {@link #adsId} of restored instances will always be {@code null}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Bundleable.Creator<AdPlaybackState> CREATOR = AdPlaybackState::fromBundle;
/** Restores a {@code AdPlaybackState} from a {@link Bundle}. */
public static AdPlaybackState fromBundle(Bundle bundle) {
@Nullable ArrayList<Bundle> adGroupBundleList = bundle.getParcelableArrayList(FIELD_AD_GROUPS);

View File

@ -34,7 +34,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
* <p>This class is based on {@link android.media.AudioAttributes}, but can be used on all supported
* API versions.
*/
public final class AudioAttributes implements Bundleable {
public final class AudioAttributes {
/** A direct wrapper around {@link android.media.AudioAttributes}. */
@RequiresApi(21)
@ -200,8 +200,6 @@ public final class AudioAttributes implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_CONTENT_TYPE = Util.intToStringMaxRadix(0);
private static final String FIELD_FLAGS = Util.intToStringMaxRadix(1);
private static final String FIELD_USAGE = Util.intToStringMaxRadix(2);
@ -209,7 +207,6 @@ public final class AudioAttributes implements Bundleable {
private static final String FIELD_SPATIALIZATION_BEHAVIOR = Util.intToStringMaxRadix(4);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_CONTENT_TYPE, contentType);
@ -220,16 +217,6 @@ public final class AudioAttributes implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link AudioAttributes} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<AudioAttributes> CREATOR = AudioAttributes::fromBundle;
/** Restores a {@code AudioAttributes} from a {@link Bundle}. */
@UnstableApi
public static AudioAttributes fromBundle(Bundle bundle) {

View File

@ -1,47 +0,0 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.media3.common;
import android.os.Bundle;
import androidx.media3.common.util.UnstableApi;
/**
* @deprecated Interface not needed, call {@code toBundle()} on the target object directly.
*/
@Deprecated
@UnstableApi
public interface Bundleable {
/** Returns a {@link Bundle} representing the information stored in this object. */
Bundle toBundle();
/**
* @deprecated Interface not needed, call {@code fromBundle()} on the target type directly.
*/
@Deprecated
interface Creator<T extends Bundleable> {
/**
* Restores a {@link Bundleable} instance from a {@link Bundle} produced by {@link
* Bundleable#toBundle()}.
*
* <p>It guarantees the compatibility of {@link Bundle} representations produced by different
* versions of {@link Bundleable#toBundle()} by providing best default values for missing
* fields. It throws an exception if any essential fields are missing.
*/
T fromBundle(Bundle bundle);
}
}

View File

@ -31,7 +31,7 @@ import org.checkerframework.dataflow.qual.Pure;
* #SDR_BT709_LIMITED} instance.
*/
@UnstableApi
public final class ColorInfo implements Bundleable {
public final class ColorInfo {
/**
* Builds {@link ColorInfo} instances.
@ -461,8 +461,6 @@ public final class ColorInfo implements Bundleable {
}
}
// Bundleable implementation
private static final String FIELD_COLOR_SPACE = Util.intToStringMaxRadix(0);
private static final String FIELD_COLOR_RANGE = Util.intToStringMaxRadix(1);
private static final String FIELD_COLOR_TRANSFER = Util.intToStringMaxRadix(2);
@ -470,7 +468,6 @@ public final class ColorInfo implements Bundleable {
private static final String FIELD_LUMA_BITDEPTH = Util.intToStringMaxRadix(4);
private static final String FIELD_CHROMA_BITDEPTH = Util.intToStringMaxRadix(5);
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_COLOR_SPACE, colorSpace);
@ -482,13 +479,6 @@ public final class ColorInfo implements Bundleable {
return bundle;
}
/**
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<ColorInfo> CREATOR = ColorInfo::fromBundle;
/** Restores a {@code ColorInfo} from a {@link Bundle}. */
public static ColorInfo fromBundle(Bundle bundle) {
return new ColorInfo(

View File

@ -32,7 +32,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** Information about the playback device. */
public final class DeviceInfo implements Bundleable {
public final class DeviceInfo {
/** Types of playback. One of {@link #PLAYBACK_TYPE_LOCAL} or {@link #PLAYBACK_TYPE_REMOTE}. */
@Documented
@ -191,15 +191,12 @@ public final class DeviceInfo implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_PLAYBACK_TYPE = Util.intToStringMaxRadix(0);
private static final String FIELD_MIN_VOLUME = Util.intToStringMaxRadix(1);
private static final String FIELD_MAX_VOLUME = Util.intToStringMaxRadix(2);
private static final String FIELD_ROUTING_CONTROLLER_ID = Util.intToStringMaxRadix(3);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (playbackType != PLAYBACK_TYPE_LOCAL) {
@ -217,16 +214,6 @@ public final class DeviceInfo implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link DeviceInfo} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<DeviceInfo> CREATOR = DeviceInfo::fromBundle;
/** Restores a {@code DeviceInfo} from a {@link Bundle}. */
@UnstableApi
public static DeviceInfo fromBundle(Bundle bundle) {

View File

@ -125,7 +125,7 @@ import java.util.UUID;
* <li>{@link #tileCountVertical}
* </ul>
*/
public final class Format implements Bundleable {
public final class Format {
/**
* Builds {@link Format} instances.
@ -1363,8 +1363,6 @@ public final class Format implements Bundleable {
return builder.toString();
}
// Bundleable implementation.
private static final String FIELD_ID = Util.intToStringMaxRadix(0);
private static final String FIELD_LABEL = Util.intToStringMaxRadix(1);
private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(2);
@ -1400,7 +1398,6 @@ public final class Format implements Bundleable {
private static final String FIELD_LABELS = Util.intToStringMaxRadix(32);
@UnstableApi
@Override
public Bundle toBundle() {
return toBundle(/* excludeMetadata= */ false);
}
@ -1434,7 +1431,7 @@ public final class Format implements Bundleable {
for (int i = 0; i < initializationData.size(); i++) {
bundle.putByteArray(keyForInitializationData(i), initializationData.get(i));
}
// DrmInitData doesn't need to be Bundleable as it's only used in the playing process to
// DrmInitData doesn't need to be put into Bundle as it's only used in the playing process to
// initialize the decoder.
bundle.putParcelable(FIELD_DRM_INIT_DATA, drmInitData);
bundle.putLong(FIELD_SUBSAMPLE_OFFSET_US, subsampleOffsetUs);
@ -1465,16 +1462,6 @@ public final class Format implements Bundleable {
return bundle;
}
/**
* Object that can restore {@code Format} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Format> CREATOR = Format::fromBundle;
/** Restores a {@code Format} from a {@link Bundle}. */
@UnstableApi
public static Format fromBundle(Bundle bundle) {

View File

@ -72,8 +72,6 @@ public final class HeartRating extends Rating {
return isHeart == other.isHeart && rated == other.rated;
}
// Bundleable implementation.
private static final @RatingType int TYPE = RATING_TYPE_HEART;
private static final String FIELD_RATED = Util.intToStringMaxRadix(1);
@ -89,16 +87,6 @@ public final class HeartRating extends Rating {
return bundle;
}
/**
* Object that can restore a {@link HeartRating} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<HeartRating> CREATOR = HeartRating::fromBundle;
/** Restores a {@code HeartRating} from a {@link Bundle}. */
@UnstableApi
public static HeartRating fromBundle(Bundle bundle) {

View File

@ -42,7 +42,7 @@ import java.util.Map;
import java.util.UUID;
/** Representation of a media item. */
public final class MediaItem implements Bundleable {
public final class MediaItem {
/**
* Creates a {@link MediaItem} for the given URI.
@ -634,7 +634,7 @@ public final class MediaItem implements Bundleable {
}
/** DRM configuration for a media item. */
public static final class DrmConfiguration implements Bundleable {
public static final class DrmConfiguration {
/** Builder for {@link DrmConfiguration}. */
public static final class Builder {
@ -937,8 +937,6 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_SCHEME = Util.intToStringMaxRadix(0);
private static final String FIELD_LICENSE_URI = Util.intToStringMaxRadix(1);
private static final String FIELD_LICENSE_REQUEST_HEADERS = Util.intToStringMaxRadix(2);
@ -951,16 +949,6 @@ public final class MediaItem implements Bundleable {
private static final String FIELD_FORCED_SESSION_TRACK_TYPES = Util.intToStringMaxRadix(6);
private static final String FIELD_KEY_SET_ID = Util.intToStringMaxRadix(7);
/**
* An object that can restore {@link DrmConfiguration} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<DrmConfiguration> CREATOR = DrmConfiguration::fromBundle;
/** Restores a {@code DrmConfiguration} from a {@link Bundle}. */
@UnstableApi
public static DrmConfiguration fromBundle(Bundle bundle) {
@ -995,7 +983,6 @@ public final class MediaItem implements Bundleable {
}
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString(FIELD_SCHEME, scheme.toString());
@ -1028,7 +1015,7 @@ public final class MediaItem implements Bundleable {
}
/** Configuration for playing back linear ads with a media item. */
public static final class AdsConfiguration implements Bundleable {
public static final class AdsConfiguration {
/** Builder for {@link AdsConfiguration} instances. */
public static final class Builder {
@ -1113,22 +1100,8 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_AD_TAG_URI = Util.intToStringMaxRadix(0);
/**
* An object that can restore {@link AdsConfiguration} from a {@link Bundle}.
*
* <p>The {@link #adsId} of a restored instance will always be {@code null}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<AdsConfiguration> CREATOR = AdsConfiguration::fromBundle;
/** Restores a {@code AdsConfiguration} from a {@link Bundle}. */
@UnstableApi
public static AdsConfiguration fromBundle(Bundle bundle) {
@ -1138,13 +1111,12 @@ public final class MediaItem implements Bundleable {
}
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #adsId} field. The {@link #adsId} of an instance restored from such a
* bundle by {@link #CREATOR} will be {@code null}.
* bundle by {@link #fromBundle} will be {@code null}.
*/
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelable(FIELD_AD_TAG_URI, adTagUri);
@ -1153,7 +1125,7 @@ public final class MediaItem implements Bundleable {
}
/** Properties for local playback. */
public static final class LocalConfiguration implements Bundleable {
public static final class LocalConfiguration {
/** The {@link Uri}. */
public final Uri uri;
@ -1261,8 +1233,6 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_URI = Util.intToStringMaxRadix(0);
private static final String FIELD_MIME_TYPE = Util.intToStringMaxRadix(1);
private static final String FIELD_DRM_CONFIGURATION = Util.intToStringMaxRadix(2);
@ -1273,13 +1243,12 @@ public final class MediaItem implements Bundleable {
private static final String FIELD_IMAGE_DURATION_MS = Util.intToStringMaxRadix(7);
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #tag} field. The {@link #tag} of an instance restored from such a
* bundle by {@link #CREATOR} will be {@code null}.
* bundle by {@link #fromBundle} will be {@code null}.
*/
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelable(FIELD_URI, uri);
@ -1312,16 +1281,6 @@ public final class MediaItem implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link LocalConfiguration} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<LocalConfiguration> CREATOR = LocalConfiguration::fromBundle;
/** Restores a {@code LocalConfiguration} from a {@link Bundle}. */
@UnstableApi
public static LocalConfiguration fromBundle(Bundle bundle) {
@ -1359,7 +1318,7 @@ public final class MediaItem implements Bundleable {
}
/** Live playback configuration. */
public static final class LiveConfiguration implements Bundleable {
public static final class LiveConfiguration {
/** Builder for {@link LiveConfiguration} instances. */
public static final class Builder {
@ -1549,8 +1508,6 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_TARGET_OFFSET_MS = Util.intToStringMaxRadix(0);
private static final String FIELD_MIN_OFFSET_MS = Util.intToStringMaxRadix(1);
private static final String FIELD_MAX_OFFSET_MS = Util.intToStringMaxRadix(2);
@ -1558,7 +1515,6 @@ public final class MediaItem implements Bundleable {
private static final String FIELD_MAX_PLAYBACK_SPEED = Util.intToStringMaxRadix(4);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (targetOffsetMs != UNSET.targetOffsetMs) {
@ -1579,16 +1535,6 @@ public final class MediaItem implements Bundleable {
return bundle;
}
/**
* An object that can restore {@link LiveConfiguration} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<LiveConfiguration> CREATOR = LiveConfiguration::fromBundle;
/** Restores a {@code LiveConfiguration} from a {@link Bundle}. */
@UnstableApi
public static LiveConfiguration fromBundle(Bundle bundle) {
@ -1609,7 +1555,7 @@ public final class MediaItem implements Bundleable {
/** Properties for a text track. */
// TODO: Mark this final when Subtitle is deleted.
public static class SubtitleConfiguration implements Bundleable {
public static class SubtitleConfiguration {
/** Builder for {@link SubtitleConfiguration} instances. */
public static final class Builder {
@ -1788,8 +1734,6 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_URI = Util.intToStringMaxRadix(0);
private static final String FIELD_MIME_TYPE = Util.intToStringMaxRadix(1);
private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(2);
@ -1798,16 +1742,6 @@ public final class MediaItem implements Bundleable {
private static final String FIELD_LABEL = Util.intToStringMaxRadix(5);
private static final String FIELD_ID = Util.intToStringMaxRadix(6);
/**
* An object that can restore {@link SubtitleConfiguration} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SubtitleConfiguration> CREATOR = SubtitleConfiguration::fromBundle;
/** Restores a {@code SubtitleConfiguration} from a {@link Bundle}. */
@UnstableApi
public static SubtitleConfiguration fromBundle(Bundle bundle) {
@ -1831,7 +1765,6 @@ public final class MediaItem implements Bundleable {
}
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelable(FIELD_URI, uri);
@ -1907,7 +1840,7 @@ public final class MediaItem implements Bundleable {
/** Optionally clips the media item to a custom start and end position. */
// TODO: Mark this final when ClippingProperties is deleted.
public static class ClippingConfiguration implements Bundleable {
public static class ClippingConfiguration {
/** A clipping configuration with default values. */
public static final ClippingConfiguration UNSET = new ClippingConfiguration.Builder().build();
@ -2106,8 +2039,6 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_START_POSITION_MS = Util.intToStringMaxRadix(0);
private static final String FIELD_END_POSITION_MS = Util.intToStringMaxRadix(1);
private static final String FIELD_RELATIVE_TO_LIVE_WINDOW = Util.intToStringMaxRadix(2);
@ -2117,7 +2048,6 @@ public final class MediaItem implements Bundleable {
static final String FIELD_END_POSITION_US = Util.intToStringMaxRadix(6);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (startPositionMs != UNSET.startPositionMs) {
@ -2144,16 +2074,6 @@ public final class MediaItem implements Bundleable {
return bundle;
}
/**
* An object that can restore {@link ClippingConfiguration} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<ClippingProperties> CREATOR = ClippingConfiguration::fromBundle;
/** Restores a {@code ClippingProperties} from a {@link Bundle}. */
@SuppressWarnings("deprecation") // Building deprecated type for backwards compatibility
@UnstableApi
@ -2213,7 +2133,7 @@ public final class MediaItem implements Bundleable {
* instances (e.g. from a {@code androidx.media3.session.MediaController}) and the player creating
* the request doesn't know the required {@link LocalConfiguration} for playback.
*/
public static final class RequestMetadata implements Bundleable {
public static final class RequestMetadata {
/** Empty request metadata. */
public static final RequestMetadata EMPTY = new Builder().build();
@ -2309,14 +2229,11 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_MEDIA_URI = Util.intToStringMaxRadix(0);
private static final String FIELD_SEARCH_QUERY = Util.intToStringMaxRadix(1);
private static final String FIELD_EXTRAS = Util.intToStringMaxRadix(2);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (mediaUri != null) {
@ -2331,16 +2248,6 @@ public final class MediaItem implements Bundleable {
return bundle;
}
/**
* An object that can restore {@link RequestMetadata} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<RequestMetadata> CREATOR = RequestMetadata::fromBundle;
/** Restores a {@code RequestMetadata} from a {@link Bundle}. */
@UnstableApi
public static RequestMetadata fromBundle(Bundle bundle) {
@ -2449,7 +2356,6 @@ public final class MediaItem implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_MEDIA_ID = Util.intToStringMaxRadix(0);
private static final String FIELD_LIVE_CONFIGURATION = Util.intToStringMaxRadix(1);
private static final String FIELD_MEDIA_METADATA = Util.intToStringMaxRadix(2);
@ -2482,13 +2388,12 @@ public final class MediaItem implements Bundleable {
}
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #localConfiguration} field. The {@link #localConfiguration} of an
* instance restored from such a bundle by {@link #CREATOR} will be {@code null}.
* instance restored from such a bundle by {@link #fromBundle} will be {@code null}.
*/
@UnstableApi
@Override
public Bundle toBundle() {
return toBundle(/* includeLocalConfiguration= */ false);
}
@ -2502,18 +2407,6 @@ public final class MediaItem implements Bundleable {
return toBundle(/* includeLocalConfiguration= */ true);
}
/**
* An object that can restore {@code MediaItem} from a {@link Bundle}.
*
* <p>The {@link #localConfiguration} of a restored instance will always be {@code null}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<MediaItem> CREATOR = MediaItem::fromBundle;
/**
* Restores a {@code MediaItem} from a {@link Bundle}.
*

View File

@ -42,7 +42,7 @@ import java.util.List;
* Metadata of a {@link MediaItem}, playlist, or a combination of multiple sources of {@link
* Metadata}.
*/
public final class MediaMetadata implements Bundleable {
public final class MediaMetadata {
/** A builder for {@link MediaMetadata} instances. */
public static final class Builder {
@ -1270,8 +1270,6 @@ public final class MediaMetadata implements Bundleable {
extras == null);
}
// Bundleable implementation.
private static final String FIELD_TITLE = Util.intToStringMaxRadix(0);
private static final String FIELD_ARTIST = Util.intToStringMaxRadix(1);
private static final String FIELD_ALBUM_TITLE = Util.intToStringMaxRadix(2);
@ -1310,7 +1308,6 @@ public final class MediaMetadata implements Bundleable {
@SuppressWarnings("deprecation") // Bundling deprecated fields.
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (title != null) {
@ -1418,16 +1415,6 @@ public final class MediaMetadata implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link MediaMetadata} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<MediaMetadata> CREATOR = MediaMetadata::fromBundle;
/** Restores a {@code MediaMetadata} from a {@link Bundle}. */
@UnstableApi
@SuppressWarnings("deprecation") // Unbundling deprecated fields.

View File

@ -70,8 +70,6 @@ public final class PercentageRating extends Rating {
return percent == ((PercentageRating) obj).percent;
}
// Bundleable implementation.
private static final @RatingType int TYPE = RATING_TYPE_PERCENTAGE;
private static final String FIELD_PERCENT = Util.intToStringMaxRadix(1);
@ -85,16 +83,6 @@ public final class PercentageRating extends Rating {
return bundle;
}
/**
* Object that can restore a {@link PercentageRating} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<PercentageRating> CREATOR = PercentageRating::fromBundle;
/** Restores a {@code PercentageRating} from a {@link Bundle}. */
@UnstableApi
public static PercentageRating fromBundle(Bundle bundle) {

View File

@ -38,7 +38,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** Thrown when a non locally recoverable playback failure occurs. */
public class PlaybackException extends Exception implements Bundleable {
public class PlaybackException extends Exception {
/**
* Codes that identify causes of player errors.
@ -457,8 +457,6 @@ public class PlaybackException extends Exception implements Bundleable {
&& timestampMs == other.timestampMs;
}
// Bundleable implementation.
private static final String FIELD_INT_ERROR_CODE = Util.intToStringMaxRadix(0);
private static final String FIELD_LONG_TIMESTAMP_MS = Util.intToStringMaxRadix(1);
private static final String FIELD_STRING_MESSAGE = Util.intToStringMaxRadix(2);
@ -474,25 +472,15 @@ public class PlaybackException extends Exception implements Bundleable {
*/
@UnstableApi protected static final int FIELD_CUSTOM_ID_BASE = 1000;
/**
* Object that can create a {@link PlaybackException} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<PlaybackException> CREATOR = PlaybackException::new;
/** Restores a {@code PlaybackException} from a {@link Bundle}. */
@UnstableApi
public static PlaybackException fromBundle(Bundle bundle) {
return new PlaybackException(bundle);
}
/** Returns a {@link Bundle} representing the information stored in this exception. */
@UnstableApi
@CallSuper
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_INT_ERROR_CODE, errorCode);

View File

@ -24,7 +24,7 @@ import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
/** Parameters that apply to playback, including speed setting. */
public final class PlaybackParameters implements Bundleable {
public final class PlaybackParameters {
/** The default playback parameters: real-time playback with no silence skipping. */
public static final PlaybackParameters DEFAULT = new PlaybackParameters(/* speed= */ 1f);
@ -113,13 +113,10 @@ public final class PlaybackParameters implements Bundleable {
return Util.formatInvariant("PlaybackParameters(speed=%.2f, pitch=%.2f)", speed, pitch);
}
// Bundleable implementation.
private static final String FIELD_SPEED = Util.intToStringMaxRadix(0);
private static final String FIELD_PITCH = Util.intToStringMaxRadix(1);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putFloat(FIELD_SPEED, speed);
@ -127,16 +124,6 @@ public final class PlaybackParameters implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link PlaybackParameters} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<PlaybackParameters> CREATOR = PlaybackParameters::fromBundle;
/** Restores a {@code PlaybackParameters} from a {@link Bundle}. */
@UnstableApi
public static PlaybackParameters fromBundle(Bundle bundle) {

View File

@ -242,7 +242,7 @@ public interface Player {
}
/** Position info describing a playback position involved in a discontinuity. */
final class PositionInfo implements Bundleable {
final class PositionInfo {
/**
* The UID of the window, or {@code null} if the timeline is {@link Timeline#isEmpty() empty}.
@ -385,8 +385,6 @@ public interface Player {
&& Objects.equal(mediaItem, other.mediaItem);
}
// Bundleable implementation.
@VisibleForTesting static final String FIELD_MEDIA_ITEM_INDEX = Util.intToStringMaxRadix(0);
private static final String FIELD_MEDIA_ITEM = Util.intToStringMaxRadix(1);
@VisibleForTesting static final String FIELD_PERIOD_INDEX = Util.intToStringMaxRadix(2);
@ -426,10 +424,11 @@ public interface Player {
}
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #windowUid} and {@link #periodUid} fields. The {@link #windowUid} and
* {@link #periodUid} of an instance restored by {@link #CREATOR} will always be {@code null}.
* {@link #periodUid} of an instance restored by {@link #fromBundle(Bundle)} will always be
* {@code null}.
*
* @param controllerInterfaceVersion The interface version of the media controller this Bundle
* will be sent to.
@ -462,27 +461,17 @@ public interface Player {
}
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #windowUid} and {@link #periodUid} fields. The {@link #windowUid} and
* {@link #periodUid} of an instance restored by {@link #CREATOR} will always be {@code null}.
* {@link #periodUid} of an instance restored by {@link #fromBundle} will always be {@code
* null}.
*/
@UnstableApi
@Override
public Bundle toBundle() {
return toBundle(Integer.MAX_VALUE);
}
/**
* Object that can restore {@link PositionInfo} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<PositionInfo> CREATOR = PositionInfo::fromBundle;
/** Restores a {@code PositionInfo} from a {@link Bundle}. */
@UnstableApi
public static PositionInfo fromBundle(Bundle bundle) {
@ -514,7 +503,7 @@ public interface Player {
*
* <p>Instances are immutable.
*/
final class Commands implements Bundleable {
final class Commands {
/** A builder for {@link Commands} instances. */
@UnstableApi
@ -744,12 +733,9 @@ public interface Player {
return flags.hashCode();
}
// Bundleable implementation.
private static final String FIELD_COMMANDS = Util.intToStringMaxRadix(0);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
ArrayList<Integer> commandsBundle = new ArrayList<>();
@ -760,16 +746,6 @@ public interface Player {
return bundle;
}
/**
* Object that can restore {@link Commands} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Commands> CREATOR = Commands::fromBundle;
/** Restores a {@code Commands} from a {@link Bundle}. */
@UnstableApi
public static Commands fromBundle(Bundle bundle) {

View File

@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* A rating for media content. The style of a rating can be one of {@link HeartRating}, {@link
* PercentageRating}, {@link StarRating}, or {@link ThumbRating}.
*/
public abstract class Rating implements Bundleable {
public abstract class Rating {
/** A float value that denotes the rating is unset. */
/* package */ static final float RATING_UNSET = -1.0f;
@ -41,7 +41,9 @@ public abstract class Rating implements Bundleable {
/** Whether the rating exists or not. */
public abstract boolean isRated();
// Bundleable implementation.
/** Returns a {@link Bundle} representing the information stored in this rating. */
@UnstableApi
public abstract Bundle toBundle();
@Documented
@Retention(RetentionPolicy.SOURCE)
@ -63,16 +65,6 @@ public abstract class Rating implements Bundleable {
/* package */ static final String FIELD_RATING_TYPE = Util.intToStringMaxRadix(0);
/**
* Object that can restore a {@link Rating} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Rating> CREATOR = Rating::fromBundle;
/** Restores a {@code Rating} from a {@link Bundle}. */
@UnstableApi
public static Rating fromBundle(Bundle bundle) {

View File

@ -96,8 +96,6 @@ public final class StarRating extends Rating {
return maxStars == other.maxStars && starRating == other.starRating;
}
// Bundleable implementation.
private static final @RatingType int TYPE = RATING_TYPE_STAR;
private static final int MAX_STARS_DEFAULT = 5;
@ -114,16 +112,6 @@ public final class StarRating extends Rating {
return bundle;
}
/**
* Object that can restore a {@link StarRating} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<StarRating> CREATOR = StarRating::fromBundle;
/** Restores a {@code StarRating} from a {@link Bundle}. */
@UnstableApi
public static StarRating fromBundle(Bundle bundle) {

View File

@ -37,7 +37,7 @@ import androidx.media3.common.util.Util;
* particular track selection.
*/
@UnstableApi
public final class StreamKey implements Comparable<StreamKey>, Parcelable, Bundleable {
public final class StreamKey implements Comparable<StreamKey>, Parcelable {
/** The period index. */
public final int periodIndex;
@ -147,13 +147,10 @@ public final class StreamKey implements Comparable<StreamKey>, Parcelable, Bundl
}
};
// Bundleable implementation.
private static final String FIELD_PERIOD_INDEX = Util.intToStringMaxRadix(0);
private static final String FIELD_GROUP_INDEX = Util.intToStringMaxRadix(1);
private static final String FIELD_STREAM_INDEX = Util.intToStringMaxRadix(2);
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (periodIndex != 0) {

View File

@ -69,8 +69,6 @@ public final class ThumbRating extends Rating {
return isThumbsUp == other.isThumbsUp && rated == other.rated;
}
// Bundleable implementation.
private static final @RatingType int TYPE = RATING_TYPE_THUMB;
private static final String FIELD_RATED = Util.intToStringMaxRadix(1);
@ -86,16 +84,6 @@ public final class ThumbRating extends Rating {
return bundle;
}
/**
* Object that can restore a {@link ThumbRating} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<ThumbRating> CREATOR = ThumbRating::fromBundle;
/** Restores a {@code ThumbRating} from a {@link Bundle}. */
@UnstableApi
public static ThumbRating fromBundle(Bundle bundle) {

View File

@ -139,7 +139,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* <p>This case includes mid-roll ad groups, which are defined as part of the timeline's single
* period. The period can be queried for information about the ad groups and the ads they contain.
*/
public abstract class Timeline implements Bundleable {
public abstract class Timeline {
/**
* Holds information about a window in a {@link Timeline}. A window usually corresponds to one
@ -152,7 +152,7 @@ public abstract class Timeline implements Bundleable {
* src="https://developer.android.com/static/images/reference/androidx/media3/common/timeline-window.svg"
* alt="Information defined by a timeline window">
*/
public static final class Window implements Bundleable {
public static final class Window {
/**
* A {@link #uid} for a window that must be used for single-window {@link Timeline Timelines}.
@ -412,8 +412,6 @@ public abstract class Timeline implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_MEDIA_ITEM = Util.intToStringMaxRadix(1);
private static final String FIELD_PRESENTATION_START_TIME_MS = Util.intToStringMaxRadix(2);
private static final String FIELD_WINDOW_START_TIME_MS = Util.intToStringMaxRadix(3);
@ -430,14 +428,13 @@ public abstract class Timeline implements Bundleable {
private static final String FIELD_POSITION_IN_FIRST_PERIOD_US = Util.intToStringMaxRadix(13);
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #uid} and {@link #manifest} fields. The {@link #uid} of an instance
* restored by {@link #CREATOR} will be a fake {@link Object} and the {@link #manifest} of the
* instance will be {@code null}.
* restored by {@link #fromBundle} will be a fake {@link Object} and the {@link #manifest} of
* the instance will be {@code null}.
*/
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (!MediaItem.EMPTY.equals(mediaItem)) {
@ -484,19 +481,6 @@ public abstract class Timeline implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link Period} from a {@link Bundle}.
*
* <p>The {@link #uid} of a restored instance will be a fake {@link Object} and the {@link
* #manifest} of the instance will be {@code null}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Window> CREATOR = Window::fromBundle;
/** Restores a {@code Window} from a {@link Bundle}. */
@UnstableApi
public static Window fromBundle(Bundle bundle) {
@ -559,7 +543,7 @@ public abstract class Timeline implements Bundleable {
* src="https://developer.android.com/static/images/reference/androidx/media3/common/timeline-period.svg"
* alt="Information defined by a period">
*/
public static final class Period implements Bundleable {
public static final class Period {
/**
* An identifier for the period. Not necessarily unique. May be null if the ids of the period
@ -908,8 +892,6 @@ public abstract class Timeline implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_WINDOW_INDEX = Util.intToStringMaxRadix(0);
private static final String FIELD_DURATION_US = Util.intToStringMaxRadix(1);
private static final String FIELD_POSITION_IN_WINDOW_US = Util.intToStringMaxRadix(2);
@ -917,13 +899,12 @@ public abstract class Timeline implements Bundleable {
private static final String FIELD_AD_PLAYBACK_STATE = Util.intToStringMaxRadix(4);
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>It omits the {@link #id} and {@link #uid} fields so these fields of an instance restored
* by {@link #CREATOR} will always be {@code null}.
* by {@link #fromBundle} will always be {@code null}.
*/
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (windowIndex != 0) {
@ -944,18 +925,6 @@ public abstract class Timeline implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link Period} from a {@link Bundle}.
*
* <p>The {@link #id} and {@link #uid} of restored instances will always be {@code null}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Period> CREATOR = Period::fromBundle;
/** Restores a {@code Period} from a {@link Bundle}. */
@UnstableApi
public static Period fromBundle(Bundle bundle) {
@ -1398,21 +1367,18 @@ public abstract class Timeline implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_WINDOWS = Util.intToStringMaxRadix(0);
private static final String FIELD_PERIODS = Util.intToStringMaxRadix(1);
private static final String FIELD_SHUFFLED_WINDOW_INDICES = Util.intToStringMaxRadix(2);
/**
* {@inheritDoc}
* Returns a {@link Bundle} representing the information stored in this object.
*
* <p>The {@link #getWindow(int, Window)} windows} and {@link #getPeriod(int, Period) periods} of
* an instance restored by {@link #CREATOR} may have missing fields as described in {@link
* an instance restored by {@link #fromBundle} may have missing fields as described in {@link
* Window#toBundle()} and {@link Period#toBundle()}.
*/
@UnstableApi
@Override
public final Bundle toBundle() {
List<Bundle> windowBundles = new ArrayList<>();
int windowCount = getWindowCount();
@ -1471,20 +1437,6 @@ public abstract class Timeline implements Bundleable {
ImmutableList.of(window), periods.build(), /* shuffledWindowIndices= */ new int[] {0});
}
/**
* Object that can restore a {@link Timeline} from a {@link Bundle}.
*
* <p>The {@link #getWindow(int, Window)} windows} and {@link #getPeriod(int, Period) periods} of
* a restored instance may have missing fields as described in {@link Window#CREATOR} and {@link
* Period#CREATOR}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Timeline> CREATOR = Timeline::fromBundle;
/** Restores a {@code Timeline} from a {@link Bundle}. */
@UnstableApi
public static Timeline fromBundle(Bundle bundle) {

View File

@ -48,7 +48,7 @@ import java.util.List;
* {@link Tracks.Group}, it does not include runtime information such as the extent to which
* playback of each track is supported by the device, or which tracks are currently selected.
*/
public final class TrackGroup implements Bundleable {
public final class TrackGroup {
private static final String TAG = "TrackGroup";
@ -161,12 +161,10 @@ public final class TrackGroup implements Bundleable {
return id.equals(other.id) && Arrays.equals(formats, other.formats);
}
// Bundleable implementation.
private static final String FIELD_FORMATS = Util.intToStringMaxRadix(0);
private static final String FIELD_ID = Util.intToStringMaxRadix(1);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
ArrayList<Bundle> arrayList = new ArrayList<>(formats.length);
@ -178,16 +176,6 @@ public final class TrackGroup implements Bundleable {
return bundle;
}
/**
* Object that can restore {@code TrackGroup} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<TrackGroup> CREATOR = TrackGroup::fromBundle;
/** Restores a {@code TrackGroup} from a {@link Bundle}. */
@UnstableApi
public static TrackGroup fromBundle(Bundle bundle) {

View File

@ -44,7 +44,7 @@ import java.util.List;
* to the one in the override. Conversely, disabling a track type will prevent selection of tracks
* of that type for all media.
*/
public final class TrackSelectionOverride implements Bundleable {
public final class TrackSelectionOverride {
/** The media {@link TrackGroup} whose {@link #trackIndices} are forced to be selected. */
public final TrackGroup mediaTrackGroup;
@ -103,10 +103,7 @@ public final class TrackSelectionOverride implements Bundleable {
return mediaTrackGroup.hashCode() + 31 * trackIndices.hashCode();
}
// Bundleable implementation
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putBundle(FIELD_TRACK_GROUP, mediaTrackGroup.toBundle());
@ -114,16 +111,6 @@ public final class TrackSelectionOverride implements Bundleable {
return bundle;
}
/**
* Object that can restore {@code TrackSelectionOverride} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<TrackSelectionOverride> CREATOR = TrackSelectionOverride::fromBundle;
/** Restores a {@code TrackSelectionOverride} from a {@link Bundle}. */
@UnstableApi
public static TrackSelectionOverride fromBundle(Bundle bundle) {

View File

@ -69,7 +69,7 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
* player.setTrackSelectionParameters(newParameters);
* }</pre>
*/
public class TrackSelectionParameters implements Bundleable {
public class TrackSelectionParameters {
/**
* A builder for {@link TrackSelectionParameters}. See the {@link TrackSelectionParameters}
@ -854,7 +854,7 @@ public class TrackSelectionParameters implements Bundleable {
/** Preferences and constraints for enabling audio offload. */
@UnstableApi
public static final class AudioOffloadPreferences implements Bundleable {
public static final class AudioOffloadPreferences {
/**
* The preference level for enabling audio offload on the audio sink. One of {@link
@ -1014,14 +1014,11 @@ public class TrackSelectionParameters implements Bundleable {
return result;
}
// Bundleable implementation
private static final String FIELD_AUDIO_OFFLOAD_MODE_PREFERENCE = Util.intToStringMaxRadix(1);
private static final String FIELD_IS_GAPLESS_SUPPORT_REQUIRED = Util.intToStringMaxRadix(2);
private static final String FIELD_IS_SPEED_CHANGE_SUPPORT_REQUIRED =
Util.intToStringMaxRadix(3);
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_AUDIO_OFFLOAD_MODE_PREFERENCE, audioOffloadMode);
@ -1380,8 +1377,6 @@ public class TrackSelectionParameters implements Bundleable {
return result;
}
// Bundleable implementation
private static final String FIELD_PREFERRED_AUDIO_LANGUAGES = Util.intToStringMaxRadix(1);
private static final String FIELD_PREFERRED_AUDIO_ROLE_FLAGS = Util.intToStringMaxRadix(2);
private static final String FIELD_PREFERRED_TEXT_LANGUAGES = Util.intToStringMaxRadix(3);
@ -1425,7 +1420,6 @@ public class TrackSelectionParameters implements Bundleable {
*/
@UnstableApi protected static final int FIELD_CUSTOM_ID_BASE = 1000;
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
@ -1482,13 +1476,4 @@ public class TrackSelectionParameters implements Bundleable {
public static TrackSelectionParameters fromBundle(Bundle bundle) {
return new Builder(bundle).build();
}
/**
* @deprecated Use {@link #fromBundle(Bundle)} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<TrackSelectionParameters> CREATOR =
TrackSelectionParameters::fromBundle;
}

View File

@ -31,14 +31,14 @@ import java.util.Arrays;
import java.util.List;
/** Information about groups of tracks. */
public final class Tracks implements Bundleable {
public final class Tracks {
/**
* Information about a single group of tracks, including the underlying {@link TrackGroup}, the
* level to which each track is supported by the player, and whether any of the tracks are
* selected.
*/
public static final class Group implements Bundleable {
public static final class Group {
/** The number of tracks in the group. */
public final int length;
@ -227,14 +227,11 @@ public final class Tracks implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_TRACK_GROUP = Util.intToStringMaxRadix(0);
private static final String FIELD_TRACK_SUPPORT = Util.intToStringMaxRadix(1);
private static final String FIELD_TRACK_SELECTED = Util.intToStringMaxRadix(3);
private static final String FIELD_ADAPTIVE_SUPPORTED = Util.intToStringMaxRadix(4);
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putBundle(FIELD_TRACK_GROUP, mediaTrackGroup.toBundle());
@ -244,16 +241,6 @@ public final class Tracks implements Bundleable {
return bundle;
}
/**
* Object that can restore a group of tracks from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Group> CREATOR = Group::fromBundle;
/** Restores a group of tracks from a {@link Bundle}. */
@UnstableApi
public static Group fromBundle(Bundle bundle) {
@ -384,28 +371,15 @@ public final class Tracks implements Bundleable {
return groups.hashCode();
}
// Bundleable implementation.
private static final String FIELD_TRACK_GROUPS = Util.intToStringMaxRadix(0);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelableArrayList(FIELD_TRACK_GROUPS, toBundleArrayList(groups, Group::toBundle));
return bundle;
}
/**
* Object that can restore tracks from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Tracks> CREATOR = Tracks::fromBundle;
/** Restores a {@code Tracks} from a {@link Bundle}. */
@UnstableApi
public static Tracks fromBundle(Bundle bundle) {

View File

@ -23,7 +23,7 @@ import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
/** Represents the video size. */
public final class VideoSize implements Bundleable {
public final class VideoSize {
private static final int DEFAULT_WIDTH = 0;
private static final int DEFAULT_HEIGHT = 0;
@ -125,15 +125,12 @@ public final class VideoSize implements Bundleable {
return result;
}
// Bundleable implementation.
private static final String FIELD_WIDTH = Util.intToStringMaxRadix(0);
private static final String FIELD_HEIGHT = Util.intToStringMaxRadix(1);
private static final String FIELD_UNAPPLIED_ROTATION_DEGREES = Util.intToStringMaxRadix(2);
private static final String FIELD_PIXEL_WIDTH_HEIGHT_RATIO = Util.intToStringMaxRadix(3);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_WIDTH, width);
@ -143,14 +140,6 @@ public final class VideoSize implements Bundleable {
return bundle;
}
/**
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<VideoSize> CREATOR = VideoSize::fromBundle;
/** Restores a {@code VideoSize} from a {@link Bundle}. */
@UnstableApi
public static VideoSize fromBundle(Bundle bundle) {

View File

@ -37,7 +37,6 @@ import android.text.TextUtils;
import androidx.annotation.ColorInt;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
@ -55,7 +54,7 @@ import org.checkerframework.dataflow.qual.Pure;
// This class shouldn't be sub-classed. If a subtitle format needs additional fields, either they
// should be generic enough to be added here, or the format-specific decoder should pass the
// information around in a sidecar object.
public final class Cue implements Bundleable {
public final class Cue {
/**
* @deprecated There's no general need for a cue with an empty text string. If you need one,
@ -830,8 +829,6 @@ public final class Cue implements Bundleable {
}
}
// Bundleable implementation.
private static final String FIELD_TEXT = Util.intToStringMaxRadix(0);
private static final String FIELD_CUSTOM_SPANS = Util.intToStringMaxRadix(17);
private static final String FIELD_TEXT_ALIGNMENT = Util.intToStringMaxRadix(1);
@ -895,7 +892,6 @@ public final class Cue implements Bundleable {
* @deprecated Use {@link #toSerializableBundle()} or {@link #toBinderBasedBundle()} instead.
*/
@UnstableApi
@Override
@Deprecated
public Bundle toBundle() {
return toBinderBasedBundle();
@ -930,14 +926,6 @@ public final class Cue implements Bundleable {
return bundle;
}
/**
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Cue> CREATOR = Cue::fromBundle;
/** Restores a cue from a {@link Bundle}. */
@UnstableApi
public static Cue fromBundle(Bundle bundle) {

View File

@ -18,7 +18,6 @@ package androidx.media3.common.text;
import android.graphics.Bitmap;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.Timeline;
import androidx.media3.common.util.BundleCollectionUtil;
import androidx.media3.common.util.UnstableApi;
@ -28,7 +27,7 @@ import java.util.ArrayList;
import java.util.List;
/** Class to represent the state of active {@link Cue Cues} at a particular time. */
public final class CueGroup implements Bundleable {
public final class CueGroup {
/** An empty group with no {@link Cue Cues} and presentation time of zero. */
@UnstableApi
@ -59,13 +58,10 @@ public final class CueGroup implements Bundleable {
this.presentationTimeUs = presentationTimeUs;
}
// Bundleable implementation.
private static final String FIELD_CUES = Util.intToStringMaxRadix(0);
private static final String FIELD_PRESENTATION_TIME_US = Util.intToStringMaxRadix(1);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelableArrayList(
@ -76,14 +72,6 @@ public final class CueGroup implements Bundleable {
return bundle;
}
/**
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<CueGroup> CREATOR = CueGroup::fromBundle;
/** Restores a {@code final CueGroup} from a {@link Bundle}. */
@UnstableApi
public static CueGroup fromBundle(Bundle bundle) {

View File

@ -525,7 +525,7 @@ public class MediaItemTest {
clippingConfigurationBundle.remove(FIELD_END_POSITION_US);
MediaItem.ClippingConfiguration clippingConfigurationFromBundle =
MediaItem.ClippingConfiguration.CREATOR.fromBundle(clippingConfigurationBundle);
MediaItem.ClippingConfiguration.fromBundle(clippingConfigurationBundle);
assertThat(clippingConfigurationFromBundle).isEqualTo(clippingConfiguration);
}

View File

@ -400,18 +400,6 @@ public final class ExoPlaybackException extends PlaybackException {
return message;
}
// Bundleable implementation.
/**
* Object that can restore {@link ExoPlaybackException} from a {@link Bundle}.
*
* @deprecated Use {@link #ExoPlaybackException(Bundle)} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<ExoPlaybackException> CREATOR = ExoPlaybackException::new;
/** Restores a {@code ExoPlaybackException} from a {@link Bundle}. */
@UnstableApi
public static ExoPlaybackException fromBundle(Bundle bundle) {
@ -434,7 +422,7 @@ public final class ExoPlaybackException extends PlaybackException {
* {@inheritDoc}
*
* <p>It omits the {@link #mediaPeriodId} field. The {@link #mediaPeriodId} of an instance
* restored by {@link #CREATOR} will always be {@code null}.
* restored by {@link #fromBundle} will always be {@code null}.
*/
@UnstableApi
@Override

View File

@ -17,7 +17,6 @@ package androidx.media3.exoplayer.source;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.C;
import androidx.media3.common.TrackGroup;
import androidx.media3.common.util.BundleCollectionUtil;
@ -39,7 +38,7 @@ import java.util.List;
* audio track in another language).
*/
@UnstableApi
public final class TrackGroupArray implements Bundleable {
public final class TrackGroupArray {
private static final String TAG = "TrackGroupArray";
@ -116,11 +115,8 @@ public final class TrackGroupArray implements Bundleable {
return length == other.length && trackGroups.equals(other.trackGroups);
}
// Bundleable implementation.
private static final String FIELD_TRACK_GROUPS = Util.intToStringMaxRadix(0);
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelableArrayList(
@ -129,15 +125,6 @@ public final class TrackGroupArray implements Bundleable {
return bundle;
}
/**
* Object that can restores a TrackGroupArray from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<TrackGroupArray> CREATOR = TrackGroupArray::fromBundle;
/** Restores a {@code TrackGroupArray} from a {@link Bundle}. */
public static TrackGroupArray fromBundle(Bundle bundle) {
@Nullable List<Bundle> trackGroupBundles = bundle.getParcelableArrayList(FIELD_TRACK_GROUPS);

View File

@ -44,7 +44,6 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.Bundleable;
import androidx.media3.common.C;
import androidx.media3.common.C.RoleFlags;
import androidx.media3.common.Format;
@ -819,7 +818,7 @@ public class DefaultTrackSelector extends MappingTrackSelector
/**
* Extends {@link Parameters} by adding fields that are specific to {@link DefaultTrackSelector}.
*/
public static final class Parameters extends TrackSelectionParameters implements Bundleable {
public static final class Parameters extends TrackSelectionParameters {
/**
* A builder for {@link Parameters}. See the {@link Parameters} documentation for explanations
@ -2029,8 +2028,6 @@ public class DefaultTrackSelector extends MappingTrackSelector
return result;
}
// Bundleable implementation.
private static final String FIELD_EXCEED_VIDEO_CONSTRAINTS_IF_NECESSARY =
Util.intToStringMaxRadix(FIELD_CUSTOM_ID_BASE);
private static final String FIELD_ALLOW_VIDEO_MIXED_MIME_TYPE_ADAPTIVENESS =
@ -2119,15 +2116,6 @@ public class DefaultTrackSelector extends MappingTrackSelector
return bundle;
}
/**
* Object that can restore {@code Parameters} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<Parameters> CREATOR = Parameters::fromBundle;
/** Restores a {@code Parameters} from a {@link Bundle}. */
public static Parameters fromBundle(Bundle bundle) {
return new Parameters.Builder(bundle).build();
@ -2227,7 +2215,7 @@ public class DefaultTrackSelector extends MappingTrackSelector
}
/** A track selection override. */
public static final class SelectionOverride implements Bundleable {
public static final class SelectionOverride {
public final int groupIndex;
public final int[] tracks;
@ -2290,14 +2278,11 @@ public class DefaultTrackSelector extends MappingTrackSelector
&& type == other.type;
}
// Bundleable implementation.
private static final String FIELD_GROUP_INDEX = Util.intToStringMaxRadix(0);
private static final String FIELD_TRACKS = Util.intToStringMaxRadix(1);
private static final String FIELD_TRACK_TYPE = Util.intToStringMaxRadix(2);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_GROUP_INDEX, groupIndex);
@ -2306,16 +2291,6 @@ public class DefaultTrackSelector extends MappingTrackSelector
return bundle;
}
/**
* Object that can restore {@code SelectionOverride} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SelectionOverride> CREATOR = SelectionOverride::fromBundle;
/** Restores a {@code SelectionOverride} from a {@link Bundle}. */
@UnstableApi
public static SelectionOverride fromBundle(Bundle bundle) {

View File

@ -51,7 +51,6 @@ import androidx.annotation.VisibleForTesting;
import androidx.media3.common.AdOverlayInfo;
import androidx.media3.common.AdPlaybackState;
import androidx.media3.common.AdViewProvider;
import androidx.media3.common.Bundleable;
import androidx.media3.common.C;
import androidx.media3.common.MediaItem;
import androidx.media3.common.Metadata;
@ -377,7 +376,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
}
/** The state of the {@link AdsLoader} that can be used when resuming from the background. */
public static class State implements Bundleable {
public static class State {
private final ImmutableMap<String, AdPlaybackState> adPlaybackStates;
@ -403,11 +402,8 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
return adPlaybackStates.hashCode();
}
// Bundleable implementation.
private static final String FIELD_AD_PLAYBACK_STATES = Util.intToStringMaxRadix(1);
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
Bundle adPlaybackStatesBundle = new Bundle();
@ -418,16 +414,6 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
return bundle;
}
/**
* Object that can restore {@link AdsLoader.State} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Bundleable.Creator<State> CREATOR = State::fromBundle;
/** Restores a {@code State} from a {@link Bundle}. */
public static State fromBundle(Bundle bundle) {
@Nullable

View File

@ -26,7 +26,6 @@ import android.text.TextUtils;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.Player;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
@ -47,7 +46,7 @@ import java.util.List;
* @see MediaSession#setCustomLayout(MediaSession.ControllerInfo, List)
* @see MediaController.Listener#onCustomLayoutChanged(MediaController, List)
*/
public final class CommandButton implements Bundleable {
public final class CommandButton {
// TODO: b/328238954 - Stabilize these constants and the corresponding methods, and deprecate the
// methods that do not use these constants.
@ -736,8 +735,6 @@ public final class CommandButton implements Bundleable {
&& playerCommands.contains(button.playerCommand));
}
// Bundleable implementation.
private static final String FIELD_SESSION_COMMAND = Util.intToStringMaxRadix(0);
private static final String FIELD_PLAYER_COMMAND = Util.intToStringMaxRadix(1);
private static final String FIELD_ICON_RES_ID = Util.intToStringMaxRadix(2);
@ -748,7 +745,6 @@ public final class CommandButton implements Bundleable {
private static final String FIELD_ICON = Util.intToStringMaxRadix(7);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (sessionCommand != null) {
@ -778,16 +774,6 @@ public final class CommandButton implements Bundleable {
return bundle;
}
/**
* Object that can restore {@code CommandButton} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<CommandButton> CREATOR = CommandButton::fromBundle;
/**
* @deprecated Use {@link #fromBundle(Bundle, int)} instead.
*/

View File

@ -20,7 +20,6 @@ import static androidx.media3.common.util.Assertions.checkNotNull;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.MediaLibraryInfo;
import androidx.media3.common.util.Util;
@ -28,7 +27,7 @@ import androidx.media3.common.util.Util;
* Created by {@link MediaController} to send its state to the {@link MediaSession} to request to
* connect.
*/
/* package */ class ConnectionRequest implements Bundleable {
/* package */ class ConnectionRequest {
public final int libraryVersion;
@ -62,8 +61,6 @@ import androidx.media3.common.util.Util;
this.connectionHints = connectionHints;
}
// Bundleable implementation.
private static final String FIELD_LIBRARY_VERSION = Util.intToStringMaxRadix(0);
private static final String FIELD_PACKAGE_NAME = Util.intToStringMaxRadix(1);
private static final String FIELD_PID = Util.intToStringMaxRadix(2);
@ -72,7 +69,6 @@ import androidx.media3.common.util.Util;
// Next id: 5
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_LIBRARY_VERSION, libraryVersion);
@ -83,15 +79,6 @@ import androidx.media3.common.util.Util;
return bundle;
}
/**
* Object that can restore {@link ConnectionRequest} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<ConnectionRequest> CREATOR = ConnectionRequest::fromBundle;
/** Restores a {@code ConnectionRequest} from a {@link Bundle}. */
public static ConnectionRequest fromBundle(Bundle bundle) {
int libraryVersion = bundle.getInt(FIELD_LIBRARY_VERSION, /* defaultValue= */ 0);

View File

@ -23,7 +23,6 @@ import android.os.Bundle;
import android.os.IBinder;
import androidx.annotation.Nullable;
import androidx.core.app.BundleCompat;
import androidx.media3.common.Bundleable;
import androidx.media3.common.Player;
import androidx.media3.common.util.BundleCollectionUtil;
import androidx.media3.common.util.Util;
@ -34,7 +33,7 @@ import java.util.List;
* Created by {@link MediaSession} to send its state to the {@link MediaController} when the
* connection request is accepted.
*/
/* package */ class ConnectionState implements Bundleable {
/* package */ class ConnectionState {
public final int libraryVersion;
@ -83,8 +82,6 @@ import java.util.List;
this.playerInfo = playerInfo;
}
// Bundleable implementation.
private static final String FIELD_LIBRARY_VERSION = Util.intToStringMaxRadix(0);
private static final String FIELD_SESSION_BINDER = Util.intToStringMaxRadix(1);
private static final String FIELD_SESSION_ACTIVITY = Util.intToStringMaxRadix(2);
@ -100,7 +97,6 @@ import java.util.List;
// Next field key = 12
@Override
public Bundle toBundle() {
return toBundleForRemoteProcess(Integer.MAX_VALUE);
}
@ -142,13 +138,6 @@ import java.util.List;
return bundle;
}
/**
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<ConnectionState> CREATOR = ConnectionState::fromBundle;
/** Restores a {@code ConnectionState} from a {@link Bundle}. */
public static ConnectionState fromBundle(Bundle bundle) {
@Nullable IBinder inProcessBinder = bundle.getBinder(FIELD_IN_PROCESS_BINDER);

View File

@ -27,7 +27,6 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.core.app.BundleCompat;
import androidx.media3.common.BundleListRetriever;
import androidx.media3.common.Bundleable;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaMetadata;
import androidx.media3.common.util.BundleCollectionUtil;
@ -46,7 +45,7 @@ import java.util.List;
* A result to be used with {@link ListenableFuture} for asynchronous calls between {@link
* MediaLibraryService.MediaLibrarySession} and {@link MediaBrowser}.
*/
public final class LibraryResult<V> implements Bundleable {
public final class LibraryResult<V> {
/** Result codes. */
@Documented
@ -326,8 +325,6 @@ public final class LibraryResult<V> implements Bundleable {
checkArgument(item.mediaMetadata.isPlayable != null, "mediaMetadata must specify isPlayable");
}
// Bundleable implementation.
private static final String FIELD_RESULT_CODE = Util.intToStringMaxRadix(0);
private static final String FIELD_COMPLETION_TIME_MS = Util.intToStringMaxRadix(1);
private static final String FIELD_PARAMS = Util.intToStringMaxRadix(2);
@ -338,7 +335,6 @@ public final class LibraryResult<V> implements Bundleable {
// Casting V to ImmutableList<MediaItem> is safe if valueType == VALUE_TYPE_ITEM_LIST.
@SuppressWarnings("unchecked")
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_RESULT_CODE, resultCode);
@ -374,49 +370,6 @@ public final class LibraryResult<V> implements Bundleable {
return bundle;
}
/**
* Object that can restore a {@code LibraryResult<Void>} from a {@link Bundle}.
*
* @deprecated Use {@link #fromVoidBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<LibraryResult<Void>> VOID_CREATOR = LibraryResult::fromVoidBundle;
/**
* Object that can restore a {@code LibraryResult<MediaItem>} from a {@link Bundle}.
*
* @deprecated Use {@link #fromItemBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<LibraryResult<MediaItem>> ITEM_CREATOR =
LibraryResult::fromItemBundle;
/**
* Object that can restore a {@code LibraryResult<ImmutableList<MediaItem>} from a {@link Bundle}.
*
* @deprecated Use {@link #fromItemListBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<LibraryResult<ImmutableList<MediaItem>>> ITEM_LIST_CREATOR =
LibraryResult::fromItemListBundle;
/**
* Object that can restore a {@code LibraryResult} with unknown value type from a {@link Bundle}.
*
* @deprecated Use {@link #fromUnknownBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<LibraryResult<?>> UNKNOWN_TYPE_CREATOR =
LibraryResult::fromUnknownBundle;
/** Restores a {@code LibraryResult<Void>} from a {@link Bundle}. */
// fromBundle will throw if the bundle doesn't have the right value type.
@UnstableApi

View File

@ -1095,7 +1095,7 @@ public class MediaController implements Player {
* Timeline.Period)}, {@link Timeline#getIndexOfPeriod(Object)}, and {@link
* Timeline#getUidOfPeriod(int)} will throw {@link UnsupportedOperationException} because of the
* limitation of restoring the instance sent from session as described in {@link
* Timeline#CREATOR}.
* Timeline#fromBundle}.
*/
@Override
public final Timeline getCurrentTimeline() {

View File

@ -31,7 +31,6 @@ import android.os.Bundle;
import android.os.IBinder;
import androidx.annotation.IntRange;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaMetadata;
import androidx.media3.common.Player;
@ -729,7 +728,7 @@ public abstract class MediaLibraryService extends MediaSessionService {
* error even though {@link MediaLibrarySession} doesn't return the parameters since they are
* optional.
*/
public static final class LibraryParams implements Bundleable {
public static final class LibraryParams {
/**
* An extra {@link Bundle} for the private contract between {@link MediaBrowser} and {@link
@ -829,15 +828,12 @@ public abstract class MediaLibraryService extends MediaSessionService {
}
}
// Bundleable implementation.
private static final String FIELD_EXTRAS = Util.intToStringMaxRadix(0);
private static final String FIELD_RECENT = Util.intToStringMaxRadix(1);
private static final String FIELD_OFFLINE = Util.intToStringMaxRadix(2);
private static final String FIELD_SUGGESTED = Util.intToStringMaxRadix(3);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putBundle(FIELD_EXTRAS, extras);
@ -847,16 +843,6 @@ public abstract class MediaLibraryService extends MediaSessionService {
return bundle;
}
/**
* Object that can restore {@link LibraryParams} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<LibraryParams> CREATOR = LibraryParams::fromBundle;
/** Restores a {@code LibraryParams} from a {@link Bundle}. */
@UnstableApi
public static LibraryParams fromBundle(Bundle bundle) {

View File

@ -30,7 +30,6 @@ import androidx.annotation.FloatRange;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.Bundleable;
import androidx.media3.common.DeviceInfo;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaMetadata;
@ -56,13 +55,13 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
* Information about the player that {@link MediaSession} uses to send its state to {@link
* MediaController}.
*/
/* package */ class PlayerInfo implements Bundleable {
/* package */ class PlayerInfo {
/**
* Holds information about what properties of the {@link PlayerInfo} have been excluded when sent
* to the controller.
*/
public static class BundlingExclusions implements Bundleable {
public static class BundlingExclusions {
/** Bundling exclusions with no exclusions. */
public static final BundlingExclusions NONE =
@ -81,15 +80,12 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
this.areCurrentTracksExcluded = areCurrentTracksExcluded;
}
// Bundleable implementation.
private static final String FIELD_IS_TIMELINE_EXCLUDED = Util.intToStringMaxRadix(0);
private static final String FIELD_ARE_CURRENT_TRACKS_EXCLUDED = Util.intToStringMaxRadix(1);
// Next field key = 2
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putBoolean(FIELD_IS_TIMELINE_EXCLUDED, isTimelineExcluded);
@ -97,13 +93,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
return bundle;
}
/**
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<BundlingExclusions> CREATOR = BundlingExclusions::fromBundle;
/** Restores a {@code BundlingExclusions} from a {@link Bundle}. */
public static BundlingExclusions fromBundle(Bundle bundle) {
return new BundlingExclusions(
@ -802,8 +791,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
&& playbackSuppressionReason == PLAYBACK_SUPPRESSION_REASON_NONE;
}
// Bundleable implementation.
private static final String FIELD_PLAYBACK_PARAMETERS = Util.intToStringMaxRadix(1);
private static final String FIELD_REPEAT_MODE = Util.intToStringMaxRadix(2);
private static final String FIELD_SHUFFLE_MODE_ENABLED = Util.intToStringMaxRadix(3);
@ -904,7 +891,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
return bundle;
}
@Override
public Bundle toBundle() {
return toBundleForRemoteProcess(Integer.MAX_VALUE);
}
@ -1013,15 +999,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
return bundle;
}
/**
* Object that can restore {@link PlayerInfo} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<PlayerInfo> CREATOR = PlayerInfo::fromBundle;
/** Restores a {@code PlayerInfo} from a {@link Bundle}. */
public static PlayerInfo fromBundle(Bundle bundle) {
@Nullable IBinder inProcessBinder = bundle.getBinder(FIELD_IN_PROCESS_BINDER);

View File

@ -23,7 +23,6 @@ import android.os.Bundle;
import android.text.TextUtils;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.Rating;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
@ -42,7 +41,7 @@ import java.lang.annotation.Target;
* {@link #commandCode} is {@link #COMMAND_CODE_CUSTOM}, it's a custom command and {@link
* #customAction} must not be {@code null}.
*/
public final class SessionCommand implements Bundleable {
public final class SessionCommand {
/** Command codes of session commands. */
@Documented
@ -172,13 +171,11 @@ public final class SessionCommand implements Bundleable {
return Objects.hashCode(customAction, commandCode);
}
// Bundleable implementation.
private static final String FIELD_COMMAND_CODE = Util.intToStringMaxRadix(0);
private static final String FIELD_CUSTOM_ACTION = Util.intToStringMaxRadix(1);
private static final String FIELD_CUSTOM_EXTRAS = Util.intToStringMaxRadix(2);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_COMMAND_CODE, commandCode);
@ -187,16 +184,6 @@ public final class SessionCommand implements Bundleable {
return bundle;
}
/**
* Object that can restore a {@link SessionCommand} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SessionCommand> CREATOR = SessionCommand::fromBundle;
/** Restores a {@code SessionCommand} from a {@link Bundle}. */
@UnstableApi
public static SessionCommand fromBundle(Bundle bundle) {

View File

@ -22,7 +22,6 @@ import static androidx.media3.session.SessionCommand.COMMAND_CODE_CUSTOM;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.core.util.ObjectsCompat;
import androidx.media3.common.Bundleable;
import androidx.media3.common.util.Log;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
@ -36,7 +35,7 @@ import java.util.List;
import java.util.Set;
/** A set of {@link SessionCommand session commands}. */
public final class SessionCommands implements Bundleable {
public final class SessionCommands {
private static final String TAG = "SessionCommands";
@ -240,12 +239,9 @@ public final class SessionCommands implements Bundleable {
return false;
}
// Bundleable implementation.
private static final String FIELD_SESSION_COMMANDS = Util.intToStringMaxRadix(0);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
ArrayList<Bundle> sessionCommandBundleList = new ArrayList<>();
@ -256,16 +252,6 @@ public final class SessionCommands implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link SessionCommands} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SessionCommands> CREATOR = SessionCommands::fromBundle;
/** Restores a {@code SessionCommands} from a {@link Bundle}. */
@UnstableApi
public static SessionCommands fromBundle(Bundle bundle) {

View File

@ -20,7 +20,6 @@ import static androidx.media3.common.util.Assertions.checkArgument;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.Bundleable;
import androidx.media3.common.C;
import androidx.media3.common.Player;
import androidx.media3.common.Player.PositionInfo;
@ -33,7 +32,7 @@ import com.google.common.base.Objects;
* <p>This class wraps {@link PositionInfo} and group relevant information in one place to
* atomically notify.
*/
/* package */ final class SessionPositionInfo implements Bundleable {
/* package */ final class SessionPositionInfo {
public static final PositionInfo DEFAULT_POSITION_INFO =
new PositionInfo(
@ -157,8 +156,6 @@ import com.google.common.base.Objects;
+ "}";
}
// Bundleable implementation.
@VisibleForTesting static final String FIELD_POSITION_INFO = Util.intToStringMaxRadix(0);
private static final String FIELD_IS_PLAYING_AD = Util.intToStringMaxRadix(1);
private static final String FIELD_EVENT_TIME_MS = Util.intToStringMaxRadix(2);
@ -202,7 +199,6 @@ import com.google.common.base.Objects;
canAccessCurrentMediaItem ? contentBufferedPositionMs : 0);
}
@Override
public Bundle toBundle() {
return toBundle(Integer.MAX_VALUE);
}
@ -242,15 +238,6 @@ import com.google.common.base.Objects;
return bundle;
}
/**
* Object that can restore {@link SessionPositionInfo} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SessionPositionInfo> CREATOR = SessionPositionInfo::fromBundle;
/** Restores a {@code SessionPositionInfo} from a {@link Bundle}. */
public static SessionPositionInfo fromBundle(Bundle bundle) {
@Nullable Bundle positionInfoBundle = bundle.getBundle(FIELD_POSITION_INFO);

View File

@ -22,7 +22,6 @@ import android.os.Bundle;
import android.os.SystemClock;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import com.google.common.util.concurrent.ListenableFuture;
@ -35,7 +34,7 @@ import java.lang.annotation.Target;
* A result to be used with {@link ListenableFuture} for asynchronous calls between {@link
* MediaSession} and {@link MediaController}.
*/
public final class SessionResult implements Bundleable {
public final class SessionResult {
/**
* Result codes.
@ -235,15 +234,12 @@ public final class SessionResult implements Bundleable {
: sessionError;
}
// Bundleable implementation.
private static final String FIELD_RESULT_CODE = Util.intToStringMaxRadix(0);
private static final String FIELD_EXTRAS = Util.intToStringMaxRadix(1);
private static final String FIELD_COMPLETION_TIME_MS = Util.intToStringMaxRadix(2);
private static final String FIELD_SESSION_ERROR = Util.intToStringMaxRadix(3);
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(FIELD_RESULT_CODE, resultCode);
@ -255,16 +251,6 @@ public final class SessionResult implements Bundleable {
return bundle;
}
/**
* Object that can restore a {@link SessionResult} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SessionResult> CREATOR = SessionResult::fromBundle;
/** Restores a {@code SessionResult} from a {@link Bundle}. */
@UnstableApi
public static SessionResult fromBundle(Bundle bundle) {

View File

@ -34,7 +34,6 @@ import android.os.ResultReceiver;
import android.text.TextUtils;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.media3.common.Bundleable;
import androidx.media3.common.C;
import androidx.media3.common.MediaLibraryInfo;
import androidx.media3.common.util.UnstableApi;
@ -71,7 +70,7 @@ import java.util.List;
// This helps controller apps to keep target of dispatching media key events in uniform way.
// For details about the reason, see following. (Android O+)
// android.media.session.MediaSessionManager.Callback#onAddressedPlayerChanged
public final class SessionToken implements Bundleable {
public final class SessionToken {
static {
MediaLibraryInfo.registerModule("media3.session");
@ -452,7 +451,7 @@ public final class SessionToken implements Bundleable {
}
}
/* package */ interface SessionTokenImpl extends Bundleable {
/* package */ interface SessionTokenImpl {
boolean isLegacySession();
@ -476,9 +475,9 @@ public final class SessionToken implements Bundleable {
@Nullable
Object getBinder();
}
// Bundleable implementation.
Bundle toBundle();
}
private static final String FIELD_IMPL_TYPE = Util.intToStringMaxRadix(0);
private static final String FIELD_IMPL = Util.intToStringMaxRadix(1);
@ -494,7 +493,6 @@ public final class SessionToken implements Bundleable {
private static final int IMPL_TYPE_LEGACY = 1;
@UnstableApi
@Override
public Bundle toBundle() {
Bundle bundle = new Bundle();
if (impl instanceof SessionTokenImplBase) {
@ -506,16 +504,6 @@ public final class SessionToken implements Bundleable {
return bundle;
}
/**
* Object that can restore {@link SessionToken} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@UnstableApi
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SessionToken> CREATOR = SessionToken::fromBundle;
/** Restores a {@code SessionToken} from a {@link Bundle}. */
@UnstableApi
public static SessionToken fromBundle(Bundle bundle) {

View File

@ -203,8 +203,6 @@ import com.google.common.base.Objects;
return iSession;
}
// Bundleable implementation.
private static final String FIELD_UID = Util.intToStringMaxRadix(0);
private static final String FIELD_TYPE = Util.intToStringMaxRadix(1);
private static final String FIELD_LIBRARY_VERSION = Util.intToStringMaxRadix(2);
@ -232,15 +230,6 @@ import com.google.common.base.Objects;
return bundle;
}
/**
* Object that can restore {@link SessionTokenImplBase} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SessionTokenImplBase> CREATOR = SessionTokenImplBase::fromBundle;
/** Restores a {@code SessionTokenImplBase} from a {@link Bundle}. */
public static SessionTokenImplBase fromBundle(Bundle bundle) {
checkArgument(bundle.containsKey(FIELD_UID), "uid should be set.");

View File

@ -168,8 +168,6 @@ import com.google.common.base.Objects;
return legacyToken;
}
// Bundleable implementation.
private static final String FIELD_LEGACY_TOKEN = Util.intToStringMaxRadix(0);
private static final String FIELD_UID = Util.intToStringMaxRadix(1);
private static final String FIELD_TYPE = Util.intToStringMaxRadix(2);
@ -189,15 +187,6 @@ import com.google.common.base.Objects;
return bundle;
}
/**
* Object that can restore {@link SessionTokenImplLegacy} from a {@link Bundle}.
*
* @deprecated Use {@link #fromBundle} instead.
*/
@Deprecated
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
public static final Creator<SessionTokenImplLegacy> CREATOR = SessionTokenImplLegacy::fromBundle;
/** Restores a {@code SessionTokenImplLegacy} from a {@link Bundle}. */
public static SessionTokenImplLegacy fromBundle(Bundle bundle) {
@Nullable Bundle legacyTokenBundle = bundle.getBundle(FIELD_LEGACY_TOKEN);