Deprecate Bundleable and Bundleable.Creator
Both interfaces are not really needed as the methods can be called on the respective classes directly. This also avoid error-prone situations where classes define to/fromBundle methods with parameters that should be used instead of the parameter-less version. Also deprecate all existing CREATOR static instances and make the corresponding fromBundle method public where needed. PiperOrigin-RevId: 579189766
This commit is contained in:
parent
0a016b59f7
commit
312203d38b
@ -429,8 +429,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||
Bundle adsLoaderStateBundle = savedInstanceState.getBundle(KEY_SERVER_SIDE_ADS_LOADER_STATE);
|
||||
if (adsLoaderStateBundle != null) {
|
||||
serverSideAdsLoaderState =
|
||||
ImaServerSideAdInsertionMediaSource.AdsLoader.State.CREATOR.fromBundle(
|
||||
adsLoaderStateBundle);
|
||||
ImaServerSideAdInsertionMediaSource.AdsLoader.State.fromBundle(adsLoaderStateBundle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,12 +496,19 @@ public final class AdPlaybackState implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link AdGroup} from a {@link 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")
|
||||
private static AdGroup fromBundle(Bundle bundle) {
|
||||
public static AdGroup fromBundle(Bundle bundle) {
|
||||
long timeUs = bundle.getLong(FIELD_TIME_US);
|
||||
int count = bundle.getInt(FIELD_COUNT);
|
||||
int originalCount = bundle.getInt(FIELD_ORIGINAL_COUNT);
|
||||
@ -1202,10 +1209,15 @@ public final class AdPlaybackState implements Bundleable {
|
||||
* 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;
|
||||
|
||||
private static AdPlaybackState fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code AdPlaybackState} from a {@link Bundle}. */
|
||||
public static AdPlaybackState fromBundle(Bundle bundle) {
|
||||
@Nullable ArrayList<Bundle> adGroupBundleList = bundle.getParcelableArrayList(FIELD_AD_GROUPS);
|
||||
@Nullable AdGroup[] adGroups;
|
||||
if (adGroupBundleList == null) {
|
||||
@ -1213,7 +1225,7 @@ public final class AdPlaybackState implements Bundleable {
|
||||
} else {
|
||||
adGroups = new AdGroup[adGroupBundleList.size()];
|
||||
for (int i = 0; i < adGroupBundleList.size(); i++) {
|
||||
adGroups[i] = AdGroup.CREATOR.fromBundle(adGroupBundleList.get(i));
|
||||
adGroups[i] = AdGroup.fromBundle(adGroupBundleList.get(i));
|
||||
}
|
||||
}
|
||||
long adResumePositionUs =
|
||||
|
@ -220,28 +220,38 @@ public final class AudioAttributes implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link AudioAttributes} from a {@link Bundle}. */
|
||||
/**
|
||||
* Object that can restore {@link AudioAttributes} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<AudioAttributes> CREATOR =
|
||||
bundle -> {
|
||||
Builder builder = new Builder();
|
||||
if (bundle.containsKey(FIELD_CONTENT_TYPE)) {
|
||||
builder.setContentType(bundle.getInt(FIELD_CONTENT_TYPE));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_FLAGS)) {
|
||||
builder.setFlags(bundle.getInt(FIELD_FLAGS));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_USAGE)) {
|
||||
builder.setUsage(bundle.getInt(FIELD_USAGE));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_ALLOWED_CAPTURE_POLICY)) {
|
||||
builder.setAllowedCapturePolicy(bundle.getInt(FIELD_ALLOWED_CAPTURE_POLICY));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_SPATIALIZATION_BEHAVIOR)) {
|
||||
builder.setSpatializationBehavior(bundle.getInt(FIELD_SPATIALIZATION_BEHAVIOR));
|
||||
}
|
||||
return builder.build();
|
||||
};
|
||||
@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) {
|
||||
Builder builder = new Builder();
|
||||
if (bundle.containsKey(FIELD_CONTENT_TYPE)) {
|
||||
builder.setContentType(bundle.getInt(FIELD_CONTENT_TYPE));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_FLAGS)) {
|
||||
builder.setFlags(bundle.getInt(FIELD_FLAGS));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_USAGE)) {
|
||||
builder.setUsage(bundle.getInt(FIELD_USAGE));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_ALLOWED_CAPTURE_POLICY)) {
|
||||
builder.setAllowedCapturePolicy(bundle.getInt(FIELD_ALLOWED_CAPTURE_POLICY));
|
||||
}
|
||||
if (bundle.containsKey(FIELD_SPATIALIZATION_BEHAVIOR)) {
|
||||
builder.setSpatializationBehavior(bundle.getInt(FIELD_SPATIALIZATION_BEHAVIOR));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
;
|
||||
|
||||
@RequiresApi(29)
|
||||
private static final class Api29 {
|
||||
|
@ -19,26 +19,19 @@ import android.os.Bundle;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
|
||||
/**
|
||||
* Interface for classes whose instance can be stored in a {@link Bundle} by {@link #toBundle()} and
|
||||
* can be restored from the {@link Bundle} by using the static {@code CREATOR} field that implements
|
||||
* {@link Bundleable.Creator}.
|
||||
*
|
||||
* <p>For example, a {@link Bundleable} class {@code Foo} supports the following:
|
||||
*
|
||||
* <pre>{@code
|
||||
* Foo foo = ...;
|
||||
* Bundle fooBundle = foo.toBundle();
|
||||
* Foo restoredFoo = Foo.CREATOR.fromBundle(fooBundle);
|
||||
* assertThat(restoredFoo).isEqualTo(foo);
|
||||
* }</pre>
|
||||
* @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();
|
||||
|
||||
/** Interface for the static {@code CREATOR} field of {@link Bundleable} classes. */
|
||||
/**
|
||||
* @deprecated Interface not needed, call {@code fromBundle()} on the target type directly.
|
||||
*/
|
||||
@Deprecated
|
||||
interface Creator<T extends Bundleable> {
|
||||
|
||||
/**
|
||||
|
@ -450,13 +450,21 @@ public final class ColorInfo implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
public static final Creator<ColorInfo> CREATOR =
|
||||
bundle ->
|
||||
new ColorInfo(
|
||||
bundle.getInt(FIELD_COLOR_SPACE, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_COLOR_RANGE, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_COLOR_TRANSFER, Format.NO_VALUE),
|
||||
bundle.getByteArray(FIELD_HDR_STATIC_INFO),
|
||||
bundle.getInt(FIELD_LUMA_BITDEPTH, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_CHROMA_BITDEPTH, Format.NO_VALUE));
|
||||
/**
|
||||
* @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(
|
||||
bundle.getInt(FIELD_COLOR_SPACE, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_COLOR_RANGE, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_COLOR_TRANSFER, Format.NO_VALUE),
|
||||
bundle.getByteArray(FIELD_HDR_STATIC_INFO),
|
||||
bundle.getInt(FIELD_LUMA_BITDEPTH, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_CHROMA_BITDEPTH, Format.NO_VALUE));
|
||||
}
|
||||
}
|
||||
|
@ -217,19 +217,28 @@ public final class DeviceInfo implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link DeviceInfo} from a {@link Bundle}. */
|
||||
/**
|
||||
* Object that can restore {@link DeviceInfo} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<DeviceInfo> CREATOR =
|
||||
bundle -> {
|
||||
int playbackType =
|
||||
bundle.getInt(FIELD_PLAYBACK_TYPE, /* defaultValue= */ PLAYBACK_TYPE_LOCAL);
|
||||
int minVolume = bundle.getInt(FIELD_MIN_VOLUME, /* defaultValue= */ 0);
|
||||
int maxVolume = bundle.getInt(FIELD_MAX_VOLUME, /* defaultValue= */ 0);
|
||||
@Nullable String routingControllerId = bundle.getString(FIELD_ROUTING_CONTROLLER_ID);
|
||||
return new DeviceInfo.Builder(playbackType)
|
||||
.setMinVolume(minVolume)
|
||||
.setMaxVolume(maxVolume)
|
||||
.setRoutingControllerId(routingControllerId)
|
||||
.build();
|
||||
};
|
||||
@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) {
|
||||
int playbackType = bundle.getInt(FIELD_PLAYBACK_TYPE, /* defaultValue= */ PLAYBACK_TYPE_LOCAL);
|
||||
int minVolume = bundle.getInt(FIELD_MIN_VOLUME, /* defaultValue= */ 0);
|
||||
int maxVolume = bundle.getInt(FIELD_MAX_VOLUME, /* defaultValue= */ 0);
|
||||
@Nullable String routingControllerId = bundle.getString(FIELD_ROUTING_CONTROLLER_ID);
|
||||
return new DeviceInfo.Builder(playbackType)
|
||||
.setMinVolume(minVolume)
|
||||
.setMaxVolume(maxVolume)
|
||||
.setRoutingControllerId(routingControllerId)
|
||||
.build();
|
||||
}
|
||||
;
|
||||
}
|
||||
|
@ -1447,8 +1447,15 @@ public final class Format implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@code Format} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<Format> CREATOR = Format::fromBundle;
|
||||
/**
|
||||
* 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
|
||||
@ -1496,7 +1503,7 @@ public final class Format implements Bundleable {
|
||||
.setStereoMode(bundle.getInt(FIELD_STEREO_MODE, DEFAULT.stereoMode));
|
||||
Bundle colorInfoBundle = bundle.getBundle(FIELD_COLOR_INFO);
|
||||
if (colorInfoBundle != null) {
|
||||
builder.setColorInfo(ColorInfo.CREATOR.fromBundle(colorInfoBundle));
|
||||
builder.setColorInfo(ColorInfo.fromBundle(colorInfoBundle));
|
||||
}
|
||||
// Audio specific.
|
||||
builder
|
||||
|
@ -89,10 +89,19 @@ public final class HeartRating extends Rating {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@link HeartRating} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<HeartRating> CREATOR = HeartRating::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static HeartRating fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code HeartRating} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static HeartRating fromBundle(Bundle bundle) {
|
||||
checkArgument(bundle.getInt(FIELD_RATING_TYPE, /* defaultValue= */ RATING_TYPE_UNSET) == TYPE);
|
||||
boolean isRated = bundle.getBoolean(FIELD_RATED, /* defaultValue= */ false);
|
||||
return isRated
|
||||
|
@ -922,12 +922,19 @@ 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}. */
|
||||
/**
|
||||
* 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
|
||||
private static DrmConfiguration fromBundle(Bundle bundle) {
|
||||
public static DrmConfiguration fromBundle(Bundle bundle) {
|
||||
UUID scheme = UUID.fromString(checkNotNull(bundle.getString(FIELD_SCHEME)));
|
||||
@Nullable Uri licenseUri = bundle.getParcelable(FIELD_LICENSE_URI);
|
||||
Bundle licenseMapAsBundle =
|
||||
@ -1085,12 +1092,17 @@ public final class MediaItem implements Bundleable {
|
||||
* 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
|
||||
private static AdsConfiguration fromBundle(Bundle bundle) {
|
||||
public static AdsConfiguration fromBundle(Bundle bundle) {
|
||||
@Nullable Uri adTagUri = bundle.getParcelable(FIELD_AD_TAG_URI);
|
||||
checkNotNull(adTagUri);
|
||||
return new AdsConfiguration.Builder(adTagUri).build();
|
||||
@ -1268,18 +1280,25 @@ public final class MediaItem implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link LocalConfiguration} from a {@link 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
|
||||
private static LocalConfiguration fromBundle(Bundle bundle) {
|
||||
public static LocalConfiguration fromBundle(Bundle bundle) {
|
||||
@Nullable Bundle drmBundle = bundle.getBundle(FIELD_DRM_CONFIGURATION);
|
||||
DrmConfiguration drmConfiguration =
|
||||
drmBundle == null ? null : DrmConfiguration.CREATOR.fromBundle(drmBundle);
|
||||
drmBundle == null ? null : DrmConfiguration.fromBundle(drmBundle);
|
||||
@Nullable Bundle adsBundle = bundle.getBundle(FIELD_ADS_CONFIGURATION);
|
||||
AdsConfiguration adsConfiguration =
|
||||
adsBundle == null ? null : AdsConfiguration.CREATOR.fromBundle(adsBundle);
|
||||
adsBundle == null ? null : AdsConfiguration.fromBundle(adsBundle);
|
||||
@Nullable List<Bundle> streamKeysBundles = bundle.getParcelableArrayList(FIELD_STREAM_KEYS);
|
||||
List<StreamKey> streamKeys =
|
||||
streamKeysBundles == null
|
||||
@ -1528,18 +1547,26 @@ public final class MediaItem implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** An object that can restore {@link LiveConfiguration} from a {@link Bundle}. */
|
||||
/**
|
||||
* An object that can restore {@link LiveConfiguration} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<LiveConfiguration> CREATOR =
|
||||
bundle ->
|
||||
new LiveConfiguration(
|
||||
bundle.getLong(FIELD_TARGET_OFFSET_MS, /* defaultValue= */ UNSET.targetOffsetMs),
|
||||
bundle.getLong(FIELD_MIN_OFFSET_MS, /* defaultValue= */ UNSET.minOffsetMs),
|
||||
bundle.getLong(FIELD_MAX_OFFSET_MS, /* defaultValue= */ UNSET.maxOffsetMs),
|
||||
bundle.getFloat(
|
||||
FIELD_MIN_PLAYBACK_SPEED, /* defaultValue= */ UNSET.minPlaybackSpeed),
|
||||
bundle.getFloat(
|
||||
FIELD_MAX_PLAYBACK_SPEED, /* defaultValue= */ UNSET.maxPlaybackSpeed));
|
||||
@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) {
|
||||
return new LiveConfiguration(
|
||||
bundle.getLong(FIELD_TARGET_OFFSET_MS, /* defaultValue= */ UNSET.targetOffsetMs),
|
||||
bundle.getLong(FIELD_MIN_OFFSET_MS, /* defaultValue= */ UNSET.minOffsetMs),
|
||||
bundle.getLong(FIELD_MAX_OFFSET_MS, /* defaultValue= */ UNSET.maxOffsetMs),
|
||||
bundle.getFloat(FIELD_MIN_PLAYBACK_SPEED, /* defaultValue= */ UNSET.minPlaybackSpeed),
|
||||
bundle.getFloat(FIELD_MAX_PLAYBACK_SPEED, /* defaultValue= */ UNSET.maxPlaybackSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
/** Properties for a text track. */
|
||||
@ -1732,12 +1759,19 @@ 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}. */
|
||||
/**
|
||||
* 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
|
||||
private static SubtitleConfiguration fromBundle(Bundle bundle) {
|
||||
public static SubtitleConfiguration fromBundle(Bundle bundle) {
|
||||
Uri uri = checkNotNull(bundle.getParcelable(FIELD_URI));
|
||||
@Nullable String mimeType = bundle.getString(FIELD_MIME_TYPE);
|
||||
@Nullable String language = bundle.getString(FIELD_LANGUAGE);
|
||||
@ -2068,41 +2102,49 @@ public final class MediaItem implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** An object that can restore {@link ClippingConfiguration} from a {@link Bundle}. */
|
||||
/**
|
||||
* An object that can restore {@link ClippingConfiguration} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<ClippingProperties> CREATOR =
|
||||
bundle -> {
|
||||
ClippingConfiguration.Builder clippingConfiguration =
|
||||
new ClippingConfiguration.Builder()
|
||||
.setStartPositionMs(
|
||||
bundle.getLong(
|
||||
FIELD_START_POSITION_MS, /* defaultValue= */ UNSET.startPositionMs))
|
||||
.setEndPositionMs(
|
||||
bundle.getLong(
|
||||
FIELD_END_POSITION_MS, /* defaultValue= */ UNSET.endPositionMs))
|
||||
.setRelativeToLiveWindow(
|
||||
bundle.getBoolean(
|
||||
FIELD_RELATIVE_TO_LIVE_WINDOW,
|
||||
/* defaultValue= */ UNSET.relativeToLiveWindow))
|
||||
.setRelativeToDefaultPosition(
|
||||
bundle.getBoolean(
|
||||
FIELD_RELATIVE_TO_DEFAULT_POSITION,
|
||||
/* defaultValue= */ UNSET.relativeToDefaultPosition))
|
||||
.setStartsAtKeyFrame(
|
||||
bundle.getBoolean(
|
||||
FIELD_STARTS_AT_KEY_FRAME, /* defaultValue= */ UNSET.startsAtKeyFrame));
|
||||
long startPositionUs =
|
||||
bundle.getLong(FIELD_START_POSITION_US, /* defaultValue= */ UNSET.startPositionUs);
|
||||
if (startPositionUs != UNSET.startPositionUs) {
|
||||
clippingConfiguration.setStartPositionUs(startPositionUs);
|
||||
}
|
||||
long endPositionUs =
|
||||
bundle.getLong(FIELD_END_POSITION_US, /* defaultValue= */ UNSET.endPositionUs);
|
||||
if (endPositionUs != UNSET.endPositionUs) {
|
||||
clippingConfiguration.setEndPositionUs(endPositionUs);
|
||||
}
|
||||
return clippingConfiguration.buildClippingProperties();
|
||||
};
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<ClippingProperties> CREATOR = ClippingConfiguration::fromBundle;
|
||||
|
||||
/** Restores a {@code ClippingProperties} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static ClippingProperties fromBundle(Bundle bundle) {
|
||||
ClippingConfiguration.Builder clippingConfiguration =
|
||||
new ClippingConfiguration.Builder()
|
||||
.setStartPositionMs(
|
||||
bundle.getLong(
|
||||
FIELD_START_POSITION_MS, /* defaultValue= */ UNSET.startPositionMs))
|
||||
.setEndPositionMs(
|
||||
bundle.getLong(FIELD_END_POSITION_MS, /* defaultValue= */ UNSET.endPositionMs))
|
||||
.setRelativeToLiveWindow(
|
||||
bundle.getBoolean(
|
||||
FIELD_RELATIVE_TO_LIVE_WINDOW,
|
||||
/* defaultValue= */ UNSET.relativeToLiveWindow))
|
||||
.setRelativeToDefaultPosition(
|
||||
bundle.getBoolean(
|
||||
FIELD_RELATIVE_TO_DEFAULT_POSITION,
|
||||
/* defaultValue= */ UNSET.relativeToDefaultPosition))
|
||||
.setStartsAtKeyFrame(
|
||||
bundle.getBoolean(
|
||||
FIELD_STARTS_AT_KEY_FRAME, /* defaultValue= */ UNSET.startsAtKeyFrame));
|
||||
long startPositionUs =
|
||||
bundle.getLong(FIELD_START_POSITION_US, /* defaultValue= */ UNSET.startPositionUs);
|
||||
if (startPositionUs != UNSET.startPositionUs) {
|
||||
clippingConfiguration.setStartPositionUs(startPositionUs);
|
||||
}
|
||||
long endPositionUs =
|
||||
bundle.getLong(FIELD_END_POSITION_US, /* defaultValue= */ UNSET.endPositionUs);
|
||||
if (endPositionUs != UNSET.endPositionUs) {
|
||||
clippingConfiguration.setEndPositionUs(endPositionUs);
|
||||
}
|
||||
return clippingConfiguration.buildClippingProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2241,15 +2283,25 @@ public final class MediaItem implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** An object that can restore {@link RequestMetadata} from a {@link Bundle}. */
|
||||
/**
|
||||
* An object that can restore {@link RequestMetadata} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<RequestMetadata> CREATOR =
|
||||
bundle ->
|
||||
new RequestMetadata.Builder()
|
||||
.setMediaUri(bundle.getParcelable(FIELD_MEDIA_URI))
|
||||
.setSearchQuery(bundle.getString(FIELD_SEARCH_QUERY))
|
||||
.setExtras(bundle.getBundle(FIELD_EXTRAS))
|
||||
.build();
|
||||
@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) {
|
||||
return new RequestMetadata.Builder()
|
||||
.setMediaUri(bundle.getParcelable(FIELD_MEDIA_URI))
|
||||
.setSearchQuery(bundle.getString(FIELD_SEARCH_QUERY))
|
||||
.setExtras(bundle.getBundle(FIELD_EXTRAS))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2403,8 +2455,13 @@ public final class MediaItem implements Bundleable {
|
||||
* 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 public static final Creator<MediaItem> CREATOR = MediaItem::fromBundle;
|
||||
@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}.
|
||||
@ -2420,35 +2477,35 @@ public final class MediaItem implements Bundleable {
|
||||
if (liveConfigurationBundle == null) {
|
||||
liveConfiguration = LiveConfiguration.UNSET;
|
||||
} else {
|
||||
liveConfiguration = LiveConfiguration.CREATOR.fromBundle(liveConfigurationBundle);
|
||||
liveConfiguration = LiveConfiguration.fromBundle(liveConfigurationBundle);
|
||||
}
|
||||
@Nullable Bundle mediaMetadataBundle = bundle.getBundle(FIELD_MEDIA_METADATA);
|
||||
MediaMetadata mediaMetadata;
|
||||
if (mediaMetadataBundle == null) {
|
||||
mediaMetadata = MediaMetadata.EMPTY;
|
||||
} else {
|
||||
mediaMetadata = MediaMetadata.CREATOR.fromBundle(mediaMetadataBundle);
|
||||
mediaMetadata = MediaMetadata.fromBundle(mediaMetadataBundle);
|
||||
}
|
||||
@Nullable Bundle clippingConfigurationBundle = bundle.getBundle(FIELD_CLIPPING_PROPERTIES);
|
||||
ClippingProperties clippingConfiguration;
|
||||
if (clippingConfigurationBundle == null) {
|
||||
clippingConfiguration = ClippingProperties.UNSET;
|
||||
} else {
|
||||
clippingConfiguration = ClippingConfiguration.CREATOR.fromBundle(clippingConfigurationBundle);
|
||||
clippingConfiguration = ClippingConfiguration.fromBundle(clippingConfigurationBundle);
|
||||
}
|
||||
@Nullable Bundle requestMetadataBundle = bundle.getBundle(FIELD_REQUEST_METADATA);
|
||||
RequestMetadata requestMetadata;
|
||||
if (requestMetadataBundle == null) {
|
||||
requestMetadata = RequestMetadata.EMPTY;
|
||||
} else {
|
||||
requestMetadata = RequestMetadata.CREATOR.fromBundle(requestMetadataBundle);
|
||||
requestMetadata = RequestMetadata.fromBundle(requestMetadataBundle);
|
||||
}
|
||||
@Nullable Bundle localConfigurationBundle = bundle.getBundle(FIELD_LOCAL_CONFIGURATION);
|
||||
LocalConfiguration localConfiguration;
|
||||
if (localConfigurationBundle == null) {
|
||||
localConfiguration = null;
|
||||
} else {
|
||||
localConfiguration = LocalConfiguration.CREATOR.fromBundle(localConfigurationBundle);
|
||||
localConfiguration = LocalConfiguration.fromBundle(localConfigurationBundle);
|
||||
}
|
||||
return new MediaItem(
|
||||
mediaId,
|
||||
|
@ -1372,11 +1372,20 @@ public final class MediaMetadata implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link MediaMetadata} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<MediaMetadata> CREATOR = MediaMetadata::fromBundle;
|
||||
/**
|
||||
* 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.
|
||||
private static MediaMetadata fromBundle(Bundle bundle) {
|
||||
public static MediaMetadata fromBundle(Bundle bundle) {
|
||||
Builder builder = new Builder();
|
||||
builder
|
||||
.setTitle(bundle.getCharSequence(FIELD_TITLE))
|
||||
@ -1403,13 +1412,13 @@ public final class MediaMetadata implements Bundleable {
|
||||
if (bundle.containsKey(FIELD_USER_RATING)) {
|
||||
@Nullable Bundle fieldBundle = bundle.getBundle(FIELD_USER_RATING);
|
||||
if (fieldBundle != null) {
|
||||
builder.setUserRating(Rating.CREATOR.fromBundle(fieldBundle));
|
||||
builder.setUserRating(Rating.fromBundle(fieldBundle));
|
||||
}
|
||||
}
|
||||
if (bundle.containsKey(FIELD_OVERALL_RATING)) {
|
||||
@Nullable Bundle fieldBundle = bundle.getBundle(FIELD_OVERALL_RATING);
|
||||
if (fieldBundle != null) {
|
||||
builder.setOverallRating(Rating.CREATOR.fromBundle(fieldBundle));
|
||||
builder.setOverallRating(Rating.fromBundle(fieldBundle));
|
||||
}
|
||||
}
|
||||
if (bundle.containsKey(FIELD_TRACK_NUMBER)) {
|
||||
|
@ -85,10 +85,19 @@ public final class PercentageRating extends Rating {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@link PercentageRating} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<PercentageRating> CREATOR = PercentageRating::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static PercentageRating fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code PercentageRating} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static PercentageRating fromBundle(Bundle bundle) {
|
||||
checkArgument(bundle.getInt(FIELD_RATING_TYPE, /* defaultValue= */ RATING_TYPE_UNSET) == TYPE);
|
||||
float percent = bundle.getFloat(FIELD_PERCENT, /* defaultValue= */ RATING_UNSET);
|
||||
return percent == RATING_UNSET ? new PercentageRating() : new PercentageRating(percent);
|
||||
|
@ -462,8 +462,21 @@ 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}. */
|
||||
@UnstableApi public static final Creator<PlaybackException> CREATOR = PlaybackException::new;
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@UnstableApi
|
||||
@CallSuper
|
||||
|
@ -127,12 +127,22 @@ public final class PlaybackParameters implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link PlaybackParameters} from a {@link Bundle}. */
|
||||
/**
|
||||
* Object that can restore {@link PlaybackParameters} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<PlaybackParameters> CREATOR =
|
||||
bundle -> {
|
||||
float speed = bundle.getFloat(FIELD_SPEED, /* defaultValue= */ 1f);
|
||||
float pitch = bundle.getFloat(FIELD_PITCH, /* defaultValue= */ 1f);
|
||||
return new PlaybackParameters(speed, pitch);
|
||||
};
|
||||
@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) {
|
||||
float speed = bundle.getFloat(FIELD_SPEED, /* defaultValue= */ 1f);
|
||||
float pitch = bundle.getFloat(FIELD_PITCH, /* defaultValue= */ 1f);
|
||||
return new PlaybackParameters(speed, pitch);
|
||||
}
|
||||
;
|
||||
}
|
||||
|
@ -473,15 +473,23 @@ public interface Player {
|
||||
return toBundle(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/** Object that can restore {@link PositionInfo} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<PositionInfo> CREATOR = PositionInfo::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static PositionInfo fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code PositionInfo} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static PositionInfo fromBundle(Bundle bundle) {
|
||||
int mediaItemIndex = bundle.getInt(FIELD_MEDIA_ITEM_INDEX, /* defaultValue= */ 0);
|
||||
@Nullable Bundle mediaItemBundle = bundle.getBundle(FIELD_MEDIA_ITEM);
|
||||
@Nullable
|
||||
MediaItem mediaItem =
|
||||
mediaItemBundle == null ? null : MediaItem.CREATOR.fromBundle(mediaItemBundle);
|
||||
MediaItem mediaItem = mediaItemBundle == null ? null : MediaItem.fromBundle(mediaItemBundle);
|
||||
int periodIndex = bundle.getInt(FIELD_PERIOD_INDEX, /* defaultValue= */ 0);
|
||||
long positionMs = bundle.getLong(FIELD_POSITION_MS, /* defaultValue= */ 0);
|
||||
long contentPositionMs = bundle.getLong(FIELD_CONTENT_POSITION_MS, /* defaultValue= */ 0);
|
||||
@ -751,10 +759,19 @@ public interface Player {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link Commands} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<Commands> CREATOR = Commands::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static Commands fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code Commands} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static Commands fromBundle(Bundle bundle) {
|
||||
@Nullable ArrayList<Integer> commands = bundle.getIntegerArrayList(FIELD_COMMANDS);
|
||||
if (commands == null) {
|
||||
return Commands.EMPTY;
|
||||
|
@ -63,21 +63,30 @@ 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}. */
|
||||
@UnstableApi public static final Creator<Rating> CREATOR = Rating::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static Rating fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code Rating} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static Rating fromBundle(Bundle bundle) {
|
||||
@RatingType
|
||||
int ratingType = bundle.getInt(FIELD_RATING_TYPE, /* defaultValue= */ RATING_TYPE_UNSET);
|
||||
switch (ratingType) {
|
||||
case RATING_TYPE_HEART:
|
||||
return HeartRating.CREATOR.fromBundle(bundle);
|
||||
return HeartRating.fromBundle(bundle);
|
||||
case RATING_TYPE_PERCENTAGE:
|
||||
return PercentageRating.CREATOR.fromBundle(bundle);
|
||||
return PercentageRating.fromBundle(bundle);
|
||||
case RATING_TYPE_STAR:
|
||||
return StarRating.CREATOR.fromBundle(bundle);
|
||||
return StarRating.fromBundle(bundle);
|
||||
case RATING_TYPE_THUMB:
|
||||
return ThumbRating.CREATOR.fromBundle(bundle);
|
||||
return ThumbRating.fromBundle(bundle);
|
||||
case RATING_TYPE_UNSET:
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown RatingType: " + ratingType);
|
||||
|
@ -114,10 +114,19 @@ public final class StarRating extends Rating {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@link StarRating} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<StarRating> CREATOR = StarRating::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static StarRating fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code StarRating} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static StarRating fromBundle(Bundle bundle) {
|
||||
checkArgument(bundle.getInt(FIELD_RATING_TYPE, /* defaultValue= */ RATING_TYPE_UNSET) == TYPE);
|
||||
int maxStars = bundle.getInt(FIELD_MAX_STARS, /* defaultValue= */ MAX_STARS_DEFAULT);
|
||||
float starRating = bundle.getFloat(FIELD_STAR_RATING, /* defaultValue= */ RATING_UNSET);
|
||||
|
@ -86,10 +86,19 @@ public final class ThumbRating extends Rating {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@link ThumbRating} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<ThumbRating> CREATOR = ThumbRating::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static ThumbRating fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code ThumbRating} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static ThumbRating fromBundle(Bundle bundle) {
|
||||
checkArgument(bundle.getInt(FIELD_RATING_TYPE, /* defaultValue= */ RATING_TYPE_UNSET) == TYPE);
|
||||
boolean rated = bundle.getBoolean(FIELD_RATED, /* defaultValue= */ false);
|
||||
return rated
|
||||
|
@ -503,14 +503,21 @@ public abstract class Timeline implements Bundleable {
|
||||
*
|
||||
* <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 public static final Creator<Window> CREATOR = Window::fromBundle;
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<Window> CREATOR = Window::fromBundle;
|
||||
|
||||
private static Window fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code Window} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static Window fromBundle(Bundle bundle) {
|
||||
@Nullable Bundle mediaItemBundle = bundle.getBundle(FIELD_MEDIA_ITEM);
|
||||
@Nullable
|
||||
MediaItem mediaItem =
|
||||
mediaItemBundle != null ? MediaItem.CREATOR.fromBundle(mediaItemBundle) : MediaItem.EMPTY;
|
||||
mediaItemBundle != null ? MediaItem.fromBundle(mediaItemBundle) : MediaItem.EMPTY;
|
||||
long presentationStartTimeMs =
|
||||
bundle.getLong(FIELD_PRESENTATION_START_TIME_MS, /* defaultValue= */ C.TIME_UNSET);
|
||||
long windowStartTimeMs =
|
||||
@ -523,7 +530,7 @@ public abstract class Timeline implements Bundleable {
|
||||
@Nullable
|
||||
MediaItem.LiveConfiguration liveConfiguration =
|
||||
liveConfigurationBundle != null
|
||||
? MediaItem.LiveConfiguration.CREATOR.fromBundle(liveConfigurationBundle)
|
||||
? MediaItem.LiveConfiguration.fromBundle(liveConfigurationBundle)
|
||||
: null;
|
||||
boolean isPlaceHolder = bundle.getBoolean(FIELD_IS_PLACEHOLDER, /* defaultValue= */ false);
|
||||
long defaultPositionUs = bundle.getLong(FIELD_DEFAULT_POSITION_US, /* defaultValue= */ 0);
|
||||
@ -955,10 +962,17 @@ public abstract class Timeline implements Bundleable {
|
||||
* 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 public static final Creator<Period> CREATOR = Period::fromBundle;
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<Period> CREATOR = Period::fromBundle;
|
||||
|
||||
private static Period fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code Period} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static Period fromBundle(Bundle bundle) {
|
||||
int windowIndex = bundle.getInt(FIELD_WINDOW_INDEX, /* defaultValue= */ 0);
|
||||
long durationUs = bundle.getLong(FIELD_DURATION_US, /* defaultValue= */ C.TIME_UNSET);
|
||||
long positionInWindowUs = bundle.getLong(FIELD_POSITION_IN_WINDOW_US, /* defaultValue= */ 0);
|
||||
@ -966,7 +980,7 @@ public abstract class Timeline implements Bundleable {
|
||||
@Nullable Bundle adPlaybackStateBundle = bundle.getBundle(FIELD_AD_PLAYBACK_STATE);
|
||||
AdPlaybackState adPlaybackState =
|
||||
adPlaybackStateBundle != null
|
||||
? AdPlaybackState.CREATOR.fromBundle(adPlaybackStateBundle)
|
||||
? AdPlaybackState.fromBundle(adPlaybackStateBundle)
|
||||
: AdPlaybackState.NONE;
|
||||
|
||||
Period period = new Period();
|
||||
@ -1477,10 +1491,17 @@ public abstract class Timeline implements Bundleable {
|
||||
* <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 public static final Creator<Timeline> CREATOR = Timeline::fromBundle;
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<Timeline> CREATOR = Timeline::fromBundle;
|
||||
|
||||
private static Timeline fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code Timeline} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static Timeline fromBundle(Bundle bundle) {
|
||||
ImmutableList<Window> windows =
|
||||
fromBundleListRetriever(Window::fromBundle, BundleUtil.getBinder(bundle, FIELD_WINDOWS));
|
||||
ImmutableList<Period> periods =
|
||||
|
@ -178,8 +178,15 @@ public final class TrackGroup implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@code TrackGroup} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<TrackGroup> CREATOR = TrackGroup::fromBundle;
|
||||
/**
|
||||
* 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
|
||||
|
@ -114,8 +114,14 @@ public final class TrackSelectionOverride implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@code TrackSelectionOverride} from a {@link 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}. */
|
||||
|
@ -1494,7 +1494,9 @@ public class TrackSelectionParameters implements Bundleable {
|
||||
/**
|
||||
* @deprecated Use {@link #fromBundle(Bundle)} instead.
|
||||
*/
|
||||
@UnstableApi @Deprecated
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<TrackSelectionParameters> CREATOR =
|
||||
TrackSelectionParameters::fromBundle;
|
||||
}
|
||||
|
@ -244,8 +244,15 @@ public final class Tracks implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a group of tracks from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<Group> CREATOR = Group::fromBundle;
|
||||
/**
|
||||
* 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
|
||||
@ -389,15 +396,25 @@ public final class Tracks implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore tracks from a {@link Bundle}. */
|
||||
/**
|
||||
* Object that can restore tracks from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<Tracks> CREATOR =
|
||||
bundle -> {
|
||||
@Nullable List<Bundle> groupBundles = bundle.getParcelableArrayList(FIELD_TRACK_GROUPS);
|
||||
List<Group> groups =
|
||||
groupBundles == null
|
||||
? ImmutableList.of()
|
||||
: BundleCollectionUtil.fromBundleList(Group::fromBundle, groupBundles);
|
||||
return new Tracks(groups);
|
||||
};
|
||||
@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) {
|
||||
@Nullable List<Bundle> groupBundles = bundle.getParcelableArrayList(FIELD_TRACK_GROUPS);
|
||||
List<Group> groups =
|
||||
groupBundles == null
|
||||
? ImmutableList.of()
|
||||
: BundleCollectionUtil.fromBundleList(Group::fromBundle, groupBundles);
|
||||
return new Tracks(groups);
|
||||
}
|
||||
;
|
||||
}
|
||||
|
@ -143,15 +143,24 @@ public final class VideoSize implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<VideoSize> CREATOR =
|
||||
bundle -> {
|
||||
int width = bundle.getInt(FIELD_WIDTH, DEFAULT_WIDTH);
|
||||
int height = bundle.getInt(FIELD_HEIGHT, DEFAULT_HEIGHT);
|
||||
int unappliedRotationDegrees =
|
||||
bundle.getInt(FIELD_UNAPPLIED_ROTATION_DEGREES, DEFAULT_UNAPPLIED_ROTATION_DEGREES);
|
||||
float pixelWidthHeightRatio =
|
||||
bundle.getFloat(FIELD_PIXEL_WIDTH_HEIGHT_RATIO, DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO);
|
||||
return new VideoSize(width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
|
||||
};
|
||||
@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) {
|
||||
int width = bundle.getInt(FIELD_WIDTH, DEFAULT_WIDTH);
|
||||
int height = bundle.getInt(FIELD_HEIGHT, DEFAULT_HEIGHT);
|
||||
int unappliedRotationDegrees =
|
||||
bundle.getInt(FIELD_UNAPPLIED_ROTATION_DEGREES, DEFAULT_UNAPPLIED_ROTATION_DEGREES);
|
||||
float pixelWidthHeightRatio =
|
||||
bundle.getFloat(FIELD_PIXEL_WIDTH_HEIGHT_RATIO, DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO);
|
||||
return new VideoSize(width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
|
||||
}
|
||||
;
|
||||
}
|
||||
|
@ -867,7 +867,13 @@ public final class Cue implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@UnstableApi public static final Creator<Cue> CREATOR = Cue::fromBundle;
|
||||
/**
|
||||
* @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
|
||||
|
@ -75,9 +75,17 @@ public final class CueGroup implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@UnstableApi public static final Creator<CueGroup> CREATOR = CueGroup::fromBundle;
|
||||
/**
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<CueGroup> CREATOR = CueGroup::fromBundle;
|
||||
|
||||
private static final CueGroup fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code final CueGroup} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static CueGroup fromBundle(Bundle bundle) {
|
||||
@Nullable ArrayList<Bundle> cueBundles = bundle.getParcelableArrayList(FIELD_CUES);
|
||||
List<Cue> cues =
|
||||
cueBundles == null
|
||||
|
@ -425,7 +425,7 @@ public class AdPlaybackStateTest {
|
||||
assertThat(adPlaybackStateWithNoAdsBundle.keySet()).isEmpty();
|
||||
|
||||
AdPlaybackState adPlaybackStateWithNoAdsFromBundle =
|
||||
AdPlaybackState.CREATOR.fromBundle(adPlaybackStateWithNoAdsBundle);
|
||||
AdPlaybackState.fromBundle(adPlaybackStateWithNoAdsBundle);
|
||||
|
||||
assertThat(adPlaybackStateWithNoAdsFromBundle.adsId).isEqualTo(adPlaybackStateWithNoAds.adsId);
|
||||
assertThat(adPlaybackStateWithNoAdsFromBundle.adGroupCount)
|
||||
@ -460,7 +460,7 @@ public class AdPlaybackStateTest {
|
||||
.withAdResumePositionUs(123)
|
||||
.withContentDurationUs(456);
|
||||
|
||||
AdPlaybackState restoredState = AdPlaybackState.CREATOR.fromBundle(originalState.toBundle());
|
||||
AdPlaybackState restoredState = AdPlaybackState.fromBundle(originalState.toBundle());
|
||||
|
||||
assertThat(restoredState.adsId).isNull();
|
||||
assertThat(restoredState.adGroupCount).isEqualTo(originalState.adGroupCount);
|
||||
@ -484,7 +484,7 @@ public class AdPlaybackStateTest {
|
||||
.withContentResumeOffsetUs(4444)
|
||||
.withIsServerSideInserted(true);
|
||||
|
||||
assertThat(AdPlaybackState.AdGroup.CREATOR.fromBundle(adGroup.toBundle())).isEqualTo(adGroup);
|
||||
assertThat(AdPlaybackState.AdGroup.fromBundle(adGroup.toBundle())).isEqualTo(adGroup);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -36,7 +36,6 @@ public class AudioAttributesTest {
|
||||
.setSpatializationBehavior(C.SPATIALIZATION_BEHAVIOR_NEVER)
|
||||
.build();
|
||||
|
||||
assertThat(AudioAttributes.CREATOR.fromBundle(audioAttributes.toBundle()))
|
||||
.isEqualTo(audioAttributes);
|
||||
assertThat(AudioAttributes.fromBundle(audioAttributes.toBundle())).isEqualTo(audioAttributes);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,6 @@ public class DeviceInfoTest {
|
||||
.setRoutingControllerId("route")
|
||||
.build();
|
||||
|
||||
assertThat(DeviceInfo.CREATOR.fromBundle(deviceInfo.toBundle())).isEqualTo(deviceInfo);
|
||||
assertThat(DeviceInfo.fromBundle(deviceInfo.toBundle())).isEqualTo(deviceInfo);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public final class FormatTest {
|
||||
@Test
|
||||
public void roundTripViaBundle_ofParameters_yieldsEqualInstance() {
|
||||
Format formatToBundle = createTestFormat();
|
||||
Format formatFromBundle = Format.CREATOR.fromBundle(formatToBundle.toBundle());
|
||||
Format formatFromBundle = Format.fromBundle(formatToBundle.toBundle());
|
||||
|
||||
assertThat(formatFromBundle).isEqualTo(formatToBundle);
|
||||
}
|
||||
@ -53,7 +53,7 @@ public final class FormatTest {
|
||||
|
||||
Bundle bundleWithMetadataExcluded = format.toBundle(/* excludeMetadata= */ true);
|
||||
|
||||
Format formatWithMetadataExcluded = Format.CREATOR.fromBundle(bundleWithMetadataExcluded);
|
||||
Format formatWithMetadataExcluded = Format.fromBundle(bundleWithMetadataExcluded);
|
||||
assertThat(formatWithMetadataExcluded).isEqualTo(format.buildUpon().setMetadata(null).build());
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ public class MediaItemTest {
|
||||
.build();
|
||||
|
||||
MediaItem.DrmConfiguration drmConfigurationFromBundle =
|
||||
MediaItem.DrmConfiguration.CREATOR.fromBundle(drmConfiguration.toBundle());
|
||||
MediaItem.DrmConfiguration.fromBundle(drmConfiguration.toBundle());
|
||||
|
||||
assertThat(drmConfigurationFromBundle).isEqualTo(drmConfiguration);
|
||||
}
|
||||
@ -352,7 +352,7 @@ public class MediaItemTest {
|
||||
assertThat(subtitleConfigurationBundle.keySet()).containsExactly("0");
|
||||
|
||||
MediaItem.SubtitleConfiguration subtitleConfigurationFromBundle =
|
||||
MediaItem.SubtitleConfiguration.CREATOR.fromBundle(subtitleConfigurationBundle);
|
||||
MediaItem.SubtitleConfiguration.fromBundle(subtitleConfigurationBundle);
|
||||
|
||||
assertThat(subtitleConfigurationFromBundle).isEqualTo(subtitleConfiguration);
|
||||
}
|
||||
@ -371,7 +371,7 @@ public class MediaItemTest {
|
||||
.build();
|
||||
|
||||
MediaItem.SubtitleConfiguration subtitleConfigurationFromBundle =
|
||||
MediaItem.SubtitleConfiguration.CREATOR.fromBundle(subtitleConfiguration.toBundle());
|
||||
MediaItem.SubtitleConfiguration.fromBundle(subtitleConfiguration.toBundle());
|
||||
|
||||
assertThat(subtitleConfigurationFromBundle).isEqualTo(subtitleConfiguration);
|
||||
}
|
||||
@ -461,7 +461,7 @@ public class MediaItemTest {
|
||||
assertThat(clippingConfigurationBundle.keySet()).isEmpty();
|
||||
|
||||
MediaItem.ClippingConfiguration clippingConfigurationFromBundle =
|
||||
MediaItem.ClippingConfiguration.CREATOR.fromBundle(clippingConfigurationBundle);
|
||||
MediaItem.ClippingConfiguration.fromBundle(clippingConfigurationBundle);
|
||||
|
||||
assertThat(clippingConfigurationFromBundle).isEqualTo(clippingConfiguration);
|
||||
}
|
||||
@ -477,7 +477,7 @@ public class MediaItemTest {
|
||||
.build();
|
||||
|
||||
MediaItem.ClippingConfiguration clippingConfigurationFromBundle =
|
||||
MediaItem.ClippingConfiguration.CREATOR.fromBundle(clippingConfiguration.toBundle());
|
||||
MediaItem.ClippingConfiguration.fromBundle(clippingConfiguration.toBundle());
|
||||
|
||||
assertThat(clippingConfigurationFromBundle).isEqualTo(clippingConfiguration);
|
||||
}
|
||||
@ -668,7 +668,7 @@ public class MediaItemTest {
|
||||
.build();
|
||||
|
||||
MediaItem.AdsConfiguration adsConfigurationFromBundle =
|
||||
MediaItem.AdsConfiguration.CREATOR.fromBundle(adsConfiguration.toBundle());
|
||||
MediaItem.AdsConfiguration.fromBundle(adsConfiguration.toBundle());
|
||||
|
||||
assertThat(adsConfigurationFromBundle.adTagUri).isEqualTo(adsConfiguration.adTagUri);
|
||||
assertThat(adsConfigurationFromBundle.adsId).isNull();
|
||||
@ -711,7 +711,7 @@ public class MediaItemTest {
|
||||
assertThat(liveConfigurationBundle.keySet()).isEmpty();
|
||||
|
||||
MediaItem.LiveConfiguration liveConfigurationFromBundle =
|
||||
MediaItem.LiveConfiguration.CREATOR.fromBundle(liveConfigurationBundle);
|
||||
MediaItem.LiveConfiguration.fromBundle(liveConfigurationBundle);
|
||||
|
||||
assertThat(liveConfigurationFromBundle).isEqualTo(liveConfiguration);
|
||||
}
|
||||
@ -726,7 +726,7 @@ public class MediaItemTest {
|
||||
.build();
|
||||
|
||||
MediaItem.LiveConfiguration liveConfigurationFromBundle =
|
||||
MediaItem.LiveConfiguration.CREATOR.fromBundle(liveConfiguration.toBundle());
|
||||
MediaItem.LiveConfiguration.fromBundle(liveConfiguration.toBundle());
|
||||
|
||||
assertThat(liveConfigurationFromBundle).isEqualTo(liveConfiguration);
|
||||
}
|
||||
@ -742,7 +742,7 @@ public class MediaItemTest {
|
||||
assertThat(localConfigurationBundle.keySet()).containsExactly("0");
|
||||
|
||||
MediaItem.LocalConfiguration restoredLocalConfiguration =
|
||||
MediaItem.LocalConfiguration.CREATOR.fromBundle(localConfigurationBundle);
|
||||
MediaItem.LocalConfiguration.fromBundle(localConfigurationBundle);
|
||||
|
||||
assertThat(restoredLocalConfiguration).isEqualTo(mediaItem.localConfiguration);
|
||||
assertThat(restoredLocalConfiguration.streamKeys).isEmpty();
|
||||
@ -784,10 +784,9 @@ public class MediaItemTest {
|
||||
|
||||
MediaItem.LocalConfiguration localConfiguration = mediaItem.localConfiguration;
|
||||
MediaItem.LocalConfiguration localConfigurationFromBundle =
|
||||
MediaItem.LocalConfiguration.CREATOR.fromBundle(localConfiguration.toBundle());
|
||||
MediaItem.LocalConfiguration.fromBundle(localConfiguration.toBundle());
|
||||
MediaItem.LocalConfiguration localConfigurationFromMediaItemBundle =
|
||||
MediaItem.CREATOR.fromBundle(mediaItem.toBundleIncludeLocalConfiguration())
|
||||
.localConfiguration;
|
||||
MediaItem.fromBundle(mediaItem.toBundleIncludeLocalConfiguration()).localConfiguration;
|
||||
|
||||
assertThat(localConfigurationFromBundle).isEqualTo(localConfiguration);
|
||||
assertThat(localConfigurationFromMediaItemBundle).isEqualTo(localConfiguration);
|
||||
@ -1016,7 +1015,7 @@ public class MediaItemTest {
|
||||
.build();
|
||||
|
||||
assertThat(mediaItem.localConfiguration).isNull();
|
||||
assertThat(MediaItem.CREATOR.fromBundle(mediaItem.toBundle())).isEqualTo(mediaItem);
|
||||
assertThat(MediaItem.fromBundle(mediaItem.toBundle())).isEqualTo(mediaItem);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1025,7 +1024,7 @@ public class MediaItemTest {
|
||||
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_STRING).build();
|
||||
|
||||
assertThat(mediaItem.localConfiguration).isNotNull();
|
||||
assertThat(MediaItem.CREATOR.fromBundle(mediaItem.toBundle()).localConfiguration).isNull();
|
||||
assertThat(MediaItem.fromBundle(mediaItem.toBundle()).localConfiguration).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1033,7 +1032,7 @@ public class MediaItemTest {
|
||||
roundTripViaBundleIncludeLocalConfiguration_mediaItemContainsLocalConfiguration_restoresLocalConfiguration() {
|
||||
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_STRING).build();
|
||||
MediaItem restoredMediaItem =
|
||||
MediaItem.CREATOR.fromBundle(mediaItem.toBundleIncludeLocalConfiguration());
|
||||
MediaItem.fromBundle(mediaItem.toBundleIncludeLocalConfiguration());
|
||||
|
||||
assertThat(mediaItem.localConfiguration).isNotNull();
|
||||
assertThat(restoredMediaItem.localConfiguration).isEqualTo(mediaItem.localConfiguration);
|
||||
@ -1062,7 +1061,7 @@ public class MediaItemTest {
|
||||
// Check that default values are skipped when bundling.
|
||||
assertThat(mediaItemBundle.keySet()).isEmpty();
|
||||
|
||||
MediaItem mediaItemFromBundle = MediaItem.CREATOR.fromBundle(mediaItem.toBundle());
|
||||
MediaItem mediaItemFromBundle = MediaItem.fromBundle(mediaItem.toBundle());
|
||||
|
||||
assertThat(mediaItemFromBundle).isEqualTo(mediaItem);
|
||||
}
|
||||
@ -1090,7 +1089,7 @@ public class MediaItemTest {
|
||||
.build())
|
||||
.build();
|
||||
|
||||
MediaItem mediaItemFromBundle = MediaItem.CREATOR.fromBundle(mediaItem.toBundle());
|
||||
MediaItem mediaItemFromBundle = MediaItem.fromBundle(mediaItem.toBundle());
|
||||
|
||||
assertThat(mediaItemFromBundle).isEqualTo(mediaItem);
|
||||
assertThat(mediaItemFromBundle.requestMetadata.extras)
|
||||
|
@ -116,7 +116,7 @@ public class MediaMetadataTest {
|
||||
// Check that default values are skipped when bundling.
|
||||
assertThat(mediaMetadataBundle.keySet()).isEmpty();
|
||||
|
||||
MediaMetadata mediaMetadataFromBundle = MediaMetadata.CREATOR.fromBundle(mediaMetadataBundle);
|
||||
MediaMetadata mediaMetadataFromBundle = MediaMetadata.fromBundle(mediaMetadataBundle);
|
||||
|
||||
assertThat(mediaMetadataFromBundle).isEqualTo(mediaMetadata);
|
||||
// Extras is not implemented in MediaMetadata.equals(Object o).
|
||||
@ -127,8 +127,7 @@ public class MediaMetadataTest {
|
||||
public void createFullyPopulatedMediaMetadata_roundTripViaBundle_yieldsEqualInstance() {
|
||||
MediaMetadata mediaMetadata = getFullyPopulatedMediaMetadata();
|
||||
|
||||
MediaMetadata mediaMetadataFromBundle =
|
||||
MediaMetadata.CREATOR.fromBundle(mediaMetadata.toBundle());
|
||||
MediaMetadata mediaMetadataFromBundle = MediaMetadata.fromBundle(mediaMetadata.toBundle());
|
||||
|
||||
assertThat(mediaMetadataFromBundle).isEqualTo(mediaMetadata);
|
||||
// Extras is not implemented in MediaMetadata.equals(Object o).
|
||||
|
@ -35,7 +35,7 @@ public class PlaybackExceptionTest {
|
||||
/* message= */ "test",
|
||||
/* cause= */ new IOException(/* message= */ "io"),
|
||||
PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND);
|
||||
PlaybackException after = PlaybackException.CREATOR.fromBundle(before.toBundle());
|
||||
PlaybackException after = PlaybackException.fromBundle(before.toBundle());
|
||||
assertPlaybackExceptionsAreEquivalent(before, after);
|
||||
}
|
||||
|
||||
@ -60,8 +60,7 @@ public class PlaybackExceptionTest {
|
||||
bundle.putString("3", expectedCause.getClass().getName());
|
||||
bundle.putString("4", "cause message");
|
||||
|
||||
assertPlaybackExceptionsAreEquivalent(
|
||||
expectedException, PlaybackException.CREATOR.fromBundle(bundle));
|
||||
assertPlaybackExceptionsAreEquivalent(expectedException, PlaybackException.fromBundle(bundle));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -99,8 +98,7 @@ public class PlaybackExceptionTest {
|
||||
bundle.putString("3", "invalid cause class name");
|
||||
bundle.putString("4", "cause message");
|
||||
|
||||
assertPlaybackExceptionsAreEquivalent(
|
||||
expectedException, PlaybackException.CREATOR.fromBundle(bundle));
|
||||
assertPlaybackExceptionsAreEquivalent(expectedException, PlaybackException.fromBundle(bundle));
|
||||
}
|
||||
|
||||
// Internal methods.
|
||||
|
@ -30,7 +30,7 @@ public class PlaybackParametersTest {
|
||||
PlaybackParameters playbackParameters =
|
||||
new PlaybackParameters(/* speed= */ 2.9f, /* pitch= */ 1.2f);
|
||||
|
||||
assertThat(PlaybackParameters.CREATOR.fromBundle(playbackParameters.toBundle()))
|
||||
assertThat(PlaybackParameters.fromBundle(playbackParameters.toBundle()))
|
||||
.isEqualTo(playbackParameters);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class PositionInfoTest {
|
||||
/* adGroupIndex= */ 2,
|
||||
/* adIndexInAdGroup= */ 444);
|
||||
|
||||
assertThat(PositionInfo.CREATOR.fromBundle(positionInfo.toBundle())).isEqualTo(positionInfo);
|
||||
assertThat(PositionInfo.fromBundle(positionInfo.toBundle())).isEqualTo(positionInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -58,7 +58,7 @@ public class PositionInfoTest {
|
||||
/* adGroupIndex= */ 2,
|
||||
/* adIndexInAdGroup= */ 444);
|
||||
|
||||
PositionInfo positionInfoFromBundle = PositionInfo.CREATOR.fromBundle(positionInfo.toBundle());
|
||||
PositionInfo positionInfoFromBundle = PositionInfo.fromBundle(positionInfo.toBundle());
|
||||
assertThat(positionInfoFromBundle.windowUid).isNull();
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class PositionInfoTest {
|
||||
/* adGroupIndex= */ 2,
|
||||
/* adIndexInAdGroup= */ 444);
|
||||
|
||||
PositionInfo positionInfoFromBundle = PositionInfo.CREATOR.fromBundle(positionInfo.toBundle());
|
||||
PositionInfo positionInfoFromBundle = PositionInfo.fromBundle(positionInfo.toBundle());
|
||||
assertThat(positionInfoFromBundle.periodUid).isNull();
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ public class PositionInfoTest {
|
||||
/* adGroupIndex= */ C.INDEX_UNSET,
|
||||
/* adIndexInAdGroup= */ C.INDEX_UNSET);
|
||||
|
||||
PositionInfo roundTripValue = PositionInfo.CREATOR.fromBundle(defaultPositionInfo.toBundle());
|
||||
PositionInfo roundTripValue = PositionInfo.fromBundle(defaultPositionInfo.toBundle());
|
||||
|
||||
assertThat(roundTripValue).isEqualTo(defaultPositionInfo);
|
||||
}
|
||||
|
@ -94,6 +94,6 @@ public class RatingTest {
|
||||
}
|
||||
|
||||
private static Rating roundTripViaBundle(Rating rating) {
|
||||
return Rating.CREATOR.fromBundle(rating.toBundle());
|
||||
return Rating.fromBundle(rating.toBundle());
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class TimelineTest {
|
||||
ImmutableList.of(AdPlaybackState.NONE),
|
||||
new MediaItem.Builder().setMediaId("mediaId3").build()));
|
||||
|
||||
Timeline restoredTimeline = Timeline.CREATOR.fromBundle(timeline.toBundle());
|
||||
Timeline restoredTimeline = Timeline.fromBundle(timeline.toBundle());
|
||||
|
||||
TimelineAsserts.assertEqualsExceptIdsAndManifest(
|
||||
/* expectedTimeline= */ timeline, /* actualTimeline= */ restoredTimeline);
|
||||
@ -299,7 +299,7 @@ public class TimelineTest {
|
||||
int windowCount = 10;
|
||||
FakeTimeline timeline = new FakeTimeline(windowCount);
|
||||
|
||||
Timeline restoredTimeline = Timeline.CREATOR.fromBundle(timeline.toBundle());
|
||||
Timeline restoredTimeline = Timeline.fromBundle(timeline.toBundle());
|
||||
|
||||
assertThat(restoredTimeline.getLastWindowIndex(/* shuffleModeEnabled= */ false))
|
||||
.isEqualTo(timeline.getLastWindowIndex(/* shuffleModeEnabled= */ false));
|
||||
@ -337,7 +337,7 @@ public class TimelineTest {
|
||||
|
||||
@Test
|
||||
public void roundTripViaBundle_ofEmptyTimeline_returnsEmptyTimeline() {
|
||||
TimelineAsserts.assertEmpty(Timeline.CREATOR.fromBundle(Timeline.EMPTY.toBundle()));
|
||||
TimelineAsserts.assertEmpty(Timeline.fromBundle(Timeline.EMPTY.toBundle()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -356,7 +356,7 @@ public class TimelineTest {
|
||||
// Check that default values are skipped when bundling.
|
||||
assertThat(windowBundle.keySet()).isEmpty();
|
||||
|
||||
Timeline.Window restoredWindow = Timeline.Window.CREATOR.fromBundle(windowBundle);
|
||||
Timeline.Window restoredWindow = Timeline.Window.fromBundle(windowBundle);
|
||||
|
||||
assertThat(restoredWindow.manifest).isNull();
|
||||
TimelineAsserts.assertWindowEqualsExceptUidAndManifest(
|
||||
@ -389,7 +389,7 @@ public class TimelineTest {
|
||||
window.lastPeriodIndex = 7;
|
||||
window.positionInFirstPeriodUs = 888;
|
||||
|
||||
Timeline.Window restoredWindow = Timeline.Window.CREATOR.fromBundle(window.toBundle());
|
||||
Timeline.Window restoredWindow = Timeline.Window.fromBundle(window.toBundle());
|
||||
|
||||
assertThat(restoredWindow.manifest).isNull();
|
||||
TimelineAsserts.assertWindowEqualsExceptUidAndManifest(
|
||||
@ -408,7 +408,7 @@ public class TimelineTest {
|
||||
// Check that default values are skipped when bundling.
|
||||
assertThat(periodBundle.keySet()).isEmpty();
|
||||
|
||||
Timeline.Period restoredPeriod = Timeline.Period.CREATOR.fromBundle(periodBundle);
|
||||
Timeline.Period restoredPeriod = Timeline.Period.fromBundle(periodBundle);
|
||||
|
||||
assertThat(restoredPeriod.id).isNull();
|
||||
assertThat(restoredPeriod.uid).isNull();
|
||||
@ -426,7 +426,7 @@ public class TimelineTest {
|
||||
period.positionInWindowUs = 4_000;
|
||||
period.isPlaceholder = true;
|
||||
|
||||
Timeline.Period restoredPeriod = Timeline.Period.CREATOR.fromBundle(period.toBundle());
|
||||
Timeline.Period restoredPeriod = Timeline.Period.fromBundle(period.toBundle());
|
||||
|
||||
assertThat(restoredPeriod.id).isNull();
|
||||
assertThat(restoredPeriod.uid).isNull();
|
||||
|
@ -31,7 +31,7 @@ public class TracksTest {
|
||||
@Test
|
||||
public void roundTripViaBundle_ofEmptyTracks_yieldsEqualInstance() {
|
||||
Tracks before = Tracks.EMPTY;
|
||||
Tracks after = Tracks.CREATOR.fromBundle(before.toBundle());
|
||||
Tracks after = Tracks.fromBundle(before.toBundle());
|
||||
assertThat(after).isEqualTo(before);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class TracksTest {
|
||||
/* adaptiveSupported= */ true,
|
||||
new int[] {C.FORMAT_UNSUPPORTED_DRM, C.FORMAT_UNSUPPORTED_TYPE},
|
||||
/* trackSelected= */ new boolean[] {false, true})));
|
||||
Tracks after = Tracks.CREATOR.fromBundle(before.toBundle());
|
||||
Tracks after = Tracks.fromBundle(before.toBundle());
|
||||
assertThat(after).isEqualTo(before);
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,10 @@ public final class VideoSizeTest {
|
||||
|
||||
@Test
|
||||
public void fromBundle_ofEmptyBundle_yieldsVideoSizeUnknown() {
|
||||
assertThat(VideoSize.CREATOR.fromBundle(new Bundle())).isEqualTo(VideoSize.UNKNOWN);
|
||||
assertThat(VideoSize.fromBundle(new Bundle())).isEqualTo(VideoSize.UNKNOWN);
|
||||
}
|
||||
|
||||
private static VideoSize roundTripViaBundle(VideoSize videoSize) {
|
||||
return VideoSize.CREATOR.fromBundle(videoSize.toBundle());
|
||||
return VideoSize.fromBundle(videoSize.toBundle());
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class CueGroupTest {
|
||||
parcel.setDataPosition(0);
|
||||
|
||||
Bundle bundle = parcel.readBundle();
|
||||
CueGroup filteredCueGroup = CueGroup.CREATOR.fromBundle(bundle);
|
||||
CueGroup filteredCueGroup = CueGroup.fromBundle(bundle);
|
||||
|
||||
assertThat(filteredCueGroup.cues).containsExactly(textCue);
|
||||
} finally {
|
||||
|
@ -146,7 +146,7 @@ public class CueTest {
|
||||
parcel.setDataPosition(0);
|
||||
|
||||
Bundle bundle = parcel.readBundle();
|
||||
return Cue.CREATOR.fromBundle(bundle);
|
||||
return Cue.fromBundle(bundle);
|
||||
} finally {
|
||||
parcel.recycle();
|
||||
}
|
||||
|
@ -260,8 +260,7 @@ public final class ExoPlaybackException extends PlaybackException {
|
||||
rendererName = bundle.getString(FIELD_RENDERER_NAME);
|
||||
rendererIndex = bundle.getInt(FIELD_RENDERER_INDEX, /* defaultValue= */ C.INDEX_UNSET);
|
||||
@Nullable Bundle rendererFormatBundle = bundle.getBundle(FIELD_RENDERER_FORMAT);
|
||||
rendererFormat =
|
||||
rendererFormatBundle == null ? null : Format.CREATOR.fromBundle(rendererFormatBundle);
|
||||
rendererFormat = rendererFormatBundle == null ? null : Format.fromBundle(rendererFormatBundle);
|
||||
rendererFormatSupport =
|
||||
bundle.getInt(FIELD_RENDERER_FORMAT_SUPPORT, /* defaultValue= */ C.FORMAT_HANDLED);
|
||||
isRecoverable = bundle.getBoolean(FIELD_IS_RECOVERABLE, /* defaultValue= */ false);
|
||||
@ -403,10 +402,22 @@ public final class ExoPlaybackException extends PlaybackException {
|
||||
|
||||
// Bundleable implementation.
|
||||
|
||||
/** Object that can restore {@link ExoPlaybackException} from a {@link Bundle}. */
|
||||
/**
|
||||
* 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) {
|
||||
return new ExoPlaybackException(bundle);
|
||||
}
|
||||
|
||||
private static final String FIELD_TYPE = Util.intToStringMaxRadix(FIELD_CUSTOM_ID_BASE + 1);
|
||||
private static final String FIELD_RENDERER_NAME =
|
||||
Util.intToStringMaxRadix(FIELD_CUSTOM_ID_BASE + 2);
|
||||
|
@ -123,7 +123,13 @@ public final class TrackGroupArray implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restores a TrackGroupArray from a {@link 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}. */
|
||||
|
@ -2061,9 +2061,19 @@ public class DefaultTrackSelector extends MappingTrackSelector
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@code Parameters} from a {@link Bundle}. */
|
||||
public static final Creator<Parameters> CREATOR =
|
||||
bundle -> new Parameters.Builder(bundle).build();
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bundles selection overrides in 3 arrays of equal length. Each triplet of matching indices is:
|
||||
@ -2238,8 +2248,14 @@ public class DefaultTrackSelector extends MappingTrackSelector
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@code SelectionOverride} from a {@link 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}. */
|
||||
|
@ -33,7 +33,7 @@ public class ExoPlaybackExceptionTest {
|
||||
@Test
|
||||
public void roundTripViaBundle_ofExoPlaybackExceptionTypeRemote_yieldsEqualInstance() {
|
||||
ExoPlaybackException before = ExoPlaybackException.createForRemote(/* message= */ "test");
|
||||
ExoPlaybackException after = ExoPlaybackException.CREATOR.fromBundle(before.toBundle());
|
||||
ExoPlaybackException after = ExoPlaybackException.fromBundle(before.toBundle());
|
||||
assertThat(areExoPlaybackExceptionsEqual(before, after)).isTrue();
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public class ExoPlaybackExceptionTest {
|
||||
/* isRecoverable= */ true,
|
||||
/* errorCode= */ PlaybackException.ERROR_CODE_DECODER_INIT_FAILED);
|
||||
|
||||
ExoPlaybackException after = ExoPlaybackException.CREATOR.fromBundle(before.toBundle());
|
||||
ExoPlaybackException after = ExoPlaybackException.fromBundle(before.toBundle());
|
||||
assertThat(areExoPlaybackExceptionsEqual(before, after)).isTrue();
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class ExoPlaybackExceptionTest {
|
||||
new RuntimeException(
|
||||
/* message= */ "anonymous exception that class loader cannot know") {},
|
||||
PlaybackException.ERROR_CODE_TIMEOUT);
|
||||
ExoPlaybackException after = ExoPlaybackException.CREATOR.fromBundle(before.toBundle());
|
||||
ExoPlaybackException after = ExoPlaybackException.fromBundle(before.toBundle());
|
||||
|
||||
assertThat(after.getCause()).isInstanceOf(RemoteException.class);
|
||||
assertThat(after.getCause()).hasMessageThat().isEqualTo(before.getCause().getMessage());
|
||||
|
@ -192,7 +192,7 @@ public final class DefaultTrackSelectorTest {
|
||||
public void roundTripViaBundle_ofParameters_yieldsEqualInstance() {
|
||||
Parameters parametersToBundle = buildParametersForEqualsTest();
|
||||
|
||||
Parameters parametersFromBundle = Parameters.CREATOR.fromBundle(parametersToBundle.toBundle());
|
||||
Parameters parametersFromBundle = Parameters.fromBundle(parametersToBundle.toBundle());
|
||||
|
||||
assertThat(parametersFromBundle).isEqualTo(parametersToBundle);
|
||||
}
|
||||
|
@ -400,18 +400,24 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link AdsLoader.State} from a {@link Bundle}. */
|
||||
/**
|
||||
* Object that can restore {@link AdsLoader.State} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Bundleable.Creator<State> CREATOR = State::fromBundle;
|
||||
|
||||
private static State fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code State} from a {@link Bundle}. */
|
||||
public static State fromBundle(Bundle bundle) {
|
||||
@Nullable
|
||||
ImmutableMap.Builder<String, AdPlaybackState> adPlaybackStateMap =
|
||||
new ImmutableMap.Builder<>();
|
||||
Bundle adPlaybackStateBundle = checkNotNull(bundle.getBundle(FIELD_AD_PLAYBACK_STATES));
|
||||
for (String key : adPlaybackStateBundle.keySet()) {
|
||||
AdPlaybackState adPlaybackState =
|
||||
AdPlaybackState.CREATOR.fromBundle(
|
||||
checkNotNull(adPlaybackStateBundle.getBundle(key)));
|
||||
AdPlaybackState.fromBundle(checkNotNull(adPlaybackStateBundle.getBundle(key)));
|
||||
adPlaybackStateMap.put(
|
||||
key, AdPlaybackState.fromAdPlaybackState(/* adsId= */ key, adPlaybackState));
|
||||
}
|
||||
|
@ -68,6 +68,6 @@ public class ImaServerSideAdInsertionMediaSourceTest {
|
||||
.put("adsId3", thirdAdPlaybackState)
|
||||
.buildOrThrow());
|
||||
|
||||
assertThat(State.CREATOR.fromBundle(state.toBundle())).isEqualTo(state);
|
||||
assertThat(State.fromBundle(state.toBundle())).isEqualTo(state);
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +322,15 @@ public final class CommandButton implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@code CommandButton} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<CommandButton> CREATOR = CommandButton::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/** Restores a {@code CommandButton} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
@ -331,9 +338,7 @@ public final class CommandButton implements Bundleable {
|
||||
@Nullable Bundle sessionCommandBundle = bundle.getBundle(FIELD_SESSION_COMMAND);
|
||||
@Nullable
|
||||
SessionCommand sessionCommand =
|
||||
sessionCommandBundle == null
|
||||
? null
|
||||
: SessionCommand.CREATOR.fromBundle(sessionCommandBundle);
|
||||
sessionCommandBundle == null ? null : SessionCommand.fromBundle(sessionCommandBundle);
|
||||
@Player.Command
|
||||
int playerCommand =
|
||||
bundle.getInt(FIELD_PLAYER_COMMAND, /* defaultValue= */ Player.COMMAND_INVALID);
|
||||
|
@ -83,21 +83,30 @@ import androidx.media3.common.util.Util;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link ConnectionRequest} from a {@link Bundle}. */
|
||||
public static final Creator<ConnectionRequest> CREATOR =
|
||||
bundle -> {
|
||||
int libraryVersion = bundle.getInt(FIELD_LIBRARY_VERSION, /* defaultValue= */ 0);
|
||||
int controllerInterfaceVersion =
|
||||
bundle.getInt(FIELD_CONTROLLER_INTERFACE_VERSION, /* defaultValue= */ 0);
|
||||
String packageName = checkNotNull(bundle.getString(FIELD_PACKAGE_NAME));
|
||||
checkArgument(bundle.containsKey(FIELD_PID));
|
||||
int pid = bundle.getInt(FIELD_PID);
|
||||
@Nullable Bundle connectionHints = bundle.getBundle(FIELD_CONNECTION_HINTS);
|
||||
return new ConnectionRequest(
|
||||
libraryVersion,
|
||||
controllerInterfaceVersion,
|
||||
packageName,
|
||||
pid,
|
||||
connectionHints == null ? Bundle.EMPTY : connectionHints);
|
||||
};
|
||||
/**
|
||||
* 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);
|
||||
int controllerInterfaceVersion =
|
||||
bundle.getInt(FIELD_CONTROLLER_INTERFACE_VERSION, /* defaultValue= */ 0);
|
||||
String packageName = checkNotNull(bundle.getString(FIELD_PACKAGE_NAME));
|
||||
checkArgument(bundle.containsKey(FIELD_PID));
|
||||
int pid = bundle.getInt(FIELD_PID);
|
||||
@Nullable Bundle connectionHints = bundle.getBundle(FIELD_CONNECTION_HINTS);
|
||||
return new ConnectionRequest(
|
||||
libraryVersion,
|
||||
controllerInterfaceVersion,
|
||||
packageName,
|
||||
pid,
|
||||
connectionHints == null ? Bundle.EMPTY : connectionHints);
|
||||
}
|
||||
;
|
||||
}
|
||||
|
@ -137,10 +137,15 @@ import java.util.List;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@link ConnectionState} from a {@link Bundle}. */
|
||||
/**
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<ConnectionState> CREATOR = ConnectionState::fromBundle;
|
||||
|
||||
private static ConnectionState fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code ConnectionState} from a {@link Bundle}. */
|
||||
public static ConnectionState fromBundle(Bundle bundle) {
|
||||
@Nullable IBinder inProcessBinder = BundleUtil.getBinder(bundle, FIELD_IN_PROCESS_BINDER);
|
||||
if (inProcessBinder instanceof InProcessBinder) {
|
||||
return ((InProcessBinder) inProcessBinder).getConnectionState();
|
||||
@ -160,25 +165,23 @@ import java.util.List;
|
||||
SessionCommands sessionCommands =
|
||||
sessionCommandsBundle == null
|
||||
? SessionCommands.EMPTY
|
||||
: SessionCommands.CREATOR.fromBundle(sessionCommandsBundle);
|
||||
: SessionCommands.fromBundle(sessionCommandsBundle);
|
||||
@Nullable
|
||||
Bundle playerCommandsFromPlayerBundle = bundle.getBundle(FIELD_PLAYER_COMMANDS_FROM_PLAYER);
|
||||
Player.Commands playerCommandsFromPlayer =
|
||||
playerCommandsFromPlayerBundle == null
|
||||
? Player.Commands.EMPTY
|
||||
: Player.Commands.CREATOR.fromBundle(playerCommandsFromPlayerBundle);
|
||||
: Player.Commands.fromBundle(playerCommandsFromPlayerBundle);
|
||||
@Nullable
|
||||
Bundle playerCommandsFromSessionBundle = bundle.getBundle(FIELD_PLAYER_COMMANDS_FROM_SESSION);
|
||||
Player.Commands playerCommandsFromSession =
|
||||
playerCommandsFromSessionBundle == null
|
||||
? Player.Commands.EMPTY
|
||||
: Player.Commands.CREATOR.fromBundle(playerCommandsFromSessionBundle);
|
||||
: Player.Commands.fromBundle(playerCommandsFromSessionBundle);
|
||||
@Nullable Bundle tokenExtras = bundle.getBundle(FIELD_TOKEN_EXTRAS);
|
||||
@Nullable Bundle playerInfoBundle = bundle.getBundle(FIELD_PLAYER_INFO);
|
||||
PlayerInfo playerInfo =
|
||||
playerInfoBundle == null
|
||||
? PlayerInfo.DEFAULT
|
||||
: PlayerInfo.CREATOR.fromBundle(playerInfoBundle);
|
||||
playerInfoBundle == null ? PlayerInfo.DEFAULT : PlayerInfo.fromBundle(playerInfoBundle);
|
||||
return new ConnectionState(
|
||||
libraryVersion,
|
||||
sessionInterfaceVersion,
|
||||
|
@ -304,48 +304,76 @@ public final class LibraryResult<V> implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@code LibraryResult<Void>} from a {@link 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}. */
|
||||
/**
|
||||
* 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
|
||||
@SuppressWarnings("unchecked")
|
||||
private static LibraryResult<Void> fromVoidBundle(Bundle bundle) {
|
||||
public static LibraryResult<Void> fromVoidBundle(Bundle bundle) {
|
||||
return (LibraryResult<Void>) fromUnknownBundle(bundle);
|
||||
}
|
||||
|
||||
/** Restores a {@code LibraryResult<MediaItem>} from a {@link Bundle}. */
|
||||
// fromBundle will throw if the bundle doesn't have the right value type.
|
||||
@UnstableApi
|
||||
@SuppressWarnings("unchecked")
|
||||
private static LibraryResult<MediaItem> fromItemBundle(Bundle bundle) {
|
||||
public static LibraryResult<MediaItem> fromItemBundle(Bundle bundle) {
|
||||
return (LibraryResult<MediaItem>) fromBundle(bundle, VALUE_TYPE_ITEM);
|
||||
}
|
||||
|
||||
/** Restores a {@code LibraryResult<ImmutableList<MediaItem>} from a {@link Bundle}. */
|
||||
// fromBundle will throw if the bundle doesn't have the right value type.
|
||||
@UnstableApi
|
||||
@SuppressWarnings("unchecked")
|
||||
private static LibraryResult<ImmutableList<MediaItem>> fromItemListBundle(Bundle bundle) {
|
||||
public static LibraryResult<ImmutableList<MediaItem>> fromItemListBundle(Bundle bundle) {
|
||||
return (LibraryResult<ImmutableList<MediaItem>>) fromBundle(bundle, VALUE_TYPE_ITEM_LIST);
|
||||
}
|
||||
|
||||
private static LibraryResult<?> fromUnknownBundle(Bundle bundle) {
|
||||
/** Restores a {@code LibraryResult} with unknown value type from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static LibraryResult<?> fromUnknownBundle(Bundle bundle) {
|
||||
return fromBundle(bundle, /* expectedType= */ null);
|
||||
}
|
||||
|
||||
@ -363,14 +391,14 @@ public final class LibraryResult<V> implements Bundleable {
|
||||
@Nullable Bundle paramsBundle = bundle.getBundle(FIELD_PARAMS);
|
||||
@Nullable
|
||||
MediaLibraryService.LibraryParams params =
|
||||
paramsBundle == null ? null : LibraryParams.CREATOR.fromBundle(paramsBundle);
|
||||
paramsBundle == null ? null : LibraryParams.fromBundle(paramsBundle);
|
||||
@ValueType int valueType = bundle.getInt(FIELD_VALUE_TYPE);
|
||||
@Nullable Object value;
|
||||
switch (valueType) {
|
||||
case VALUE_TYPE_ITEM:
|
||||
checkState(expectedType == null || expectedType == VALUE_TYPE_ITEM);
|
||||
@Nullable Bundle valueBundle = bundle.getBundle(FIELD_VALUE);
|
||||
value = valueBundle == null ? null : MediaItem.CREATOR.fromBundle(valueBundle);
|
||||
value = valueBundle == null ? null : MediaItem.fromBundle(valueBundle);
|
||||
break;
|
||||
case VALUE_TYPE_ITEM_LIST:
|
||||
checkState(expectedType == null || expectedType == VALUE_TYPE_ITEM_LIST);
|
||||
|
@ -50,7 +50,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public void onSessionResult(int sequenceNum, Bundle sessionResultBundle) {
|
||||
SessionResult result;
|
||||
try {
|
||||
result = SessionResult.CREATOR.fromBundle(sessionResultBundle);
|
||||
result = SessionResult.fromBundle(sessionResultBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for SessionResult", e);
|
||||
return;
|
||||
@ -65,7 +65,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public void onLibraryResult(int sequenceNum, Bundle libraryResultBundle) {
|
||||
LibraryResult<?> result;
|
||||
try {
|
||||
result = LibraryResult.UNKNOWN_TYPE_CREATOR.fromBundle(libraryResultBundle);
|
||||
result = LibraryResult.fromUnknownBundle(libraryResultBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for LibraryResult", e);
|
||||
return;
|
||||
@ -80,7 +80,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public void onConnected(int seq, Bundle connectionResultBundle) {
|
||||
ConnectionState connectionState;
|
||||
try {
|
||||
connectionState = ConnectionState.CREATOR.fromBundle(connectionResultBundle);
|
||||
connectionState = ConnectionState.fromBundle(connectionResultBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Malformed Bundle for ConnectionResult. Disconnected from the session.", e);
|
||||
onDisconnected(seq);
|
||||
@ -114,14 +114,14 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
int seq, Bundle sessionCommandsBundle, Bundle playerCommandsBundle) {
|
||||
SessionCommands sessionCommands;
|
||||
try {
|
||||
sessionCommands = SessionCommands.CREATOR.fromBundle(sessionCommandsBundle);
|
||||
sessionCommands = SessionCommands.fromBundle(sessionCommandsBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for SessionCommands", e);
|
||||
return;
|
||||
}
|
||||
Commands playerCommands;
|
||||
try {
|
||||
playerCommands = Commands.CREATOR.fromBundle(playerCommandsBundle);
|
||||
playerCommands = Commands.fromBundle(playerCommandsBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for Commands", e);
|
||||
return;
|
||||
@ -135,7 +135,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public void onAvailableCommandsChangedFromPlayer(int seq, Bundle commandsBundle) {
|
||||
Commands commandsFromPlayer;
|
||||
try {
|
||||
commandsFromPlayer = Commands.CREATOR.fromBundle(commandsBundle);
|
||||
commandsFromPlayer = Commands.fromBundle(commandsBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for Commands", e);
|
||||
return;
|
||||
@ -152,7 +152,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
}
|
||||
SessionCommand command;
|
||||
try {
|
||||
command = SessionCommand.CREATOR.fromBundle(commandBundle);
|
||||
command = SessionCommand.fromBundle(commandBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for SessionCommand", e);
|
||||
return;
|
||||
@ -171,7 +171,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public void onPeriodicSessionPositionInfoChanged(int seq, Bundle sessionPositionInfoBundle) {
|
||||
SessionPositionInfo sessionPositionInfo;
|
||||
try {
|
||||
sessionPositionInfo = SessionPositionInfo.CREATOR.fromBundle(sessionPositionInfoBundle);
|
||||
sessionPositionInfo = SessionPositionInfo.fromBundle(sessionPositionInfoBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for SessionPositionInfo", e);
|
||||
return;
|
||||
@ -199,14 +199,14 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
int seq, Bundle playerInfoBundle, Bundle playerInfoExclusions) {
|
||||
PlayerInfo playerInfo;
|
||||
try {
|
||||
playerInfo = PlayerInfo.CREATOR.fromBundle(playerInfoBundle);
|
||||
playerInfo = PlayerInfo.fromBundle(playerInfoBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for PlayerInfo", e);
|
||||
return;
|
||||
}
|
||||
BundlingExclusions bundlingExclusions;
|
||||
try {
|
||||
bundlingExclusions = BundlingExclusions.CREATOR.fromBundle(playerInfoExclusions);
|
||||
bundlingExclusions = BundlingExclusions.fromBundle(playerInfoExclusions);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for BundlingExclusions", e);
|
||||
return;
|
||||
@ -246,9 +246,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
browser.notifySearchResultChanged(
|
||||
query,
|
||||
itemCount,
|
||||
libraryParams == null
|
||||
? null
|
||||
: LibraryParams.CREATOR.fromBundle(libraryParams)));
|
||||
libraryParams == null ? null : LibraryParams.fromBundle(libraryParams)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -268,9 +266,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
browser.notifyChildrenChanged(
|
||||
parentId,
|
||||
itemCount,
|
||||
libraryParams == null
|
||||
? null
|
||||
: LibraryParams.CREATOR.fromBundle(libraryParams)));
|
||||
libraryParams == null ? null : LibraryParams.fromBundle(libraryParams)));
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
@ -813,10 +813,19 @@ public abstract class MediaLibraryService extends MediaSessionService {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link LibraryParams} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<LibraryParams> CREATOR = LibraryParams::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static LibraryParams fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code LibraryParams} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static LibraryParams fromBundle(Bundle bundle) {
|
||||
@Nullable Bundle extras = bundle.getBundle(FIELD_EXTRAS);
|
||||
boolean recent = bundle.getBoolean(FIELD_RECENT, /* defaultValue= */ false);
|
||||
boolean offline = bundle.getBoolean(FIELD_OFFLINE, /* defaultValue= */ false);
|
||||
|
@ -664,7 +664,7 @@ public abstract class MediaSessionService extends Service {
|
||||
}
|
||||
ConnectionRequest request;
|
||||
try {
|
||||
request = ConnectionRequest.CREATOR.fromBundle(connectionRequestBundle);
|
||||
request = ConnectionRequest.fromBundle(connectionRequestBundle);
|
||||
} catch (RuntimeException e) {
|
||||
// Malformed call from potentially malicious controller.
|
||||
// No need to notify that we're ignoring call.
|
||||
|
@ -600,7 +600,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
ConnectionRequest request;
|
||||
try {
|
||||
request = ConnectionRequest.CREATOR.fromBundle(connectionRequestBundle);
|
||||
request = ConnectionRequest.fromBundle(connectionRequestBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for ConnectionRequest", e);
|
||||
return;
|
||||
@ -677,7 +677,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
SessionResult result;
|
||||
try {
|
||||
result = SessionResult.CREATOR.fromBundle(sessionResultBundle);
|
||||
result = SessionResult.fromBundle(sessionResultBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for SessionResult", e);
|
||||
return;
|
||||
@ -859,7 +859,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
SessionCommand command;
|
||||
try {
|
||||
command = SessionCommand.CREATOR.fromBundle(commandBundle);
|
||||
command = SessionCommand.fromBundle(commandBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for SessionCommand", e);
|
||||
return;
|
||||
@ -888,7 +888,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
Rating rating;
|
||||
try {
|
||||
rating = Rating.CREATOR.fromBundle(ratingBundle);
|
||||
rating = Rating.fromBundle(ratingBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for Rating", e);
|
||||
return;
|
||||
@ -910,7 +910,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
Rating rating;
|
||||
try {
|
||||
rating = Rating.CREATOR.fromBundle(ratingBundle);
|
||||
rating = Rating.fromBundle(ratingBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for Rating", e);
|
||||
return;
|
||||
@ -942,8 +942,7 @@ import java.util.concurrent.ExecutionException;
|
||||
if (caller == null || playbackParametersBundle == null) {
|
||||
return;
|
||||
}
|
||||
PlaybackParameters playbackParameters =
|
||||
PlaybackParameters.CREATOR.fromBundle(playbackParametersBundle);
|
||||
PlaybackParameters playbackParameters = PlaybackParameters.fromBundle(playbackParametersBundle);
|
||||
queueSessionTaskWithPlayerCommand(
|
||||
caller,
|
||||
sequenceNumber,
|
||||
@ -969,7 +968,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
MediaItem mediaItem;
|
||||
try {
|
||||
mediaItem = MediaItem.CREATOR.fromBundle(mediaItemBundle);
|
||||
mediaItem = MediaItem.fromBundle(mediaItemBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for MediaItem", e);
|
||||
return;
|
||||
@ -1000,7 +999,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
MediaItem mediaItem;
|
||||
try {
|
||||
mediaItem = MediaItem.CREATOR.fromBundle(mediaItemBundle);
|
||||
mediaItem = MediaItem.fromBundle(mediaItemBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for MediaItem", e);
|
||||
return;
|
||||
@ -1118,7 +1117,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
MediaMetadata playlistMetadata;
|
||||
try {
|
||||
playlistMetadata = MediaMetadata.CREATOR.fromBundle(playlistMetadataBundle);
|
||||
playlistMetadata = MediaMetadata.fromBundle(playlistMetadataBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for MediaMetadata", e);
|
||||
return;
|
||||
@ -1138,7 +1137,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
MediaItem mediaItem;
|
||||
try {
|
||||
mediaItem = MediaItem.CREATOR.fromBundle(mediaItemBundle);
|
||||
mediaItem = MediaItem.fromBundle(mediaItemBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for MediaItem", e);
|
||||
return;
|
||||
@ -1163,7 +1162,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
MediaItem mediaItem;
|
||||
try {
|
||||
mediaItem = MediaItem.CREATOR.fromBundle(mediaItemBundle);
|
||||
mediaItem = MediaItem.fromBundle(mediaItemBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for MediaItem", e);
|
||||
return;
|
||||
@ -1321,7 +1320,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
MediaItem mediaItem;
|
||||
try {
|
||||
mediaItem = MediaItem.CREATOR.fromBundle(mediaItemBundle);
|
||||
mediaItem = MediaItem.fromBundle(mediaItemBundle);
|
||||
} catch (RuntimeException e) {
|
||||
Log.w(TAG, "Ignoring malformed Bundle for MediaItem", e);
|
||||
return;
|
||||
@ -1616,7 +1615,7 @@ import java.util.concurrent.ExecutionException;
|
||||
sendSessionResultSuccess(
|
||||
player ->
|
||||
player.setAudioAttributes(
|
||||
AudioAttributes.CREATOR.fromBundle(audioAttributes), handleAudioFocus)));
|
||||
AudioAttributes.fromBundle(audioAttributes), handleAudioFocus)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1694,7 +1693,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
@Nullable
|
||||
LibraryParams libraryParams =
|
||||
libraryParamsBundle == null ? null : LibraryParams.CREATOR.fromBundle(libraryParamsBundle);
|
||||
libraryParamsBundle == null ? null : LibraryParams.fromBundle(libraryParamsBundle);
|
||||
dispatchSessionTaskWithSessionCommand(
|
||||
caller,
|
||||
sequenceNumber,
|
||||
@ -1750,7 +1749,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
@Nullable
|
||||
LibraryParams libraryParams =
|
||||
libraryParamsBundle == null ? null : LibraryParams.CREATOR.fromBundle(libraryParamsBundle);
|
||||
libraryParamsBundle == null ? null : LibraryParams.fromBundle(libraryParamsBundle);
|
||||
dispatchSessionTaskWithSessionCommand(
|
||||
caller,
|
||||
sequenceNumber,
|
||||
@ -1776,7 +1775,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
@Nullable
|
||||
LibraryParams libraryParams =
|
||||
libraryParamsBundle == null ? null : LibraryParams.CREATOR.fromBundle(libraryParamsBundle);
|
||||
libraryParamsBundle == null ? null : LibraryParams.fromBundle(libraryParamsBundle);
|
||||
dispatchSessionTaskWithSessionCommand(
|
||||
caller,
|
||||
sequenceNumber,
|
||||
@ -1811,7 +1810,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
@Nullable
|
||||
LibraryParams libraryParams =
|
||||
libraryParamsBundle == null ? null : LibraryParams.CREATOR.fromBundle(libraryParamsBundle);
|
||||
libraryParamsBundle == null ? null : LibraryParams.fromBundle(libraryParamsBundle);
|
||||
dispatchSessionTaskWithSessionCommand(
|
||||
caller,
|
||||
sequenceNumber,
|
||||
@ -1837,7 +1836,7 @@ import java.util.concurrent.ExecutionException;
|
||||
}
|
||||
@Nullable
|
||||
LibraryParams libraryParams =
|
||||
libraryParamsBundle == null ? null : LibraryParams.CREATOR.fromBundle(libraryParamsBundle);
|
||||
libraryParamsBundle == null ? null : LibraryParams.fromBundle(libraryParamsBundle);
|
||||
dispatchSessionTaskWithSessionCommand(
|
||||
caller,
|
||||
sequenceNumber,
|
||||
|
@ -98,9 +98,7 @@ public class MediaStyleNotificationHelper {
|
||||
return null;
|
||||
}
|
||||
Bundle sessionTokenBundle = extras.getBundle(EXTRA_MEDIA3_SESSION);
|
||||
return sessionTokenBundle == null
|
||||
? null
|
||||
: SessionToken.CREATOR.fromBundle(sessionTokenBundle);
|
||||
return sessionTokenBundle == null ? null : SessionToken.fromBundle(sessionTokenBundle);
|
||||
}
|
||||
|
||||
private static final int MAX_MEDIA_BUTTONS_IN_COMPACT = 3;
|
||||
|
@ -98,11 +98,19 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
public static final Creator<BundlingExclusions> CREATOR =
|
||||
bundle ->
|
||||
new BundlingExclusions(
|
||||
bundle.getBoolean(FIELD_IS_TIMELINE_EXCLUDED, /* defaultValue= */ false),
|
||||
bundle.getBoolean(FIELD_ARE_CURRENT_TRACKS_EXCLUDED, /* defaultValue= */ false));
|
||||
/**
|
||||
* @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(
|
||||
bundle.getBoolean(FIELD_IS_TIMELINE_EXCLUDED, /* defaultValue= */ false),
|
||||
bundle.getBoolean(FIELD_ARE_CURRENT_TRACKS_EXCLUDED, /* defaultValue= */ false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object o) {
|
||||
@ -1006,10 +1014,17 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link PlayerInfo} from a {@link 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;
|
||||
|
||||
private static PlayerInfo fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code PlayerInfo} from a {@link Bundle}. */
|
||||
public static PlayerInfo fromBundle(Bundle bundle) {
|
||||
@Nullable IBinder inProcessBinder = BundleUtil.getBinder(bundle, FIELD_IN_PROCESS_BINDER);
|
||||
if (inProcessBinder instanceof InProcessBinder) {
|
||||
return ((InProcessBinder) inProcessBinder).getPlayerInfo();
|
||||
@ -1017,65 +1032,61 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
@Nullable Bundle playerErrorBundle = bundle.getBundle(FIELD_PLAYBACK_ERROR);
|
||||
@Nullable
|
||||
PlaybackException playerError =
|
||||
playerErrorBundle == null ? null : PlaybackException.CREATOR.fromBundle(playerErrorBundle);
|
||||
playerErrorBundle == null ? null : PlaybackException.fromBundle(playerErrorBundle);
|
||||
int mediaItemTransitionReason =
|
||||
bundle.getInt(FIELD_MEDIA_ITEM_TRANSITION_REASON, MEDIA_ITEM_TRANSITION_REASON_DEFAULT);
|
||||
@Nullable Bundle sessionPositionInfoBundle = bundle.getBundle(FIELD_SESSION_POSITION_INFO);
|
||||
SessionPositionInfo sessionPositionInfo =
|
||||
sessionPositionInfoBundle == null
|
||||
? SessionPositionInfo.DEFAULT
|
||||
: SessionPositionInfo.CREATOR.fromBundle(sessionPositionInfoBundle);
|
||||
: SessionPositionInfo.fromBundle(sessionPositionInfoBundle);
|
||||
@Nullable Bundle oldPositionInfoBundle = bundle.getBundle(FIELD_OLD_POSITION_INFO);
|
||||
PositionInfo oldPositionInfo =
|
||||
oldPositionInfoBundle == null
|
||||
? SessionPositionInfo.DEFAULT_POSITION_INFO
|
||||
: PositionInfo.CREATOR.fromBundle(oldPositionInfoBundle);
|
||||
: PositionInfo.fromBundle(oldPositionInfoBundle);
|
||||
@Nullable Bundle newPositionInfoBundle = bundle.getBundle(FIELD_NEW_POSITION_INFO);
|
||||
PositionInfo newPositionInfo =
|
||||
newPositionInfoBundle == null
|
||||
? SessionPositionInfo.DEFAULT_POSITION_INFO
|
||||
: PositionInfo.CREATOR.fromBundle(newPositionInfoBundle);
|
||||
: PositionInfo.fromBundle(newPositionInfoBundle);
|
||||
int discontinuityReason =
|
||||
bundle.getInt(FIELD_DISCONTINUITY_REASON, DISCONTINUITY_REASON_DEFAULT);
|
||||
@Nullable Bundle playbackParametersBundle = bundle.getBundle(FIELD_PLAYBACK_PARAMETERS);
|
||||
PlaybackParameters playbackParameters =
|
||||
playbackParametersBundle == null
|
||||
? PlaybackParameters.DEFAULT
|
||||
: PlaybackParameters.CREATOR.fromBundle(playbackParametersBundle);
|
||||
: PlaybackParameters.fromBundle(playbackParametersBundle);
|
||||
@Player.RepeatMode
|
||||
int repeatMode = bundle.getInt(FIELD_REPEAT_MODE, /* defaultValue= */ Player.REPEAT_MODE_OFF);
|
||||
boolean shuffleModeEnabled =
|
||||
bundle.getBoolean(FIELD_SHUFFLE_MODE_ENABLED, /* defaultValue= */ false);
|
||||
@Nullable Bundle timelineBundle = bundle.getBundle(FIELD_TIMELINE);
|
||||
Timeline timeline =
|
||||
timelineBundle == null ? Timeline.EMPTY : Timeline.CREATOR.fromBundle(timelineBundle);
|
||||
timelineBundle == null ? Timeline.EMPTY : Timeline.fromBundle(timelineBundle);
|
||||
int timelineChangeReason =
|
||||
bundle.getInt(
|
||||
FIELD_TIMELINE_CHANGE_REASON, /* defaultValue= */ TIMELINE_CHANGE_REASON_DEFAULT);
|
||||
@Nullable Bundle videoSizeBundle = bundle.getBundle(FIELD_VIDEO_SIZE);
|
||||
VideoSize videoSize =
|
||||
videoSizeBundle == null ? VideoSize.UNKNOWN : VideoSize.CREATOR.fromBundle(videoSizeBundle);
|
||||
videoSizeBundle == null ? VideoSize.UNKNOWN : VideoSize.fromBundle(videoSizeBundle);
|
||||
@Nullable Bundle playlistMetadataBundle = bundle.getBundle(FIELD_PLAYLIST_METADATA);
|
||||
MediaMetadata playlistMetadata =
|
||||
playlistMetadataBundle == null
|
||||
? MediaMetadata.EMPTY
|
||||
: MediaMetadata.CREATOR.fromBundle(playlistMetadataBundle);
|
||||
: MediaMetadata.fromBundle(playlistMetadataBundle);
|
||||
float volume = bundle.getFloat(FIELD_VOLUME, /* defaultValue= */ 1);
|
||||
@Nullable Bundle audioAttributesBundle = bundle.getBundle(FIELD_AUDIO_ATTRIBUTES);
|
||||
AudioAttributes audioAttributes =
|
||||
audioAttributesBundle == null
|
||||
? AudioAttributes.DEFAULT
|
||||
: AudioAttributes.CREATOR.fromBundle(audioAttributesBundle);
|
||||
: AudioAttributes.fromBundle(audioAttributesBundle);
|
||||
@Nullable Bundle cueGroupBundle = bundle.getBundle(FIELD_CUE_GROUP);
|
||||
CueGroup cueGroup =
|
||||
cueGroupBundle == null
|
||||
? CueGroup.EMPTY_TIME_ZERO
|
||||
: CueGroup.CREATOR.fromBundle(cueGroupBundle);
|
||||
cueGroupBundle == null ? CueGroup.EMPTY_TIME_ZERO : CueGroup.fromBundle(cueGroupBundle);
|
||||
@Nullable Bundle deviceInfoBundle = bundle.getBundle(FIELD_DEVICE_INFO);
|
||||
DeviceInfo deviceInfo =
|
||||
deviceInfoBundle == null
|
||||
? DeviceInfo.UNKNOWN
|
||||
: DeviceInfo.CREATOR.fromBundle(deviceInfoBundle);
|
||||
deviceInfoBundle == null ? DeviceInfo.UNKNOWN : DeviceInfo.fromBundle(deviceInfoBundle);
|
||||
int deviceVolume = bundle.getInt(FIELD_DEVICE_VOLUME, /* defaultValue= */ 0);
|
||||
boolean deviceMuted = bundle.getBoolean(FIELD_DEVICE_MUTED, /* defaultValue= */ false);
|
||||
boolean playWhenReady = bundle.getBoolean(FIELD_PLAY_WHEN_READY, /* defaultValue= */ false);
|
||||
@ -1096,7 +1107,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
MediaMetadata mediaMetadata =
|
||||
mediaMetadataBundle == null
|
||||
? MediaMetadata.EMPTY
|
||||
: MediaMetadata.CREATOR.fromBundle(mediaMetadataBundle);
|
||||
: MediaMetadata.fromBundle(mediaMetadataBundle);
|
||||
long seekBackIncrementMs = bundle.getLong(FIELD_SEEK_BACK_INCREMENT_MS, /* defaultValue= */ 0);
|
||||
long seekForwardIncrementMs =
|
||||
bundle.getLong(FIELD_SEEK_FORWARD_INCREMENT_MS, /* defaultValue= */ 0);
|
||||
@ -1104,7 +1115,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
bundle.getLong(FIELD_MAX_SEEK_TO_PREVIOUS_POSITION_MS, /* defaultValue= */ 0);
|
||||
Bundle currentTracksBundle = bundle.getBundle(FIELD_CURRENT_TRACKS);
|
||||
Tracks currentTracks =
|
||||
currentTracksBundle == null ? Tracks.EMPTY : Tracks.CREATOR.fromBundle(currentTracksBundle);
|
||||
currentTracksBundle == null ? Tracks.EMPTY : Tracks.fromBundle(currentTracksBundle);
|
||||
@Nullable
|
||||
Bundle trackSelectionParametersBundle = bundle.getBundle(FIELD_TRACK_SELECTION_PARAMETERS);
|
||||
TrackSelectionParameters trackSelectionParameters =
|
||||
|
@ -187,19 +187,27 @@ public final class SessionCommand implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@link SessionCommand} from a {@link Bundle}. */
|
||||
/**
|
||||
* Object that can restore a {@link SessionCommand} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<SessionCommand> CREATOR =
|
||||
bundle -> {
|
||||
int commandCode =
|
||||
bundle.getInt(FIELD_COMMAND_CODE, /* defaultValue= */ COMMAND_CODE_CUSTOM);
|
||||
if (commandCode != COMMAND_CODE_CUSTOM) {
|
||||
return new SessionCommand(commandCode);
|
||||
} else {
|
||||
String customAction = checkNotNull(bundle.getString(FIELD_CUSTOM_ACTION));
|
||||
@Nullable Bundle customExtras = bundle.getBundle(FIELD_CUSTOM_EXTRAS);
|
||||
return new SessionCommand(
|
||||
customAction, customExtras == null ? Bundle.EMPTY : customExtras);
|
||||
}
|
||||
};
|
||||
@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) {
|
||||
int commandCode = bundle.getInt(FIELD_COMMAND_CODE, /* defaultValue= */ COMMAND_CODE_CUSTOM);
|
||||
if (commandCode != COMMAND_CODE_CUSTOM) {
|
||||
return new SessionCommand(commandCode);
|
||||
} else {
|
||||
String customAction = checkNotNull(bundle.getString(FIELD_CUSTOM_ACTION));
|
||||
@Nullable Bundle customExtras = bundle.getBundle(FIELD_CUSTOM_EXTRAS);
|
||||
return new SessionCommand(customAction, customExtras == null ? Bundle.EMPTY : customExtras);
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
|
@ -256,22 +256,32 @@ public final class SessionCommands implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link SessionCommands} from a {@link Bundle}. */
|
||||
/**
|
||||
* Object that can restore {@link SessionCommands} from a {@link Bundle}.
|
||||
*
|
||||
* @deprecated Use {@link #fromBundle} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static final Creator<SessionCommands> CREATOR =
|
||||
bundle -> {
|
||||
@Nullable
|
||||
ArrayList<Bundle> sessionCommandBundleList =
|
||||
bundle.getParcelableArrayList(FIELD_SESSION_COMMANDS);
|
||||
if (sessionCommandBundleList == null) {
|
||||
Log.w(TAG, "Missing commands. Creating an empty SessionCommands");
|
||||
return SessionCommands.EMPTY;
|
||||
}
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation") // Deprecated instance of deprecated class
|
||||
public static final Creator<SessionCommands> CREATOR = SessionCommands::fromBundle;
|
||||
|
||||
Builder builder = new Builder();
|
||||
for (int i = 0; i < sessionCommandBundleList.size(); i++) {
|
||||
builder.add(SessionCommand.CREATOR.fromBundle(sessionCommandBundleList.get(i)));
|
||||
}
|
||||
return builder.build();
|
||||
};
|
||||
/** Restores a {@code SessionCommands} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static SessionCommands fromBundle(Bundle bundle) {
|
||||
@Nullable
|
||||
ArrayList<Bundle> sessionCommandBundleList =
|
||||
bundle.getParcelableArrayList(FIELD_SESSION_COMMANDS);
|
||||
if (sessionCommandBundleList == null) {
|
||||
Log.w(TAG, "Missing commands. Creating an empty SessionCommands");
|
||||
return SessionCommands.EMPTY;
|
||||
}
|
||||
|
||||
Builder builder = new Builder();
|
||||
for (int i = 0; i < sessionCommandBundleList.size(); i++) {
|
||||
builder.add(SessionCommand.fromBundle(sessionCommandBundleList.get(i)));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
;
|
||||
}
|
||||
|
@ -242,15 +242,22 @@ import com.google.common.base.Objects;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link SessionPositionInfo} from a {@link 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;
|
||||
|
||||
private static SessionPositionInfo fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code SessionPositionInfo} from a {@link Bundle}. */
|
||||
public static SessionPositionInfo fromBundle(Bundle bundle) {
|
||||
@Nullable Bundle positionInfoBundle = bundle.getBundle(FIELD_POSITION_INFO);
|
||||
PositionInfo positionInfo =
|
||||
positionInfoBundle == null
|
||||
? DEFAULT_POSITION_INFO
|
||||
: PositionInfo.CREATOR.fromBundle(positionInfoBundle);
|
||||
: PositionInfo.fromBundle(positionInfoBundle);
|
||||
boolean isPlayingAd = bundle.getBoolean(FIELD_IS_PLAYING_AD, /* defaultValue= */ false);
|
||||
long eventTimeMs = bundle.getLong(FIELD_EVENT_TIME_MS, /* defaultValue= */ C.TIME_UNSET);
|
||||
long durationMs = bundle.getLong(FIELD_DURATION_MS, /* defaultValue= */ C.TIME_UNSET);
|
||||
|
@ -190,10 +190,19 @@ public final class SessionResult implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore a {@link SessionResult} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<SessionResult> CREATOR = SessionResult::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static SessionResult fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code SessionResult} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static SessionResult fromBundle(Bundle bundle) {
|
||||
int resultCode = bundle.getInt(FIELD_RESULT_CODE, /* defaultValue= */ RESULT_ERROR_UNKNOWN);
|
||||
@Nullable Bundle extras = bundle.getBundle(FIELD_EXTRAS);
|
||||
long completionTimeMs =
|
||||
|
@ -158,9 +158,9 @@ public final class SessionToken implements Bundleable {
|
||||
@SessionTokenImplType int implType = bundle.getInt(FIELD_IMPL_TYPE);
|
||||
Bundle implBundle = checkNotNull(bundle.getBundle(FIELD_IMPL));
|
||||
if (implType == IMPL_TYPE_BASE) {
|
||||
impl = SessionTokenImplBase.CREATOR.fromBundle(implBundle);
|
||||
impl = SessionTokenImplBase.fromBundle(implBundle);
|
||||
} else {
|
||||
impl = SessionTokenImplLegacy.CREATOR.fromBundle(implBundle);
|
||||
impl = SessionTokenImplLegacy.fromBundle(implBundle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ public final class SessionToken implements Bundleable {
|
||||
// Remove timeout callback.
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
try {
|
||||
future.set(SessionToken.CREATOR.fromBundle(resultData));
|
||||
future.set(SessionToken.fromBundle(resultData));
|
||||
} catch (RuntimeException e) {
|
||||
// Fallback to a legacy token if we receive an unexpected result, e.g. a legacy
|
||||
// session acknowledging commands by a success callback.
|
||||
@ -508,10 +508,19 @@ public final class SessionToken implements Bundleable {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link SessionToken} from a {@link Bundle}. */
|
||||
@UnstableApi public static final Creator<SessionToken> CREATOR = SessionToken::fromBundle;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private static SessionToken fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code SessionToken} from a {@link Bundle}. */
|
||||
@UnstableApi
|
||||
public static SessionToken fromBundle(Bundle bundle) {
|
||||
return new SessionToken(bundle);
|
||||
}
|
||||
}
|
||||
|
@ -232,10 +232,17 @@ import com.google.common.base.Objects;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link SessionTokenImplBase} from a {@link 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;
|
||||
|
||||
private static SessionTokenImplBase fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code SessionTokenImplBase} from a {@link Bundle}. */
|
||||
public static SessionTokenImplBase fromBundle(Bundle bundle) {
|
||||
checkArgument(bundle.containsKey(FIELD_UID), "uid should be set.");
|
||||
int uid = bundle.getInt(FIELD_UID);
|
||||
checkArgument(bundle.containsKey(FIELD_TYPE), "type should be set.");
|
||||
|
@ -189,10 +189,17 @@ import com.google.common.base.Objects;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/** Object that can restore {@link SessionTokenImplLegacy} from a {@link 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;
|
||||
|
||||
private static SessionTokenImplLegacy fromBundle(Bundle bundle) {
|
||||
/** Restores a {@code SessionTokenImplLegacy} from a {@link Bundle}. */
|
||||
public static SessionTokenImplLegacy fromBundle(Bundle bundle) {
|
||||
@Nullable Bundle legacyTokenBundle = bundle.getBundle(FIELD_LEGACY_TOKEN);
|
||||
@Nullable
|
||||
MediaSessionCompat.Token legacyToken =
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package androidx.media3.session;
|
||||
|
||||
import static androidx.media3.session.CommandButton.CREATOR;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
@ -168,7 +167,7 @@ public class CommandButtonTest {
|
||||
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
|
||||
.build();
|
||||
|
||||
assertThat(button).isEqualTo(CREATOR.fromBundle(button.toBundle()));
|
||||
assertThat(button).isEqualTo(CommandButton.fromBundle(button.toBundle()));
|
||||
assertThat(button)
|
||||
.isNotEqualTo(
|
||||
new CommandButton.Builder()
|
||||
|
@ -16,7 +16,6 @@
|
||||
package androidx.media3.session;
|
||||
|
||||
import static androidx.media3.session.LibraryResult.RESULT_ERROR_NOT_SUPPORTED;
|
||||
import static androidx.media3.session.LibraryResult.UNKNOWN_TYPE_CREATOR;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
@ -70,11 +69,11 @@ public class LibraryResultTest {
|
||||
LibraryResult<MediaItem> libraryResult = LibraryResult.ofItem(mediaItem, params);
|
||||
Bundle libraryResultBundle = libraryResult.toBundle();
|
||||
LibraryResult<?> libraryResultFromUntyped =
|
||||
UNKNOWN_TYPE_CREATOR.fromBundle(libraryResultBundle);
|
||||
LibraryResult.fromUnknownBundle(libraryResultBundle);
|
||||
|
||||
Bundle bundleOfUntyped = libraryResultFromUntyped.toBundle();
|
||||
|
||||
assertThat(UNKNOWN_TYPE_CREATOR.fromBundle(bundleOfUntyped).value).isEqualTo(mediaItem);
|
||||
assertThat(LibraryResult.fromUnknownBundle(bundleOfUntyped).value).isEqualTo(mediaItem);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -90,11 +89,11 @@ public class LibraryResultTest {
|
||||
LibraryResult.ofItemList(ImmutableList.of(mediaItem), params);
|
||||
Bundle libraryResultBundle = libraryResult.toBundle();
|
||||
LibraryResult<?> mediaItemLibraryResultFromUntyped =
|
||||
UNKNOWN_TYPE_CREATOR.fromBundle(libraryResultBundle);
|
||||
LibraryResult.fromUnknownBundle(libraryResultBundle);
|
||||
|
||||
Bundle bundleOfUntyped = mediaItemLibraryResultFromUntyped.toBundle();
|
||||
|
||||
assertThat(UNKNOWN_TYPE_CREATOR.fromBundle(bundleOfUntyped).value)
|
||||
assertThat(LibraryResult.fromUnknownBundle(bundleOfUntyped).value)
|
||||
.isEqualTo(ImmutableList.of(mediaItem));
|
||||
}
|
||||
|
||||
@ -104,12 +103,12 @@ public class LibraryResultTest {
|
||||
LibraryResult.ofError(LibraryResult.RESULT_ERROR_NOT_SUPPORTED);
|
||||
Bundle errorLibraryResultBundle = libraryResult.toBundle();
|
||||
LibraryResult<?> libraryResultFromUntyped =
|
||||
UNKNOWN_TYPE_CREATOR.fromBundle(errorLibraryResultBundle);
|
||||
LibraryResult.fromUnknownBundle(errorLibraryResultBundle);
|
||||
|
||||
Bundle bundleOfUntyped = libraryResultFromUntyped.toBundle();
|
||||
|
||||
assertThat(UNKNOWN_TYPE_CREATOR.fromBundle(bundleOfUntyped).value).isNull();
|
||||
assertThat(UNKNOWN_TYPE_CREATOR.fromBundle(bundleOfUntyped).resultCode)
|
||||
assertThat(LibraryResult.fromUnknownBundle(bundleOfUntyped).value).isNull();
|
||||
assertThat(LibraryResult.fromUnknownBundle(bundleOfUntyped).resultCode)
|
||||
.isEqualTo(RESULT_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
@ -119,12 +118,12 @@ public class LibraryResultTest {
|
||||
LibraryResult.ofError(LibraryResult.RESULT_ERROR_NOT_SUPPORTED);
|
||||
Bundle errorLibraryResultBundle = libraryResult.toBundle();
|
||||
LibraryResult<?> libraryResultFromUntyped =
|
||||
UNKNOWN_TYPE_CREATOR.fromBundle(errorLibraryResultBundle);
|
||||
LibraryResult.fromUnknownBundle(errorLibraryResultBundle);
|
||||
|
||||
Bundle bundleOfUntyped = libraryResultFromUntyped.toBundle();
|
||||
|
||||
assertThat(UNKNOWN_TYPE_CREATOR.fromBundle(bundleOfUntyped).value).isNull();
|
||||
assertThat(UNKNOWN_TYPE_CREATOR.fromBundle(bundleOfUntyped).resultCode)
|
||||
assertThat(LibraryResult.fromUnknownBundle(bundleOfUntyped).value).isNull();
|
||||
assertThat(LibraryResult.fromUnknownBundle(bundleOfUntyped).resultCode)
|
||||
.isEqualTo(RESULT_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class PlayerInfoTest {
|
||||
Bundle bundle = bundlingExclusions.toBundle();
|
||||
|
||||
PlayerInfo.BundlingExclusions resultingBundlingExclusions =
|
||||
PlayerInfo.BundlingExclusions.CREATOR.fromBundle(bundle);
|
||||
PlayerInfo.BundlingExclusions.fromBundle(bundle);
|
||||
|
||||
assertThat(resultingBundlingExclusions).isEqualTo(bundlingExclusions);
|
||||
}
|
||||
@ -163,7 +163,7 @@ public class PlayerInfoTest {
|
||||
.setVideoSize(new VideoSize(/* width= */ 1024, /* height= */ 768))
|
||||
.build();
|
||||
|
||||
PlayerInfo infoAfterBundling = PlayerInfo.CREATOR.fromBundle(playerInfo.toBundle());
|
||||
PlayerInfo infoAfterBundling = PlayerInfo.fromBundle(playerInfo.toBundle());
|
||||
|
||||
assertThat(infoAfterBundling.oldPositionInfo.mediaItemIndex).isEqualTo(5);
|
||||
assertThat(infoAfterBundling.oldPositionInfo.periodIndex).isEqualTo(4);
|
||||
@ -283,7 +283,7 @@ public class PlayerInfoTest {
|
||||
.build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -404,7 +404,7 @@ public class PlayerInfoTest {
|
||||
.build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -473,7 +473,7 @@ public class PlayerInfoTest {
|
||||
.build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -493,7 +493,7 @@ public class PlayerInfoTest {
|
||||
PlayerInfo playerInfo = new PlayerInfo.Builder(PlayerInfo.DEFAULT).setVolume(0.5f).build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -513,7 +513,7 @@ public class PlayerInfoTest {
|
||||
new PlayerInfo.Builder(PlayerInfo.DEFAULT).setDeviceVolume(10).setDeviceMuted(true).build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -537,7 +537,7 @@ public class PlayerInfoTest {
|
||||
.build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -559,7 +559,7 @@ public class PlayerInfoTest {
|
||||
.build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -589,7 +589,7 @@ public class PlayerInfoTest {
|
||||
.build();
|
||||
|
||||
PlayerInfo infoAfterBundling =
|
||||
PlayerInfo.CREATOR.fromBundle(
|
||||
PlayerInfo.fromBundle(
|
||||
playerInfo
|
||||
.filterByAvailableCommands(
|
||||
new Player.Commands.Builder()
|
||||
@ -605,7 +605,7 @@ public class PlayerInfoTest {
|
||||
|
||||
@Test
|
||||
public void toBundleFromBundle_withDefaultValues_restoresAllData() {
|
||||
PlayerInfo roundTripValue = PlayerInfo.CREATOR.fromBundle(PlayerInfo.DEFAULT.toBundle());
|
||||
PlayerInfo roundTripValue = PlayerInfo.fromBundle(PlayerInfo.DEFAULT.toBundle());
|
||||
|
||||
assertThat(roundTripValue.oldPositionInfo).isEqualTo(PlayerInfo.DEFAULT.oldPositionInfo);
|
||||
assertThat(roundTripValue.newPositionInfo).isEqualTo(PlayerInfo.DEFAULT.newPositionInfo);
|
||||
|
@ -55,7 +55,7 @@ public class SessionPositionInfoTest {
|
||||
/* contentBufferedPositionMs= */ 223L);
|
||||
Bundle sessionPositionInfoBundle = testSessionPositionInfo.toBundle();
|
||||
SessionPositionInfo sessionPositionInfo =
|
||||
SessionPositionInfo.CREATOR.fromBundle(sessionPositionInfoBundle);
|
||||
SessionPositionInfo.fromBundle(sessionPositionInfoBundle);
|
||||
assertThat(sessionPositionInfo).isEqualTo(testSessionPositionInfo);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ public class SessionPositionInfoTest {
|
||||
@Test
|
||||
public void roundTripViaBundle_withDefaultValues_yieldsEqualInstance() {
|
||||
SessionPositionInfo roundTripValue =
|
||||
SessionPositionInfo.CREATOR.fromBundle(SessionPositionInfo.DEFAULT.toBundle());
|
||||
SessionPositionInfo.fromBundle(SessionPositionInfo.DEFAULT.toBundle());
|
||||
|
||||
assertThat(roundTripValue).isEqualTo(SessionPositionInfo.DEFAULT);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class MediaControllerProviderService extends Service {
|
||||
Bundle connectionHints,
|
||||
boolean waitForConnection)
|
||||
throws RemoteException {
|
||||
SessionToken token = SessionToken.CREATOR.fromBundle(tokenBundle);
|
||||
SessionToken token = SessionToken.fromBundle(tokenBundle);
|
||||
ListenableFuture<? extends MediaController> controllerFuture =
|
||||
runOnHandler(
|
||||
() -> {
|
||||
@ -272,7 +272,7 @@ public class MediaControllerProviderService extends Service {
|
||||
public void setPlaybackParameters(String controllerId, Bundle playbackParametersBundle)
|
||||
throws RemoteException {
|
||||
PlaybackParameters playbackParameters =
|
||||
PlaybackParameters.CREATOR.fromBundle(playbackParametersBundle);
|
||||
PlaybackParameters.fromBundle(playbackParametersBundle);
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
@ -294,7 +294,7 @@ public class MediaControllerProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.setMediaItem(MediaItem.CREATOR.fromBundle(mediaItemBundle));
|
||||
controller.setMediaItem(MediaItem.fromBundle(mediaItemBundle));
|
||||
});
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ public class MediaControllerProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.setMediaItem(MediaItem.CREATOR.fromBundle(mediaItemBundle), startPositionMs);
|
||||
controller.setMediaItem(MediaItem.fromBundle(mediaItemBundle), startPositionMs);
|
||||
});
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ public class MediaControllerProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.setMediaItem(MediaItem.CREATOR.fromBundle(mediaItemBundle), resetPosition);
|
||||
controller.setMediaItem(MediaItem.fromBundle(mediaItemBundle), resetPosition);
|
||||
});
|
||||
}
|
||||
|
||||
@ -377,8 +377,7 @@ public class MediaControllerProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.setPlaylistMetadata(
|
||||
MediaMetadata.CREATOR.fromBundle(playlistMetadataBundle));
|
||||
controller.setPlaylistMetadata(MediaMetadata.fromBundle(playlistMetadataBundle));
|
||||
});
|
||||
}
|
||||
|
||||
@ -387,7 +386,7 @@ public class MediaControllerProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.addMediaItem(MediaItem.CREATOR.fromBundle(mediaItemBundle));
|
||||
controller.addMediaItem(MediaItem.fromBundle(mediaItemBundle));
|
||||
});
|
||||
}
|
||||
|
||||
@ -397,7 +396,7 @@ public class MediaControllerProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.addMediaItem(index, MediaItem.CREATOR.fromBundle(mediaItemBundle));
|
||||
controller.addMediaItem(index, MediaItem.fromBundle(mediaItemBundle));
|
||||
});
|
||||
}
|
||||
|
||||
@ -478,7 +477,7 @@ public class MediaControllerProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.replaceMediaItem(index, MediaItem.CREATOR.fromBundle(mediaItem));
|
||||
controller.replaceMediaItem(index, MediaItem.fromBundle(mediaItem));
|
||||
});
|
||||
}
|
||||
|
||||
@ -593,7 +592,7 @@ public class MediaControllerProviderService extends Service {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
Future<SessionResult> future =
|
||||
runOnHandler(
|
||||
() -> controller.sendCustomCommand(SessionCommand.CREATOR.fromBundle(command), args));
|
||||
() -> controller.sendCustomCommand(SessionCommand.fromBundle(command), args));
|
||||
SessionResult result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
@ -603,7 +602,7 @@ public class MediaControllerProviderService extends Service {
|
||||
throws RemoteException {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
Future<SessionResult> future =
|
||||
runOnHandler(() -> controller.setRating(mediaId, Rating.CREATOR.fromBundle(rating)));
|
||||
runOnHandler(() -> controller.setRating(mediaId, Rating.fromBundle(rating)));
|
||||
SessionResult result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
@ -612,7 +611,7 @@ public class MediaControllerProviderService extends Service {
|
||||
public Bundle setRating(String controllerId, Bundle rating) throws RemoteException {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
Future<SessionResult> future =
|
||||
runOnHandler(() -> controller.setRating(Rating.CREATOR.fromBundle(rating)));
|
||||
runOnHandler(() -> controller.setRating(Rating.fromBundle(rating)));
|
||||
SessionResult result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
@ -710,7 +709,7 @@ public class MediaControllerProviderService extends Service {
|
||||
() -> {
|
||||
MediaController controller = mediaControllerMap.get(controllerId);
|
||||
controller.setAudioAttributes(
|
||||
AudioAttributes.CREATOR.fromBundle(audioAttributes), handleAudioFocus);
|
||||
AudioAttributes.fromBundle(audioAttributes), handleAudioFocus);
|
||||
});
|
||||
}
|
||||
|
||||
@ -779,7 +778,7 @@ public class MediaControllerProviderService extends Service {
|
||||
browser.getLibraryRoot(
|
||||
libraryParams == null
|
||||
? null
|
||||
: MediaLibraryService.LibraryParams.CREATOR.fromBundle(libraryParams)));
|
||||
: MediaLibraryService.LibraryParams.fromBundle(libraryParams)));
|
||||
LibraryResult<MediaItem> result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
@ -795,7 +794,7 @@ public class MediaControllerProviderService extends Service {
|
||||
parentId,
|
||||
libraryParams == null
|
||||
? null
|
||||
: MediaLibraryService.LibraryParams.CREATOR.fromBundle(libraryParams)));
|
||||
: MediaLibraryService.LibraryParams.fromBundle(libraryParams)));
|
||||
LibraryResult<Void> result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
@ -822,7 +821,7 @@ public class MediaControllerProviderService extends Service {
|
||||
pageSize,
|
||||
libraryParams == null
|
||||
? null
|
||||
: MediaLibraryService.LibraryParams.CREATOR.fromBundle(libraryParams)));
|
||||
: MediaLibraryService.LibraryParams.fromBundle(libraryParams)));
|
||||
LibraryResult<ImmutableList<MediaItem>> result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
@ -865,7 +864,7 @@ public class MediaControllerProviderService extends Service {
|
||||
query,
|
||||
libraryParams == null
|
||||
? null
|
||||
: MediaLibraryService.LibraryParams.CREATOR.fromBundle(libraryParams)));
|
||||
: MediaLibraryService.LibraryParams.fromBundle(libraryParams)));
|
||||
LibraryResult<Void> result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
@ -884,7 +883,7 @@ public class MediaControllerProviderService extends Service {
|
||||
pageSize,
|
||||
libraryParams == null
|
||||
? null
|
||||
: MediaLibraryService.LibraryParams.CREATOR.fromBundle(libraryParams)));
|
||||
: MediaLibraryService.LibraryParams.fromBundle(libraryParams)));
|
||||
LibraryResult<ImmutableList<MediaItem>> result = getFutureResult(future);
|
||||
return result.toBundle();
|
||||
}
|
||||
|
@ -244,8 +244,7 @@ public class MediaSessionProviderService extends Service {
|
||||
case TEST_IS_SESSION_COMMAND_AVAILABLE:
|
||||
{
|
||||
SessionCommands availableSessionCommands =
|
||||
SessionCommands.CREATOR.fromBundle(
|
||||
tokenExtras.getBundle(KEY_AVAILABLE_SESSION_COMMANDS));
|
||||
SessionCommands.fromBundle(tokenExtras.getBundle(KEY_AVAILABLE_SESSION_COMMANDS));
|
||||
builder.setCallback(
|
||||
new MediaSession.Callback() {
|
||||
@Override
|
||||
@ -393,7 +392,7 @@ public class MediaSessionProviderService extends Service {
|
||||
MockPlayer player = new MockPlayer.Builder().build();
|
||||
@Nullable Bundle playerErrorBundle = config.getBundle(KEY_PLAYER_ERROR);
|
||||
if (playerErrorBundle != null) {
|
||||
player.playerError = PlaybackException.CREATOR.fromBundle(playerErrorBundle);
|
||||
player.playerError = PlaybackException.fromBundle(playerErrorBundle);
|
||||
}
|
||||
player.currentPosition = config.getLong(KEY_CURRENT_POSITION, player.currentPosition);
|
||||
player.bufferedPosition = config.getLong(KEY_BUFFERED_POSITION, player.bufferedPosition);
|
||||
@ -413,11 +412,11 @@ public class MediaSessionProviderService extends Service {
|
||||
config.getInt(KEY_CURRENT_AD_INDEX_IN_AD_GROUP, player.currentAdIndexInAdGroup);
|
||||
@Nullable Bundle playbackParametersBundle = config.getBundle(KEY_PLAYBACK_PARAMETERS);
|
||||
if (playbackParametersBundle != null) {
|
||||
player.playbackParameters = PlaybackParameters.CREATOR.fromBundle(playbackParametersBundle);
|
||||
player.playbackParameters = PlaybackParameters.fromBundle(playbackParametersBundle);
|
||||
}
|
||||
@Nullable Bundle timelineBundle = config.getBundle(KEY_TIMELINE);
|
||||
if (timelineBundle != null) {
|
||||
player.timeline = Timeline.CREATOR.fromBundle(timelineBundle);
|
||||
player.timeline = Timeline.fromBundle(timelineBundle);
|
||||
}
|
||||
player.currentMediaItemIndex =
|
||||
config.getInt(KEY_CURRENT_MEDIA_ITEM_INDEX, player.currentMediaItemIndex);
|
||||
@ -425,25 +424,23 @@ public class MediaSessionProviderService extends Service {
|
||||
config.getInt(KEY_CURRENT_PERIOD_INDEX, player.currentPeriodIndex);
|
||||
@Nullable Bundle playlistMetadataBundle = config.getBundle(KEY_PLAYLIST_METADATA);
|
||||
if (playlistMetadataBundle != null) {
|
||||
player.playlistMetadata = MediaMetadata.CREATOR.fromBundle(playlistMetadataBundle);
|
||||
player.playlistMetadata = MediaMetadata.fromBundle(playlistMetadataBundle);
|
||||
}
|
||||
@Nullable Bundle videoSizeBundle = config.getBundle(KEY_VIDEO_SIZE);
|
||||
if (videoSizeBundle != null) {
|
||||
player.videoSize = VideoSize.CREATOR.fromBundle(videoSizeBundle);
|
||||
player.videoSize = VideoSize.fromBundle(videoSizeBundle);
|
||||
}
|
||||
player.volume = config.getFloat(KEY_VOLUME, player.volume);
|
||||
@Nullable Bundle audioAttributesBundle = config.getBundle(KEY_AUDIO_ATTRIBUTES);
|
||||
if (audioAttributesBundle != null) {
|
||||
player.audioAttributes = AudioAttributes.CREATOR.fromBundle(audioAttributesBundle);
|
||||
player.audioAttributes = AudioAttributes.fromBundle(audioAttributesBundle);
|
||||
}
|
||||
Bundle cueGroupBundle = config.getBundle(KEY_CURRENT_CUE_GROUP);
|
||||
player.cueGroup =
|
||||
cueGroupBundle == null
|
||||
? CueGroup.EMPTY_TIME_ZERO
|
||||
: CueGroup.CREATOR.fromBundle(cueGroupBundle);
|
||||
cueGroupBundle == null ? CueGroup.EMPTY_TIME_ZERO : CueGroup.fromBundle(cueGroupBundle);
|
||||
@Nullable Bundle deviceInfoBundle = config.getBundle(KEY_DEVICE_INFO);
|
||||
if (deviceInfoBundle != null) {
|
||||
player.deviceInfo = DeviceInfo.CREATOR.fromBundle(deviceInfoBundle);
|
||||
player.deviceInfo = DeviceInfo.fromBundle(deviceInfoBundle);
|
||||
}
|
||||
player.deviceVolume = config.getInt(KEY_DEVICE_VOLUME, player.deviceVolume);
|
||||
player.deviceMuted = config.getBoolean(KEY_DEVICE_MUTED, player.deviceMuted);
|
||||
@ -461,13 +458,13 @@ public class MediaSessionProviderService extends Service {
|
||||
config.getLong(KEY_SEEK_FORWARD_INCREMENT_MS, player.seekForwardIncrementMs);
|
||||
@Nullable Bundle mediaMetadataBundle = config.getBundle(KEY_MEDIA_METADATA);
|
||||
if (mediaMetadataBundle != null) {
|
||||
player.mediaMetadata = MediaMetadata.CREATOR.fromBundle(mediaMetadataBundle);
|
||||
player.mediaMetadata = MediaMetadata.fromBundle(mediaMetadataBundle);
|
||||
}
|
||||
player.maxSeekToPreviousPositionMs =
|
||||
config.getLong(KEY_MAX_SEEK_TO_PREVIOUS_POSITION_MS, player.maxSeekToPreviousPositionMs);
|
||||
@Nullable Bundle currentTracksBundle = config.getBundle(KEY_CURRENT_TRACKS);
|
||||
if (currentTracksBundle != null) {
|
||||
player.currentTracks = Tracks.CREATOR.fromBundle(currentTracksBundle);
|
||||
player.currentTracks = Tracks.fromBundle(currentTracksBundle);
|
||||
}
|
||||
@Nullable
|
||||
Bundle trackSelectionParametersBundle = config.getBundle(KEY_TRACK_SELECTION_PARAMETERS);
|
||||
@ -477,7 +474,7 @@ public class MediaSessionProviderService extends Service {
|
||||
}
|
||||
@Nullable Bundle availableCommandsBundle = config.getBundle(KEY_AVAILABLE_COMMANDS);
|
||||
if (availableCommandsBundle != null) {
|
||||
player.commands = Player.Commands.CREATOR.fromBundle(availableCommandsBundle);
|
||||
player.commands = Player.Commands.fromBundle(availableCommandsBundle);
|
||||
}
|
||||
return player;
|
||||
}
|
||||
@ -488,7 +485,7 @@ public class MediaSessionProviderService extends Service {
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
session.broadcastCustomCommand(SessionCommand.CREATOR.fromBundle(command), args);
|
||||
session.broadcastCustomCommand(SessionCommand.fromBundle(command), args);
|
||||
});
|
||||
}
|
||||
|
||||
@ -506,7 +503,7 @@ public class MediaSessionProviderService extends Service {
|
||||
"No connected controllers to receive custom command. sessionId=" + sessionId);
|
||||
}
|
||||
for (ControllerInfo info : controllerInfos) {
|
||||
session.sendCustomCommand(info, SessionCommand.CREATOR.fromBundle(command), args);
|
||||
session.sendCustomCommand(info, SessionCommand.fromBundle(command), args);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -535,8 +532,8 @@ public class MediaSessionProviderService extends Service {
|
||||
for (ControllerInfo info : controllerInfos) {
|
||||
session.setAvailableCommands(
|
||||
info,
|
||||
SessionCommands.CREATOR.fromBundle(sessionCommands),
|
||||
Player.Commands.CREATOR.fromBundle(playerCommands));
|
||||
SessionCommands.fromBundle(sessionCommands),
|
||||
Player.Commands.fromBundle(playerCommands));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -551,7 +548,7 @@ public class MediaSessionProviderService extends Service {
|
||||
() -> {
|
||||
ImmutableList.Builder<CommandButton> builder = new ImmutableList.Builder<>();
|
||||
for (Bundle bundle : layout) {
|
||||
builder.add(CommandButton.CREATOR.fromBundle(bundle));
|
||||
builder.add(CommandButton.fromBundle(bundle));
|
||||
}
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
session.setCustomLayout(builder.build());
|
||||
@ -602,7 +599,7 @@ public class MediaSessionProviderService extends Service {
|
||||
PlaybackException playerError =
|
||||
playerErrorBundle == null
|
||||
? player.playerError
|
||||
: PlaybackException.CREATOR.fromBundle(playerErrorBundle);
|
||||
: PlaybackException.fromBundle(playerErrorBundle);
|
||||
player.notifyPlayerError(playerError);
|
||||
});
|
||||
}
|
||||
@ -727,7 +724,7 @@ public class MediaSessionProviderService extends Service {
|
||||
public void setPlaybackParameters(String sessionId, Bundle playbackParametersBundle)
|
||||
throws RemoteException {
|
||||
PlaybackParameters playbackParameters =
|
||||
PlaybackParameters.CREATOR.fromBundle(playbackParametersBundle);
|
||||
PlaybackParameters.fromBundle(playbackParametersBundle);
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
@ -853,8 +850,8 @@ public class MediaSessionProviderService extends Service {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
MockPlayer player = (MockPlayer) session.getPlayer();
|
||||
player.notifyPositionDiscontinuity(
|
||||
PositionInfo.CREATOR.fromBundle(oldPositionBundle),
|
||||
PositionInfo.CREATOR.fromBundle(newPositionBundle),
|
||||
PositionInfo.fromBundle(oldPositionBundle),
|
||||
PositionInfo.fromBundle(newPositionBundle),
|
||||
reason);
|
||||
});
|
||||
}
|
||||
@ -867,7 +864,7 @@ public class MediaSessionProviderService extends Service {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
MockPlayer player = (MockPlayer) session.getPlayer();
|
||||
player.notifyPlaybackParametersChanged(
|
||||
PlaybackParameters.CREATOR.fromBundle(playbackParametersBundle));
|
||||
PlaybackParameters.fromBundle(playbackParametersBundle));
|
||||
});
|
||||
}
|
||||
|
||||
@ -890,7 +887,7 @@ public class MediaSessionProviderService extends Service {
|
||||
@Override
|
||||
public void notifyAudioAttributesChanged(String sessionId, Bundle audioAttributesBundle)
|
||||
throws RemoteException {
|
||||
AudioAttributes audioAttributes = AudioAttributes.CREATOR.fromBundle(audioAttributesBundle);
|
||||
AudioAttributes audioAttributes = AudioAttributes.fromBundle(audioAttributesBundle);
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
@ -910,7 +907,7 @@ public class MediaSessionProviderService extends Service {
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
MockPlayer player = (MockPlayer) session.getPlayer();
|
||||
player.timeline = Timeline.CREATOR.fromBundle(timelineBundle);
|
||||
player.timeline = Timeline.fromBundle(timelineBundle);
|
||||
List<MediaItem> mediaItems = new ArrayList<>();
|
||||
for (int i = 0; i < player.timeline.getWindowCount(); i++) {
|
||||
mediaItems.add(
|
||||
@ -945,7 +942,7 @@ public class MediaSessionProviderService extends Service {
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
MockPlayer player = (MockPlayer) session.getPlayer();
|
||||
player.mediaMetadata = MediaMetadata.CREATOR.fromBundle(metadataBundle);
|
||||
player.mediaMetadata = MediaMetadata.fromBundle(metadataBundle);
|
||||
});
|
||||
}
|
||||
|
||||
@ -956,7 +953,7 @@ public class MediaSessionProviderService extends Service {
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
MockPlayer player = (MockPlayer) session.getPlayer();
|
||||
player.playlistMetadata = MediaMetadata.CREATOR.fromBundle(playlistMetadataBundle);
|
||||
player.playlistMetadata = MediaMetadata.fromBundle(playlistMetadataBundle);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1022,7 +1019,7 @@ public class MediaSessionProviderService extends Service {
|
||||
player.notifyAvailableCommandsChanged(
|
||||
commandsBundle == null
|
||||
? Player.Commands.EMPTY
|
||||
: Player.Commands.CREATOR.fromBundle(commandsBundle));
|
||||
: Player.Commands.fromBundle(commandsBundle));
|
||||
});
|
||||
}
|
||||
|
||||
@ -1097,7 +1094,7 @@ public class MediaSessionProviderService extends Service {
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
MockPlayer player = (MockPlayer) session.getPlayer();
|
||||
VideoSize videoSizeObj = VideoSize.CREATOR.fromBundle(videoSize);
|
||||
VideoSize videoSizeObj = VideoSize.fromBundle(videoSize);
|
||||
player.notifyVideoSizeChanged(videoSizeObj);
|
||||
});
|
||||
}
|
||||
@ -1134,7 +1131,7 @@ public class MediaSessionProviderService extends Service {
|
||||
|
||||
@Override
|
||||
public void notifyCuesChanged(String sessionId, Bundle cueGroupBundle) throws RemoteException {
|
||||
CueGroup cueGroup = CueGroup.CREATOR.fromBundle(cueGroupBundle);
|
||||
CueGroup cueGroup = CueGroup.fromBundle(cueGroupBundle);
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
@ -1147,7 +1144,7 @@ public class MediaSessionProviderService extends Service {
|
||||
@Override
|
||||
public void notifyDeviceInfoChanged(String sessionId, Bundle deviceInfoBundle)
|
||||
throws RemoteException {
|
||||
DeviceInfo deviceInfo = DeviceInfo.CREATOR.fromBundle(deviceInfoBundle);
|
||||
DeviceInfo deviceInfo = DeviceInfo.fromBundle(deviceInfoBundle);
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
@ -1160,7 +1157,7 @@ public class MediaSessionProviderService extends Service {
|
||||
@Override
|
||||
public void notifyMediaMetadataChanged(String sessionId, Bundle mediaMetadataBundle)
|
||||
throws RemoteException {
|
||||
MediaMetadata mediaMetadata = MediaMetadata.CREATOR.fromBundle(mediaMetadataBundle);
|
||||
MediaMetadata mediaMetadata = MediaMetadata.fromBundle(mediaMetadataBundle);
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
@ -1207,7 +1204,7 @@ public class MediaSessionProviderService extends Service {
|
||||
|
||||
@Override
|
||||
public void notifyTracksChanged(String sessionId, Bundle tracksBundle) throws RemoteException {
|
||||
Tracks tracks = Tracks.CREATOR.fromBundle(tracksBundle);
|
||||
Tracks tracks = Tracks.fromBundle(tracksBundle);
|
||||
runOnHandler(
|
||||
() -> {
|
||||
MediaSession session = sessionMap.get(sessionId);
|
||||
|
@ -472,7 +472,7 @@ public class MockMediaLibraryService extends MediaLibraryService {
|
||||
@Nullable Bundle paramsBundle = args.getBundle(CUSTOM_ACTION_ASSERT_PARAMS);
|
||||
@Nullable
|
||||
LibraryParams params =
|
||||
paramsBundle == null ? null : LibraryParams.CREATOR.fromBundle(paramsBundle);
|
||||
paramsBundle == null ? null : LibraryParams.fromBundle(paramsBundle);
|
||||
setAssertLibraryParams(params);
|
||||
return Futures.immediateFuture(new SessionResult(SessionResult.RESULT_SUCCESS));
|
||||
default: // fall out
|
||||
|
@ -46,19 +46,19 @@ public class RemoteMediaBrowser extends RemoteMediaController {
|
||||
public LibraryResult<MediaItem> getLibraryRoot(@Nullable LibraryParams params)
|
||||
throws RemoteException {
|
||||
Bundle result = binder.getLibraryRoot(controllerId, params == null ? null : params.toBundle());
|
||||
return LibraryResult.ITEM_CREATOR.fromBundle(result);
|
||||
return LibraryResult.fromItemBundle(result);
|
||||
}
|
||||
|
||||
public LibraryResult<Void> subscribe(String parentId, @Nullable LibraryParams params)
|
||||
throws RemoteException {
|
||||
Bundle result =
|
||||
binder.subscribe(controllerId, parentId, params == null ? null : params.toBundle());
|
||||
return LibraryResult.VOID_CREATOR.fromBundle(result);
|
||||
return LibraryResult.fromVoidBundle(result);
|
||||
}
|
||||
|
||||
public LibraryResult<Void> unsubscribe(String parentId) throws RemoteException {
|
||||
Bundle result = binder.unsubscribe(controllerId, parentId);
|
||||
return LibraryResult.VOID_CREATOR.fromBundle(result);
|
||||
return LibraryResult.fromVoidBundle(result);
|
||||
}
|
||||
|
||||
public LibraryResult<ImmutableList<MediaItem>> getChildren(
|
||||
@ -67,18 +67,18 @@ public class RemoteMediaBrowser extends RemoteMediaController {
|
||||
Bundle result =
|
||||
binder.getChildren(
|
||||
controllerId, parentId, page, pageSize, params == null ? null : params.toBundle());
|
||||
return LibraryResult.ITEM_LIST_CREATOR.fromBundle(result);
|
||||
return LibraryResult.fromItemListBundle(result);
|
||||
}
|
||||
|
||||
public LibraryResult<MediaItem> getItem(String mediaId) throws RemoteException {
|
||||
Bundle result = binder.getItem(controllerId, mediaId);
|
||||
return LibraryResult.ITEM_CREATOR.fromBundle(result);
|
||||
return LibraryResult.fromItemBundle(result);
|
||||
}
|
||||
|
||||
public LibraryResult<Void> search(String query, @Nullable LibraryParams params)
|
||||
throws RemoteException {
|
||||
Bundle result = binder.search(controllerId, query, params == null ? null : params.toBundle());
|
||||
return LibraryResult.VOID_CREATOR.fromBundle(result);
|
||||
return LibraryResult.fromVoidBundle(result);
|
||||
}
|
||||
|
||||
public LibraryResult<ImmutableList<MediaItem>> getSearchResult(
|
||||
@ -86,7 +86,7 @@ public class RemoteMediaBrowser extends RemoteMediaController {
|
||||
Bundle result =
|
||||
binder.getSearchResult(
|
||||
controllerId, query, page, pageSize, params == null ? null : params.toBundle());
|
||||
return LibraryResult.ITEM_LIST_CREATOR.fromBundle(result);
|
||||
return LibraryResult.fromItemListBundle(result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -94,7 +94,7 @@ public class RemoteMediaController {
|
||||
@Nullable
|
||||
public SessionToken getConnectedSessionToken() throws RemoteException {
|
||||
@Nullable Bundle sessionTokenBundle = binder.getConnectedSessionToken(controllerId);
|
||||
return sessionTokenBundle == null ? null : SessionToken.CREATOR.fromBundle(sessionTokenBundle);
|
||||
return sessionTokenBundle == null ? null : SessionToken.fromBundle(sessionTokenBundle);
|
||||
}
|
||||
|
||||
public void play() throws RemoteException {
|
||||
@ -336,17 +336,17 @@ public class RemoteMediaController {
|
||||
public SessionResult sendCustomCommand(SessionCommand command, Bundle args)
|
||||
throws RemoteException {
|
||||
Bundle result = binder.sendCustomCommand(controllerId, command.toBundle(), args);
|
||||
return SessionResult.CREATOR.fromBundle(result);
|
||||
return SessionResult.fromBundle(result);
|
||||
}
|
||||
|
||||
public SessionResult setRating(String mediaId, Rating rating) throws RemoteException {
|
||||
Bundle result = binder.setRatingWithMediaId(controllerId, mediaId, rating.toBundle());
|
||||
return SessionResult.CREATOR.fromBundle(result);
|
||||
return SessionResult.fromBundle(result);
|
||||
}
|
||||
|
||||
public SessionResult setRating(Rating rating) throws RemoteException {
|
||||
Bundle result = binder.setRating(controllerId, rating.toBundle());
|
||||
return SessionResult.CREATOR.fromBundle(result);
|
||||
return SessionResult.fromBundle(result);
|
||||
}
|
||||
|
||||
public void release() throws RemoteException {
|
||||
@ -377,14 +377,14 @@ public class RemoteMediaController {
|
||||
ArrayList<Bundle> list = customLayoutBundle.getParcelableArrayList(KEY_COMMAND_BUTTON_LIST);
|
||||
ImmutableList.Builder<CommandButton> customLayout = new ImmutableList.Builder<>();
|
||||
for (Bundle bundle : list) {
|
||||
customLayout.add(CommandButton.CREATOR.fromBundle(bundle));
|
||||
customLayout.add(CommandButton.fromBundle(bundle));
|
||||
}
|
||||
return customLayout.build();
|
||||
}
|
||||
|
||||
public Player.Commands getAvailableCommands() throws RemoteException {
|
||||
Bundle commandsBundle = binder.getAvailableCommands(controllerId);
|
||||
return Player.Commands.CREATOR.fromBundle(commandsBundle);
|
||||
return Player.Commands.fromBundle(commandsBundle);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -151,7 +151,7 @@ public class RemoteMediaSession {
|
||||
*/
|
||||
@Nullable
|
||||
public SessionToken getToken() throws RemoteException {
|
||||
return SessionToken.CREATOR.fromBundle(binder.getToken(sessionId));
|
||||
return SessionToken.fromBundle(binder.getToken(sessionId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user