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

Commit d02172c6 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun
Browse files

Add "name" to RoutingSessionInfo

The name of dynamic group can be set by providers.

Bug: 150249359
Test: cts tests
Change-Id: I1b74fe5b7976eb0ad6a52fd29203446dde480de8
parent f416c7f9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27479,6 +27479,7 @@ package android.media {
    method @Nullable public android.os.Bundle getControlHints();
    method @NonNull public java.util.List<java.lang.String> getDeselectableRoutes();
    method @NonNull public String getId();
    method @Nullable public CharSequence getName();
    method @NonNull public java.util.List<java.lang.String> getSelectableRoutes();
    method @NonNull public java.util.List<java.lang.String> getSelectedRoutes();
    method @NonNull public java.util.List<java.lang.String> getTransferableRoutes();
@@ -27506,6 +27507,7 @@ package android.media {
    method @NonNull public android.media.RoutingSessionInfo.Builder removeSelectedRoute(@NonNull String);
    method @NonNull public android.media.RoutingSessionInfo.Builder removeTransferableRoute(@NonNull String);
    method @NonNull public android.media.RoutingSessionInfo.Builder setControlHints(@Nullable android.os.Bundle);
    method @NonNull public android.media.RoutingSessionInfo.Builder setName(@Nullable CharSequence);
    method @NonNull public android.media.RoutingSessionInfo.Builder setVolume(int);
    method @NonNull public android.media.RoutingSessionInfo.Builder setVolumeHandling(int);
    method @NonNull public android.media.RoutingSessionInfo.Builder setVolumeMax(int);
+34 −11
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public final class RoutingSessionInfo implements Parcelable {
    private static final String TAG = "RoutingSessionInfo";

    final String mId;
    final CharSequence mName;
    final String mClientPackageName;
    @Nullable
    final String mProviderId;
@@ -69,6 +70,7 @@ public final class RoutingSessionInfo implements Parcelable {
        Objects.requireNonNull(builder, "builder must not be null.");

        mId = builder.mId;
        mName = builder.mName;
        mClientPackageName = builder.mClientPackageName;
        mProviderId = builder.mProviderId;

@@ -94,6 +96,7 @@ public final class RoutingSessionInfo implements Parcelable {
        Objects.requireNonNull(src, "src must not be null.");

        mId = ensureString(src.readString());
        mName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(src);
        mClientPackageName = ensureString(src.readString());
        mProviderId = src.readString();

@@ -111,10 +114,7 @@ public final class RoutingSessionInfo implements Parcelable {
    }

    private static String ensureString(String str) {
        if (str != null) {
            return str;
        }
        return "";
        return str != null ? str : "";
    }

    private static <T> List<T> ensureList(List<? extends T> list) {
@@ -142,6 +142,14 @@ public final class RoutingSessionInfo implements Parcelable {
        }
    }

    /**
     * Gets the user-visible name of the session. It may be {@code null}.
     */
    @Nullable
    public CharSequence getName() {
        return mName;
    }

    /**
     * Gets the original id set by {@link Builder#Builder(String, String)}.
     * @hide
@@ -169,7 +177,7 @@ public final class RoutingSessionInfo implements Parcelable {
    }

    /**
     * Gets the list of ids of selected routes for the session. It shouldn't be empty.
     * Gets the list of IDs of selected routes for the session. It shouldn't be empty.
     */
    @NonNull
    public List<String> getSelectedRoutes() {
@@ -177,7 +185,7 @@ public final class RoutingSessionInfo implements Parcelable {
    }

    /**
     * Gets the list of ids of selectable routes for the session.
     * Gets the list of IDs of selectable routes for the session.
     */
    @NonNull
    public List<String> getSelectableRoutes() {
@@ -185,7 +193,7 @@ public final class RoutingSessionInfo implements Parcelable {
    }

    /**
     * Gets the list of ids of deselectable routes for the session.
     * Gets the list of IDs of deselectable routes for the session.
     */
    @NonNull
    public List<String> getDeselectableRoutes() {
@@ -193,7 +201,7 @@ public final class RoutingSessionInfo implements Parcelable {
    }

    /**
     * Gets the list of ids of transferable routes for the session.
     * Gets the list of IDs of transferable routes for the session.
     */
    @NonNull
    public List<String> getTransferableRoutes() {
@@ -255,6 +263,7 @@ public final class RoutingSessionInfo implements Parcelable {
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(mId);
        dest.writeCharSequence(mName);
        dest.writeString(mClientPackageName);
        dest.writeString(mProviderId);
        dest.writeStringList(mSelectedRoutes);
@@ -279,6 +288,7 @@ public final class RoutingSessionInfo implements Parcelable {

        RoutingSessionInfo other = (RoutingSessionInfo) obj;
        return Objects.equals(mId, other.mId)
                && Objects.equals(mName, other.mName)
                && Objects.equals(mClientPackageName, other.mClientPackageName)
                && Objects.equals(mProviderId, other.mProviderId)
                && Objects.equals(mSelectedRoutes, other.mSelectedRoutes)
@@ -292,7 +302,7 @@ public final class RoutingSessionInfo implements Parcelable {

    @Override
    public int hashCode() {
        return Objects.hash(mId, mClientPackageName, mProviderId,
        return Objects.hash(mId, mName, mClientPackageName, mProviderId,
                mSelectedRoutes, mSelectableRoutes, mDeselectableRoutes, mTransferableRoutes,
                mVolumeMax, mVolumeHandling, mVolume);
    }
@@ -302,6 +312,7 @@ public final class RoutingSessionInfo implements Parcelable {
        StringBuilder result = new StringBuilder()
                .append("RoutingSessionInfo{ ")
                .append("sessionId=").append(mId)
                .append(", name=").append(mName)
                .append(", selectedRoutes={")
                .append(String.join(",", mSelectedRoutes))
                .append("}")
@@ -345,6 +356,7 @@ public final class RoutingSessionInfo implements Parcelable {
    public static final class Builder {
        // TODO: Reorder these (important ones first)
        final String mId;
        CharSequence mName;
        final String mClientPackageName;
        String mProviderId;
        final List<String> mSelectedRoutes;
@@ -357,6 +369,7 @@ public final class RoutingSessionInfo implements Parcelable {
        Bundle mControlHints;
        boolean mIsSystemSession;

        //TODO: Remove this.
        /**
         * Constructor for builder to create {@link RoutingSessionInfo}.
         * <p>
@@ -374,10 +387,10 @@ public final class RoutingSessionInfo implements Parcelable {
            if (TextUtils.isEmpty(id)) {
                throw new IllegalArgumentException("id must not be empty");
            }
            Objects.requireNonNull(clientPackageName, "clientPackageName must not be null");

            mId = id;
            mClientPackageName = clientPackageName;
            mClientPackageName =
                    Objects.requireNonNull(clientPackageName, "clientPackageName must not be null");
            mSelectedRoutes = new ArrayList<>();
            mSelectableRoutes = new ArrayList<>();
            mDeselectableRoutes = new ArrayList<>();
@@ -394,6 +407,7 @@ public final class RoutingSessionInfo implements Parcelable {
            Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");

            mId = sessionInfo.mId;
            mName = sessionInfo.mName;
            mClientPackageName = sessionInfo.mClientPackageName;
            mProviderId = sessionInfo.mProviderId;

@@ -410,6 +424,15 @@ public final class RoutingSessionInfo implements Parcelable {
            mIsSystemSession = sessionInfo.mIsSystemSession;
        }

        /**
         * Sets the user-visible name of the session.
         */
        @NonNull
        public Builder setName(@Nullable CharSequence name) {
            mName = name;
            return this;
        }

        /**
         * Sets the provider ID of the session.
         *