Merge "Add "name" to RoutingSessionInfo" into rvc-dev

This commit is contained in:
Kyunglyul Hyun
2020-03-02 02:42:28 +00:00
committed by Android (Google) Code Review
2 changed files with 36 additions and 11 deletions

View File

@@ -27477,6 +27477,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();
@@ -27504,6 +27505,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);

View File

@@ -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.
*