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

Commit 914aa177 authored by Ray Chin's avatar Ray Chin
Browse files

Use last volume level instead of the level specified in Intent

Intents were processed asynchronously and the order is not garenteed.
When devices send Volume change intent continuously in a short time
window the volume bar will move back and forth on the UI. This issue
can be reproduce on subatomic devices easily by adjusting the volume
continuously after switch between apps.

Flag: EXEMPT bugfix
Bug: 361354592
Test: Test on a TV subatomic device (loki)
Change-Id: Ib8c0b06e3dbd48cb18230ff1b7b021e9243e2007
parent 2ffa33c0
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -1305,13 +1305,12 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
            if (action.equals(AudioManager.VOLUME_CHANGED_ACTION)) {
            if (action.equals(AudioManager.VOLUME_CHANGED_ACTION)) {
                final int stream = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
                final int stream = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
                        STREAM_UNKNOWN);
                        STREAM_UNKNOWN);
                final int level = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, -1);
                final int oldLevel = intent
                final int oldLevel = intent
                        .getIntExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, -1);
                        .getIntExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, -1);
                if (D.BUG) Log.d(TAG, "onReceive VOLUME_CHANGED_ACTION stream=" + stream
                if (D.BUG) Log.d(TAG, "onReceive VOLUME_CHANGED_ACTION stream=" + stream
                        + " level=" + level + " oldLevel=" + oldLevel);
                        + " oldLevel=" + oldLevel);
                if (stream != STREAM_UNKNOWN) {
                if (stream != STREAM_UNKNOWN) {
                    changed = updateStreamLevelW(stream, level);
                    changed |= onVolumeChangedW(stream, 0);
                }
                }
            } else if (action.equals(AudioManager.STREAM_DEVICES_CHANGED_ACTION)) {
            } else if (action.equals(AudioManager.STREAM_DEVICES_CHANGED_ACTION)) {
                final int stream = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
                final int stream = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,