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;
  }
  @Override
  public boolean performClick() {
    // Send the appropriate accessibility events and call listeners
    boolean handled = super.performClick();
    if (!handled) {
      playSoundEffect(SoundEffectConstants.CLICK);
    }

    if (mToggleMode) {
      if (mRemoteActive) {
        mRouter.selectRouteInt(mRouteTypes, mRouter.getSystemAudioRoute());
      } 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()) {
            mRouter.selectRouteInt(mRouteTypes, route);
          }
        }
      }
    } else {
      showDialog();
    }

    return handled;
  }
 @SuppressWarnings({"rawtypes", "unchecked"})
 public static List getRoutes(Object routerObj) {
   final android.media.MediaRouter router = (android.media.MediaRouter) routerObj;
   final int count = router.getRouteCount();
   List out = new ArrayList(count);
   for (int i = 0; i < count; i++) {
     out.add(router.getRouteAt(i));
   }
   return out;
 }
 public static List getRoutes(Object paramObject)
 {
   MediaRouter localMediaRouter = (MediaRouter)paramObject;
   int i = localMediaRouter.getRouteCount();
   ArrayList localArrayList = new ArrayList(i);
   int j = 0;
   while (j < i)
   {
     MediaRouter.RouteInfo localRouteInfo = localMediaRouter.getRouteAt(j);
     boolean bool = localArrayList.add(localRouteInfo);
     j += 1;
   }
   return localArrayList;
 }
    public Object getDefaultRoute(Object routerObj) {
      android.media.MediaRouter router = (android.media.MediaRouter) routerObj;

      if (mGetSystemAudioRouteMethod != null) {
        try {
          return mGetSystemAudioRouteMethod.invoke(router);
        } catch (IllegalAccessException ex) {
        } catch (InvocationTargetException ex) {
        }
      }

      // Could not find the method or it does not work.
      // Return the first route and hope for the best.
      return router.getRouteAt(0);
    }