diff options
| author | 2022-12-02 13:53:22 +0000 | |
|---|---|---|
| committer | 2022-12-02 13:53:22 +0000 | |
| commit | 0a968fefbb05ea1da9750024aa9a085655715ce2 (patch) | |
| tree | d651c49f9e2ebbe8f77d0e0ae21a852ba8239648 | |
| parent | fa648d660ac81005b2832f1c34728a09c0868c31 (diff) | |
| parent | 2276aab27cdec17444cae7edb91fdb5da82da128 (diff) | |
Merge "Add RouteListingPref.Item disable reason and flags"
| -rw-r--r-- | core/api/current.txt | 8 | ||||
| -rw-r--r-- | media/java/android/media/RouteListingPreference.java | 83 |
2 files changed, 87 insertions, 4 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index f7a9a505f80b..f6ec91b36c91 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -23953,11 +23953,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 { diff --git a/media/java/android/media/RouteListingPreference.java b/media/java/android/media/RouteListingPreference.java index 26b190b9fd81..62f233e42989 100644 --- a/media/java/android/media/RouteListingPreference.java +++ b/media/java/android/media/RouteListingPreference.java @@ -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); } } } |