Merge "System routes are not automatically exposed" into rvc-dev am: c8f4a8a5e9 am: 387622bd1d am: d7243c4e39
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11926262 Change-Id: Ib862ba2f86fcfd10326845320be2344a34688686
This commit is contained in:
@@ -226,7 +226,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
public static final int TYPE_GROUP = 2000;
|
public static final int TYPE_GROUP = 2000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media feature: Live audio.
|
* Route feature: Live audio.
|
||||||
* <p>
|
* <p>
|
||||||
* A route that supports live audio routing will allow the media audio stream
|
* A route that supports live audio routing will allow the media audio stream
|
||||||
* to be sent to supported destinations. This can include internal speakers or
|
* to be sent to supported destinations. This can include internal speakers or
|
||||||
@@ -241,7 +241,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
public static final String FEATURE_LIVE_AUDIO = "android.media.route.feature.LIVE_AUDIO";
|
public static final String FEATURE_LIVE_AUDIO = "android.media.route.feature.LIVE_AUDIO";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media feature: Live video.
|
* Route feature: Live video.
|
||||||
* <p>
|
* <p>
|
||||||
* A route that supports live video routing will allow a mirrored version
|
* A route that supports live video routing will allow a mirrored version
|
||||||
* of the device's primary display or a customized
|
* of the device's primary display or a customized
|
||||||
@@ -262,7 +262,14 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
public static final String FEATURE_LIVE_VIDEO = "android.media.route.feature.LIVE_VIDEO";
|
public static final String FEATURE_LIVE_VIDEO = "android.media.route.feature.LIVE_VIDEO";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media feature: Remote playback.
|
* Route feature: Local playback.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String FEATURE_LOCAL_PLAYBACK =
|
||||||
|
"android.media.route.feature.LOCAL_PLAYBACK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route feature: Remote playback.
|
||||||
* <p>
|
* <p>
|
||||||
* A route that supports remote playback routing will allow an application to send
|
* A route that supports remote playback routing will allow an application to send
|
||||||
* requests to play content remotely to supported destinations.
|
* requests to play content remotely to supported destinations.
|
||||||
@@ -283,7 +290,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
"android.media.route.feature.REMOTE_PLAYBACK";
|
"android.media.route.feature.REMOTE_PLAYBACK";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media feature: Remote audio playback.
|
* Route feature: Remote audio playback.
|
||||||
* <p>
|
* <p>
|
||||||
* A route that supports remote audio playback routing will allow an application to send
|
* A route that supports remote audio playback routing will allow an application to send
|
||||||
* requests to play audio content remotely to supported destinations.
|
* requests to play audio content remotely to supported destinations.
|
||||||
@@ -295,7 +302,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
"android.media.route.feature.REMOTE_AUDIO_PLAYBACK";
|
"android.media.route.feature.REMOTE_AUDIO_PLAYBACK";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media feature: Remote video playback.
|
* Route feature: Remote video playback.
|
||||||
* <p>
|
* <p>
|
||||||
* A route that supports remote video playback routing will allow an application to send
|
* A route that supports remote video playback routing will allow an application to send
|
||||||
* requests to play video content remotely to supported destinations.
|
* requests to play video content remotely to supported destinations.
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public final class MediaRouter2 {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static boolean checkRouteListContainsRouteId(@NonNull List<MediaRoute2Info> routeList,
|
static boolean checkRouteListContainsRouteId(@NonNull List<MediaRoute2Info> routeList,
|
||||||
@NonNull String routeId) {
|
@NonNull String routeId) {
|
||||||
for (MediaRoute2Info info : routeList) {
|
for (MediaRoute2Info info : routeList) {
|
||||||
if (TextUtils.equals(routeId, info.getId())) {
|
if (TextUtils.equals(routeId, info.getId())) {
|
||||||
@@ -258,8 +258,6 @@ public final class MediaRouter2 {
|
|||||||
* Gets the unmodifiable list of {@link MediaRoute2Info routes} currently
|
* Gets the unmodifiable list of {@link MediaRoute2Info routes} currently
|
||||||
* known to the media router.
|
* known to the media router.
|
||||||
* <p>
|
* <p>
|
||||||
* {@link MediaRoute2Info#isSystemRoute() System routes} such as phone speaker,
|
|
||||||
* Bluetooth devices are always included in the list.
|
|
||||||
* Please note that the list can be changed before callbacks are invoked.
|
* Please note that the list can be changed before callbacks are invoked.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
@@ -274,8 +272,7 @@ public final class MediaRouter2 {
|
|||||||
|
|
||||||
List<MediaRoute2Info> filteredRoutes = new ArrayList<>();
|
List<MediaRoute2Info> filteredRoutes = new ArrayList<>();
|
||||||
for (MediaRoute2Info route : mRoutes.values()) {
|
for (MediaRoute2Info route : mRoutes.values()) {
|
||||||
if (route.isSystemRoute()
|
if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
||||||
|| route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
|
||||||
filteredRoutes.add(route);
|
filteredRoutes.add(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -526,8 +523,7 @@ public final class MediaRouter2 {
|
|||||||
if (!currentRoutesIds.contains(routeId)) {
|
if (!currentRoutesIds.contains(routeId)) {
|
||||||
// This route is removed while the callback is unregistered.
|
// This route is removed while the callback is unregistered.
|
||||||
MediaRoute2Info route = mRoutes.get(routeId);
|
MediaRoute2Info route = mRoutes.get(routeId);
|
||||||
if (route.isSystemRoute()
|
if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
||||||
|| route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
|
||||||
removedRoutes.add(mRoutes.get(routeId));
|
removedRoutes.add(mRoutes.get(routeId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,16 +533,14 @@ public final class MediaRouter2 {
|
|||||||
if (mRoutes.containsKey(route.getId())) {
|
if (mRoutes.containsKey(route.getId())) {
|
||||||
if (!route.equals(mRoutes.get(route.getId()))) {
|
if (!route.equals(mRoutes.get(route.getId()))) {
|
||||||
// This route is changed while the callback is unregistered.
|
// This route is changed while the callback is unregistered.
|
||||||
if (route.isSystemRoute()
|
if (route.hasAnyFeatures(
|
||||||
|| route.hasAnyFeatures(
|
|
||||||
mDiscoveryPreference.getPreferredFeatures())) {
|
mDiscoveryPreference.getPreferredFeatures())) {
|
||||||
changedRoutes.add(route);
|
changedRoutes.add(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This route is added while the callback is unregistered.
|
// This route is added while the callback is unregistered.
|
||||||
if (route.isSystemRoute()
|
if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
||||||
|| route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
|
||||||
addedRoutes.add(route);
|
addedRoutes.add(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -582,8 +576,7 @@ public final class MediaRouter2 {
|
|||||||
synchronized (sRouterLock) {
|
synchronized (sRouterLock) {
|
||||||
for (MediaRoute2Info route : routes) {
|
for (MediaRoute2Info route : routes) {
|
||||||
mRoutes.put(route.getId(), route);
|
mRoutes.put(route.getId(), route);
|
||||||
if (route.isSystemRoute()
|
if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
||||||
|| route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
|
||||||
addedRoutes.add(route);
|
addedRoutes.add(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -599,8 +592,7 @@ public final class MediaRouter2 {
|
|||||||
synchronized (sRouterLock) {
|
synchronized (sRouterLock) {
|
||||||
for (MediaRoute2Info route : routes) {
|
for (MediaRoute2Info route : routes) {
|
||||||
mRoutes.remove(route.getId());
|
mRoutes.remove(route.getId());
|
||||||
if (route.isSystemRoute()
|
if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
||||||
|| route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
|
||||||
removedRoutes.add(route);
|
removedRoutes.add(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -616,8 +608,7 @@ public final class MediaRouter2 {
|
|||||||
synchronized (sRouterLock) {
|
synchronized (sRouterLock) {
|
||||||
for (MediaRoute2Info route : routes) {
|
for (MediaRoute2Info route : routes) {
|
||||||
mRoutes.put(route.getId(), route);
|
mRoutes.put(route.getId(), route);
|
||||||
if (route.isSystemRoute()
|
if (route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
||||||
|| route.hasAnyFeatures(mDiscoveryPreference.getPreferredFeatures())) {
|
|
||||||
changedRoutes.add(route);
|
changedRoutes.add(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -799,8 +790,7 @@ public final class MediaRouter2 {
|
|||||||
private List<MediaRoute2Info> filterRoutes(List<MediaRoute2Info> routes,
|
private List<MediaRoute2Info> filterRoutes(List<MediaRoute2Info> routes,
|
||||||
RouteDiscoveryPreference discoveryRequest) {
|
RouteDiscoveryPreference discoveryRequest) {
|
||||||
return routes.stream()
|
return routes.stream()
|
||||||
.filter(route -> route.isSystemRoute()
|
.filter(route -> route.hasAnyFeatures(discoveryRequest.getPreferredFeatures()))
|
||||||
|| route.hasAnyFeatures(discoveryRequest.getPreferredFeatures()))
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,20 +165,8 @@ public final class MediaRouter2Manager {
|
|||||||
public List<MediaRoute2Info> getAvailableRoutes(@NonNull String packageName) {
|
public List<MediaRoute2Info> getAvailableRoutes(@NonNull String packageName) {
|
||||||
Objects.requireNonNull(packageName, "packageName must not be null");
|
Objects.requireNonNull(packageName, "packageName must not be null");
|
||||||
|
|
||||||
List<MediaRoute2Info> routes = new ArrayList<>();
|
List<RoutingSessionInfo> sessions = getRoutingSessions(packageName);
|
||||||
|
return getAvailableRoutesForRoutingSession(sessions.get(sessions.size() - 1));
|
||||||
List<String> preferredFeatures = mPreferredFeaturesMap.get(packageName);
|
|
||||||
if (preferredFeatures == null) {
|
|
||||||
preferredFeatures = Collections.emptyList();
|
|
||||||
}
|
|
||||||
synchronized (mRoutesLock) {
|
|
||||||
for (MediaRoute2Info route : mRoutes.values()) {
|
|
||||||
if (route.isSystemRoute() || route.hasAnyFeatures(preferredFeatures)) {
|
|
||||||
routes.add(route);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return routes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,7 +190,7 @@ public final class MediaRouter2Manager {
|
|||||||
}
|
}
|
||||||
synchronized (mRoutesLock) {
|
synchronized (mRoutesLock) {
|
||||||
for (MediaRoute2Info route : mRoutes.values()) {
|
for (MediaRoute2Info route : mRoutes.values()) {
|
||||||
if (route.isSystemRoute() || route.hasAnyFeatures(preferredFeatures)
|
if (route.hasAnyFeatures(preferredFeatures)
|
||||||
|| sessionInfo.getSelectedRoutes().contains(route.getId())
|
|| sessionInfo.getSelectedRoutes().contains(route.getId())
|
||||||
|| sessionInfo.getTransferableRoutes().contains(route.getId())) {
|
|| sessionInfo.getTransferableRoutes().contains(route.getId())) {
|
||||||
routes.add(route);
|
routes.add(route);
|
||||||
@@ -303,7 +291,7 @@ public final class MediaRouter2Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of all discovered routes
|
* Gets the list of all discovered routes.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<MediaRoute2Info> getAllRoutes() {
|
public List<MediaRoute2Info> getAllRoutes() {
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ public class MediaRouter2ManagerTest {
|
|||||||
|
|
||||||
public static final List<String> FEATURES_ALL = new ArrayList();
|
public static final List<String> FEATURES_ALL = new ArrayList();
|
||||||
public static final List<String> FEATURES_SPECIAL = new ArrayList();
|
public static final List<String> FEATURES_SPECIAL = new ArrayList();
|
||||||
private static final List<String> FEATURES_LIVE_AUDIO = new ArrayList<>();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
FEATURES_ALL.add(FEATURE_SAMPLE);
|
FEATURES_ALL.add(FEATURE_SAMPLE);
|
||||||
@@ -105,8 +104,6 @@ public class MediaRouter2ManagerTest {
|
|||||||
FEATURES_ALL.add(FEATURE_LIVE_AUDIO);
|
FEATURES_ALL.add(FEATURE_LIVE_AUDIO);
|
||||||
|
|
||||||
FEATURES_SPECIAL.add(FEATURE_SPECIAL);
|
FEATURES_SPECIAL.add(FEATURE_SPECIAL);
|
||||||
|
|
||||||
FEATURES_LIVE_AUDIO.add(FEATURE_LIVE_AUDIO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ class BluetoothRouteProvider {
|
|||||||
// Current volume will be set when connected.
|
// Current volume will be set when connected.
|
||||||
newBtRoute.route = new MediaRoute2Info.Builder(routeId, deviceName)
|
newBtRoute.route = new MediaRoute2Info.Builder(routeId, deviceName)
|
||||||
.addFeature(MediaRoute2Info.FEATURE_LIVE_AUDIO)
|
.addFeature(MediaRoute2Info.FEATURE_LIVE_AUDIO)
|
||||||
|
.addFeature(MediaRoute2Info.FEATURE_LOCAL_PLAYBACK)
|
||||||
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_DISCONNECTED)
|
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_DISCONNECTED)
|
||||||
.setDescription(mContext.getResources().getText(
|
.setDescription(mContext.getResources().getText(
|
||||||
R.string.bluetooth_a2dp_audio_route_name).toString())
|
R.string.bluetooth_a2dp_audio_route_name).toString())
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.server.media;
|
|||||||
|
|
||||||
import static android.media.MediaRoute2Info.FEATURE_LIVE_AUDIO;
|
import static android.media.MediaRoute2Info.FEATURE_LIVE_AUDIO;
|
||||||
import static android.media.MediaRoute2Info.FEATURE_LIVE_VIDEO;
|
import static android.media.MediaRoute2Info.FEATURE_LIVE_VIDEO;
|
||||||
|
import static android.media.MediaRoute2Info.FEATURE_LOCAL_PLAYBACK;
|
||||||
import static android.media.MediaRoute2Info.TYPE_BUILTIN_SPEAKER;
|
import static android.media.MediaRoute2Info.TYPE_BUILTIN_SPEAKER;
|
||||||
import static android.media.MediaRoute2Info.TYPE_DOCK;
|
import static android.media.MediaRoute2Info.TYPE_DOCK;
|
||||||
import static android.media.MediaRoute2Info.TYPE_HDMI;
|
import static android.media.MediaRoute2Info.TYPE_HDMI;
|
||||||
@@ -262,6 +263,7 @@ class SystemMediaRoute2Provider extends MediaRoute2Provider {
|
|||||||
.setType(type)
|
.setType(type)
|
||||||
.addFeature(FEATURE_LIVE_AUDIO)
|
.addFeature(FEATURE_LIVE_AUDIO)
|
||||||
.addFeature(FEATURE_LIVE_VIDEO)
|
.addFeature(FEATURE_LIVE_VIDEO)
|
||||||
|
.addFeature(FEATURE_LOCAL_PLAYBACK)
|
||||||
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_CONNECTED)
|
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_CONNECTED)
|
||||||
.build();
|
.build();
|
||||||
updateProviderState();
|
updateProviderState();
|
||||||
|
|||||||
Reference in New Issue
Block a user