summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2012-11-28 10:46:56 -0800
committerAdam Powell <adamp@google.com>2012-11-28 11:22:01 -0800
commit1cf2ca83584a4cf0aa3ded787bd191b9a60e3521 (patch)
treea437972a98300f3d9c5356b57289c4c0910bcb4f /media
parentba4ac51823c59152e2167365b81ac56857b6b4d0 (diff)
downloadframeworks_base-1cf2ca83584a4cf0aa3ded787bd191b9a60e3521.zip
frameworks_base-1cf2ca83584a4cf0aa3ded787bd191b9a60e3521.tar.gz
frameworks_base-1cf2ca83584a4cf0aa3ded787bd191b9a60e3521.tar.bz2
Clean up behavior of type arguments for MediaRouter#getSelectedRoute
MediaRouter's policy so far has been around a single selected route, but when route types are entirely orthogonal this should not be the case. However we still don't want to get into a situation where we have multiple, very different routes selected for different types at the same time, we still want to have more of an element of predictability. Behavior of getSelectedRoute is now: * If the selected route matches at least one type with the requested type flags, it is still considered selected for that request. * If the caller specifically requested the selected user route and the currently selected route is not a user route, return null. * If the requested type flags do not match any types with the selected route, return the default system route. Note that this is "any" behavior instead of "all" - this matches existing usage of the method. We may consider adding an "all" variant later on. Bug 7588042 Change-Id: I3a79d8153ca6b882fd3ef6b9b1de8f538873dec2
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MediaRouter.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index 8701f36..8b489b1 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -313,13 +313,25 @@ public class MediaRouter {
}
/**
- * Return the currently selected route for the given types
+ * Return the currently selected route for any of the given types
*
* @param type route types
* @return the selected route
*/
public RouteInfo getSelectedRoute(int type) {
- return sStatic.mSelectedRoute;
+ if (sStatic.mSelectedRoute != null &&
+ (sStatic.mSelectedRoute.mSupportedTypes & type) != 0) {
+ // If the selected route supports any of the types supplied, it's still considered
+ // 'selected' for that type.
+ return sStatic.mSelectedRoute;
+ } else if (type == ROUTE_TYPE_USER) {
+ // The caller specifically asked for a user route and the currently selected route
+ // doesn't qualify.
+ return null;
+ }
+ // If the above didn't match and we're not specifically asking for a user route,
+ // consider the default selected.
+ return sStatic.mDefaultAudioVideo;
}
/**