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