Search in sources :

Example 1 with RouteInfo

use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by ParanoidAndroid.

the class MediaRouteButton method updateRouteCount.

void updateRouteCount() {
    final int N = mRouter.getRouteCount();
    int count = 0;
    boolean hasVideoRoutes = false;
    for (int i = 0; i < N; i++) {
        final RouteInfo route = mRouter.getRouteAt(i);
        final int routeTypes = route.getSupportedTypes();
        if ((routeTypes & mRouteTypes) != 0) {
            if (route instanceof RouteGroup) {
                count += ((RouteGroup) route).getRouteCount();
            } else {
                count++;
            }
            if ((routeTypes & MediaRouter.ROUTE_TYPE_LIVE_VIDEO) != 0) {
                hasVideoRoutes = true;
            }
        }
    }
    setEnabled(count != 0);
    // Only allow toggling if we have more than just user routes.
    // Don't toggle if we support video routes, we may have to let the dialog scan.
    mToggleMode = count == 2 && (mRouteTypes & MediaRouter.ROUTE_TYPE_LIVE_AUDIO) != 0 && !hasVideoRoutes;
}
Also used : RouteGroup(android.media.MediaRouter.RouteGroup) RouteInfo(android.media.MediaRouter.RouteInfo)

Example 2 with RouteInfo

use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by ResurrectionRemix.

the class CastControllerImpl method dump.

public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    pw.println("CastController state:");
    pw.print("  mDiscovering=");
    pw.println(mDiscovering);
    pw.print("  mCallbackRegistered=");
    pw.println(mCallbackRegistered);
    pw.print("  mCallbacks.size=");
    pw.println(mCallbacks.size());
    pw.print("  mRoutes.size=");
    pw.println(mRoutes.size());
    for (int i = 0; i < mRoutes.size(); i++) {
        final RouteInfo route = mRoutes.valueAt(i);
        pw.print("    ");
        pw.println(routeToString(route));
    }
    pw.print("  mProjection=");
    pw.println(mProjection);
}
Also used : RouteInfo(android.media.MediaRouter.RouteInfo)

Example 3 with RouteInfo

use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by ResurrectionRemix.

the class CastControllerImpl method getCastDevices.

@Override
public Set<CastDevice> getCastDevices() {
    final ArraySet<CastDevice> devices = new ArraySet<CastDevice>();
    synchronized (mProjectionLock) {
        if (mProjection != null) {
            final CastDevice device = new CastDevice();
            device.id = mProjection.getPackageName();
            device.name = getAppName(mProjection.getPackageName());
            device.description = mContext.getString(R.string.quick_settings_casting);
            device.state = CastDevice.STATE_CONNECTED;
            device.tag = mProjection;
            devices.add(device);
            return devices;
        }
    }
    synchronized (mRoutes) {
        for (RouteInfo route : mRoutes.values()) {
            final CastDevice device = new CastDevice();
            device.id = route.getTag().toString();
            final CharSequence name = route.getName(mContext);
            device.name = name != null ? name.toString() : null;
            final CharSequence description = route.getDescription();
            device.description = description != null ? description.toString() : null;
            device.state = route.isConnecting() ? CastDevice.STATE_CONNECTING : route.isSelected() ? CastDevice.STATE_CONNECTED : CastDevice.STATE_DISCONNECTED;
            device.tag = route;
            devices.add(device);
        }
    }
    return devices;
}
Also used : ArraySet(android.util.ArraySet) RouteInfo(android.media.MediaRouter.RouteInfo)

Example 4 with RouteInfo

use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by DirtyUnicorns.

the class CastControllerImpl method dump.

public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    pw.println("CastController state:");
    pw.print("  mDiscovering=");
    pw.println(mDiscovering);
    pw.print("  mCallbackRegistered=");
    pw.println(mCallbackRegistered);
    pw.print("  mCallbacks.size=");
    pw.println(mCallbacks.size());
    pw.print("  mRoutes.size=");
    pw.println(mRoutes.size());
    for (int i = 0; i < mRoutes.size(); i++) {
        final RouteInfo route = mRoutes.valueAt(i);
        pw.print("    ");
        pw.println(routeToString(route));
    }
    pw.print("  mProjection=");
    pw.println(mProjection);
}
Also used : RouteInfo(android.media.MediaRouter.RouteInfo)

Example 5 with RouteInfo

use of android.media.MediaRouter.RouteInfo in project android_frameworks_base by DirtyUnicorns.

the class CastControllerImpl method startCasting.

@Override
public void startCasting(CastDevice device) {
    if (device == null || device.tag == null)
        return;
    final RouteInfo route = (RouteInfo) device.tag;
    if (DEBUG)
        Log.d(TAG, "startCasting: " + routeToString(route));
    mMediaRouter.selectRoute(ROUTE_TYPE_REMOTE_DISPLAY, route);
}
Also used : RouteInfo(android.media.MediaRouter.RouteInfo)

Aggregations

RouteInfo (android.media.MediaRouter.RouteInfo)33 Test (org.junit.Test)8 ArraySet (android.util.ArraySet)5 Config (org.robolectric.annotation.Config)3 RouteGroup (android.media.MediaRouter.RouteGroup)1 Display (android.view.Display)1 WindowManager (android.view.WindowManager)1