am d7c00d2b: Merge "MediaRouter group volume reporting" into jb-dev

* commit 'd7c00d2bdd011d3a73faf1c4a5bb8012d24dd648':
  MediaRouter group volume reporting
This commit is contained in:
Adam Powell
2012-06-21 11:52:19 -07:00
committed by Android Git Automerger

View File

@@ -1033,6 +1033,9 @@ public class MediaRouter {
mVolume = volume;
setPlaybackInfoOnRcc(RemoteControlClient.PLAYBACKINFO_VOLUME, volume);
dispatchRouteVolumeChanged(this);
if (mGroup != null) {
mGroup.memberVolumeChanged(this);
}
}
}
@@ -1148,6 +1151,7 @@ public class MediaRouter {
mRoutes.add(route);
route.mGroup = this;
mUpdateName = true;
updateVolume();
dispatchRouteGrouped(route, this, at);
routeUpdated();
}
@@ -1171,6 +1175,7 @@ public class MediaRouter {
mRoutes.add(insertAt, route);
route.mGroup = this;
mUpdateName = true;
updateVolume();
dispatchRouteGrouped(route, this, insertAt);
routeUpdated();
}
@@ -1188,6 +1193,7 @@ public class MediaRouter {
mRoutes.remove(route);
route.mGroup = null;
mUpdateName = true;
updateVolume();
dispatchRouteUngrouped(route, this);
routeUpdated();
}
@@ -1201,6 +1207,7 @@ public class MediaRouter {
RouteInfo route = mRoutes.remove(index);
route.mGroup = null;
mUpdateName = true;
updateVolume();
dispatchRouteUngrouped(route, this);
routeUpdated();
}
@@ -1270,11 +1277,15 @@ public class MediaRouter {
}
final int routeCount = getRouteCount();
int volume = 0;
for (int i = 0; i < routeCount; i++) {
final RouteInfo route = getRouteAt(i);
route.requestUpdateVolume(direction);
final int routeVol = route.getVolume();
if (routeVol > volume) {
volume = routeVol;
}
}
final int volume = Math.max(0, Math.min(mVolume + direction, maxVol));
if (volume != mVolume) {
mVolume = volume;
dispatchRouteVolumeChanged(this);
@@ -1290,6 +1301,26 @@ public class MediaRouter {
setStatusInt(status);
}
void memberVolumeChanged(RouteInfo info) {
updateVolume();
}
void updateVolume() {
// A group always represents the highest component volume value.
final int routeCount = getRouteCount();
int volume = 0;
for (int i = 0; i < routeCount; i++) {
final int routeVol = getRouteAt(i).getVolume();
if (routeVol > volume) {
volume = routeVol;
}
}
if (volume != mVolume) {
mVolume = volume;
dispatchRouteVolumeChanged(this);
}
}
@Override
void routeUpdated() {
int types = 0;