OSDN Git Service

MediaSession2: Remove rating style from session
authorHyundo Moon <hdmoon@google.com>
Wed, 21 Feb 2018 06:29:26 +0000 (15:29 +0900)
committerJaewan Kim <jaewan@google.com>
Wed, 21 Feb 2018 17:00:23 +0000 (02:00 +0900)
Bug: 73615699
Test: Passed MediaController2Test
Change-Id: Icc35bf982e0943ba7586003bf30dd6dfa90d747e

media/java/android/media/MediaController2.java
media/java/android/media/MediaLibraryService2.java
media/java/android/media/MediaMetadata2.java
media/java/android/media/MediaSession2.java
media/java/android/media/update/MediaController2Provider.java
media/java/android/media/update/MediaSession2Provider.java

index bfd1fd4..6682e08 100644 (file)
@@ -521,24 +521,6 @@ public class MediaController2 implements AutoCloseable {
     }
 
     /**
-     * Get the rating type supported by the session. One of:
-     * <ul>
-     * <li>{@link Rating2#RATING_NONE}</li>
-     * <li>{@link Rating2#RATING_HEART}</li>
-     * <li>{@link Rating2#RATING_THUMB_UP_DOWN}</li>
-     * <li>{@link Rating2#RATING_3_STARS}</li>
-     * <li>{@link Rating2#RATING_4_STARS}</li>
-     * <li>{@link Rating2#RATING_5_STARS}</li>
-     * <li>{@link Rating2#RATING_PERCENTAGE}</li>
-     * </ul>
-     *
-     * @return The supported rating type
-     */
-    public int getRatingType() {
-        return mProvider.getRatingType_impl();
-    }
-
-    /**
      * Get an intent for launching UI associated with this session if one exists.
      *
      * @return A {@link PendingIntent} to launch UI or null.
@@ -571,7 +553,12 @@ public class MediaController2 implements AutoCloseable {
 
     /**
      * Rate the media. This will cause the rating to be set for the current user.
-     * The Rating type must match the type returned by {@link #getRatingType()}.
+     * The rating style must follow the user rating style from the session.
+     * You can get the rating style from the session through the
+     * {@link MediaMetadata#getRating(String)} with the key
+     * {@link MediaMetadata#METADATA_KEY_USER_RATING}.
+     * <p>
+     * If the user rating was {@code null}, the media item does not accept setting user rating.
      *
      * @param mediaId The id of the media
      * @param rating The rating to set
index c984697..19cefa7 100644 (file)
@@ -252,11 +252,6 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
         }
 
         @Override
-        public MediaLibrarySessionBuilder setRatingType(int type) {
-            return super.setRatingType(type);
-        }
-
-        @Override
         public MediaLibrarySessionBuilder setSessionActivity(@Nullable PendingIntent pi) {
             return super.setSessionActivity(pi);
         }
index 54a9057..fabf42b 100644 (file)
@@ -436,6 +436,9 @@ public final class MediaMetadata2 {
     /**
      * Return a {@link Rating2} for the given key or null if no rating exists for
      * the given key.
+     * <p>
+     * For the {@link #METADATA_KEY_USER_RATING}, A {@code null} return value means that user rating
+     * cannot be set by {@link MediaController2}.
      *
      * @param key The key the value is stored under
      * @return A {@link Rating2} or {@code null}
index 0258dca..83b083a 100644 (file)
@@ -87,8 +87,7 @@ public class MediaSession2 implements AutoCloseable {
     // TODO(jaewan): Should we define IntDef? Currently we don't have to allow subclass to add more.
     // TODO(jaewan): Shouldn't we pull out?
     // TODO(jaewan): Should we also protect getters not related with metadata?
-    //               Getters are getRatingType(), getPlaybackState(), getSessionActivity(),
-    //               getPlaylistParams())
+    //               Getters are getPlaybackState(), getSessionActivity(), getPlaylistParams()
     // Next ID: 23
     /**
      * Command code for the custom command which can be defined by string action in the
@@ -454,6 +453,11 @@ public class MediaSession2 implements AutoCloseable {
         /**
          * Called when a controller set rating of a media item through
          * {@link MediaController2#setRating(String, Rating2)}.
+         * <p>
+         * To allow setting user rating for a {@link MediaItem2}, the media item's metadata
+         * should have {@link Rating2} with the key {@link MediaMetadata#METADATA_KEY_USER_RATING},
+         * in order to provide possible rating style for controller. Controller will follow the
+         * rating style.
          *
          * @param controller controller information
          * @param mediaId media id from the controller
@@ -621,24 +625,6 @@ public class MediaSession2 implements AutoCloseable {
         }
 
         /**
-         * 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 Rating2#RATING_NONE}</li>
-         * <li>{@link Rating2#RATING_3_STARS}</li>
-         * <li>{@link Rating2#RATING_4_STARS}</li>
-         * <li>{@link Rating2#RATING_5_STARS}</li>
-         * <li>{@link Rating2#RATING_HEART}</li>
-         * <li>{@link Rating2#RATING_PERCENTAGE}</li>
-         * <li>{@link Rating2#RATING_THUMB_UP_DOWN}</li>
-         * </ul>
-         */
-        U setRatingType(@Rating2.Style int type) {
-            mProvider.setRatingType_impl(type);
-            return (U) this;
-        }
-
-        /**
          * Set an intent for launching UI for this Session. This can be used as a
          * quick link to an ongoing media screen. The intent should be for an
          * activity that may be started using {@link Context#startActivity(Intent)}.
@@ -710,11 +696,6 @@ public class MediaSession2 implements AutoCloseable {
         }
 
         @Override
-        public Builder setRatingType(@Rating2.Style int type) {
-            return super.setRatingType(type);
-        }
-
-        @Override
         public Builder setSessionActivity(@Nullable PendingIntent pi) {
             return super.setSessionActivity(pi);
         }
index 738bd0c..8d9efd5 100644 (file)
@@ -43,7 +43,6 @@ public interface MediaController2Provider extends TransportControlProvider {
     boolean isConnected_impl();
 
     PendingIntent getSessionActivity_impl();
-    int getRatingType_impl();
 
     void setVolumeTo_impl(int value, int flags);
     void adjustVolume_impl(int direction, int flags);
index 41162e0..159e230 100644 (file)
@@ -117,7 +117,6 @@ public interface MediaSession2Provider extends TransportControlProvider {
 
     interface BuilderBaseProvider<T extends MediaSession2, C extends SessionCallback> {
         void setVolumeProvider_impl(VolumeProvider2 volumeProvider);
-        void setRatingType_impl(int type);
         void setSessionActivity_impl(PendingIntent pi);
         void setId_impl(String id);
         void setSessionCallback_impl(Executor executor, C callback);