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

Commit 2276aab2 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Add RouteListingPref.Item disable reason and flags

Test: atest MediaRouter2HostSideTest
Bug: 241888071
Bug: 235352899
Change-Id: Ia69778e624929f0cb932370310a4a2b19fc481b0
parent 8b11b90b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -23906,11 +23906,17 @@ package android.media {
  }
  public static final class RouteListingPreference.Item implements android.os.Parcelable {
    ctor public RouteListingPreference.Item(@NonNull String);
    ctor public RouteListingPreference.Item(@NonNull String, int, int);
    method public int describeContents();
    method public int getDisableReason();
    method public int getFlags();
    method @NonNull public String getRouteId();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.RouteListingPreference.Item> CREATOR;
    field public static final int DISABLE_REASON_NONE = 0; // 0x0
    field public static final int DISABLE_REASON_SUBSCRIPTION_REQUIRED = 1; // 0x1
    field public static final int FLAG_ONGOING_SESSION = 1; // 0x1
    field public static final int FLAG_SUGGESTED_ROUTE = 2; // 0x2
  }
  public final class RoutingSessionInfo implements android.os.Parcelable {
+80 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
@@ -23,6 +24,8 @@ import android.text.TextUtils;

import com.android.internal.util.Preconditions;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -111,6 +114,45 @@ public final class RouteListingPreference implements Parcelable {
    /** Holds preference information for a specific route in a media routing listing. */
    public static final class Item implements Parcelable {

        /** @hide */
        @Retention(RetentionPolicy.SOURCE)
        @IntDef(
                flag = true,
                prefix = {"FLAG_"},
                value = {FLAG_ONGOING_SESSION, FLAG_SUGGESTED_ROUTE})
        public @interface Flags {}

        /**
         * The corresponding route is already hosting a session with the app that owns this listing
         * preference.
         */
        public static final int FLAG_ONGOING_SESSION = 1;

        /**
         * The corresponding route is specially likely to be selected by the user.
         *
         * <p>A UI reflecting this preference may reserve a specific space for suggested routes,
         * making it more accessible to the user. If the number of suggested routes exceeds the
         * number supported by the UI, the routes listed first in {@link
         * RouteListingPreference#getItems()} will take priority.
         */
        public static final int FLAG_SUGGESTED_ROUTE = 1 << 1;

        /** @hide */
        @Retention(RetentionPolicy.SOURCE)
        @IntDef(
                prefix = {"DISABLE_REASON_"},
                value = {DISABLE_REASON_NONE, DISABLE_REASON_SUBSCRIPTION_REQUIRED})
        public @interface DisableReason {}

        /** The corresponding route is available for routing. */
        public static final int DISABLE_REASON_NONE = 0;
        /**
         * The corresponding route requires a special subscription in order to be available for
         * routing.
         */
        public static final int DISABLE_REASON_SUBSCRIPTION_REQUIRED = 1;

        @NonNull
        public static final Creator<Item> CREATOR =
                new Creator<>() {
@@ -126,21 +168,29 @@ public final class RouteListingPreference implements Parcelable {
                };

        @NonNull private final String mRouteId;
        @Flags private final int mFlags;
        @DisableReason private final int mDisableReason;

        /**
         * Creates an instance with the given value.
         *
         * @param routeId See {@link #getRouteId()}. Must not be empty.
         * @param flags See {@link #getFlags()}.
         * @param disableReason See {@link #getDisableReason()}.
         */
        public Item(@NonNull String routeId) {
        public Item(@NonNull String routeId, @Flags int flags, @DisableReason int disableReason) {
            Preconditions.checkArgument(!TextUtils.isEmpty(routeId));
            mRouteId = routeId;
            mFlags = flags;
            mDisableReason = disableReason;
        }

        private Item(Parcel in) {
            String routeId = in.readString();
            Preconditions.checkArgument(!TextUtils.isEmpty(routeId));
            mRouteId = routeId;
            mFlags = in.readInt();
            mDisableReason = in.readInt();
        }

        /** Returns the id of the route that corresponds to this route listing preference item. */
@@ -149,6 +199,29 @@ public final class RouteListingPreference implements Parcelable {
            return mRouteId;
        }

        /**
         * Returns the flags associated to the route that corresponds to this item.
         *
         * @see #FLAG_ONGOING_SESSION
         * @see #FLAG_SUGGESTED_ROUTE
         */
        @Flags
        public int getFlags() {
            return mFlags;
        }

        /**
         * Returns the reason for the corresponding route to be disabled, or {@link
         * #DISABLE_REASON_NONE} if the route is not disabled.
         *
         * @see #DISABLE_REASON_NONE
         * @see #DISABLE_REASON_SUBSCRIPTION_REQUIRED
         */
        @DisableReason
        public int getDisableReason() {
            return mDisableReason;
        }

        // Item Parcelable implementation.

        @Override
@@ -159,6 +232,8 @@ public final class RouteListingPreference implements Parcelable {
        @Override
        public void writeToParcel(@NonNull Parcel dest, int flags) {
            dest.writeString(mRouteId);
            dest.writeInt(mFlags);
            dest.writeInt(mDisableReason);
        }

        // Equals and hashCode.
@@ -172,12 +247,14 @@ public final class RouteListingPreference implements Parcelable {
                return false;
            }
            Item item = (Item) other;
            return mRouteId.equals(item.mRouteId);
            return mRouteId.equals(item.mRouteId)
                    && mFlags == item.mFlags
                    && mDisableReason == item.mDisableReason;
        }

        @Override
        public int hashCode() {
            return Objects.hash(mRouteId);
            return Objects.hash(mRouteId, mFlags, mDisableReason);
        }
    }
}