Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b5cdf4f authored by Adam Powell's avatar Adam Powell Committed by Android Git Automerger
Browse files

am 4dd21c8e: Volume changes in MediaRouteChooserDialog

* commit '4dd21c8e':
  Volume changes in MediaRouteChooserDialog
parents a6b8189f 4dd21c8e
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -70,7 +70,6 @@ public class MediaRouteChooserDialogFragment extends DialogFragment {
    };
    };


    MediaRouter mRouter;
    MediaRouter mRouter;
    AudioManager mAudio;
    private int mRouteTypes;
    private int mRouteTypes;


    private LayoutInflater mInflater;
    private LayoutInflater mInflater;
@@ -98,7 +97,6 @@ public class MediaRouteChooserDialogFragment extends DialogFragment {
    public void onAttach(Activity activity) {
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        super.onAttach(activity);
        mRouter = (MediaRouter) activity.getSystemService(Context.MEDIA_ROUTER_SERVICE);
        mRouter = (MediaRouter) activity.getSystemService(Context.MEDIA_ROUTER_SERVICE);
        mAudio = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
    }
    }


    @Override
    @Override
@@ -150,7 +148,7 @@ public class MediaRouteChooserDialogFragment extends DialogFragment {


        final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
        final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
        if (selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) {
        if (selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) {
            final int maxVolume = mAudio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
            final int maxVolume = selectedRoute.getVolumeMax();
            newValue = Math.max(0, Math.min(newValue, maxVolume));
            newValue = Math.max(0, Math.min(newValue, maxVolume));
            selectedRoute.requestSetVolume(newValue);
            selectedRoute.requestSetVolume(newValue);
        }
        }