Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15c52f69 authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

Move Rating and MediaDescription into mainline module

Bug: 119539695
Test: pass MediaSessionTest, MediaControllerTest and
      MediaSessionManagerTest
Change-Id: I2274a473700b6ea432e368aeeb5201d449d53635
parent b391c999
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -66,7 +66,9 @@ filegroup {
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",
+22 −1
Original line number Diff line number Diff line
/*
 * 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;
@@ -375,6 +391,11 @@ public class MediaDescription implements Parcelable {
            return this;
        }

        /**
         * Build {@link MediaDescription}.
         *
         * @return a new media description.
         */
        public MediaDescription build() {
            return new MediaDescription(mMediaId, mTitle, mSubtitle, mDescription, mIcon, mIconUri,
                    mExtras, mMediaUri);
+14 −15
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import java.lang.annotation.RetentionPolicy;
 * 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 @@ public final class Rating implements Parcelable {
     * 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 @@ public final class Rating implements Parcelable {
        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
@@ -281,16 +280,16 @@ public final class Rating implements Parcelable {
     *    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;
    }

    /**