Loading media/java/android/media/MediaRoute2Info.java 0 → 100644 +170 −0 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.NonNull; import android.annotation.Nullable; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; /** * Describes the properties of a route. * @hide */ public final class MediaRoute2Info implements Parcelable { public static final Creator<MediaRoute2Info> CREATOR = new Creator<MediaRoute2Info>() { @Override public MediaRoute2Info createFromParcel(Parcel in) { return new MediaRoute2Info(in); } @Override public MediaRoute2Info[] newArray(int size) { return new MediaRoute2Info[size]; } }; @NonNull final String mId; @NonNull final String mName; @Nullable final String mDescription; @Nullable final Bundle mExtras; MediaRoute2Info(@NonNull Builder builder) { mId = builder.mId; mName = builder.mName; mDescription = builder.mDescription; mExtras = builder.mExtras; } MediaRoute2Info(@NonNull Parcel in) { mId = in.readString(); mName = in.readString(); mDescription = in.readString(); mExtras = in.readBundle(); } @NonNull public String getId() { return mId; } @NonNull public String getName() { return mName; } @Nullable public String getDescription() { return mDescription; } @Nullable public Bundle getExtras() { return mExtras; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(mId); dest.writeString(mName); dest.writeString(mDescription); dest.writeBundle(mExtras); } /** * Builder for {@link MediaRoute2Info media route info}. */ public static final class Builder { String mId; String mName; String mDescription; Bundle mExtras; public Builder(@NonNull String id, @NonNull String name) { if (TextUtils.isEmpty(id)) { throw new IllegalArgumentException("id must not be null or empty"); } if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must not be null or empty"); } setId(id); setName(name); } public Builder(@NonNull MediaRoute2Info routeInfo) { if (routeInfo == null) { throw new IllegalArgumentException("route info must not be null"); } setId(routeInfo.mId); setName(routeInfo.mName); mDescription = routeInfo.mDescription; } /** * Sets the unique id of the route. */ @NonNull public Builder setId(@NonNull String id) { if (TextUtils.isEmpty(id)) { throw new IllegalArgumentException("id must not be null or empty"); } mId = id; return this; } /** * Sets the user-visible name of the route. */ @NonNull public Builder setName(@NonNull String name) { if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must not be null or empty"); } mName = name; return this; } /** * Sets the user-visible description of the route. */ @NonNull public Builder setDescription(@Nullable String description) { mDescription = description; return this; } /** * Builds the {@link MediaRoute2Info media route info}. */ @NonNull public MediaRoute2Info build() { return new MediaRoute2Info(this); } } } media/java/android/media/MediaRoute2ProviderInfo.java 0 → 100644 +132 −0 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.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; /** * Describes the state of a media router provider and the routes that it publishes. * @hide */ public final class MediaRoute2ProviderInfo implements Parcelable { public static final Parcelable.Creator<MediaRoute2ProviderInfo> CREATOR = new Parcelable.Creator<MediaRoute2ProviderInfo>() { @Override public MediaRoute2ProviderInfo createFromParcel(Parcel in) { return new MediaRoute2ProviderInfo(in); } @Override public MediaRoute2ProviderInfo[] newArray(int size) { return new MediaRoute2ProviderInfo[size]; } }; @NonNull private final List<MediaRoute2Info> mRoutes; MediaRoute2ProviderInfo(@Nullable List<MediaRoute2Info> routes) { mRoutes = (routes == null) ? Collections.emptyList() : routes; } MediaRoute2ProviderInfo(@NonNull Parcel src) { mRoutes = src.createTypedArrayList(MediaRoute2Info.CREATOR); } /** * Gets the unmodifiable list of all routes that this provider has published. */ @NonNull public List<MediaRoute2Info> getRoutes() { return Collections.unmodifiableList(mRoutes); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeTypedList(mRoutes); } /** * Builder for {@link MediaRoute2ProviderInfo media route provider info}. */ public static final class Builder { @NonNull private final List<MediaRoute2Info> mRoutes; public Builder() { mRoutes = new ArrayList<>(); } public Builder(@NonNull MediaRoute2ProviderInfo descriptor) { if (descriptor == null) { throw new IllegalArgumentException("descriptor must not be null"); } mRoutes = new ArrayList<>(descriptor.mRoutes); } /** * Adds a route to the provider */ public Builder addRoute(@NonNull MediaRoute2Info route) { if (route == null) { throw new IllegalArgumentException("route must not be null"); } if (mRoutes.contains(route)) { throw new IllegalArgumentException("route descriptor already added"); } mRoutes.add(route); return this; } /** * Adds a list of routes to the provider */ public Builder addRoutes(@NonNull Collection<MediaRoute2Info> routes) { if (routes == null) { throw new IllegalArgumentException("routes must not be null"); } if (!routes.isEmpty()) { for (MediaRoute2Info route : routes) { addRoute(route); } } return this; } /** * Builds {@link MediaRoute2ProviderInfo media route provider info}. */ @NonNull public MediaRoute2ProviderInfo build() { return new MediaRoute2ProviderInfo(mRoutes); } } } Loading
media/java/android/media/MediaRoute2Info.java 0 → 100644 +170 −0 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.NonNull; import android.annotation.Nullable; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; /** * Describes the properties of a route. * @hide */ public final class MediaRoute2Info implements Parcelable { public static final Creator<MediaRoute2Info> CREATOR = new Creator<MediaRoute2Info>() { @Override public MediaRoute2Info createFromParcel(Parcel in) { return new MediaRoute2Info(in); } @Override public MediaRoute2Info[] newArray(int size) { return new MediaRoute2Info[size]; } }; @NonNull final String mId; @NonNull final String mName; @Nullable final String mDescription; @Nullable final Bundle mExtras; MediaRoute2Info(@NonNull Builder builder) { mId = builder.mId; mName = builder.mName; mDescription = builder.mDescription; mExtras = builder.mExtras; } MediaRoute2Info(@NonNull Parcel in) { mId = in.readString(); mName = in.readString(); mDescription = in.readString(); mExtras = in.readBundle(); } @NonNull public String getId() { return mId; } @NonNull public String getName() { return mName; } @Nullable public String getDescription() { return mDescription; } @Nullable public Bundle getExtras() { return mExtras; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(mId); dest.writeString(mName); dest.writeString(mDescription); dest.writeBundle(mExtras); } /** * Builder for {@link MediaRoute2Info media route info}. */ public static final class Builder { String mId; String mName; String mDescription; Bundle mExtras; public Builder(@NonNull String id, @NonNull String name) { if (TextUtils.isEmpty(id)) { throw new IllegalArgumentException("id must not be null or empty"); } if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must not be null or empty"); } setId(id); setName(name); } public Builder(@NonNull MediaRoute2Info routeInfo) { if (routeInfo == null) { throw new IllegalArgumentException("route info must not be null"); } setId(routeInfo.mId); setName(routeInfo.mName); mDescription = routeInfo.mDescription; } /** * Sets the unique id of the route. */ @NonNull public Builder setId(@NonNull String id) { if (TextUtils.isEmpty(id)) { throw new IllegalArgumentException("id must not be null or empty"); } mId = id; return this; } /** * Sets the user-visible name of the route. */ @NonNull public Builder setName(@NonNull String name) { if (TextUtils.isEmpty(name)) { throw new IllegalArgumentException("name must not be null or empty"); } mName = name; return this; } /** * Sets the user-visible description of the route. */ @NonNull public Builder setDescription(@Nullable String description) { mDescription = description; return this; } /** * Builds the {@link MediaRoute2Info media route info}. */ @NonNull public MediaRoute2Info build() { return new MediaRoute2Info(this); } } }
media/java/android/media/MediaRoute2ProviderInfo.java 0 → 100644 +132 −0 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.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; /** * Describes the state of a media router provider and the routes that it publishes. * @hide */ public final class MediaRoute2ProviderInfo implements Parcelable { public static final Parcelable.Creator<MediaRoute2ProviderInfo> CREATOR = new Parcelable.Creator<MediaRoute2ProviderInfo>() { @Override public MediaRoute2ProviderInfo createFromParcel(Parcel in) { return new MediaRoute2ProviderInfo(in); } @Override public MediaRoute2ProviderInfo[] newArray(int size) { return new MediaRoute2ProviderInfo[size]; } }; @NonNull private final List<MediaRoute2Info> mRoutes; MediaRoute2ProviderInfo(@Nullable List<MediaRoute2Info> routes) { mRoutes = (routes == null) ? Collections.emptyList() : routes; } MediaRoute2ProviderInfo(@NonNull Parcel src) { mRoutes = src.createTypedArrayList(MediaRoute2Info.CREATOR); } /** * Gets the unmodifiable list of all routes that this provider has published. */ @NonNull public List<MediaRoute2Info> getRoutes() { return Collections.unmodifiableList(mRoutes); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeTypedList(mRoutes); } /** * Builder for {@link MediaRoute2ProviderInfo media route provider info}. */ public static final class Builder { @NonNull private final List<MediaRoute2Info> mRoutes; public Builder() { mRoutes = new ArrayList<>(); } public Builder(@NonNull MediaRoute2ProviderInfo descriptor) { if (descriptor == null) { throw new IllegalArgumentException("descriptor must not be null"); } mRoutes = new ArrayList<>(descriptor.mRoutes); } /** * Adds a route to the provider */ public Builder addRoute(@NonNull MediaRoute2Info route) { if (route == null) { throw new IllegalArgumentException("route must not be null"); } if (mRoutes.contains(route)) { throw new IllegalArgumentException("route descriptor already added"); } mRoutes.add(route); return this; } /** * Adds a list of routes to the provider */ public Builder addRoutes(@NonNull Collection<MediaRoute2Info> routes) { if (routes == null) { throw new IllegalArgumentException("routes must not be null"); } if (!routes.isEmpty()) { for (MediaRoute2Info route : routes) { addRoute(route); } } return this; } /** * Builds {@link MediaRoute2ProviderInfo media route provider info}. */ @NonNull public MediaRoute2ProviderInfo build() { return new MediaRoute2ProviderInfo(mRoutes); } } }