Search in sources :

Example 26 with RouteInfo

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

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 27 with RouteInfo

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

the class CastControllerImpl method updateRemoteDisplays.

private void updateRemoteDisplays() {
    synchronized (mRoutes) {
        mRoutes.clear();
        final int n = mMediaRouter.getRouteCount();
        for (int i = 0; i < n; i++) {
            final RouteInfo route = mMediaRouter.getRouteAt(i);
            if (!route.isEnabled())
                continue;
            if (!route.matchesTypes(ROUTE_TYPE_REMOTE_DISPLAY))
                continue;
            ensureTagExists(route);
            mRoutes.put(route.getTag().toString(), route);
        }
        final RouteInfo selected = mMediaRouter.getSelectedRoute(ROUTE_TYPE_REMOTE_DISPLAY);
        if (selected != null && !selected.isDefault()) {
            ensureTagExists(selected);
            mRoutes.put(selected.getTag().toString(), selected);
        }
    }
    fireOnCastDevicesChanged();
}
Also used : RouteInfo(android.media.MediaRouter.RouteInfo)

Example 28 with RouteInfo

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

the class CastControllerImpl method startCasting.

@Override
public void startCasting(CastDevice device) {
    if (device == null || !(device.tag instanceof RouteInfo))
        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)

Example 29 with RouteInfo

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

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 30 with RouteInfo

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

the class CastControllerImpl method startCasting.

@Override
public void startCasting(CastDevice device) {
    if (device == null || !(device.tag instanceof RouteInfo))
        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