diff options
author | Adam Powell <adamp@google.com> | 2012-11-28 10:46:56 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2012-11-28 11:22:01 -0800 |
commit | 1cf2ca83584a4cf0aa3ded787bd191b9a60e3521 (patch) | |
tree | a437972a98300f3d9c5356b57289c4c0910bcb4f /core/java/com/android | |
parent | ba4ac51823c59152e2167365b81ac56857b6b4d0 (diff) | |
download | frameworks_base-1cf2ca83584a4cf0aa3ded787bd191b9a60e3521.zip frameworks_base-1cf2ca83584a4cf0aa3ded787bd191b9a60e3521.tar.gz frameworks_base-1cf2ca83584a4cf0aa3ded787bd191b9a60e3521.tar.bz2 |
Clean up behavior of type arguments for MediaRouter#getSelectedRoute
MediaRouter's policy so far has been around a single selected route,
but when route types are entirely orthogonal this should not be the
case. However we still don't want to get into a situation where we
have multiple, very different routes selected for different types at
the same time, we still want to have more of an element of
predictability.
Behavior of getSelectedRoute is now:
* If the selected route matches at least one type with the requested
type flags, it is still considered selected for that request.
* If the caller specifically requested the selected user route and the
currently selected route is not a user route, return null.
* If the requested type flags do not match any types with the selected
route, return the default system route.
Note that this is "any" behavior instead of "all" - this matches
existing usage of the method. We may consider adding an "all" variant
later on.
Bug 7588042
Change-Id: I3a79d8153ca6b882fd3ef6b9b1de8f538873dec2
Diffstat (limited to 'core/java/com/android')
-rw-r--r-- | core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java b/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java index 386f387..2bc80ff 100644 --- a/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java +++ b/core/java/com/android/internal/app/MediaRouteChooserDialogFragment.java @@ -136,13 +136,14 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { if (mRouter == null) return; final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes); - mVolumeIcon.setImageResource( + mVolumeIcon.setImageResource(selectedRoute == null || selectedRoute.getPlaybackType() == RouteInfo.PLAYBACK_TYPE_LOCAL ? R.drawable.ic_audio_vol : R.drawable.ic_media_route_on_holo_dark); mIgnoreSliderVolumeChanges = true; - if (selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_FIXED) { + if (selectedRoute == null || + selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_FIXED) { // Disable the slider and show it at max volume. mVolumeSlider.setMax(1); mVolumeSlider.setProgress(1); @@ -160,7 +161,8 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { if (mIgnoreSliderVolumeChanges) return; final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes); - if (selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) { + if (selectedRoute != null && + selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) { final int maxVolume = selectedRoute.getVolumeMax(); newValue = Math.max(0, Math.min(newValue, maxVolume)); selectedRoute.requestSetVolume(newValue); @@ -652,14 +654,19 @@ public class MediaRouteChooserDialogFragment extends DialogFragment { public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && mVolumeSlider.isEnabled()) { - mRouter.getSelectedRoute(mRouteTypes).requestUpdateVolume(-1); - return true; + final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes); + if (selectedRoute != null) { + selectedRoute.requestUpdateVolume(-1); + return true; + } } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && mVolumeSlider.isEnabled()) { - mRouter.getSelectedRoute(mRouteTypes).requestUpdateVolume(1); - return true; - } else { - return super.onKeyDown(keyCode, event); + final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes); + if (selectedRoute != null) { + mRouter.getSelectedRoute(mRouteTypes).requestUpdateVolume(1); + return true; + } } + return super.onKeyDown(keyCode, event); } public boolean onKeyUp(int keyCode, KeyEvent event) { |