Loading core/api/current.txt +36 −0 Original line number Original line Diff line number Diff line Loading @@ -24074,13 +24074,49 @@ package android.media.effect { package android.media.metrics { package android.media.metrics { public abstract class Event { ctor protected Event(long); method @IntRange(from=0xffffffff) public long getTimeSinceCreatedMillis(); } public class MediaMetricsManager { public class MediaMetricsManager { method @NonNull public android.media.metrics.PlaybackSession createPlaybackSession(); method @NonNull public android.media.metrics.PlaybackSession createPlaybackSession(); field public static final long INVALID_TIMESTAMP = -1L; // 0xffffffffffffffffL } } public final class PlaybackSession implements java.lang.AutoCloseable { public final class PlaybackSession implements java.lang.AutoCloseable { method public void close(); method public void close(); method @NonNull public String getId(); method @NonNull public String getId(); method public void reportPlaybackStateEvent(@NonNull android.media.metrics.PlaybackStateEvent); } public final class PlaybackStateEvent extends android.media.metrics.Event implements android.os.Parcelable { method public int describeContents(); method public int getState(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.media.metrics.PlaybackStateEvent> CREATOR; field public static final int STATE_ABANDONED = 15; // 0xf field public static final int STATE_BUFFERING = 6; // 0x6 field public static final int STATE_ENDED = 11; // 0xb field public static final int STATE_FAILED = 13; // 0xd field public static final int STATE_INTERRUPTED_BY_AD = 14; // 0xe field public static final int STATE_JOINING_BACKGROUND = 1; // 0x1 field public static final int STATE_JOINING_FOREGROUND = 2; // 0x2 field public static final int STATE_NOT_STARTED = 0; // 0x0 field public static final int STATE_PAUSED = 4; // 0x4 field public static final int STATE_PAUSED_BUFFERING = 7; // 0x7 field public static final int STATE_PLAYING = 3; // 0x3 field public static final int STATE_SEEKING = 5; // 0x5 field public static final int STATE_STOPPED = 12; // 0xc field public static final int STATE_SUPPRESSED = 9; // 0x9 field public static final int STATE_SUPPRESSED_BUFFERING = 10; // 0xa } public static final class PlaybackStateEvent.Builder { ctor public PlaybackStateEvent.Builder(); method @NonNull public android.media.metrics.PlaybackStateEvent build(); method @NonNull public android.media.metrics.PlaybackStateEvent.Builder setState(int); method @NonNull public android.media.metrics.PlaybackStateEvent.Builder setTimeSinceCreatedMillis(@IntRange(from=0xffffffff) long); } } } } media/java/android/media/metrics/Event.java 0 → 100644 +44 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.media.metrics; import android.annotation.IntRange; /** * Abstract class for metrics events. */ public abstract class Event { private final long mTimeSinceCreatedMillis; // hide default constructor /* package */ Event() { mTimeSinceCreatedMillis = MediaMetricsManager.INVALID_TIMESTAMP; } protected Event(long timeSinceCreatedMillis) { mTimeSinceCreatedMillis = timeSinceCreatedMillis; } /** * Gets time since the corresponding instance is created in millisecond. * @return the timestamp since the instance is created, or -1 if unknown. */ @IntRange(from = -1) public long getTimeSinceCreatedMillis() { return mTimeSinceCreatedMillis; } } media/java/android/media/metrics/MediaMetricsManager.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ import android.os.RemoteException; */ */ @SystemService(Context.MEDIA_METRICS_SERVICE) @SystemService(Context.MEDIA_METRICS_SERVICE) public class MediaMetricsManager { public class MediaMetricsManager { // TODO: unhide APIs. public static final long INVALID_TIMESTAMP = -1; private static final String TAG = "MediaMetricsManager"; private static final String TAG = "MediaMetricsManager"; private IMediaMetricsManager mService; private IMediaMetricsManager mService; Loading media/java/android/media/metrics/PlaybackSession.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -69,9 +69,8 @@ public final class PlaybackSession implements AutoCloseable { /** /** * Reports playback state event. * Reports playback state event. * @hide */ */ public void reportPlaybackStateEvent(PlaybackStateEvent event) { public void reportPlaybackStateEvent(@NonNull PlaybackStateEvent event) { mManager.reportPlaybackStateEvent(mId, event); mManager.reportPlaybackStateEvent(mId, event); } } Loading media/java/android/media/metrics/PlaybackStateEvent.java +111 −17 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.media.metrics; package android.media.metrics; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcel; Loading @@ -27,10 +28,8 @@ import java.util.Objects; /** /** * Playback state event. * Playback state event. * @hide */ */ public final class PlaybackStateEvent implements Parcelable { public final class PlaybackStateEvent extends Event implements Parcelable { // TODO: more states /** Playback has not started (initial state) */ /** Playback has not started (initial state) */ public static final int STATE_NOT_STARTED = 0; public static final int STATE_NOT_STARTED = 0; /** Playback is buffering in the background for initial playback start */ /** Playback is buffering in the background for initial playback start */ Loading @@ -41,23 +40,57 @@ public final class PlaybackStateEvent implements Parcelable { public static final int STATE_PLAYING = 3; public static final int STATE_PLAYING = 3; /** Playback is paused but ready to play */ /** Playback is paused but ready to play */ public static final int STATE_PAUSED = 4; public static final int STATE_PAUSED = 4; /** Playback is handling a seek. */ private int mState; public static final int STATE_SEEKING = 5; private long mTimeSincePlaybackCreatedMillis; /** Playback is buffering to resume active playback. */ public static final int STATE_BUFFERING = 6; /** Playback is buffering while paused. */ public static final int STATE_PAUSED_BUFFERING = 7; /** Playback is suppressed (e.g. due to audio focus loss). */ public static final int STATE_SUPPRESSED = 9; /** * Playback is suppressed (e.g. due to audio focus loss) while buffering to resume a playback. */ public static final int STATE_SUPPRESSED_BUFFERING = 10; /** Playback has reached the end of the media. */ public static final int STATE_ENDED = 11; /** Playback is stopped and can be restarted. */ public static final int STATE_STOPPED = 12; /** Playback is stopped due a fatal error and can be retried. */ public static final int STATE_FAILED = 13; /** Playback is interrupted by an ad. */ public static final int STATE_INTERRUPTED_BY_AD = 14; /** Playback is abandoned before reaching the end of the media. */ public static final int STATE_ABANDONED = 15; private final int mState; private final long mTimeSinceCreatedMillis; // These track ExoPlayer states. See the ExoPlayer documentation for the state transitions. // These track ExoPlayer states. See the ExoPlayer documentation for the state transitions. /** @hide */ @IntDef(prefix = "STATE_", value = { @IntDef(prefix = "STATE_", value = { STATE_NOT_STARTED, STATE_NOT_STARTED, STATE_JOINING_BACKGROUND, STATE_JOINING_BACKGROUND, STATE_JOINING_FOREGROUND, STATE_JOINING_FOREGROUND, STATE_PLAYING, STATE_PLAYING, STATE_PAUSED STATE_PAUSED, STATE_SEEKING, STATE_BUFFERING, STATE_PAUSED_BUFFERING, STATE_SUPPRESSED, STATE_SUPPRESSED_BUFFERING, STATE_ENDED, STATE_STOPPED, STATE_FAILED, STATE_INTERRUPTED_BY_AD, STATE_ABANDONED, }) }) @Retention(java.lang.annotation.RetentionPolicy.SOURCE) @Retention(java.lang.annotation.RetentionPolicy.SOURCE) public @interface State {} public @interface State {} /** /** * Converts playback state to string. * Converts playback state to string. * @hide */ */ public static String stateToString(@State int value) { public static String stateToString(@State int value) { switch (value) { switch (value) { Loading @@ -71,6 +104,26 @@ public final class PlaybackStateEvent implements Parcelable { return "STATE_PLAYING"; return "STATE_PLAYING"; case STATE_PAUSED: case STATE_PAUSED: return "STATE_PAUSED"; return "STATE_PAUSED"; case STATE_SEEKING: return "STATE_SEEKING"; case STATE_BUFFERING: return "STATE_BUFFERING"; case STATE_PAUSED_BUFFERING: return "STATE_PAUSED_BUFFERING"; case STATE_SUPPRESSED: return "STATE_SUPPRESSED"; case STATE_SUPPRESSED_BUFFERING: return "STATE_SUPPRESSED_BUFFERING"; case STATE_ENDED: return "STATE_ENDED"; case STATE_STOPPED: return "STATE_STOPPED"; case STATE_FAILED: return "STATE_FAILED"; case STATE_INTERRUPTED_BY_AD: return "STATE_INTERRUPTED_BY_AD"; case STATE_ABANDONED: return "STATE_ABANDONED"; default: default: return Integer.toHexString(value); return Integer.toHexString(value); } } Loading @@ -83,14 +136,13 @@ public final class PlaybackStateEvent implements Parcelable { */ */ public PlaybackStateEvent( public PlaybackStateEvent( int state, int state, long timeSincePlaybackCreatedMillis) { long timeSinceCreatedMillis) { this.mTimeSinceCreatedMillis = timeSinceCreatedMillis; this.mState = state; this.mState = state; this.mTimeSincePlaybackCreatedMillis = timeSincePlaybackCreatedMillis; } } /** /** * Gets playback state. * Gets playback state. * @return */ */ public int getState() { public int getState() { return mState; return mState; Loading @@ -98,9 +150,12 @@ public final class PlaybackStateEvent implements Parcelable { /** /** * Gets time since the corresponding playback is created in millisecond. * Gets time since the corresponding playback is created in millisecond. * @return the timestamp since the playback is created, or -1 if unknown. */ */ public long getTimeSincePlaybackCreatedMillis() { @Override return mTimeSincePlaybackCreatedMillis; @IntRange(from = -1) public long getTimeSinceCreatedMillis() { return mTimeSinceCreatedMillis; } } @Override @Override Loading @@ -109,18 +164,18 @@ public final class PlaybackStateEvent implements Parcelable { if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false; PlaybackStateEvent that = (PlaybackStateEvent) o; PlaybackStateEvent that = (PlaybackStateEvent) o; return mState == that.mState return mState == that.mState && mTimeSincePlaybackCreatedMillis == that.mTimeSincePlaybackCreatedMillis; && mTimeSinceCreatedMillis == that.mTimeSinceCreatedMillis; } } @Override @Override public int hashCode() { public int hashCode() { return Objects.hash(mState, mTimeSincePlaybackCreatedMillis); return Objects.hash(mState, mTimeSinceCreatedMillis); } } @Override @Override public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeInt(mState); dest.writeInt(mState); dest.writeLong(mTimeSincePlaybackCreatedMillis); dest.writeLong(mTimeSinceCreatedMillis); } } @Override @Override Loading @@ -131,10 +186,10 @@ public final class PlaybackStateEvent implements Parcelable { /** @hide */ /** @hide */ /* package-private */ PlaybackStateEvent(@NonNull Parcel in) { /* package-private */ PlaybackStateEvent(@NonNull Parcel in) { int state = in.readInt(); int state = in.readInt(); long timeSincePlaybackCreatedMillis = in.readLong(); long timeSinceCreatedMillis = in.readLong(); this.mState = state; this.mState = state; this.mTimeSincePlaybackCreatedMillis = timeSincePlaybackCreatedMillis; this.mTimeSinceCreatedMillis = timeSinceCreatedMillis; } } public static final @NonNull Parcelable.Creator<PlaybackStateEvent> CREATOR = public static final @NonNull Parcelable.Creator<PlaybackStateEvent> CREATOR = Loading @@ -150,4 +205,43 @@ public final class PlaybackStateEvent implements Parcelable { } } }; }; /** * A builder for {@link PlaybackStateEvent} */ public static final class Builder { private int mState = STATE_NOT_STARTED; private long mTimeSinceCreatedMillis = -1; /** * Creates a new Builder. */ public Builder() { } /** * Sets playback state. */ public @NonNull Builder setState(@State int value) { mState = value; return this; } /** * Sets timestamp since the creation in milliseconds. * @param value the timestamp since the creation in milliseconds. * -1 indicates the value is unknown. */ public @NonNull Builder setTimeSinceCreatedMillis(@IntRange(from = -1) long value) { mTimeSinceCreatedMillis = value; return this; } /** Builds the instance. */ public @NonNull PlaybackStateEvent build() { PlaybackStateEvent o = new PlaybackStateEvent( mState, mTimeSinceCreatedMillis); return o; } } } } Loading
core/api/current.txt +36 −0 Original line number Original line Diff line number Diff line Loading @@ -24074,13 +24074,49 @@ package android.media.effect { package android.media.metrics { package android.media.metrics { public abstract class Event { ctor protected Event(long); method @IntRange(from=0xffffffff) public long getTimeSinceCreatedMillis(); } public class MediaMetricsManager { public class MediaMetricsManager { method @NonNull public android.media.metrics.PlaybackSession createPlaybackSession(); method @NonNull public android.media.metrics.PlaybackSession createPlaybackSession(); field public static final long INVALID_TIMESTAMP = -1L; // 0xffffffffffffffffL } } public final class PlaybackSession implements java.lang.AutoCloseable { public final class PlaybackSession implements java.lang.AutoCloseable { method public void close(); method public void close(); method @NonNull public String getId(); method @NonNull public String getId(); method public void reportPlaybackStateEvent(@NonNull android.media.metrics.PlaybackStateEvent); } public final class PlaybackStateEvent extends android.media.metrics.Event implements android.os.Parcelable { method public int describeContents(); method public int getState(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.media.metrics.PlaybackStateEvent> CREATOR; field public static final int STATE_ABANDONED = 15; // 0xf field public static final int STATE_BUFFERING = 6; // 0x6 field public static final int STATE_ENDED = 11; // 0xb field public static final int STATE_FAILED = 13; // 0xd field public static final int STATE_INTERRUPTED_BY_AD = 14; // 0xe field public static final int STATE_JOINING_BACKGROUND = 1; // 0x1 field public static final int STATE_JOINING_FOREGROUND = 2; // 0x2 field public static final int STATE_NOT_STARTED = 0; // 0x0 field public static final int STATE_PAUSED = 4; // 0x4 field public static final int STATE_PAUSED_BUFFERING = 7; // 0x7 field public static final int STATE_PLAYING = 3; // 0x3 field public static final int STATE_SEEKING = 5; // 0x5 field public static final int STATE_STOPPED = 12; // 0xc field public static final int STATE_SUPPRESSED = 9; // 0x9 field public static final int STATE_SUPPRESSED_BUFFERING = 10; // 0xa } public static final class PlaybackStateEvent.Builder { ctor public PlaybackStateEvent.Builder(); method @NonNull public android.media.metrics.PlaybackStateEvent build(); method @NonNull public android.media.metrics.PlaybackStateEvent.Builder setState(int); method @NonNull public android.media.metrics.PlaybackStateEvent.Builder setTimeSinceCreatedMillis(@IntRange(from=0xffffffff) long); } } } }
media/java/android/media/metrics/Event.java 0 → 100644 +44 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.media.metrics; import android.annotation.IntRange; /** * Abstract class for metrics events. */ public abstract class Event { private final long mTimeSinceCreatedMillis; // hide default constructor /* package */ Event() { mTimeSinceCreatedMillis = MediaMetricsManager.INVALID_TIMESTAMP; } protected Event(long timeSinceCreatedMillis) { mTimeSinceCreatedMillis = timeSinceCreatedMillis; } /** * Gets time since the corresponding instance is created in millisecond. * @return the timestamp since the instance is created, or -1 if unknown. */ @IntRange(from = -1) public long getTimeSinceCreatedMillis() { return mTimeSinceCreatedMillis; } }
media/java/android/media/metrics/MediaMetricsManager.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ import android.os.RemoteException; */ */ @SystemService(Context.MEDIA_METRICS_SERVICE) @SystemService(Context.MEDIA_METRICS_SERVICE) public class MediaMetricsManager { public class MediaMetricsManager { // TODO: unhide APIs. public static final long INVALID_TIMESTAMP = -1; private static final String TAG = "MediaMetricsManager"; private static final String TAG = "MediaMetricsManager"; private IMediaMetricsManager mService; private IMediaMetricsManager mService; Loading
media/java/android/media/metrics/PlaybackSession.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -69,9 +69,8 @@ public final class PlaybackSession implements AutoCloseable { /** /** * Reports playback state event. * Reports playback state event. * @hide */ */ public void reportPlaybackStateEvent(PlaybackStateEvent event) { public void reportPlaybackStateEvent(@NonNull PlaybackStateEvent event) { mManager.reportPlaybackStateEvent(mId, event); mManager.reportPlaybackStateEvent(mId, event); } } Loading
media/java/android/media/metrics/PlaybackStateEvent.java +111 −17 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.media.metrics; package android.media.metrics; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcel; Loading @@ -27,10 +28,8 @@ import java.util.Objects; /** /** * Playback state event. * Playback state event. * @hide */ */ public final class PlaybackStateEvent implements Parcelable { public final class PlaybackStateEvent extends Event implements Parcelable { // TODO: more states /** Playback has not started (initial state) */ /** Playback has not started (initial state) */ public static final int STATE_NOT_STARTED = 0; public static final int STATE_NOT_STARTED = 0; /** Playback is buffering in the background for initial playback start */ /** Playback is buffering in the background for initial playback start */ Loading @@ -41,23 +40,57 @@ public final class PlaybackStateEvent implements Parcelable { public static final int STATE_PLAYING = 3; public static final int STATE_PLAYING = 3; /** Playback is paused but ready to play */ /** Playback is paused but ready to play */ public static final int STATE_PAUSED = 4; public static final int STATE_PAUSED = 4; /** Playback is handling a seek. */ private int mState; public static final int STATE_SEEKING = 5; private long mTimeSincePlaybackCreatedMillis; /** Playback is buffering to resume active playback. */ public static final int STATE_BUFFERING = 6; /** Playback is buffering while paused. */ public static final int STATE_PAUSED_BUFFERING = 7; /** Playback is suppressed (e.g. due to audio focus loss). */ public static final int STATE_SUPPRESSED = 9; /** * Playback is suppressed (e.g. due to audio focus loss) while buffering to resume a playback. */ public static final int STATE_SUPPRESSED_BUFFERING = 10; /** Playback has reached the end of the media. */ public static final int STATE_ENDED = 11; /** Playback is stopped and can be restarted. */ public static final int STATE_STOPPED = 12; /** Playback is stopped due a fatal error and can be retried. */ public static final int STATE_FAILED = 13; /** Playback is interrupted by an ad. */ public static final int STATE_INTERRUPTED_BY_AD = 14; /** Playback is abandoned before reaching the end of the media. */ public static final int STATE_ABANDONED = 15; private final int mState; private final long mTimeSinceCreatedMillis; // These track ExoPlayer states. See the ExoPlayer documentation for the state transitions. // These track ExoPlayer states. See the ExoPlayer documentation for the state transitions. /** @hide */ @IntDef(prefix = "STATE_", value = { @IntDef(prefix = "STATE_", value = { STATE_NOT_STARTED, STATE_NOT_STARTED, STATE_JOINING_BACKGROUND, STATE_JOINING_BACKGROUND, STATE_JOINING_FOREGROUND, STATE_JOINING_FOREGROUND, STATE_PLAYING, STATE_PLAYING, STATE_PAUSED STATE_PAUSED, STATE_SEEKING, STATE_BUFFERING, STATE_PAUSED_BUFFERING, STATE_SUPPRESSED, STATE_SUPPRESSED_BUFFERING, STATE_ENDED, STATE_STOPPED, STATE_FAILED, STATE_INTERRUPTED_BY_AD, STATE_ABANDONED, }) }) @Retention(java.lang.annotation.RetentionPolicy.SOURCE) @Retention(java.lang.annotation.RetentionPolicy.SOURCE) public @interface State {} public @interface State {} /** /** * Converts playback state to string. * Converts playback state to string. * @hide */ */ public static String stateToString(@State int value) { public static String stateToString(@State int value) { switch (value) { switch (value) { Loading @@ -71,6 +104,26 @@ public final class PlaybackStateEvent implements Parcelable { return "STATE_PLAYING"; return "STATE_PLAYING"; case STATE_PAUSED: case STATE_PAUSED: return "STATE_PAUSED"; return "STATE_PAUSED"; case STATE_SEEKING: return "STATE_SEEKING"; case STATE_BUFFERING: return "STATE_BUFFERING"; case STATE_PAUSED_BUFFERING: return "STATE_PAUSED_BUFFERING"; case STATE_SUPPRESSED: return "STATE_SUPPRESSED"; case STATE_SUPPRESSED_BUFFERING: return "STATE_SUPPRESSED_BUFFERING"; case STATE_ENDED: return "STATE_ENDED"; case STATE_STOPPED: return "STATE_STOPPED"; case STATE_FAILED: return "STATE_FAILED"; case STATE_INTERRUPTED_BY_AD: return "STATE_INTERRUPTED_BY_AD"; case STATE_ABANDONED: return "STATE_ABANDONED"; default: default: return Integer.toHexString(value); return Integer.toHexString(value); } } Loading @@ -83,14 +136,13 @@ public final class PlaybackStateEvent implements Parcelable { */ */ public PlaybackStateEvent( public PlaybackStateEvent( int state, int state, long timeSincePlaybackCreatedMillis) { long timeSinceCreatedMillis) { this.mTimeSinceCreatedMillis = timeSinceCreatedMillis; this.mState = state; this.mState = state; this.mTimeSincePlaybackCreatedMillis = timeSincePlaybackCreatedMillis; } } /** /** * Gets playback state. * Gets playback state. * @return */ */ public int getState() { public int getState() { return mState; return mState; Loading @@ -98,9 +150,12 @@ public final class PlaybackStateEvent implements Parcelable { /** /** * Gets time since the corresponding playback is created in millisecond. * Gets time since the corresponding playback is created in millisecond. * @return the timestamp since the playback is created, or -1 if unknown. */ */ public long getTimeSincePlaybackCreatedMillis() { @Override return mTimeSincePlaybackCreatedMillis; @IntRange(from = -1) public long getTimeSinceCreatedMillis() { return mTimeSinceCreatedMillis; } } @Override @Override Loading @@ -109,18 +164,18 @@ public final class PlaybackStateEvent implements Parcelable { if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false; PlaybackStateEvent that = (PlaybackStateEvent) o; PlaybackStateEvent that = (PlaybackStateEvent) o; return mState == that.mState return mState == that.mState && mTimeSincePlaybackCreatedMillis == that.mTimeSincePlaybackCreatedMillis; && mTimeSinceCreatedMillis == that.mTimeSinceCreatedMillis; } } @Override @Override public int hashCode() { public int hashCode() { return Objects.hash(mState, mTimeSincePlaybackCreatedMillis); return Objects.hash(mState, mTimeSinceCreatedMillis); } } @Override @Override public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeInt(mState); dest.writeInt(mState); dest.writeLong(mTimeSincePlaybackCreatedMillis); dest.writeLong(mTimeSinceCreatedMillis); } } @Override @Override Loading @@ -131,10 +186,10 @@ public final class PlaybackStateEvent implements Parcelable { /** @hide */ /** @hide */ /* package-private */ PlaybackStateEvent(@NonNull Parcel in) { /* package-private */ PlaybackStateEvent(@NonNull Parcel in) { int state = in.readInt(); int state = in.readInt(); long timeSincePlaybackCreatedMillis = in.readLong(); long timeSinceCreatedMillis = in.readLong(); this.mState = state; this.mState = state; this.mTimeSincePlaybackCreatedMillis = timeSincePlaybackCreatedMillis; this.mTimeSinceCreatedMillis = timeSinceCreatedMillis; } } public static final @NonNull Parcelable.Creator<PlaybackStateEvent> CREATOR = public static final @NonNull Parcelable.Creator<PlaybackStateEvent> CREATOR = Loading @@ -150,4 +205,43 @@ public final class PlaybackStateEvent implements Parcelable { } } }; }; /** * A builder for {@link PlaybackStateEvent} */ public static final class Builder { private int mState = STATE_NOT_STARTED; private long mTimeSinceCreatedMillis = -1; /** * Creates a new Builder. */ public Builder() { } /** * Sets playback state. */ public @NonNull Builder setState(@State int value) { mState = value; return this; } /** * Sets timestamp since the creation in milliseconds. * @param value the timestamp since the creation in milliseconds. * -1 indicates the value is unknown. */ public @NonNull Builder setTimeSinceCreatedMillis(@IntRange(from = -1) long value) { mTimeSinceCreatedMillis = value; return this; } /** Builds the instance. */ public @NonNull PlaybackStateEvent build() { PlaybackStateEvent o = new PlaybackStateEvent( mState, mTimeSinceCreatedMillis); return o; } } } }