Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3afc18af authored by Jeff Brown's avatar Jeff Brown
Browse files

Enhance MediaRouter API.

The support library MediaRouter implementation needs a couple
of extra generally useful APIs in the platform MediaRouter to ensure
that it can safely synchronize its state.

Change-Id: I72c5652e10f3b6de48800abfa922affbefbd250f
parent 9f3443c5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11792,6 +11792,7 @@ package android.media {
    method public android.media.MediaRouter.UserRouteInfo createUserRoute(android.media.MediaRouter.RouteCategory);
    method public android.media.MediaRouter.RouteCategory getCategoryAt(int);
    method public int getCategoryCount();
    method public android.media.MediaRouter.RouteInfo getDefaultRoute();
    method public android.media.MediaRouter.RouteInfo getRouteAt(int);
    method public int getRouteCount();
    method public android.media.MediaRouter.RouteInfo getSelectedRoute(int);
+3 −3
Original line number Diff line number Diff line
@@ -123,13 +123,13 @@ public class MediaRouteButton extends View {

        if (mToggleMode) {
            if (mRemoteActive) {
                mRouter.selectRouteInt(mRouteTypes, mRouter.getSystemAudioRoute());
                mRouter.selectRouteInt(mRouteTypes, mRouter.getDefaultRoute());
            } else {
                final int N = mRouter.getRouteCount();
                for (int i = 0; i < N; i++) {
                    final RouteInfo route = mRouter.getRouteAt(i);
                    if ((route.getSupportedTypes() & mRouteTypes) != 0 &&
                            route != mRouter.getSystemAudioRoute()) {
                            route != mRouter.getDefaultRoute()) {
                        mRouter.selectRouteInt(mRouteTypes, route);
                    }
                }
@@ -216,7 +216,7 @@ public class MediaRouteButton extends View {

    void updateRemoteIndicator() {
        final RouteInfo selected = mRouter.getSelectedRoute(mRouteTypes);
        final boolean isRemote = selected != mRouter.getSystemAudioRoute();
        final boolean isRemote = selected != mRouter.getDefaultRoute();
        final boolean isConnecting = selected != null &&
                selected.getStatusCode() == RouteInfo.STATUS_CONNECTING;

+14 −6
Original line number Diff line number Diff line
@@ -299,16 +299,21 @@ public class MediaRouter {
    }

    /**
     * @hide for use by framework routing UI
     * Gets the default route for playing media content on the system.
     * <p>
     * The system always provides a default route.
     * </p>
     *
     * @return The default route, which is guaranteed to never be null.
     */
    public RouteInfo getSystemAudioRoute() {
    public RouteInfo getDefaultRoute() {
        return sStatic.mDefaultAudioVideo;
    }

    /**
     * @hide for use by framework routing UI
     */
    public RouteCategory getSystemAudioCategory() {
    public RouteCategory getSystemCategory() {
        return sStatic.mSystemCategory;
    }

@@ -372,14 +377,17 @@ public class MediaRouter {

    /**
     * Select the specified route to use for output of the given media types.
     * <p class="note">
     * As API version 18, this function may be used to select any route.
     * In prior versions, this function could only be used to select user
     * routes and would ignore any attempt to select a system route.
     * </p>
     *
     * @param types type flags indicating which types this route should be used for.
     *              The route must support at least a subset.
     * @param route Route to select
     */
    public void selectRoute(int types, RouteInfo route) {
        // Applications shouldn't programmatically change anything but user routes.
        types &= ROUTE_TYPE_USER;
        selectRouteStatic(types, route);
    }
    
@@ -454,7 +462,7 @@ public class MediaRouter {
     * App-specified route definitions are created using {@link #createUserRoute(RouteCategory)}
     *
     * @param info Definition of the route to add
     * @see #createUserRoute()
     * @see #createUserRoute(RouteCategory)
     * @see #removeUserRoute(UserRouteInfo)
     */
    public void addUserRoute(UserRouteInfo info) {