OSDN Git Service

Add setRatingType to MediaSession
authorRoboErik <epastern@google.com>
Tue, 4 Nov 2014 21:00:22 +0000 (13:00 -0800)
committerRoboErik <epastern@google.com>
Tue, 4 Nov 2014 21:14:19 +0000 (13:14 -0800)
This was missing in L. Needed to tell controllers how to rate content.

bug:18051829
Change-Id: I26e662ff04f77ed7f2922bf9e74acf74c850547b

api/current.txt
media/java/android/media/session/MediaSession.java
media/java/android/media/session/PlaybackState.java

index 6851bbf..4162611 100644 (file)
@@ -16304,6 +16304,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
index 86da80a..ee296d0 100644 (file)
@@ -449,6 +449,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.
      * Keys should be fully qualified (e.g. com.example.MY_EXTRA) to avoid conflicts.
index 267d1ff..2e9e0fb 100644 (file)
@@ -306,6 +306,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;