Move Rating and MediaDescription into mainline module

Bug: 119539695
Test: pass MediaSessionTest, MediaControllerTest and
      MediaSessionManagerTest
Change-Id: I2274a473700b6ea432e368aeeb5201d449d53635
diff --git a/media/Android.bp b/media/Android.bp
index 3181a29..e7d5faf 100644
--- a/media/Android.bp
+++ b/media/Android.bp
@@ -66,7 +66,9 @@
 filegroup {
     name: "media1-srcs",
     srcs: [
+        "apex/java/android/media/MediaDescription.java",
         "apex/java/android/media/MediaParceledListSlice.java",
+        "apex/java/android/media/Rating.java",
         "apex/java/android/media/VolumeProvider.java",
         "apex/java/android/media/browse/MediaBrowser.java",
         "apex/java/android/media/browse/MediaBrowserUtils.java",
diff --git a/media/java/android/media/MediaDescription.aidl b/media/apex/java/android/media/MediaDescription.aidl
similarity index 100%
rename from media/java/android/media/MediaDescription.aidl
rename to media/apex/java/android/media/MediaDescription.aidl
diff --git a/media/java/android/media/MediaDescription.java b/media/apex/java/android/media/MediaDescription.java
similarity index 93%
rename from media/java/android/media/MediaDescription.java
rename to media/apex/java/android/media/MediaDescription.java
index 31079e5..39eeb3e 100644
--- a/media/java/android/media/MediaDescription.java
+++ b/media/apex/java/android/media/MediaDescription.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2019 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;
 
 import android.annotation.Nullable;
@@ -226,7 +242,7 @@
             return false;
         }
 
-        if (!(o instanceof MediaDescription)){
+        if (!(o instanceof MediaDescription)) {
             return false;
         }
 
@@ -375,6 +391,11 @@
             return this;
         }
 
+        /**
+         * Build {@link MediaDescription}.
+         *
+         * @return a new media description.
+         */
         public MediaDescription build() {
             return new MediaDescription(mMediaId, mTitle, mSubtitle, mDescription, mIcon, mIconUri,
                     mExtras, mMediaUri);
diff --git a/media/java/android/media/Rating.aidl b/media/apex/java/android/media/Rating.aidl
similarity index 100%
rename from media/java/android/media/Rating.aidl
rename to media/apex/java/android/media/Rating.aidl
diff --git a/media/java/android/media/Rating.java b/media/apex/java/android/media/Rating.java
similarity index 93%
rename from media/java/android/media/Rating.java
rename to media/apex/java/android/media/Rating.java
index 04d5364f..ffe7e48 100644
--- a/media/java/android/media/Rating.java
+++ b/media/apex/java/android/media/Rating.java
@@ -33,7 +33,7 @@
  * through one of the factory methods.
  */
 public final class Rating implements Parcelable {
-    private final static String TAG = "Rating";
+    private static final String TAG = "Rating";
 
     /**
      * @hide
@@ -55,40 +55,40 @@
      * type, but can be used by other classes to indicate they do not support
      * Rating.
      */
-    public final static int RATING_NONE = 0;
+    public static final int RATING_NONE = 0;
 
     /**
      * A rating style with a single degree of rating, "heart" vs "no heart". Can be used to
      * indicate the content referred to is a favorite (or not).
      */
-    public final static int RATING_HEART = 1;
+    public static final int RATING_HEART = 1;
 
     /**
      * A rating style for "thumb up" vs "thumb down".
      */
-    public final static int RATING_THUMB_UP_DOWN = 2;
+    public static final int RATING_THUMB_UP_DOWN = 2;
 
     /**
      * A rating style with 0 to 3 stars.
      */
-    public final static int RATING_3_STARS = 3;
+    public static final int RATING_3_STARS = 3;
 
     /**
      * A rating style with 0 to 4 stars.
      */
-    public final static int RATING_4_STARS = 4;
+    public static final int RATING_4_STARS = 4;
 
     /**
      * A rating style with 0 to 5 stars.
      */
-    public final static int RATING_5_STARS = 5;
+    public static final int RATING_5_STARS = 5;
 
     /**
      * A rating style expressed as a percentage.
      */
-    public final static int RATING_PERCENTAGE = 6;
+    public static final int RATING_PERCENTAGE = 6;
 
-    private final static float RATING_NOT_RATED = -1.0f;
+    private static final float RATING_NOT_RATED = -1.0f;
 
     private final int mRatingStyle;
 
@@ -116,8 +116,7 @@
         dest.writeFloat(mRatingValue);
     }
 
-    public static final Parcelable.Creator<Rating> CREATOR
-            = new Parcelable.Creator<Rating>() {
+    public static final Parcelable.Creator<Rating> CREATOR = new Parcelable.Creator<Rating>() {
         /**
          * Rebuilds a Rating previously stored with writeToParcel().
          * @param p    Parcel object to read the Rating from
@@ -205,7 +204,7 @@
                 break;
             default:
                 Log.e(TAG, "Invalid rating style (" + starRatingStyle + ") for a star rating");
-                        return null;
+                return null;
         }
         if ((starRating < 0.0f) || (starRating > maxRating)) {
             Log.e(TAG, "Trying to set out of range star-based rating");
@@ -281,16 +280,16 @@
      *    not star-based, or if it is unrated.
      */
     public float getStarRating() {
+        float ratingValue = -1.0f;
         switch (mRatingStyle) {
             case RATING_3_STARS:
             case RATING_4_STARS:
             case RATING_5_STARS:
                 if (isRated()) {
-                    return mRatingValue;
+                    ratingValue = mRatingValue;
                 }
-            default:
-                return -1.0f;
         }
+        return ratingValue;
     }
 
     /**