am e2b8dab0: am 5604a85a: Merge changes Ia3bc5b0d,I26e662ff into lmp-mr1-dev

* commit 'e2b8dab0d0f541e4a014536f8088ac51afc06c49':
  Add extras to the PlaybackState
  Add setRatingType to MediaSession
This commit is contained in:
RoboErik
2014-11-05 18:55:46 +00:00
committed by Android Git Automerger
3 changed files with 56 additions and 4 deletions

View File

@@ -16310,6 +16310,7 @@ package android.media.session {
method public void setPlaybackToRemote(android.media.VolumeProvider);
method public void setQueue(java.util.List<android.media.session.MediaSession.QueueItem>);
method public void setQueueTitle(java.lang.CharSequence);
method public void setRatingType(int);
method public void setSessionActivity(android.app.PendingIntent);
field public static final int FLAG_HANDLES_MEDIA_BUTTONS = 1; // 0x1
field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
@@ -16368,6 +16369,7 @@ package android.media.session {
method public long getBufferedPosition();
method public java.util.List<android.media.session.PlaybackState.CustomAction> getCustomActions();
method public java.lang.CharSequence getErrorMessage();
method public android.os.Bundle getExtras();
method public long getLastPositionUpdateTime();
method public float getPlaybackSpeed();
method public long getPosition();
@@ -16412,6 +16414,7 @@ package android.media.session {
method public android.media.session.PlaybackState.Builder setActiveQueueItemId(long);
method public android.media.session.PlaybackState.Builder setBufferedPosition(long);
method public android.media.session.PlaybackState.Builder setErrorMessage(java.lang.CharSequence);
method public android.media.session.PlaybackState.Builder setExtras(android.os.Bundle);
method public android.media.session.PlaybackState.Builder setState(int, long, float, long);
method public android.media.session.PlaybackState.Builder setState(int, long, float);
}

View File

@@ -448,6 +448,27 @@ public final class MediaSession {
}
}
/**
* Set the style of rating used by this session. Apps trying to set the
* rating should use this style. Must be one of the following:
* <ul>
* <li>{@link Rating#RATING_NONE}</li>
* <li>{@link Rating#RATING_3_STARS}</li>
* <li>{@link Rating#RATING_4_STARS}</li>
* <li>{@link Rating#RATING_5_STARS}</li>
* <li>{@link Rating#RATING_HEART}</li>
* <li>{@link Rating#RATING_PERCENTAGE}</li>
* <li>{@link Rating#RATING_THUMB_UP_DOWN}</li>
* </ul>
*/
public void setRatingType(int type) {
try {
mBinder.setRatingType(type);
} catch (RemoteException e) {
Log.e(TAG, "Error in setRatingType.", e);
}
}
/**
* Set some extras that can be associated with the {@link MediaSession}. No assumptions should
* be made as to how a {@link MediaController} will handle these extras.

View File

@@ -16,6 +16,7 @@
package android.media.session;
import android.annotation.DrawableRes;
import android.annotation.Nullable;
import android.media.RemoteControlClient;
import android.os.Bundle;
import android.os.Parcel;
@@ -232,11 +233,12 @@ public final class PlaybackState implements Parcelable {
private final CharSequence mErrorMessage;
private final long mUpdateTime;
private final long mActiveItemId;
private final Bundle mExtras;
private PlaybackState(int state, long position, long updateTime, float speed,
long bufferedPosition, long transportControls,
List<PlaybackState.CustomAction> customActions, long activeItemId,
CharSequence error) {
CharSequence error, Bundle extras) {
mState = state;
mPosition = position;
mSpeed = speed;
@@ -246,6 +248,7 @@ public final class PlaybackState implements Parcelable {
mCustomActions = new ArrayList<>(customActions);
mActiveItemId = activeItemId;
mErrorMessage = error;
mExtras = extras;
}
private PlaybackState(Parcel in) {
@@ -258,7 +261,7 @@ public final class PlaybackState implements Parcelable {
mCustomActions = in.createTypedArrayList(CustomAction.CREATOR);
mActiveItemId = in.readLong();
mErrorMessage = in.readCharSequence();
mExtras = in.readBundle();
}
@Override
@@ -293,6 +296,7 @@ public final class PlaybackState implements Parcelable {
dest.writeTypedList(mCustomActions);
dest.writeLong(mActiveItemId);
dest.writeCharSequence(mErrorMessage);
dest.writeBundle(mExtras);
}
/**
@@ -306,6 +310,7 @@ public final class PlaybackState implements Parcelable {
* <li> {@link PlaybackState#STATE_REWINDING}</li>
* <li> {@link PlaybackState#STATE_BUFFERING}</li>
* <li> {@link PlaybackState#STATE_ERROR}</li>
* </ul>
*/
public int getState() {
return mState;
@@ -393,6 +398,15 @@ public final class PlaybackState implements Parcelable {
return mActiveItemId;
}
/**
* Get any custom extras that were set on this playback state.
*
* @return The extras for this state or null.
*/
public @Nullable Bundle getExtras() {
return mExtras;
}
/**
* Get the {@link PlaybackState} state for the given
* {@link RemoteControlClient} state.
@@ -737,6 +751,7 @@ public final class PlaybackState implements Parcelable {
private CharSequence mErrorMessage;
private long mUpdateTime;
private long mActiveItemId = MediaSession.QueueItem.UNKNOWN_ID;
private Bundle mExtras;
/**
* Creates an initially empty state builder.
@@ -765,6 +780,7 @@ public final class PlaybackState implements Parcelable {
mErrorMessage = from.mErrorMessage;
mUpdateTime = from.mUpdateTime;
mActiveItemId = from.mActiveItemId;
mExtras = from.mExtras;
}
/**
@@ -947,13 +963,25 @@ public final class PlaybackState implements Parcelable {
}
/**
* Build and return the {@link PlaybackState} instance with these values.
* Set any custom extras to be included with the playback state.
*
* @param extras The extras to include.
* @return this
*/
public Builder setExtras(Bundle extras) {
mExtras = extras;
return this;
}
/**
* Build and return the {@link PlaybackState} instance with these
* values.
*
* @return A new state instance.
*/
public PlaybackState build() {
return new PlaybackState(mState, mPosition, mUpdateTime, mSpeed, mBufferedPosition,
mActions, mCustomActions, mActiveItemId, mErrorMessage);
mActions, mCustomActions, mActiveItemId, mErrorMessage, mExtras);
}
}
}