diff options
author | Adam Powell <adamp@google.com> | 2012-06-20 23:46:19 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2012-06-20 23:59:14 -0700 |
commit | f8ac14a7f5a59b4ec8e89283a2da40b626e42065 (patch) | |
tree | bb40079ff45415be44957efebf7a1c9bd0ff1032 /media | |
parent | 09829b71de3a84cb9d1bc0d8aad78dd16daadddf (diff) | |
download | frameworks_base-f8ac14a7f5a59b4ec8e89283a2da40b626e42065.zip frameworks_base-f8ac14a7f5a59b4ec8e89283a2da40b626e42065.tar.gz frameworks_base-f8ac14a7f5a59b4ec8e89283a2da40b626e42065.tar.bz2 |
MediaRouter group volume reporting
RouteGroups always report back the loudest volume of their component
routes. Maintain this through volume update requests (such as those
reported by volume hard keys) such that each route updates
individually, but the group slider always indicates the loudest value.
Change-Id: I5de4b9048bf55682b6271e9485fe50496a1c97c2
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaRouter.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java index 3de2db2..fe261cf 100644 --- a/media/java/android/media/MediaRouter.java +++ b/media/java/android/media/MediaRouter.java @@ -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; |