/* * Copyright 2020 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.annotation.SystemApi; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; /** * A media route discovery preference describing the features of routes that media router * would like to discover and whether to perform active scanning. *
* When {@link MediaRouter2} instances set discovery preferences by calling * {@link MediaRouter2#registerRouteCallback}, they are merged into a single discovery preference * and it is delivered to call {@link MediaRoute2ProviderService#onDiscoveryPreferenceChanged}. *
* According to the given discovery preference, {@link MediaRoute2ProviderService} discovers * routes and publishes them. *
* * @see MediaRouter2#registerRouteCallback */ public final class RouteDiscoveryPreference implements Parcelable { @NonNull public static final Creator* Routes that have at least one of the features will be discovered. * They may include predefined features such as * {@link MediaRoute2Info#FEATURE_LIVE_AUDIO}, {@link MediaRoute2Info#FEATURE_LIVE_VIDEO}, * or {@link MediaRoute2Info#FEATURE_REMOTE_PLAYBACK} or custom features defined by a provider. *
*/ @NonNull public List
* Duplicate route removal is enabled if the returned list is non-empty. Routes are deduplicated
* based on their {@link MediaRoute2Info#getDeduplicationIds() deduplication IDs}. If two routes
* have a deduplication ID in common, only the route from the provider whose package name is
* first in the provided list will remain.
*
* @see #shouldRemoveDuplicates()
* @hide
*/
@NonNull
public List
* If it's not empty, it will only discover routes from the provider whose package name
* belongs to the list.
* @hide
*/
@NonNull
public List
* If any of discovery preferences sets this as {@code true}, active scanning will
* be performed regardless of other discovery preferences.
*
* If it's non-empty, media router only discovers route from the provider in the list.
* The default value is empty, which discovers routes from all providers.
* @hide
*/
@NonNull
public Builder setAllowedPackages(@NonNull List
* Since active scanning uses more system resources, set this as {@code true} only
* when it's necessary.
*
* Routes are deduplicated based on their
* {@link MediaRoute2Info#getDeduplicationIds() deduplication IDs}.
* If two routes have a deduplication ID in common, only the route from the provider whose
* package name is first in the provided list will remain.
*
* @param packageOrder ordered list of package names used to remove duplicate routes, or an
* empty list if deduplication should not be enabled.
* @hide
*/
@NonNull
public Builder setDeduplicationPackageOrder(@NonNull List