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

Commit 0a376af2 authored by John Spurlock's avatar John Spurlock
Browse files

AudioService: Resolve stream before sending to volume UI.

- Don't send streams that the UI cannot display.
- Add an input validation check to adjustSuggestedStreamVolume.
- Remove unused validation method.

Bug: 19949071
Change-Id: Ib7a7c9bf386a8b2d7a0fb13928d103d764ec7aa9
parent 221d2cbf
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -234,9 +234,6 @@ public class AudioService extends IAudioService.Stub {
    private final Object mSoundEffectsLock = new Object();
    private static final int NUM_SOUNDPOOL_CHANNELS = 4;

    // Maximum volume adjust steps allowed in a single batch call.
    private static final int MAX_BATCH_VOLUME_ADJUST_STEPS = 4;

    /* Sound effect file names  */
    private static final String SOUND_EFFECTS_PATH = "/media/audio/ui/";
    private static final List<String> SOUND_EFFECT_FILES = new ArrayList<String>();
@@ -988,6 +985,7 @@ public class AudioService extends IAudioService.Stub {
        } else {
            streamType = getActiveStreamType(suggestedStreamType);
        }
        ensureValidStreamType(streamType);
        final int resolvedStream = mStreamVolumeAlias[streamType];

        // Play sounds on STREAM_RING only.
@@ -1421,6 +1419,8 @@ public class AudioService extends IAudioService.Stub {
    private void sendVolumeUpdate(int streamType, int oldIndex, int index, int flags) {
        if (!isPlatformVoice() && (streamType == AudioSystem.STREAM_RING)) {
            streamType = AudioSystem.STREAM_NOTIFICATION;
        } else {
            streamType = mStreamVolumeAlias[streamType];
        }

        if (streamType == AudioSystem.STREAM_MUSIC) {
@@ -3131,12 +3131,6 @@ public class AudioService extends IAudioService.Stub {
        }
    }

    private void ensureValidSteps(int steps) {
        if (Math.abs(steps) > MAX_BATCH_VOLUME_ADJUST_STEPS) {
            throw new IllegalArgumentException("Bad volume adjust steps " + steps);
        }
    }

    private void ensureValidStreamType(int streamType) {
        if (streamType < 0 || streamType >= mStreamStates.length) {
            throw new IllegalArgumentException("Bad stream type " + streamType);