MediaRouter: Update volume sliders simultaneously

Bug: 24149822
Change-Id: Id880af8277d3957a3fab355645ee1640d1ecdf6b
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
index fab1a59..5ce8f75 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
@@ -569,7 +569,7 @@
 
     private void updateVolumeControl() {
         if (!mVolumeSliderTouched) {
-            if (isVolumeControlAvailable()) {
+            if (isVolumeControlAvailable(mRoute)) {
                 mVolumeControl.setVisibility(View.VISIBLE);
                 mVolumeSlider.setMax(mRoute.getVolumeMax());
                 mVolumeSlider.setProgress(mRoute.getVolume());
@@ -589,6 +589,18 @@
                 mVolumeControl.setVisibility(View.GONE);
             }
             updateLayoutHeight();
+        } else if (mVolumeControl.getVisibility() == View.VISIBLE) {
+            mVolumeSlider.setProgress(mRoute.getVolume());
+            if (mIsGroupExpanded) {
+                for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) {
+                    MediaRouter.RouteInfo route = getGroup().getRouteAt(i);
+                    if (isVolumeControlAvailable(route)) {
+                        SeekBar volumeSlider = (SeekBar) mVolumeGroupList.getChildAt(i)
+                                .findViewById(R.id.mr_volume_slider);
+                        volumeSlider.setProgress(route.getVolume());
+                    }
+                }
+            }
         }
     }
 
@@ -653,9 +665,9 @@
         updateLayoutHeight();
     }
 
-    private boolean isVolumeControlAvailable() {
-        return mVolumeControlEnabled && mRoute.getVolumeHandling() ==
-                MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE;
+    private boolean isVolumeControlAvailable(MediaRouter.RouteInfo route) {
+        return mVolumeControlEnabled && route.getVolumeHandling()
+                == MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE;
     }
 
     private static void setLayoutHeight(View view, int height) {
@@ -812,8 +824,7 @@
                 volumeSlider.setTag(VOLUME_SLIDER_TAG_BASE + position);
                 volumeSlider.setShowThumb(isEnabled);
                 if (isEnabled) {
-                    if (route.getVolumeHandling()
-                            == MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE) {
+                    if (isVolumeControlAvailable(route)) {
                         volumeSlider.setMax(route.getVolumeMax());
                         volumeSlider.setProgress(route.getVolume());
                         volumeSlider.setOnSeekBarChangeListener(mVolumeChangeListener);